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);
1543 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType):_father(fath),_geo_type(geoType)
1547 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):_father(fath),_geo_type(geoType)
1549 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1550 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1551 med_geometry_type mgeoti;
1552 med_entity_type menti(ConvertIntoMEDFileType(type,geoType,mgeoti));
1553 int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName));
1554 _field_pm_pt_pd.resize(nbProfiles);
1555 for(int i=0;i<nbProfiles;i++)
1557 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i,pd);
1561 int nbProfiles2=MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName);
1562 for(int i=0;i<nbProfiles2;i++)
1563 _field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i,pd));
1567 void MEDFileFieldPerMeshPerType::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
1569 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1570 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1573 void MEDFileFieldPerMeshPerType::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1575 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1576 (*it)->loadBigArray(fid,nasc);
1579 void MEDFileFieldPerMeshPerType::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1581 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1583 (*it)->copyOptionsFrom(*this);
1584 (*it)->writeLL(fid,nasc);
1588 med_entity_type MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1593 medfGeoType=typmai3[(int)ikGeoType];
1596 medfGeoType=MED_NONE;
1599 medfGeoType=typmai3[(int)ikGeoType];
1600 return MED_NODE_ELEMENT;
1602 medfGeoType=typmai3[(int)ikGeoType];
1605 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1607 return MED_UNDEF_ENTITY_TYPE;
1610 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm)
1612 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm);
1615 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1617 return new MEDFileFieldPerMesh(fath,mesh);
1620 std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
1622 return _mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType >);
1625 std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildrenWithNull() const
1627 std::vector<const BigMemoryObject *> ret;
1628 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1629 ret.push_back((const MEDFileFieldPerMeshPerType *)*it);
1633 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCpy(MEDFileAnyTypeField1TSWithoutSDA *father) const
1635 MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1636 ret->_father=father;
1638 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1640 if((const MEDFileFieldPerMeshPerType *)*it)
1641 ret->_field_pm_pt[i]=(*it)->deepCpy((MEDFileFieldPerMesh *)(ret));
1646 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1648 std::string startLine(bkOffset,' ');
1649 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1650 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1652 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1654 const MEDFileFieldPerMeshPerType *cur=*it;
1656 cur->simpleRepr(bkOffset,oss,i);
1659 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1664 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh)
1666 _mesh_name=mesh->getName();
1667 mesh->getTime(_mesh_iteration,_mesh_order);
1670 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1672 int nbOfTypes=code.size()/3;
1674 for(int i=0;i<nbOfTypes;i++)
1676 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1677 int nbOfCells=code[3*i+1];
1678 int pos=addNewEntryIfNecessary(type);
1679 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1685 * This method is the most general one. No optimization is done here.
1686 * \param [in] multiTypePfl is the end user profile specified in high level API
1687 * \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].
1688 * \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.
1689 * \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.
1690 * \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.
1691 * \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.
1693 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)
1695 int nbOfTypes(code.size()/3);
1696 for(int i=0;i<nbOfTypes;i++)
1698 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1699 int pos=addNewEntryIfNecessary(type);
1700 DataArrayInt *pfl=0;
1702 pfl=idsPerType[code[3*i+2]];
1703 int nbOfTupes2=code2.size()/3;
1705 for(;found<nbOfTupes2;found++)
1706 if(code[3*i]==code2[3*found])
1708 if(found==nbOfTupes2)
1709 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1710 _field_pm_pt[pos]->assignFieldProfile(nbOfTypes==1,start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1714 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1716 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1717 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1720 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1722 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1723 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1726 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
1728 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1729 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1732 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1734 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1735 (*it)->loadBigArraysRecursively(fid,nasc);
1738 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1740 int nbOfTypes=_field_pm_pt.size();
1741 for(int i=0;i<nbOfTypes;i++)
1743 _field_pm_pt[i]->copyOptionsFrom(*this);
1744 _field_pm_pt[i]->writeLL(fid,nasc);
1748 void MEDFileFieldPerMesh::getDimension(int& dim) const
1750 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1751 (*it)->getDimension(dim);
1754 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1756 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1757 (*it)->fillTypesOfFieldAvailable(types);
1760 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
1762 int sz=_field_pm_pt.size();
1763 std::vector< std::vector<std::pair<int,int> > > ret(sz);
1764 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1765 for(int i=0;i<sz;i++)
1767 types[i]=_field_pm_pt[i]->getGeoType();
1768 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1773 double MEDFileFieldPerMesh::getTime() const
1776 return _father->getTime(tmp1,tmp2);
1779 int MEDFileFieldPerMesh::getIteration() const
1781 return _father->getIteration();
1784 int MEDFileFieldPerMesh::getOrder() const
1786 return _father->getOrder();
1789 int MEDFileFieldPerMesh::getNumberOfComponents() const
1791 return _father->getNumberOfComponents();
1794 bool MEDFileFieldPerMesh::presenceOfMultiDiscPerGeoType() const
1796 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1798 const MEDFileFieldPerMeshPerType *fpmt(*it);
1801 if(fpmt->presenceOfMultiDiscPerGeoType())
1807 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
1810 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1811 return _father->getOrCreateAndGetArray();
1814 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
1817 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1818 return _father->getOrCreateAndGetArray();
1821 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1823 return _father->getInfo();
1827 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
1828 * 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.
1829 * It returns 2 output vectors :
1830 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
1831 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
1832 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
1834 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)
1836 int notNullPflsSz=0;
1837 int nbOfArrs=geoTypes.size();
1838 for(int i=0;i<nbOfArrs;i++)
1841 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
1842 int nbOfDiffGeoTypes=geoTypes3.size();
1843 code.resize(3*nbOfDiffGeoTypes);
1844 notNullPfls.resize(notNullPflsSz);
1847 for(int i=0;i<nbOfDiffGeoTypes;i++)
1850 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
1851 std::vector<const DataArrayInt *> notNullTmp;
1853 notNullTmp.push_back(pfls[j]);
1855 for(;j<nbOfArrs;j++)
1856 if(geoTypes[j]==refType)
1859 notNullTmp.push_back(pfls[j]);
1863 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
1864 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
1865 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
1866 code[3*i]=(int)refType;
1867 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
1868 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
1869 if(notNullTmp.empty())
1873 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
1874 code[3*i+2]=notNullPflsSz++;
1880 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
1882 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)
1886 for(int i=0;i<sz;i++)
1890 if(type!=ON_GAUSS_NE)
1891 ret+=dads[i].second-dads[i].first;
1894 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
1895 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
1900 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
1901 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
1907 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
1909 std::vector<std::string> ret;
1910 std::set<std::string> ret2;
1911 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1913 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
1914 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1915 if(ret2.find(*it2)==ret2.end())
1917 ret.push_back(*it2);
1924 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
1926 std::vector<std::string> ret;
1927 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1929 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
1930 ret.insert(ret.end(),tmp.begin(),tmp.end());
1935 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
1937 std::vector<std::string> ret;
1938 std::set<std::string> ret2;
1939 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1941 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
1942 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1943 if(ret2.find(*it2)==ret2.end())
1945 ret.push_back(*it2);
1952 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
1954 std::vector<std::string> ret;
1955 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1957 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
1958 ret.insert(ret.end(),tmp.begin(),tmp.end());
1963 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
1965 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
1967 if((*it).first==_mesh_name)
1969 _mesh_name=(*it).second;
1976 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
1977 MEDFileFieldGlobsReal& glob)
1979 if(_mesh_name!=meshName)
1981 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
1982 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
1983 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
1984 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
1985 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
1986 getUndergroundDataArrayExt(entries);
1987 DataArray *arr0=getOrCreateAndGetArray();//tony
1989 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
1990 DataArrayDouble *arr=dynamic_cast<DataArrayDouble *>(arr0);//tony
1992 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
1995 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
1996 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
1998 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
2000 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2001 sz+=(*it).second.second-(*it).second.first;
2004 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2006 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
2007 ////////////////////
2008 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
2009 int *workI2=explicitIdsOldInMesh->getPointer();
2010 int sz1=0,sz2=0,sid=1;
2011 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
2012 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
2013 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
2015 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
2016 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
2017 int *workI=explicitIdsOldInArr->getPointer();
2018 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
2020 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
2021 (*itL2)->setLocId(sz2);
2022 (*itL2)->_tmp_work1=(*itL2)->getStart();
2023 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
2025 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
2027 explicitIdsOldInMesh->reAlloc(sz2);
2028 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
2029 ////////////////////
2030 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
2031 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
2032 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
2033 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
2035 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
2036 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
2037 otherEntriesNew.back()->setLocId((*it)->getGeoType());
2039 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
2040 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
2041 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
2043 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
2044 int newStart=elt->getLocId();
2045 elt->setLocId((*it)->getGeoType());
2046 elt->setNewStart(newStart);
2047 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
2048 entriesKeptNew.push_back(elt);
2049 entriesKeptNew2.push_back(elt);
2051 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
2052 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
2053 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
2054 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
2056 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
2059 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
2061 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
2062 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
2064 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
2065 glob,arr2,otherEntriesNew) || ret;
2069 // Assign new dispatching
2070 assignNewLeaves(otherEntriesNew);
2071 arr->cpyFrom(*arr2);
2076 * \param [in,out] globalNum a global numbering counter for the renumbering.
2077 * \param [out] its - list of pair (start,stop) kept
2079 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
2081 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > ret;
2082 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2084 std::vector< std::pair<int,int> > its2;
2085 if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
2088 its.insert(its.end(),its2.begin(),its2.end());
2095 * \param [in,out] globalNum a global numbering counter for the renumbering.
2096 * \param [out] its - list of pair (start,stop) kept
2098 void MEDFileFieldPerMesh::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
2100 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > ret;
2101 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2103 std::vector< std::pair<int,int> > its2;
2104 if((*it)->keepOnlyGaussDiscretization(idOfDisc,globalNum,its2))
2107 its.insert(its.end(),its2.begin(),its2.end());
2113 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
2115 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > > types;
2116 for( std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
2117 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
2119 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > fieldPmPt(types.size());
2120 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
2121 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=fieldPmPt.begin();
2122 for(;it1!=types.end();it1++,it2++)
2124 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
2125 elt->setLeaves((*it1).second);
2128 _field_pm_pt=fieldPmPt;
2131 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2133 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2134 (*it)->changePflsRefsNamesGen(mapOfModif);
2137 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2139 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2140 (*it)->changeLocsRefsNamesGen(mapOfModif);
2144 * \param [in] mesh is the whole mesh
2146 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2148 if(_field_pm_pt.empty())
2149 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2151 std::vector< std::pair<int,int> > dads;
2152 std::vector<const DataArrayInt *> pfls;
2153 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2154 std::vector<int> locs,code;
2155 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2156 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2157 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2159 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2162 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2163 throw INTERP_KERNEL::Exception(oss.str().c_str());
2166 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2167 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2170 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2172 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2175 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr);
2176 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2182 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2186 if(nb!=mesh->getNumberOfNodes())
2188 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2189 oss << " nodes in mesh !";
2190 throw INTERP_KERNEL::Exception(oss.str().c_str());
2192 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2195 return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2199 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
2201 if(_field_pm_pt.empty())
2202 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2204 std::vector<std::pair<int,int> > dads;
2205 std::vector<const DataArrayInt *> pfls;
2206 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2207 std::vector<int> locs,code;
2208 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2209 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2210 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2212 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2215 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2216 throw INTERP_KERNEL::Exception(oss.str().c_str());
2218 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2219 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2222 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2223 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2228 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2232 if(nb!=mesh->getNumberOfNodes())
2234 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2235 oss << " nodes in mesh !";
2236 throw INTERP_KERNEL::Exception(oss.str().c_str());
2239 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2245 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
2249 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2251 (*it)->getSizes(globalSz,nbOfEntries);
2253 entries.resize(nbOfEntries);
2255 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2257 (*it)->fillValues(nbOfEntries,entries);
2261 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
2263 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2265 if((*it)->getGeoType()==typ)
2266 return (*it)->getLeafGivenLocId(locId);
2268 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2269 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2270 oss << "Possiblities are : ";
2271 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2273 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2274 oss << "\"" << cm2.getRepr() << "\", ";
2276 throw INTERP_KERNEL::Exception(oss.str().c_str());
2279 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
2281 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2283 if((*it)->getGeoType()==typ)
2284 return (*it)->getLeafGivenLocId(locId);
2286 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2287 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2288 oss << "Possiblities are : ";
2289 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2291 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2292 oss << "\"" << cm2.getRepr() << "\", ";
2294 throw INTERP_KERNEL::Exception(oss.str().c_str());
2297 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2300 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2301 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=_field_pm_pt.begin();
2302 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2304 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2309 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2314 int ret=std::distance(_field_pm_pt.begin(),it2);
2315 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2320 * 'dads' and 'locs' input parameters have the same number of elements
2321 * \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
2323 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2324 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2325 const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2328 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2329 ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2330 MEDCouplingAutoRefCountObjectPtr<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2331 const std::vector<std::string>& infos=getInfo();
2332 da->setInfoOnComponents(infos);
2334 if(type==ON_GAUSS_PT)
2337 int nbOfArrs=dads.size();
2338 for(int i=0;i<nbOfArrs;i++)
2340 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2341 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2342 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2343 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> di=DataArrayInt::New();
2344 di->alloc(nbOfElems,1);
2346 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2347 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2356 * 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.
2357 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2358 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2359 * The order of cells in the returned field is those imposed by the profile.
2360 * \param [in] mesh is the global mesh.
2362 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2363 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2364 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2365 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2367 if(da->isIdentity())
2369 int nbOfTuples=da->getNumberOfTuples();
2370 if(nbOfTuples==mesh->getNumberOfCells())
2371 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2373 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2374 m2->setName(mesh->getName().c_str());
2375 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2381 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2383 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2384 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2385 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2387 if(da->isIdentity())
2389 int nbOfTuples=da->getNumberOfTuples();
2390 if(nbOfTuples==mesh->getNumberOfNodes())//No problem for NORM_ERROR because it is in context of node
2391 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2393 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2394 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2397 if(meshu->getNodalConnectivity()==0)
2399 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2400 int nb=da->getNbOfElems();
2401 const int *ptr=da->getConstPointer();
2402 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2403 meshuc->allocateCells(nb);
2404 for(int i=0;i<nb;i++)
2405 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2406 meshuc->finishInsertingCells();
2407 ret->setMesh(meshuc);
2408 const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2409 if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2410 disc->checkCoherencyBetween(meshuc,arrOut);
2415 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2417 DataArrayInt *arr2=0;
2418 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2419 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2420 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3(arr2);
2421 int nnodes=mesh2->getNumberOfNodes();
2422 if(nnodes==(int)da->getNbOfElems())
2424 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2425 arrOut->renumberInPlace(da3->getConstPointer());
2426 mesh2->setName(mesh->getName().c_str());
2427 ret->setMesh(mesh2);
2432 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 !!!";
2433 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2434 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2435 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2436 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2437 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2438 throw INTERP_KERNEL::Exception(oss.str().c_str());
2444 * This method is the most light method of field retrieving.
2446 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
2450 pflOut=DataArrayInt::New();
2451 pflOut->alloc(nbOfElems,1);
2456 pflOut=const_cast<DataArrayInt*>(pflIn);
2459 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> safePfl(pflOut);
2460 MEDCouplingAutoRefCountObjectPtr<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2461 const std::vector<std::string>& infos=getInfo();
2462 int nbOfComp=infos.size();
2463 for(int i=0;i<nbOfComp;i++)
2464 da->setInfoOnComponent(i,infos[i].c_str());
2469 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),
2472 INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2473 INTERP_KERNEL::AutoPtr<char> pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2474 INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2475 const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
2476 for(int i=0;i<MED_N_CELL_FIXED_GEO;i++)
2478 int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL ,typmai[i],meshCsit+1,meshName,pflName,locName));
2479 std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2480 int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[i],meshCsit+1,meshName,pflName,locName));
2481 std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2482 if(nbProfile>0 || nbProfile2>0)
2484 const PartDefinition *pd(0);
2486 pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[i]),typmai2[i]);
2487 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[i],nasc,pd));
2494 int nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName);
2497 const PartDefinition *pd(0);
2499 pd=mmu->getPartDefAtLevel(1,INTERP_KERNEL::NORM_ERROR);
2500 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd));
2501 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2505 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2507 copyTinyInfoFrom(mesh);
2510 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
2512 if(id>=(int)_pfls.size())
2514 _pfls[id]=DataArrayInt::New();
2515 int lgth=MEDprofileSizeByName(fid,pflName.c_str());
2516 _pfls[id]->setName(pflName);
2517 _pfls[id]->alloc(lgth,1);
2518 MEDprofileRd(fid,pflName.c_str(),_pfls[id]->getPointer());
2519 _pfls[id]->applyLin(1,-1,0);//Converting into C format
2522 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2524 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2526 MEDprofileInfo(fid,i+1,pflName,&sz);
2527 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2528 if(i>=(int)_pfls.size())
2530 _pfls[i]=DataArrayInt::New();
2531 _pfls[i]->alloc(sz,1);
2532 _pfls[i]->setName(pflCpp.c_str());
2533 MEDprofileRd(fid,pflName,_pfls[i]->getPointer());
2534 _pfls[i]->applyLin(1,-1,0);//Converting into C format
2537 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
2539 int nbOfPfls=_pfls.size();
2540 for(int i=0;i<nbOfPfls;i++)
2542 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cpy=_pfls[i]->deepCpy();
2543 cpy->applyLin(1,1,0);
2544 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2545 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2546 MEDprofileWr(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer());
2549 int nbOfLocs=_locs.size();
2550 for(int i=0;i<nbOfLocs;i++)
2551 _locs[i]->writeLL(fid);
2554 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
2556 std::vector<std::string> pfls=getPfls();
2557 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2559 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2562 _pfls.push_back(*it);
2566 int id=std::distance(pfls.begin(),it2);
2567 if(!(*it)->isEqual(*_pfls[id]))
2569 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2570 throw INTERP_KERNEL::Exception(oss.str().c_str());
2574 std::vector<std::string> locs=getLocs();
2575 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
2577 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2580 _locs.push_back(*it);
2584 int id=std::distance(locs.begin(),it2);
2585 if(!(*it)->isEqual(*_locs[id],eps))
2587 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2588 throw INTERP_KERNEL::Exception(oss.str().c_str());
2594 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
2596 for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
2597 getProfile((*it).c_str());
2600 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
2602 for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
2603 getLocalization((*it).c_str());
2606 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
2608 std::vector<std::string> profiles=real.getPflsReallyUsed();
2609 int sz=profiles.size();
2611 for(int i=0;i<sz;i++)
2612 loadProfileInFile(fid,i,profiles[i].c_str());
2614 std::vector<std::string> locs=real.getLocsReallyUsed();
2617 for(int i=0;i<sz;i++)
2618 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2621 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid)
2623 int nProfil=MEDnProfile(fid);
2624 for(int i=0;i<nProfil;i++)
2625 loadProfileInFile(fid,i);
2626 int sz=MEDnLocalization(fid);
2628 for(int i=0;i<sz;i++)
2630 _locs[i]=MEDFileFieldLoc::New(fid,i);
2634 MEDFileFieldGlobs *MEDFileFieldGlobs::New(const std::string& fname)
2636 return new MEDFileFieldGlobs(fname);
2639 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2641 return new MEDFileFieldGlobs;
2644 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
2646 return _file_name.capacity()+_pfls.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<DataArrayInt>)+_locs.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>);
2649 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildrenWithNull() const
2651 std::vector<const BigMemoryObject *> ret;
2652 for(std::vector< MEDCouplingAutoRefCountObjectPtr< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2653 ret.push_back((const DataArrayInt *)*it);
2654 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2655 ret.push_back((const MEDFileFieldLoc *)*it);
2659 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpy() const
2661 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
2663 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2665 if((const DataArrayInt *)*it)
2666 ret->_pfls[i]=(*it)->deepCpy();
2669 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2671 if((const MEDFileFieldLoc*)*it)
2672 ret->_locs[i]=(*it)->deepCpy();
2678 * \throw if a profile in \a pfls in not in \a this.
2679 * \throw if a localization in \a locs in not in \a this.
2680 * \sa MEDFileFieldGlobs::deepCpyPart
2682 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2684 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2685 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2687 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2689 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
2691 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2(pfl);
2692 ret->_pfls.push_back(pfl2);
2694 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2696 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2698 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
2700 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> loc2(loc);
2701 ret->_locs.push_back(loc2);
2703 ret->setFileName(getFileName());
2708 * \throw if a profile in \a pfls in not in \a this.
2709 * \throw if a localization in \a locs in not in \a this.
2710 * \sa MEDFileFieldGlobs::shallowCpyPart
2712 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2714 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2715 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2717 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2719 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
2720 ret->_pfls.push_back(pfl->deepCpy());
2722 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2724 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2726 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
2727 ret->_locs.push_back(loc->deepCpy());
2729 ret->setFileName(getFileName());
2733 MEDFileFieldGlobs::MEDFileFieldGlobs(const std::string& fname):_file_name(fname)
2737 MEDFileFieldGlobs::MEDFileFieldGlobs()
2741 MEDFileFieldGlobs::~MEDFileFieldGlobs()
2745 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
2747 oss << "Profiles :\n";
2748 std::size_t n=_pfls.size();
2749 for(std::size_t i=0;i<n;i++)
2751 oss << " - #" << i << " ";
2752 const DataArrayInt *pfl=_pfls[i];
2754 oss << "\"" << pfl->getName() << "\"\n";
2759 oss << "Localizations :\n";
2760 for(std::size_t i=0;i<n;i++)
2762 oss << " - #" << i << " ";
2763 const MEDFileFieldLoc *loc=_locs[i];
2765 loc->simpleRepr(oss);
2771 void MEDFileFieldGlobs::setFileName(const std::string& fileName)
2773 _file_name=fileName;
2776 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2778 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
2780 DataArrayInt *elt(*it);
2783 std::string name(elt->getName());
2784 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2786 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2788 elt->setName((*it2).second.c_str());
2796 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2798 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
2800 MEDFileFieldLoc *elt(*it);
2803 std::string name(elt->getName());
2804 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2806 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2808 elt->setName((*it2).second.c_str());
2816 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
2818 if(locId<0 || locId>=(int)_locs.size())
2819 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
2820 return _locs[locId]->getNbOfGaussPtPerCell();
2823 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
2825 return getLocalizationFromId(getLocalizationId(locName));
2828 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
2830 if(locId<0 || locId>=(int)_locs.size())
2831 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2832 return *_locs[locId];
2835 namespace ParaMEDMEMImpl
2840 LocFinder(const std::string& loc):_loc(loc) { }
2841 bool operator() (const MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
2843 const std::string &_loc;
2849 PflFinder(const std::string& pfl):_pfl(pfl) { }
2850 bool operator() (const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
2852 const std::string& _pfl;
2856 int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
2858 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),ParaMEDMEMImpl::LocFinder(loc));
2861 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
2862 for(it=_locs.begin();it!=_locs.end();it++)
2863 oss << "\"" << (*it)->getName() << "\", ";
2864 throw INTERP_KERNEL::Exception(oss.str().c_str());
2866 return std::distance(_locs.begin(),it);
2870 * The returned value is never null.
2872 const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
2874 std::string pflNameCpp(pflName);
2875 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2878 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2879 for(it=_pfls.begin();it!=_pfls.end();it++)
2880 oss << "\"" << (*it)->getName() << "\", ";
2881 throw INTERP_KERNEL::Exception(oss.str().c_str());
2886 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
2888 if(pflId<0 || pflId>=(int)_pfls.size())
2889 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2890 return _pfls[pflId];
2893 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
2895 if(locId<0 || locId>=(int)_locs.size())
2896 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2897 return *_locs[locId];
2900 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
2902 return getLocalizationFromId(getLocalizationId(locName));
2906 * The returned value is never null.
2908 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
2910 std::string pflNameCpp(pflName);
2911 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2914 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2915 for(it=_pfls.begin();it!=_pfls.end();it++)
2916 oss << "\"" << (*it)->getName() << "\", ";
2917 throw INTERP_KERNEL::Exception(oss.str().c_str());
2922 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
2924 if(pflId<0 || pflId>=(int)_pfls.size())
2925 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2926 return _pfls[pflId];
2929 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
2931 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newPfls;
2933 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2935 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
2936 newPfls.push_back(*it);
2941 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
2943 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> > newLocs;
2945 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2947 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
2948 newLocs.push_back(*it);
2953 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
2955 int sz=_pfls.size();
2956 std::vector<std::string> ret(sz);
2957 for(int i=0;i<sz;i++)
2958 ret[i]=_pfls[i]->getName();
2962 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
2964 int sz=_locs.size();
2965 std::vector<std::string> ret(sz);
2966 for(int i=0;i<sz;i++)
2967 ret[i]=_locs[i]->getName();
2971 bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
2973 std::vector<std::string> v=getPfls();
2974 std::string s(pflName);
2975 return std::find(v.begin(),v.end(),s)!=v.end();
2978 bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
2980 std::vector<std::string> v=getLocs();
2981 std::string s(locName);
2982 return std::find(v.begin(),v.end(),s)!=v.end();
2985 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
2987 std::map<int,std::vector<int> > m;
2989 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2991 const DataArrayInt *tmp=(*it);
2994 m[tmp->getHashCode()].push_back(i);
2997 std::vector< std::vector<int> > ret;
2998 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
3000 if((*it2).second.size()>1)
3002 std::vector<int> ret0;
3003 bool equalityOrNot=false;
3004 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
3006 std::vector<int>::const_iterator it4=it3; it4++;
3007 for(;it4!=(*it2).second.end();it4++)
3009 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
3012 ret0.push_back(*it3);
3013 ret0.push_back(*it4);
3019 ret.push_back(ret0);
3025 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
3027 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
3030 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
3032 std::string name(pfl->getName());
3034 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
3035 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3036 if(name==(*it)->getName())
3038 if(!pfl->isEqual(*(*it)))
3040 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
3041 throw INTERP_KERNEL::Exception(oss.str().c_str());
3045 _pfls.push_back(pfl);
3048 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)
3050 std::string name(locName);
3052 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
3053 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
3054 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3055 if((*it)->isName(locName))
3057 if(!(*it)->isEqual(*obj,1e-12))
3059 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
3060 throw INTERP_KERNEL::Exception(oss.str().c_str());
3063 _locs.push_back(obj);
3066 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
3068 std::vector<std::string> names=getPfls();
3069 return CreateNewNameNotIn("NewPfl_",names);
3072 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
3074 std::vector<std::string> names=getLocs();
3075 return CreateNewNameNotIn("NewLoc_",names);
3078 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
3080 for(std::size_t sz=0;sz<100000;sz++)
3082 std::ostringstream tryName;
3083 tryName << prefix << sz;
3084 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
3085 return tryName.str();
3087 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
3091 * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
3092 * \param [in] fname - the file name.
3094 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(const std::string& fname):_globals(MEDFileFieldGlobs::New(fname))
3099 * Creates an empty MEDFileFieldGlobsReal.
3101 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
3105 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
3110 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildrenWithNull() const
3112 std::vector<const BigMemoryObject *> ret;
3113 ret.push_back((const MEDFileFieldGlobs *)_globals);
3118 * Returns a string describing profiles and Gauss points held in \a this.
3119 * \return std::string - the description string.
3121 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
3123 const MEDFileFieldGlobs *glob=_globals;
3124 std::ostringstream oss2; oss2 << glob;
3125 std::string stars(oss2.str().length(),'*');
3126 oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n";
3128 glob->simpleRepr(oss);
3130 oss << "NO GLOBAL INFORMATION !\n";
3133 void MEDFileFieldGlobsReal::resetContent()
3135 _globals=MEDFileFieldGlobs::New();
3138 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
3143 * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
3144 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3146 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3148 _globals=other._globals;
3152 * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3153 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3155 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3157 const MEDFileFieldGlobs *otherg(other._globals);
3160 _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3164 * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3165 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3167 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3169 const MEDFileFieldGlobs *otherg(other._globals);
3172 _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3175 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3177 _globals=other._globals;
3178 if((const MEDFileFieldGlobs *)_globals)
3179 _globals=other._globals->deepCpy();
3183 * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3184 * \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3185 * \param [in] eps - a precision used to compare Gauss points with same name held by
3186 * \a this and \a other MEDFileFieldGlobsReal.
3187 * \throw If \a this and \a other hold profiles with equal names but different ids.
3188 * \throw If \a this and \a other hold different Gauss points with equal names.
3190 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
3192 const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3193 if(thisGlobals==otherGlobals)
3197 _globals=other._globals;
3200 _globals->appendGlobs(*other._globals,eps);
3203 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
3205 checkGlobsPflsPartCoherency();
3206 checkGlobsLocsPartCoherency();
3209 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
3211 contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3214 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
3216 contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3219 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3221 contentNotNull()->loadProfileInFile(fid,id,pflName);
3224 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3226 contentNotNull()->loadProfileInFile(fid,id);
3229 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
3231 contentNotNull()->loadGlobals(fid,*this);
3234 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid)
3236 contentNotNull()->loadAllGlobals(fid);
3239 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3241 contentNotNull()->writeGlobals(fid,opt);
3245 * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3246 * or getPflsReallyUsedMulti().
3247 * \return std::vector<std::string> - a sequence of names of all profiles.
3249 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3251 return contentNotNull()->getPfls();
3255 * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3256 * or getLocsReallyUsedMulti().
3257 * \return std::vector<std::string> - a sequence of names of all localizations.
3259 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3261 return contentNotNull()->getLocs();
3265 * Checks if the profile with a given name exists.
3266 * \param [in] pflName - the profile name of interest.
3267 * \return bool - \c true if the profile named \a pflName exists.
3269 bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
3271 return contentNotNull()->existsPfl(pflName);
3275 * Checks if the localization with a given name exists.
3276 * \param [in] locName - the localization name of interest.
3277 * \return bool - \c true if the localization named \a locName exists.
3279 bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
3281 return contentNotNull()->existsLoc(locName);
3284 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
3286 return contentNotNull()->createNewNameOfPfl();
3289 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
3291 return contentNotNull()->createNewNameOfLoc();
3295 * Sets the name of a MED file.
3296 * \param [inout] fileName - the file name.
3298 void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
3300 contentNotNull()->setFileName(fileName);
3304 * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3305 * in the same order.
3306 * \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3307 * Each item of this sequence is a vector containing ids of equal profiles.
3309 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3311 return contentNotNull()->whichAreEqualProfiles();
3315 * Finds equal localizations.
3316 * \param [in] eps - a precision used to compare real values of the localizations.
3317 * \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3318 * Each item of this sequence is a vector containing ids of equal localizations.
3320 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3322 return contentNotNull()->whichAreEqualLocs(eps);
3326 * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3327 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3328 * this sequence is a pair whose
3329 * - the first item is a vector of profile names to replace by the second item,
3330 * - the second item is a profile name to replace every profile name of the first item.
3332 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3334 contentNotNull()->changePflsNamesInStruct(mapOfModif);
3338 * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3339 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3340 * this sequence is a pair whose
3341 * - the first item is a vector of localization names to replace by the second item,
3342 * - the second item is a localization name to replace every localization name of the first item.
3344 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3346 contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3350 * Replaces references to some profiles (a reference is a profile name) by references
3351 * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3352 * them-selves accordingly. <br>
3353 * This method is a generalization of changePflName().
3354 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3355 * this sequence is a pair whose
3356 * - the first item is a vector of profile names to replace by the second item,
3357 * - the second item is a profile name to replace every profile of the first item.
3358 * \sa changePflsRefsNamesGen()
3359 * \sa changePflName()
3361 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3363 changePflsRefsNamesGen(mapOfModif);
3364 changePflsNamesInStruct(mapOfModif);
3368 * Replaces references to some localizations (a reference is a localization name) by references
3369 * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3370 * them-selves accordingly. <br>
3371 * This method is a generalization of changeLocName().
3372 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3373 * this sequence is a pair whose
3374 * - the first item is a vector of localization names to replace by the second item,
3375 * - the second item is a localization name to replace every localization of the first item.
3376 * \sa changeLocsRefsNamesGen()
3377 * \sa changeLocName()
3379 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3381 changeLocsRefsNamesGen(mapOfModif);
3382 changeLocsNamesInStruct(mapOfModif);
3386 * Renames the profile having a given name and updates references to this profile.
3387 * \param [in] oldName - the name of the profile to rename.
3388 * \param [in] newName - a new name of the profile.
3389 * \sa changePflsNames().
3391 void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
3393 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3394 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3396 changePflsNames(mapOfModif);
3400 * Renames the localization having a given name and updates references to this localization.
3401 * \param [in] oldName - the name of the localization to rename.
3402 * \param [in] newName - a new name of the localization.
3403 * \sa changeLocsNames().
3405 void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
3407 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3408 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3410 changeLocsNames(mapOfModif);
3414 * Removes duplicated profiles. Returns a map used to update references to removed
3415 * profiles via changePflsRefsNamesGen().
3416 * Equal profiles are found using whichAreEqualProfiles().
3417 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3418 * a sequence describing the performed replacements of profiles. Each element of
3419 * this sequence is a pair whose
3420 * - the first item is a vector of profile names replaced by the second item,
3421 * - the second item is a profile name replacing every profile of the first item.
3423 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
3425 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3426 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3428 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3430 std::vector< std::string > tmp((*it).size());
3432 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3433 tmp[j]=std::string(getProfileFromId(*it2)->getName());
3434 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3436 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3437 killProfileIds(tmp2);
3439 changePflsRefsNamesGen(ret);
3444 * Removes duplicated localizations. Returns a map used to update references to removed
3445 * localizations via changeLocsRefsNamesGen().
3446 * Equal localizations are found using whichAreEqualLocs().
3447 * \param [in] eps - a precision used to compare real values of the localizations.
3448 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3449 * a sequence describing the performed replacements of localizations. Each element of
3450 * this sequence is a pair whose
3451 * - the first item is a vector of localization names replaced by the second item,
3452 * - the second item is a localization name replacing every localization of the first item.
3454 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
3456 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3457 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3459 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3461 std::vector< std::string > tmp((*it).size());
3463 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3464 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3465 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3467 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3468 killLocalizationIds(tmp2);
3470 changeLocsRefsNamesGen(ret);
3475 * Returns number of Gauss points per cell in a given localization.
3476 * \param [in] locId - an id of the localization of interest.
3477 * \return int - the number of the Gauss points per cell.
3479 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
3481 return contentNotNull()->getNbOfGaussPtPerCell(locId);
3485 * Returns an id of a localization by its name.
3486 * \param [in] loc - the localization name of interest.
3487 * \return int - the id of the localization.
3488 * \throw If there is no a localization named \a loc.
3490 int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
3492 return contentNotNull()->getLocalizationId(loc);
3496 * Returns the name of the MED file.
3497 * \return const std::string& - the MED file name.
3499 std::string MEDFileFieldGlobsReal::getFileName() const
3501 return contentNotNull()->getFileName();
3505 * Returns a localization object by its name.
3506 * \param [in] locName - the name of the localization of interest.
3507 * \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3508 * \throw If there is no a localization named \a locName.
3510 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
3512 return contentNotNull()->getLocalization(locName);
3516 * Returns a localization object by its id.
3517 * \param [in] locId - the id of the localization of interest.
3518 * \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3519 * \throw If there is no a localization with id \a locId.
3521 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
3523 return contentNotNull()->getLocalizationFromId(locId);
3527 * Returns a profile array by its name.
3528 * \param [in] pflName - the name of the profile of interest.
3529 * \return const DataArrayInt * - the profile array having the name \a pflName.
3530 * \throw If there is no a profile named \a pflName.
3532 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
3534 return contentNotNull()->getProfile(pflName);
3538 * Returns a profile array by its id.
3539 * \param [in] pflId - the id of the profile of interest.
3540 * \return const DataArrayInt * - the profile array having the id \a pflId.
3541 * \throw If there is no a profile with id \a pflId.
3543 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
3545 return contentNotNull()->getProfileFromId(pflId);
3549 * Returns a localization object, apt for modification, by its id.
3550 * \param [in] locId - the id of the localization of interest.
3551 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3552 * having the id \a locId.
3553 * \throw If there is no a localization with id \a locId.
3555 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
3557 return contentNotNull()->getLocalizationFromId(locId);
3561 * Returns a localization object, apt for modification, by its name.
3562 * \param [in] locName - the name of the localization of interest.
3563 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3564 * having the name \a locName.
3565 * \throw If there is no a localization named \a locName.
3567 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
3569 return contentNotNull()->getLocalization(locName);
3573 * Returns a profile array, apt for modification, by its name.
3574 * \param [in] pflName - the name of the profile of interest.
3575 * \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3576 * \throw If there is no a profile named \a pflName.
3578 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
3580 return contentNotNull()->getProfile(pflName);
3584 * Returns a profile array, apt for modification, by its id.
3585 * \param [in] pflId - the id of the profile of interest.
3586 * \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3587 * \throw If there is no a profile with id \a pflId.
3589 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
3591 return contentNotNull()->getProfileFromId(pflId);
3595 * Removes profiles given by their ids. No data is updated to track this removal.
3596 * \param [in] pflIds - a sequence of ids of the profiles to remove.
3598 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
3600 contentNotNull()->killProfileIds(pflIds);
3604 * Removes localizations given by their ids. No data is updated to track this removal.
3605 * \param [in] locIds - a sequence of ids of the localizations to remove.
3607 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
3609 contentNotNull()->killLocalizationIds(locIds);
3613 * Stores a profile array.
3614 * \param [in] pfl - the profile array to store.
3615 * \throw If the name of \a pfl is empty.
3616 * \throw If a profile with the same name as that of \a pfl already exists but contains
3619 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
3621 contentNotNull()->appendProfile(pfl);
3625 * Adds a new localization of Gauss points.
3626 * \param [in] locName - the name of the new localization.
3627 * \param [in] geoType - a geometrical type of the reference cell.
3628 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
3629 * must be \c nbOfNodesPerCell * \c dimOfType.
3630 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
3631 * must be _wg_.size() * \c dimOfType.
3632 * \param [in] w - the weights of Gauss points.
3633 * \throw If \a locName is empty.
3634 * \throw If a localization with the name \a locName already exists but is
3635 * different form the new one.
3637 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)
3639 contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
3642 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
3644 MEDFileFieldGlobs *g(_globals);
3646 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
3650 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
3652 const MEDFileFieldGlobs *g(_globals);
3654 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
3658 //= MEDFileFieldNameScope
3660 MEDFileFieldNameScope::MEDFileFieldNameScope()
3664 MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName):_name(fieldName)
3669 * Returns the name of \a this field.
3670 * \return std::string - a string containing the field name.
3672 std::string MEDFileFieldNameScope::getName() const
3678 * Sets name of \a this field
3679 * \param [in] name - the new field name.
3681 void MEDFileFieldNameScope::setName(const std::string& fieldName)
3686 std::string MEDFileFieldNameScope::getDtUnit() const
3691 void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
3696 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
3699 _dt_unit=other._dt_unit;
3702 //= MEDFileAnyTypeField1TSWithoutSDA
3704 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
3706 _field_per_mesh.resize(other._field_per_mesh.size());
3708 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
3710 if((const MEDFileFieldPerMesh *)*it)
3711 _field_per_mesh[i]=(*it)->deepCpy(this);
3716 * Prints a string describing \a this field into a stream. This string is outputted
3717 * by \c print Python command.
3718 * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
3719 * \param [in,out] oss - the out stream.
3720 * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
3721 * info id printed, else, not.
3723 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
3725 std::string startOfLine(bkOffset,' ');
3726 oss << startOfLine << "Field ";
3728 oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
3729 oss << "on one time Step ";
3731 oss << "(" << f1tsId << ") ";
3732 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
3733 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
3734 const DataArray *arr=getUndergroundDataArray();
3737 const std::vector<std::string> &comps=arr->getInfoOnComponents();
3740 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
3741 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
3742 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
3744 if(arr->isAllocated())
3746 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
3749 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
3753 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
3755 oss << startOfLine << "----------------------" << std::endl;
3756 if(!_field_per_mesh.empty())
3759 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
3761 const MEDFileFieldPerMesh *cur=(*it2);
3763 cur->simpleRepr(bkOffset,oss,i);
3765 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
3770 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
3772 oss << startOfLine << "----------------------" << std::endl;
3775 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
3777 const DataArray *arr(getUndergroundDataArray());
3779 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
3780 int nbOfCompo=arr->getNumberOfComponents();
3781 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
3782 for(int i=0;i<nbOfCompo;i++)
3785 std::vector<int> v(1,i);
3786 MEDCouplingAutoRefCountObjectPtr<DataArray> arr2=arr->keepSelectedComponents(v);
3787 ret[i]->setArray(arr2);
3792 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)
3796 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
3801 * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
3802 * empty. Returns -1 if this in on nodes.
3803 * \return int - the dimension of \a this.
3805 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
3808 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3809 (*it)->getDimension(ret);
3814 * Returns the mesh name.
3815 * \return std::string - a string holding the mesh name.
3816 * \throw If \c _field_per_mesh.empty()
3818 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const
3820 if(_field_per_mesh.empty())
3821 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
3822 return _field_per_mesh[0]->getMeshName();
3825 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const std::string& newMeshName)
3827 std::string oldName(getMeshName());
3828 std::vector< std::pair<std::string,std::string> > v(1);
3829 v[0].first=oldName; v[0].second=newMeshName;
3833 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
3836 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3838 MEDFileFieldPerMesh *cur(*it);
3840 ret=cur->changeMeshNames(modifTab) || ret;
3846 * Returns the number of iteration of the state of underlying mesh.
3847 * \return int - the iteration number.
3848 * \throw If \c _field_per_mesh.empty()
3850 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
3852 if(_field_per_mesh.empty())
3853 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
3854 return _field_per_mesh[0]->getMeshIteration();
3858 * Returns the order number of iteration of the state of underlying mesh.
3859 * \return int - the order number.
3860 * \throw If \c _field_per_mesh.empty()
3862 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
3864 if(_field_per_mesh.empty())
3865 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
3866 return _field_per_mesh[0]->getMeshOrder();
3870 * Checks if \a this field is tagged by a given iteration number and a given
3871 * iteration order number.
3872 * \param [in] iteration - the iteration number of interest.
3873 * \param [in] order - the iteration order number of interest.
3874 * \return bool - \c true if \a this->getIteration() == \a iteration &&
3875 * \a this->getOrder() == \a order.
3877 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
3879 return iteration==_iteration && order==_order;
3883 * Returns number of iteration and order number of iteration when
3884 * \a this field has been calculated.
3885 * \return std::pair<int,int> - a pair of the iteration number and the iteration
3888 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
3890 std::pair<int,int> p;
3896 * Returns number of iteration and order number of iteration when
3897 * \a this field has been calculated.
3898 * \param [in,out] p - a pair returning the iteration number and the iteration
3901 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
3908 * Returns all types of spatial discretization of \a this field.
3909 * \param [in,out] types - a sequence of types of \a this field.
3911 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
3913 std::set<TypeOfField> types2;
3914 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3916 (*it)->fillTypesOfFieldAvailable(types2);
3918 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
3919 std::copy(types2.begin(),types2.end(),bi);
3923 * Returns all types of spatial discretization of \a this field.
3924 * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
3927 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
3929 std::vector<TypeOfField> ret;
3930 fillTypesOfFieldAvailable(ret);
3934 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
3936 std::vector<std::string> ret;
3937 std::set<std::string> ret2;
3938 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3940 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
3941 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3942 if(ret2.find(*it2)==ret2.end())
3944 ret.push_back(*it2);
3951 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
3953 std::vector<std::string> ret;
3954 std::set<std::string> ret2;
3955 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3957 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
3958 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3959 if(ret2.find(*it2)==ret2.end())
3961 ret.push_back(*it2);
3968 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
3970 std::vector<std::string> ret;
3971 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3973 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
3974 ret.insert(ret.end(),tmp.begin(),tmp.end());
3979 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
3981 std::vector<std::string> ret;
3982 std::set<std::string> ret2;
3983 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3985 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
3986 ret.insert(ret.end(),tmp.begin(),tmp.end());
3991 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3993 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3994 (*it)->changePflsRefsNamesGen(mapOfModif);
3997 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3999 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4000 (*it)->changeLocsRefsNamesGen(mapOfModif);
4004 * Returns all attributes of parts of \a this field lying on a given mesh.
4005 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4006 * item of every of returned sequences refers to the _i_-th part of \a this field.
4007 * Thus all sequences returned by this method are of the same length equal to number
4008 * of different types of supporting entities.<br>
4009 * A field part can include sub-parts with several different spatial discretizations,
4010 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
4011 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4012 * of a nested sequence corresponds to a type of spatial discretization.<br>
4013 * This method allows for iteration over MEDFile DataStructure without any overhead.
4014 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4015 * for the case with only one underlying mesh. (Actually, the number of meshes is
4016 * not checked if \a mname == \c NULL).
4017 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4018 * a field part is returned.
4019 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4020 * This sequence is of the same length as \a types.
4021 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4022 * discretization. A profile name can be empty.
4023 * Length of this and of nested sequences is the same as that of \a typesF.
4024 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4025 * discretization. A localization name can be empty.
4026 * Length of this and of nested sequences is the same as that of \a typesF.
4027 * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
4028 * of ids of tuples within the data array, per each type of spatial
4029 * discretization within one mesh entity type.
4030 * Length of this and of nested sequences is the same as that of \a typesF.
4031 * \throw If no field is lying on \a mname.
4033 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
4037 meshId=getMeshIdFromMeshName(mname);
4039 if(_field_per_mesh.empty())
4040 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4041 return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4045 * Returns dimensions of mesh elements \a this field lies on. The returned value is a
4046 * maximal absolute dimension and values returned via the out parameter \a levs are
4047 * dimensions relative to the maximal absolute dimension. <br>
4048 * This method is designed for MEDFileField1TS instances that have a discretization
4049 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS",
4050 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT",
4051 * \ref ParaMEDMEM::ON_GAUSS_NE "ON_GAUSS_NE".
4052 * Only these 3 discretizations will be taken into account here. If \a this is
4053 * \ref ParaMEDMEM::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
4054 * This method is useful to make the link between the dimension of the underlying mesh
4055 * and the levels of \a this, because it is possible that the highest dimension of \a this
4056 * field is not equal to the dimension of the underlying mesh.
4058 * Let's consider the following case:
4059 * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
4060 * TETRA4, HEXA8, TRI3 and SEG2.
4061 * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
4062 * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
4064 * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
4065 * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
4066 * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
4067 * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
4068 * parameter of getFieldAtLevel() is computed basing on the returned values as this:
4069 * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
4071 * to retrieve the highest level of
4072 * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br>
4073 * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
4074 * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
4075 * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
4076 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4077 * for the case with only one underlying mesh. (Actually, the number of meshes is
4078 * not checked if \a mname == \c NULL).
4079 * \param [in,out] levs - a sequence returning the dimensions relative to the maximal
4080 * absolute one. They are in decreasing order. This sequence is cleared before
4082 * \return int - the maximal absolute dimension of elements \a this fields lies on.
4083 * \throw If no field is lying on \a mname.
4085 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
4088 int meshId=getMeshIdFromMeshName(mname);
4089 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4090 std::vector< std::vector<TypeOfField> > typesF;
4091 std::vector< std::vector<std::string> > pfls, locs;
4092 _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4094 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
4095 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
4096 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
4098 st.erase(INTERP_KERNEL::NORM_ERROR);
4100 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
4102 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
4103 ret1.insert((int)cm.getDimension());
4105 int ret=*std::max_element(ret1.begin(),ret1.end());
4106 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
4107 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
4112 * \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.
4113 * \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.
4114 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4115 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4117 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
4119 int mid=getMeshIdFromMeshName(mName);
4120 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4124 * \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.
4125 * \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.
4126 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4127 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4129 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
4131 int mid=getMeshIdFromMeshName(mName);
4132 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4136 * \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.
4138 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
4140 if(_field_per_mesh.empty())
4141 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4144 std::string mName2(mName);
4146 std::vector<std::string> msg;
4147 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4148 if(mName2==(*it)->getMeshName())
4151 msg.push_back((*it)->getMeshName());
4152 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4153 oss << "Possible meshes are : ";
4154 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4155 oss << "\"" << (*it2) << "\" ";
4156 throw INTERP_KERNEL::Exception(oss.str().c_str());
4159 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
4162 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4163 std::string tmp(mesh->getName());
4165 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4166 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4168 for(;it!=_field_per_mesh.end();it++,i++)
4170 if((*it)->getMeshName()==tmp)
4173 int sz=_field_per_mesh.size();
4174 _field_per_mesh.resize(sz+1);
4175 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4179 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4180 MEDFileFieldGlobsReal& glob)
4183 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4185 MEDFileFieldPerMesh *fpm(*it);
4187 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4193 * This method splits \a this into several sub-parts so that each sub parts have exactly one spatial discretization. This method implements the minimal
4194 * splitting that leads to single spatial discretization of this.
4196 * \sa splitMultiDiscrPerGeoTypes
4198 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
4200 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4201 std::vector< std::vector<TypeOfField> > typesF;
4202 std::vector< std::vector<std::string> > pfls,locs;
4203 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4204 std::set<TypeOfField> allEnt;
4205 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4206 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4207 allEnt.insert(*it2);
4208 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4209 std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4210 for(std::size_t i=0;i<allEnt.size();i++,it3++)
4212 std::vector< std::pair<int,int> > its;
4213 ret[i]=shallowCpy();
4214 int newLgth(ret[i]->keepOnlySpatialDiscretization(*it3,its));
4215 ret[i]->updateData(newLgth,its);
4221 * This method performs a sub splitting as splitDiscretizations does but finer. This is the finest spliting level that can be done.
4222 * This method implements the minimal splitting so that each returned elements are mono Gauss discretization per geometric type.
4224 * \sa splitDiscretizations
4226 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes() const
4228 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4229 std::vector< std::vector<TypeOfField> > typesF;
4230 std::vector< std::vector<std::string> > pfls,locs;
4231 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4232 std::set<TypeOfField> allEnt;
4233 std::size_t nbOfMDPGT(0),ii(0);
4234 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++,ii++)
4236 nbOfMDPGT=std::max(nbOfMDPGT,locs[ii].size());
4237 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4238 allEnt.insert(*it2);
4240 if(allEnt.size()!=1)
4241 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : this field is expected to be defined only on one spatial discretization !");
4243 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
4246 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret0(1);
4247 ret0[0]=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(this); this->incrRef();
4250 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfMDPGT);
4251 for(std::size_t i=0;i<allEnt.size();i++)
4253 std::vector< std::pair<int,int> > its;
4254 ret[i]=shallowCpy();
4255 int newLgth(ret[i]->keepOnlyGaussDiscretization(i,its));
4256 ret[i]->updateData(newLgth,its);
4261 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
4263 int globalCounter(0);
4264 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4265 (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4266 return globalCounter;
4269 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlyGaussDiscretization(std::size_t idOfDisc, std::vector< std::pair<int,int> >& its)
4271 int globalCounter(0);
4272 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4273 (*it)->keepOnlyGaussDiscretization(idOfDisc,globalCounter,its);
4274 return globalCounter;
4277 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
4279 if(_nb_of_tuples_to_be_allocated>=0)
4281 _nb_of_tuples_to_be_allocated=newLgth;
4282 const DataArray *oldArr(getUndergroundDataArray());
4285 MEDCouplingAutoRefCountObjectPtr<DataArray> newArr(createNewEmptyDataArrayInstance());
4286 newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
4288 _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
4292 if(_nb_of_tuples_to_be_allocated==-1)
4294 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4296 const DataArray *oldArr(getUndergroundDataArray());
4297 if(!oldArr || !oldArr->isAllocated())
4298 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4299 MEDCouplingAutoRefCountObjectPtr<DataArray> newArr(createNewEmptyDataArrayInstance());
4300 newArr->alloc(newLgth,getNumberOfComponents());
4302 newArr->copyStringInfoFrom(*oldArr);
4304 for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4306 if((*it).second<(*it).first)
4307 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4308 newArr->setContigPartOfSelectedValues2(pos,oldArr,(*it).first,(*it).second,1);
4309 pos+=(*it).second-(*it).first;
4314 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4317 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
4319 if(_field_per_mesh.empty())
4320 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4321 if(_field_per_mesh.size()>1)
4322 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4323 _field_per_mesh[0]->copyOptionsFrom(opts);
4324 _field_per_mesh[0]->writeLL(fid,nasc);
4328 * 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.
4329 * If false is returned the memory allocation is not required.
4331 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
4333 if(_nb_of_tuples_to_be_allocated>=0)
4335 getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4336 _nb_of_tuples_to_be_allocated=-2;
4339 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4341 if(_nb_of_tuples_to_be_allocated==-1)
4342 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4343 if(_nb_of_tuples_to_be_allocated<-3)
4344 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4345 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4348 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms)
4350 med_int numdt,numit;
4354 med_int meshnumdt,meshnumit;
4355 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4356 MEDfieldComputingStepInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt);
4357 MEDfield23ComputingStepMeshInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit);
4358 if(_iteration!=numdt || _order!=numit)
4359 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4360 _field_per_mesh.resize(nmesh);
4365 std::string meshNameCpp(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
4366 mm=ms->getMeshWithName(meshNameCpp);
4369 for(int i=0;i<nmesh;i++)
4370 _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i,meshnumdt,meshnumit,nasc,mm);
4371 _nb_of_tuples_to_be_allocated=0;
4372 for(int i=0;i<nmesh;i++)
4373 _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4376 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
4378 allocIfNecessaryTheArrayToReceiveDataFromFile();
4379 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4380 (*it)->loadBigArraysRecursively(fid,nasc);
4383 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
4385 if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4386 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4387 (*it)->loadBigArraysRecursively(fid,nasc);
4390 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms)
4392 loadOnlyStructureOfDataRecursively(fid,nasc,ms);
4393 loadBigArraysRecursively(fid,nasc);
4396 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
4398 DataArray *thisArr(getUndergroundDataArray());
4399 if(thisArr && thisArr->isAllocated())
4401 _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
4402 thisArr->desallocate();
4406 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
4408 return _dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh >);
4411 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
4413 std::vector<const BigMemoryObject *> ret;
4414 if(getUndergroundDataArray())
4415 ret.push_back(getUndergroundDataArray());
4416 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4417 ret.push_back((const MEDFileFieldPerMesh *)*it);
4422 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4423 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4424 * "Sort By Type"), if not, an exception is thrown.
4425 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
4426 * \param [in] arr - the array of values.
4427 * \param [in,out] glob - the global data where profiles and localization present in
4428 * \a field, if any, are added.
4429 * \throw If the name of \a field is empty.
4430 * \throw If the data array of \a field is not set.
4431 * \throw If \a this->_arr is already allocated but has different number of components
4433 * \throw If the underlying mesh of \a field has no name.
4434 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4436 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4438 const MEDCouplingMesh *mesh=field->getMesh();
4440 TypeOfField type=field->getTypeOfField();
4441 std::vector<DataArrayInt *> dummy;
4442 int start=copyTinyInfoFrom(field,arr);
4443 int pos=addNewEntryIfNecessary(mesh);
4446 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4447 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4450 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4454 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4455 * of a given mesh are used as the support of the given field (a real support is not used).
4456 * Elements of the given mesh must be sorted suitable for writing to MED file.
4457 * Order of underlying mesh entities of the given field specified by \a profile parameter
4458 * is not prescribed; this method permutes field values to have them sorted by element
4459 * type as required for writing to MED file. A new profile is added only if no equal
4460 * profile is missing.
4461 * \param [in] field - the field to add to \a this. The field double values are ignored.
4462 * \param [in] arrOfVals - the values of the field \a field used.
4463 * \param [in] mesh - the supporting mesh of \a field.
4464 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4465 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
4466 * \param [in,out] glob - the global data where profiles and localization present in
4467 * \a field, if any, are added.
4468 * \throw If either \a field or \a mesh or \a profile has an empty name.
4469 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4470 * \throw If the data array of \a field is not set.
4471 * \throw If \a this->_arr is already allocated but has different number of components
4473 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4474 * \sa setFieldNoProfileSBT()
4476 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4479 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
4480 if(!arrOfVals || !arrOfVals->isAllocated())
4481 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
4482 TypeOfField type=field->getTypeOfField();
4483 std::vector<DataArrayInt *> idsInPflPerType;
4484 std::vector<DataArrayInt *> idsPerType;
4485 std::vector<int> code,code2;
4486 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4489 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4490 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
4491 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin());
4492 std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
4494 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> field2=field->clone(false);
4495 int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
4496 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4498 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4499 throw INTERP_KERNEL::Exception(oss.str().c_str());
4502 int start=copyTinyInfoFrom(field,arrOfVals);
4503 code2=m->getDistributionOfTypes();
4505 int pos=addNewEntryIfNecessary(m);
4506 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4510 if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
4511 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
4512 std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
4513 std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
4514 int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
4515 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4517 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4518 throw INTERP_KERNEL::Exception(oss.str().c_str());
4520 int start=copyTinyInfoFrom(field,arrOfVals);
4521 int pos=addNewEntryIfNecessary(m);
4522 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4527 * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
4529 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
4531 if(_nb_of_tuples_to_be_allocated>=0)
4532 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 !");
4533 DataArray *arr(getOrCreateAndGetArray());
4534 arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
4535 _nb_of_tuples_to_be_allocated=-3;
4539 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4540 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4541 * larger by the size of \a field. Returns an id of the first not filled
4542 * tuple of \a this->_arr.
4543 * \param [in] field - the field to copy the info on components and the name from.
4544 * \return int - the id of first not initialized tuple of \a this->_arr.
4545 * \throw If the name of \a field is empty.
4546 * \throw If the data array of \a field is not set.
4547 * \throw If \a this->_arr is already allocated but has different number of components
4550 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
4553 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4554 std::string name(field->getName());
4555 setName(name.c_str());
4556 setDtUnit(field->getTimeUnit());
4558 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4560 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4561 if(!arr->isAllocated())
4562 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
4563 _dt=field->getTime(_iteration,_order);
4564 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4565 if(!getOrCreateAndGetArray()->isAllocated())
4567 allocNotFromFile(arr->getNumberOfTuples());
4572 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4573 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4574 getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
4575 _nb_of_tuples_to_be_allocated=-3;
4576 return oldNbOfTuples;
4581 * Returns number of components in \a this field
4582 * \return int - the number of components.
4584 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4586 return getOrCreateAndGetArray()->getNumberOfComponents();
4590 * Change info on components in \a this.
4591 * \throw If size of \a infos is not equal to the number of components already in \a this.
4593 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
4595 DataArray *arr=getOrCreateAndGetArray();
4596 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
4600 * Returns info on components of \a this field.
4601 * \return const std::vector<std::string>& - a sequence of strings each being an
4602 * information on _i_-th component.
4604 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
4606 const DataArray *arr=getOrCreateAndGetArray();
4607 return arr->getInfoOnComponents();
4611 * Returns a mutable info on components of \a this field.
4612 * \return std::vector<std::string>& - a sequence of strings each being an
4613 * information on _i_-th component.
4615 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
4617 DataArray *arr=getOrCreateAndGetArray();
4618 return arr->getInfoOnComponents();
4621 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const
4623 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4625 const MEDFileFieldPerMesh *fpm(*it);
4628 if(fpm->presenceOfMultiDiscPerGeoType())
4635 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4636 * \param [in] type - a spatial discretization of the new field.
4637 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4638 * \param [in] mName - a name of the supporting mesh.
4639 * \param [in] renumPol - specifies how to permute values of the result field according to
4640 * the optional numbers of cells and nodes, if any. The valid values are
4641 * - 0 - do not permute.
4642 * - 1 - permute cells.
4643 * - 2 - permute nodes.
4644 * - 3 - permute cells and nodes.
4646 * \param [in] glob - the global data storing profiles and localization.
4647 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4648 * caller is to delete this field using decrRef() as it is no more needed.
4649 * \throw If the MED file is not readable.
4650 * \throw If there is no mesh named \a mName in the MED file.
4651 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4652 * \throw If no field of \a this is lying on the mesh \a mName.
4653 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4655 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4657 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4659 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4661 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4662 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4666 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4667 * \param [in] type - a spatial discretization of the new field.
4668 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4669 * \param [in] renumPol - specifies how to permute values of the result field according to
4670 * the optional numbers of cells and nodes, if any. The valid values are
4671 * - 0 - do not permute.
4672 * - 1 - permute cells.
4673 * - 2 - permute nodes.
4674 * - 3 - permute cells and nodes.
4676 * \param [in] glob - the global data storing profiles and localization.
4677 * \param [in] mesh - the supporting mesh.
4678 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4679 * caller is to delete this field using decrRef() as it is no more needed.
4680 * \throw If the MED file is not readable.
4681 * \throw If no field of \a this is lying on \a mesh.
4682 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4683 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4685 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4687 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax,false);
4688 const DataArrayInt *d=mesh->getNumberFieldAtLevel(meshDimRelToMax);
4689 const DataArrayInt *e=mesh->getNumberFieldAtLevel(1);
4690 if(meshDimRelToMax==1)
4691 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
4692 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
4696 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
4698 * \param [in] type - a spatial discretization of the new field.
4699 * \param [in] mName - a name of the supporting mesh.
4700 * \param [in] renumPol - specifies how to permute values of the result field according to
4701 * the optional numbers of cells and nodes, if any. The valid values are
4702 * - 0 - do not permute.
4703 * - 1 - permute cells.
4704 * - 2 - permute nodes.
4705 * - 3 - permute cells and nodes.
4707 * \param [in] glob - the global data storing profiles and localization.
4708 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4709 * caller is to delete this field using decrRef() as it is no more needed.
4710 * \throw If the MED file is not readable.
4711 * \throw If there is no mesh named \a mName in the MED file.
4712 * \throw If there are no mesh entities in the mesh.
4713 * \throw If no field values of the given \a type are available.
4715 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4717 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4719 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4721 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4722 int absDim=getDimension();
4723 int meshDimRelToMax=absDim-mm->getMeshDimension();
4724 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4728 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4729 * \param [in] type - a spatial discretization of the new field.
4730 * \param [in] renumPol - specifies how to permute values of the result field according to
4731 * the optional numbers of cells and nodes, if any. The valid values are
4732 * - 0 - do not permute.
4733 * - 1 - permute cells.
4734 * - 2 - permute nodes.
4735 * - 3 - permute cells and nodes.
4737 * \param [in] glob - the global data storing profiles and localization.
4738 * \param [in] mesh - the supporting mesh.
4739 * \param [in] cellRenum - the cell numbers array used for permutation of the result
4740 * field according to \a renumPol.
4741 * \param [in] nodeRenum - the node numbers array used for permutation of the result
4742 * field according to \a renumPol.
4743 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4744 * caller is to delete this field using decrRef() as it is no more needed.
4745 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4746 * \throw If no field of \a this is lying on \a mesh.
4747 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4749 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
4751 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
4752 int meshId=getMeshIdFromMeshName(mesh->getName());
4754 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
4759 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4766 throw INTERP_KERNEL::Exception(msg1);
4767 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4770 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
4772 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4773 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
4774 throw INTERP_KERNEL::Exception(oss.str().c_str());
4776 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
4777 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
4778 std::vector<DataArray *> arrOut2(1,arrOut);
4779 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
4780 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
4781 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
4788 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4790 throw INTERP_KERNEL::Exception(msg1);
4793 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
4795 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4796 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
4797 throw INTERP_KERNEL::Exception(oss.str().c_str());
4799 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
4800 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
4801 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
4802 ret->renumberNodes(nodeRenumSafe->getConstPointer());
4807 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
4812 * Returns values and a profile of the field of a given type lying on a given support.
4813 * \param [in] type - a spatial discretization of the field.
4814 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4815 * \param [in] mesh - the supporting mesh.
4816 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
4817 * field of interest lies on. If the field lies on all entities of the given
4818 * dimension, all ids in \a pfl are zero. The caller is to delete this array
4819 * using decrRef() as it is no more needed.
4820 * \param [in] glob - the global data storing profiles and localization.
4821 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
4822 * field. The caller is to delete this array using decrRef() as it is no more needed.
4823 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4824 * \throw If no field of \a this is lying on \a mesh.
4825 * \throw If no field values of the given \a type are available.
4827 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
4829 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4830 int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
4831 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
4832 ret->setName(nasc.getName().c_str());
4836 //= MEDFileField1TSWithoutSDA
4839 * Throws if a given value is not a valid (non-extended) relative dimension.
4840 * \param [in] meshDimRelToMax - the relative dimension value.
4841 * \throw If \a meshDimRelToMax > 0.
4843 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
4845 if(meshDimRelToMax>0)
4846 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
4850 * Checks if elements of a given mesh are in the order suitable for writing
4851 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
4852 * vector describing types of elements and their number.
4853 * \param [in] mesh - the mesh to check.
4854 * \return std::vector<int> - a vector holding for each element type (1) item of
4855 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
4856 * These values are in full-interlace mode.
4857 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4859 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
4862 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
4863 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
4864 int nbOfTypes=geoTypes.size();
4865 std::vector<int> code(3*nbOfTypes);
4866 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr1=DataArrayInt::New();
4867 arr1->alloc(nbOfTypes,1);
4868 int *arrPtr=arr1->getPointer();
4869 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
4870 for(int i=0;i<nbOfTypes;i++,it++)
4871 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
4872 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
4873 const int *arrPtr2=arr2->getConstPointer();
4875 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
4878 int nbCells=mesh->getNumberOfCellsWithType(*it);
4879 code[3*pos]=(int)(*it);
4880 code[3*pos+1]=nbCells;
4881 code[3*pos+2]=-1;//no profiles
4883 std::vector<const DataArrayInt *> idsPerType;//no profiles
4884 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
4888 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
4893 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
4895 return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
4899 * Returns all attributes and values of parts of \a this field lying on a given mesh.
4900 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4901 * item of every of returned sequences refers to the _i_-th part of \a this field.
4902 * Thus all sequences returned by this method are of the same length equal to number
4903 * of different types of supporting entities.<br>
4904 * A field part can include sub-parts with several different spatial discretizations,
4905 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
4906 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4907 * of a nested sequence corresponds to a type of spatial discretization.<br>
4908 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
4909 * The overhead is due to selecting values into new instances of DataArrayDouble.
4910 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4911 * for the case with only one underlying mesh. (Actually, the number of meshes is
4912 * not checked if \a mname == \c NULL).
4913 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4914 * a field part is returned.
4915 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4916 * A field part can include sub-parts with several different spatial discretizations,
4917 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and
4918 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT" for example.
4919 * This sequence is of the same length as \a types.
4920 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4921 * discretization. A profile name can be empty.
4922 * Length of this and of nested sequences is the same as that of \a typesF.
4923 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4924 * discretization. A localization name can be empty.
4925 * Length of this and of nested sequences is the same as that of \a typesF.
4926 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
4927 * per each type of spatial discretization within one mesh entity type.
4928 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
4929 * Length of this and of nested sequences is the same as that of \a typesF.
4930 * \throw If no field is lying on \a mname.
4932 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
4936 meshId=getMeshIdFromMeshName(mname);
4938 if(_field_per_mesh.empty())
4939 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4940 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4941 int nbOfRet=ret0.size();
4942 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
4943 for(int i=0;i<nbOfRet;i++)
4945 const std::vector< std::pair<int,int> >& p=ret0[i];
4946 int nbOfRet1=p.size();
4947 ret[i].resize(nbOfRet1);
4948 for(int j=0;j<nbOfRet1;j++)
4950 DataArrayDouble *tmp=_arr->selectByTupleId2(p[j].first,p[j].second,1);
4958 * Returns a pointer to the underground DataArrayDouble instance. So the
4959 * caller should not decrRef() it. This method allows for a direct access to the field
4960 * values. This method is quite unusable if there is more than a nodal field or a cell
4961 * field on single geometric cell type.
4962 * \return DataArrayDouble * - the pointer to the field values array.
4964 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDouble() const
4966 const DataArrayDouble *ret=_arr;
4968 return const_cast<DataArrayDouble *>(ret);
4973 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
4978 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
4980 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
4981 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
4982 ret->deepCpyLeavesFrom(*this);
4983 const DataArrayDouble *arr(_arr);
4986 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr->convertToIntArr());
4987 ret->setArray(arr2);
4993 * Returns a pointer to the underground DataArrayDouble instance. So the
4994 * caller should not decrRef() it. This method allows for a direct access to the field
4995 * values. This method is quite unusable if there is more than a nodal field or a cell
4996 * field on single geometric cell type.
4997 * \return DataArrayDouble * - the pointer to the field values array.
4999 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArray() const
5001 return getUndergroundDataArrayDouble();
5005 * Returns a pointer to the underground DataArrayDouble instance and a
5006 * sequence describing parameters of a support of each part of \a this field. The
5007 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5008 * direct access to the field values. This method is intended for the field lying on one
5010 * \param [in,out] entries - the sequence describing parameters of a support of each
5011 * part of \a this field. Each item of this sequence consists of two parts. The
5012 * first part describes a type of mesh entity and an id of discretization of a
5013 * current field part. The second part describes a range of values [begin,end)
5014 * within the returned array relating to the current field part.
5015 * \return DataArrayDouble * - the pointer to the field values array.
5016 * \throw If the number of underlying meshes is not equal to 1.
5017 * \throw If no field values are available.
5018 * \sa getUndergroundDataArray()
5020 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5022 if(_field_per_mesh.size()!=1)
5023 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5024 if(_field_per_mesh[0]==0)
5025 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5026 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5027 return getUndergroundDataArrayDouble();
5031 * Returns a pointer to the underground DataArrayDouble instance and a
5032 * sequence describing parameters of a support of each part of \a this field. The
5033 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5034 * direct access to the field values. This method is intended for the field lying on one
5036 * \param [in,out] entries - the sequence describing parameters of a support of each
5037 * part of \a this field. Each item of this sequence consists of two parts. The
5038 * first part describes a type of mesh entity and an id of discretization of a
5039 * current field part. The second part describes a range of values [begin,end)
5040 * within the returned array relating to the current field part.
5041 * \return DataArrayDouble * - the pointer to the field values array.
5042 * \throw If the number of underlying meshes is not equal to 1.
5043 * \throw If no field values are available.
5044 * \sa getUndergroundDataArray()
5046 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5048 return getUndergroundDataArrayDoubleExt(entries);
5051 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
5053 DataArrayDouble *arr(getOrCreateAndGetArrayDouble());
5054 arr->setInfoAndChangeNbOfCompo(infos);
5057 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
5061 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
5063 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
5064 ret->deepCpyLeavesFrom(*this);
5068 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCpy() const
5070 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret=static_cast<MEDFileField1TSWithoutSDA *>(shallowCpy());
5071 if((const DataArrayDouble *)_arr)
5072 ret->_arr=_arr->deepCpy();
5076 void MEDFileField1TSWithoutSDA::setArray(DataArray *arr)
5080 _nb_of_tuples_to_be_allocated=-1;
5084 DataArrayDouble *arrC=dynamic_cast<DataArrayDouble *>(arr);
5086 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayDouble !");
5088 _nb_of_tuples_to_be_allocated=-3;
5093 DataArray *MEDFileField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
5095 return DataArrayDouble::New();
5098 DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble()
5100 DataArrayDouble *ret=_arr;
5103 _arr=DataArrayDouble::New();
5107 DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray()
5109 return getOrCreateAndGetArrayDouble();
5112 const DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble() const
5114 const DataArrayDouble *ret=_arr;
5117 DataArrayDouble *ret2=DataArrayDouble::New();
5118 const_cast<MEDFileField1TSWithoutSDA *>(this)->_arr=DataArrayDouble::New();
5122 const DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray() const
5124 return getOrCreateAndGetArrayDouble();
5127 //= MEDFileIntField1TSWithoutSDA
5129 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5131 return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5134 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
5138 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order,
5139 const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
5141 DataArrayInt *arr(getOrCreateAndGetArrayInt());
5142 arr->setInfoAndChangeNbOfCompo(infos);
5145 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
5150 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const
5152 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
5153 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5154 ret->deepCpyLeavesFrom(*this);
5155 const DataArrayInt *arr(_arr);
5158 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2(arr->convertToDblArr());
5159 ret->setArray(arr2);
5165 * Returns a pointer to the underground DataArrayInt instance. So the
5166 * caller should not decrRef() it. This method allows for a direct access to the field
5167 * values. This method is quite unusable if there is more than a nodal field or a cell
5168 * field on single geometric cell type.
5169 * \return DataArrayInt * - the pointer to the field values array.
5171 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArray() const
5173 return getUndergroundDataArrayInt();
5177 * Returns a pointer to the underground DataArrayInt instance. So the
5178 * caller should not decrRef() it. This method allows for a direct access to the field
5179 * values. This method is quite unusable if there is more than a nodal field or a cell
5180 * field on single geometric cell type.
5181 * \return DataArrayInt * - the pointer to the field values array.
5183 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayInt() const
5185 const DataArrayInt *ret=_arr;
5187 return const_cast<DataArrayInt *>(ret);
5193 * Returns a pointer to the underground DataArrayInt instance and a
5194 * sequence describing parameters of a support of each part of \a this field. The
5195 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5196 * direct access to the field values. This method is intended for the field lying on one
5198 * \param [in,out] entries - the sequence describing parameters of a support of each
5199 * part of \a this field. Each item of this sequence consists of two parts. The
5200 * first part describes a type of mesh entity and an id of discretization of a
5201 * current field part. The second part describes a range of values [begin,end)
5202 * within the returned array relating to the current field part.
5203 * \return DataArrayInt * - the pointer to the field values array.
5204 * \throw If the number of underlying meshes is not equal to 1.
5205 * \throw If no field values are available.
5206 * \sa getUndergroundDataArray()
5208 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5210 return getUndergroundDataArrayIntExt(entries);
5214 * Returns a pointer to the underground DataArrayInt instance and a
5215 * sequence describing parameters of a support of each part of \a this field. The
5216 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5217 * direct access to the field values. This method is intended for the field lying on one
5219 * \param [in,out] entries - the sequence describing parameters of a support of each
5220 * part of \a this field. Each item of this sequence consists of two parts. The
5221 * first part describes a type of mesh entity and an id of discretization of a
5222 * current field part. The second part describes a range of values [begin,end)
5223 * within the returned array relating to the current field part.
5224 * \return DataArrayInt * - the pointer to the field values array.
5225 * \throw If the number of underlying meshes is not equal to 1.
5226 * \throw If no field values are available.
5227 * \sa getUndergroundDataArray()
5229 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5231 if(_field_per_mesh.size()!=1)
5232 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5233 if(_field_per_mesh[0]==0)
5234 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5235 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5236 return getUndergroundDataArrayInt();
5239 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5241 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5242 ret->deepCpyLeavesFrom(*this);
5246 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCpy() const
5248 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret=static_cast<MEDFileIntField1TSWithoutSDA *>(shallowCpy());
5249 if((const DataArrayInt *)_arr)
5250 ret->_arr=_arr->deepCpy();
5254 void MEDFileIntField1TSWithoutSDA::setArray(DataArray *arr)
5258 _nb_of_tuples_to_be_allocated=-1;
5262 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>(arr);
5264 throw INTERP_KERNEL::Exception("MEDFileIntField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayInt !");
5266 _nb_of_tuples_to_be_allocated=-3;
5271 DataArray *MEDFileIntField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
5273 return DataArrayInt::New();
5276 DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt()
5278 DataArrayInt *ret=_arr;
5281 _arr=DataArrayInt::New();
5285 DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray()
5287 return getOrCreateAndGetArrayInt();
5290 const DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt() const
5292 const DataArrayInt *ret=_arr;
5295 DataArrayInt *ret2=DataArrayInt::New();
5296 const_cast<MEDFileIntField1TSWithoutSDA *>(this)->_arr=DataArrayInt::New();
5300 const DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray() const
5302 return getOrCreateAndGetArrayInt();
5305 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5309 //= MEDFileAnyTypeField1TS
5311 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
5313 med_field_type typcha;
5315 std::vector<std::string> infos;
5316 std::string dtunit,fieldName;
5317 LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
5318 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5323 ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5328 ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5333 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] !";
5334 throw INTERP_KERNEL::Exception(oss.str().c_str());
5337 ret->setDtUnit(dtunit.c_str());
5338 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5340 med_int numdt,numit;
5342 MEDfieldComputingStepInfo(fid,fieldName.c_str(),1,&numdt,&numit,&dt);
5343 ret->setTime(numdt,numit,dt);
5346 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms);
5348 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms);
5352 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
5353 try:MEDFileFieldGlobsReal(fileName)
5355 MEDFileUtilities::CheckFileForRead(fileName);
5356 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5357 _content=BuildContentFrom(fid,fileName,loadAll,ms);
5360 catch(INTERP_KERNEL::Exception& e)
5365 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5367 med_field_type typcha;
5368 std::vector<std::string> infos;
5371 int nbSteps=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5372 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5377 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5382 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5387 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] !";
5388 throw INTERP_KERNEL::Exception(oss.str().c_str());
5391 ret->setDtUnit(dtunit.c_str());
5392 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5396 std::ostringstream oss; oss << "MEDFileField1TS(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5397 throw INTERP_KERNEL::Exception(oss.str().c_str());
5400 med_int numdt,numit;
5402 MEDfieldComputingStepInfo(fid,fieldName.c_str(),1,&numdt,&numit,&dt);
5403 ret->setTime(numdt,numit,dt);
5406 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms);
5408 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms);
5412 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5413 try:MEDFileFieldGlobsReal(fileName)
5415 MEDFileUtilities::CheckFileForRead(fileName);
5416 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5417 _content=BuildContentFrom(fid,fileName,fieldName,loadAll,ms);
5420 catch(INTERP_KERNEL::Exception& e)
5425 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, const std::string& fileName)
5428 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5429 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5431 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New();
5432 ret->setFileName(fileName);
5433 ret->_content=c; c->incrRef();
5436 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5438 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New();
5439 ret->setFileName(fileName);
5440 ret->_content=c; c->incrRef();
5443 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5446 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
5448 MEDFileUtilities::CheckFileForRead(fileName);
5449 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5450 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll,0);
5451 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5452 ret->loadGlobals(fid);
5456 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
5458 MEDFileUtilities::CheckFileForRead(fileName);
5459 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5460 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll,0);
5461 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5462 ret->loadGlobals(fid);
5466 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
5468 MEDFileUtilities::CheckFileForRead(fileName);
5469 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5470 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,iteration,order,loadAll,0);
5471 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5472 ret->loadGlobals(fid);
5476 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5478 med_field_type typcha;
5479 std::vector<std::string> infos;
5482 int nbOfStep2=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5483 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5488 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5493 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5498 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] !";
5499 throw INTERP_KERNEL::Exception(oss.str().c_str());
5502 ret->setDtUnit(dtunit.c_str());
5503 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5506 std::vector< std::pair<int,int> > dtits(nbOfStep2);
5507 for(int i=0;i<nbOfStep2 && !found;i++)
5509 med_int numdt,numit;
5511 MEDfieldComputingStepInfo(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt);
5512 if(numdt==iteration && numit==order)
5518 dtits[i]=std::pair<int,int>(numdt,numit);
5522 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << fileName << "' ! Available iterations are : ";
5523 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5524 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5525 throw INTERP_KERNEL::Exception(oss.str().c_str());
5528 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms);
5530 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms);
5534 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5535 try:MEDFileFieldGlobsReal(fileName)
5537 MEDFileUtilities::CheckFileForRead(fileName);
5538 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5539 _content=BuildContentFrom(fid,fileName.c_str(),fieldName.c_str(),iteration,order,loadAll,ms);
5542 catch(INTERP_KERNEL::Exception& e)
5548 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5549 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5551 * \warning this is a shallow copy constructor
5553 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5555 if(!shallowCopyOfContent)
5557 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5558 otherPtr->incrRef();
5559 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5563 _content=other.shallowCpy();
5567 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)
5571 int nbFields=MEDnField(fid);
5572 if(fieldIdCFormat>=nbFields)
5574 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << fileName << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5575 throw INTERP_KERNEL::Exception(oss.str().c_str());
5578 int ncomp=MEDfieldnComponent(fid,fieldIdCFormat+1);
5579 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5580 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5581 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5582 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5583 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5586 MEDfieldInfo(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
5587 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5588 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5589 infos.clear(); infos.resize(ncomp);
5590 for(int j=0;j<ncomp;j++)
5591 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5596 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5599 * \return in case of success the number of time steps available for the field with name \a fieldName.
5601 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)
5603 int nbFields=MEDnField(fid);
5605 std::vector<std::string> fns(nbFields);
5607 for(int i=0;i<nbFields && !found;i++)
5610 nbOfStep2=LocateField2(fid,fileName,i,false,tmp,typcha,infos,dtunitOut);
5612 found=(tmp==fieldName);
5618 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
5619 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5620 oss << "\"" << *it << "\" ";
5621 throw INTERP_KERNEL::Exception(oss.str().c_str());
5627 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5628 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5629 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5630 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5631 * to keep a valid instance.
5632 * 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.
5633 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5634 * 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.
5636 * \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.
5637 * \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.
5638 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5639 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5640 * \param [in] newLocName is the new localization name.
5641 * \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.
5642 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5644 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
5646 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5647 std::string oldPflName=disc->getProfile();
5648 std::vector<std::string> vv=getPflsReallyUsedMulti();
5649 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5650 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5652 disc->setProfile(newPflName);
5653 DataArrayInt *pfl=getProfile(oldPflName.c_str());
5654 pfl->setName(newPflName);
5658 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5659 throw INTERP_KERNEL::Exception(oss.str().c_str());
5664 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5665 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5666 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5667 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5668 * to keep a valid instance.
5669 * 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.
5670 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5671 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5672 * 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.
5674 * \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.
5675 * \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.
5676 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5677 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5678 * \param [in] newLocName is the new localization name.
5679 * \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.
5680 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
5682 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
5684 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5685 std::string oldLocName=disc->getLocalization();
5686 std::vector<std::string> vv=getLocsReallyUsedMulti();
5687 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
5688 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
5690 disc->setLocalization(newLocName);
5691 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
5692 loc.setName(newLocName);
5696 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
5697 throw INTERP_KERNEL::Exception(oss.str().c_str());
5701 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
5703 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5705 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
5709 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
5711 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5713 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
5718 * Writes \a this field into a MED file specified by its name.
5719 * \param [in] fileName - the MED file name.
5720 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
5721 * - 2 - erase; an existing file is removed.
5722 * - 1 - append; same data should not be present in an existing file.
5723 * - 0 - overwrite; same data present in an existing file is overwritten.
5724 * \throw If the field name is not set.
5725 * \throw If no field data is set.
5726 * \throw If \a mode == 1 and the same data is present in an existing file.
5728 void MEDFileAnyTypeField1TS::write(const std::string& fileName, int mode) const
5730 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
5731 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
5736 * This method alloc the arrays and load potentially huge arrays contained in this field.
5737 * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
5738 * This method can be also called to refresh or reinit values from a file.
5740 * \throw If the fileName is not set or points to a non readable MED file.
5741 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5743 void MEDFileAnyTypeField1TS::loadArrays()
5745 if(getFileName().empty())
5746 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
5747 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
5748 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
5752 * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
5753 * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
5754 * this method does not throw if \a this does not come from file read.
5756 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
5758 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
5760 if(!getFileName().empty())
5762 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
5763 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
5768 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
5769 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
5770 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
5772 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
5774 void MEDFileAnyTypeField1TS::unloadArrays()
5776 contentNotNullBase()->unloadArrays();
5780 * 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.
5781 * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
5782 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
5784 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5786 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
5788 if(!getFileName().empty())
5789 contentNotNullBase()->unloadArrays();
5792 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
5794 int nbComp=getNumberOfComponents();
5795 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5796 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5797 for(int i=0;i<nbComp;i++)
5799 std::string info=getInfo()[i];
5801 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
5802 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
5803 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
5805 if(getName().empty())
5806 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
5807 MEDfieldCr(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
5808 writeGlobals(fid,*this);
5809 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
5812 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
5814 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
5817 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
5819 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
5820 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
5825 * Returns a string describing \a this field. This string is outputted
5826 * by \c print Python command.
5828 std::string MEDFileAnyTypeField1TS::simpleRepr() const
5830 std::ostringstream oss;
5831 contentNotNullBase()->simpleRepr(0,oss,-1);
5832 simpleReprGlobs(oss);
5837 * This method returns all profiles whose name is non empty used.
5838 * \b WARNING If profile is used several times it will be reported \b only \b once.
5839 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
5841 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
5843 return contentNotNullBase()->getPflsReallyUsed2();
5847 * This method returns all localizations whose name is non empty used.
5848 * \b WARNING If localization is used several times it will be reported \b only \b once.
5850 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
5852 return contentNotNullBase()->getLocsReallyUsed2();
5856 * This method returns all profiles whose name is non empty used.
5857 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
5859 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
5861 return contentNotNullBase()->getPflsReallyUsedMulti2();
5865 * This method returns all localizations whose name is non empty used.
5866 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
5868 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
5870 return contentNotNullBase()->getLocsReallyUsedMulti2();
5873 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5875 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
5878 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5880 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
5883 int MEDFileAnyTypeField1TS::getDimension() const
5885 return contentNotNullBase()->getDimension();
5888 int MEDFileAnyTypeField1TS::getIteration() const
5890 return contentNotNullBase()->getIteration();
5893 int MEDFileAnyTypeField1TS::getOrder() const
5895 return contentNotNullBase()->getOrder();
5898 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
5900 return contentNotNullBase()->getTime(iteration,order);
5903 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
5905 contentNotNullBase()->setTime(iteration,order,val);
5908 std::string MEDFileAnyTypeField1TS::getName() const
5910 return contentNotNullBase()->getName();
5913 void MEDFileAnyTypeField1TS::setName(const std::string& name)
5915 contentNotNullBase()->setName(name);
5918 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
5920 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
5923 std::string MEDFileAnyTypeField1TS::getDtUnit() const
5925 return contentNotNullBase()->getDtUnit();
5928 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
5930 contentNotNullBase()->setDtUnit(dtUnit);
5933 std::string MEDFileAnyTypeField1TS::getMeshName() const
5935 return contentNotNullBase()->getMeshName();
5938 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
5940 contentNotNullBase()->setMeshName(newMeshName);
5943 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
5945 return contentNotNullBase()->changeMeshNames(modifTab);
5948 int MEDFileAnyTypeField1TS::getMeshIteration() const
5950 return contentNotNullBase()->getMeshIteration();
5953 int MEDFileAnyTypeField1TS::getMeshOrder() const
5955 return contentNotNullBase()->getMeshOrder();
5958 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
5960 return contentNotNullBase()->getNumberOfComponents();
5963 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
5965 return contentNotNullBase()->isDealingTS(iteration,order);
5968 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
5970 return contentNotNullBase()->getDtIt();
5973 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
5975 contentNotNullBase()->fillIteration(p);
5978 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
5980 contentNotNullBase()->fillTypesOfFieldAvailable(types);
5983 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
5985 contentNotNullBase()->setInfo(infos);
5988 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
5990 return contentNotNullBase()->getInfo();
5992 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
5994 return contentNotNullBase()->getInfo();
5997 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
5999 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
6002 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
6004 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6007 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
6009 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6012 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
6014 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
6017 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
6019 return contentNotNullBase()->getTypesOfFieldAvailable();
6022 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,
6023 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6025 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
6029 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
6030 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
6031 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
6033 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
6035 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6037 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
6038 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
6039 std::size_t sz(contentsSplit.size());
6040 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
6041 for(std::size_t i=0;i<sz;i++)
6043 ret[i]=shallowCpy();
6044 ret[i]->_content=contentsSplit[i];
6050 * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
6051 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6053 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
6055 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6057 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
6058 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
6059 std::size_t sz(contentsSplit.size());
6060 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
6061 for(std::size_t i=0;i<sz;i++)
6063 ret[i]=shallowCpy();
6064 ret[i]->_content=contentsSplit[i];
6070 * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this.
6071 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6073 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const
6075 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6077 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !");
6078 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
6079 std::size_t sz(contentsSplit.size());
6080 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
6081 for(std::size_t i=0;i<sz;i++)
6083 ret[i]=shallowCpy();
6084 ret[i]->_content=contentsSplit[i];
6089 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCpy() const
6091 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=shallowCpy();
6092 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
6093 ret->_content=_content->deepCpy();
6094 ret->deepCpyGlobs(*this);
6098 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
6100 return contentNotNullBase()->copyTinyInfoFrom(field,arr);
6106 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6107 * the first field that has been read from a specified MED file.
6108 * \param [in] fileName - the name of the MED file to read.
6109 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6110 * is to delete this field using decrRef() as it is no more needed.
6111 * \throw If reading the file fails.
6113 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll)
6115 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret(new MEDFileField1TS(fileName,loadAll,0));
6116 ret->contentNotNull();
6121 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6122 * a given field that has been read from a specified MED file.
6123 * \param [in] fileName - the name of the MED file to read.
6124 * \param [in] fieldName - the name of the field to read.
6125 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6126 * is to delete this field using decrRef() as it is no more needed.
6127 * \throw If reading the file fails.
6128 * \throw If there is no field named \a fieldName in the file.
6130 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6132 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret(new MEDFileField1TS(fileName,fieldName,loadAll,0));
6133 ret->contentNotNull();
6138 * Returns a new instance of MEDFileField1TS holding data of a given time step of
6139 * a given field that has been read from a specified MED file.
6140 * \param [in] fileName - the name of the MED file to read.
6141 * \param [in] fieldName - the name of the field to read.
6142 * \param [in] iteration - the iteration number of a required time step.
6143 * \param [in] order - the iteration order number of required time step.
6144 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6145 * is to delete this field using decrRef() as it is no more needed.
6146 * \throw If reading the file fails.
6147 * \throw If there is no field named \a fieldName in the file.
6148 * \throw If the required time step is missing from the file.
6150 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6152 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret(new MEDFileField1TS(fileName,fieldName,iteration,order,loadAll,0));
6153 ret->contentNotNull();
6158 * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6159 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6161 * Returns a new instance of MEDFileField1TS holding either a shallow copy
6162 * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
6163 * \warning this is a shallow copy constructor
6164 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
6165 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
6166 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6167 * is to delete this field using decrRef() as it is no more needed.
6169 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6171 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(other,shallowCopyOfContent);
6172 ret->contentNotNull();
6177 * Returns a new empty instance of MEDFileField1TS.
6178 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6179 * is to delete this field using decrRef() as it is no more needed.
6181 MEDFileField1TS *MEDFileField1TS::New()
6183 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS;
6184 ret->contentNotNull();
6189 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
6190 * following the given input policy.
6192 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6193 * By default (true) the globals are deeply copied.
6194 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
6196 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
6198 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret;
6199 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6202 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
6204 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
6205 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
6206 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc,getFileName()));
6209 ret=MEDFileIntField1TS::New();
6211 ret->deepCpyGlobs(*this);
6213 ret->shallowCpyGlobs(*this);
6217 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const
6219 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6221 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
6222 const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
6224 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 !");
6228 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull()
6230 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6232 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
6233 MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
6235 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 !");
6239 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MEDCouplingAutoRefCountObjectPtr<DataArray>& arr)
6242 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
6243 if(!((DataArray*)arr))
6244 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
6245 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
6247 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6248 f->setArray(arrOutC);
6251 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr)
6253 if(!((DataArray*)arr))
6254 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
6255 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
6257 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6262 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
6263 try:MEDFileAnyTypeField1TS(fileName,loadAll,ms)
6266 catch(INTERP_KERNEL::Exception& e)
6269 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6270 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll,ms)
6273 catch(INTERP_KERNEL::Exception& e)
6276 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6277 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll,ms)
6280 catch(INTERP_KERNEL::Exception& e)
6284 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6285 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6287 * \warning this is a shallow copy constructor
6289 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6290 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6293 catch(INTERP_KERNEL::Exception& e)
6296 MEDFileField1TS::MEDFileField1TS()
6298 _content=new MEDFileField1TSWithoutSDA;
6302 * Returns a new MEDCouplingFieldDouble of a given type lying on
6303 * mesh entities of a given dimension of the first mesh in MED file. If \a this field
6304 * has not been constructed via file reading, an exception is thrown.
6305 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6306 * \param [in] type - a spatial discretization of interest.
6307 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6308 * \param [in] renumPol - specifies how to permute values of the result field according to
6309 * the optional numbers of cells and nodes, if any. The valid values are
6310 * - 0 - do not permute.
6311 * - 1 - permute cells.
6312 * - 2 - permute nodes.
6313 * - 3 - permute cells and nodes.
6315 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6316 * caller is to delete this field using decrRef() as it is no more needed.
6317 * \throw If \a this field has not been constructed via file reading.
6318 * \throw If the MED file is not readable.
6319 * \throw If there is no mesh in the MED file.
6320 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6321 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6322 * \sa getFieldOnMeshAtLevel()
6324 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6326 if(getFileName().empty())
6327 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6328 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6329 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull());
6330 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6335 * Returns a new MEDCouplingFieldDouble of a given type lying on
6336 * the top level cells of the first mesh in MED file. If \a this field
6337 * has not been constructed via file reading, an exception is thrown.
6338 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6339 * \param [in] type - a spatial discretization of interest.
6340 * \param [in] renumPol - specifies how to permute values of the result field according to
6341 * the optional numbers of cells and nodes, if any. The valid values are
6342 * - 0 - do not permute.
6343 * - 1 - permute cells.
6344 * - 2 - permute nodes.
6345 * - 3 - permute cells and nodes.
6347 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6348 * caller is to delete this field using decrRef() as it is no more needed.
6349 * \throw If \a this field has not been constructed via file reading.
6350 * \throw If the MED file is not readable.
6351 * \throw If there is no mesh in the MED file.
6352 * \throw If no field values of the given \a type.
6353 * \throw If no field values lying on the top level support.
6354 * \sa getFieldAtLevel()
6356 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
6358 if(getFileName().empty())
6359 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6360 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6361 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull());
6362 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6367 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6368 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6369 * \param [in] type - a spatial discretization of the new field.
6370 * \param [in] mesh - the supporting mesh.
6371 * \param [in] renumPol - specifies how to permute values of the result field according to
6372 * the optional numbers of cells and nodes, if any. The valid values are
6373 * - 0 - do not permute.
6374 * - 1 - permute cells.
6375 * - 2 - permute nodes.
6376 * - 3 - permute cells and nodes.
6378 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6379 * caller is to delete this field using decrRef() as it is no more needed.
6380 * \throw If no field of \a this is lying on \a mesh.
6381 * \throw If the mesh is empty.
6382 * \throw If no field values of the given \a type are available.
6383 * \sa getFieldAtLevel()
6384 * \sa getFieldOnMeshAtLevel()
6386 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
6388 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6389 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull());
6390 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6395 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6396 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6397 * \param [in] type - a spatial discretization of interest.
6398 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6399 * \param [in] mesh - the supporting mesh.
6400 * \param [in] renumPol - specifies how to permute values of the result field according to
6401 * the optional numbers of cells and nodes, if any. The valid values are
6402 * - 0 - do not permute.
6403 * - 1 - permute cells.
6404 * - 2 - permute nodes.
6405 * - 3 - permute cells and nodes.
6407 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6408 * caller is to delete this field using decrRef() as it is no more needed.
6409 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6410 * \throw If no field of \a this is lying on \a mesh.
6411 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6412 * \sa getFieldAtLevel()
6413 * \sa getFieldOnMeshAtLevel()
6415 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
6417 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6418 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull());
6419 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6424 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6425 * This method is called "Old" because in MED3 norm a field has only one meshName
6426 * attached, so this method is for readers of MED2 files. If \a this field
6427 * has not been constructed via file reading, an exception is thrown.
6428 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6429 * \param [in] type - a spatial discretization of interest.
6430 * \param [in] mName - a name of the supporting mesh.
6431 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6432 * \param [in] renumPol - specifies how to permute values of the result field according to
6433 * the optional numbers of cells and nodes, if any. The valid values are
6434 * - 0 - do not permute.
6435 * - 1 - permute cells.
6436 * - 2 - permute nodes.
6437 * - 3 - permute cells and nodes.
6439 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6440 * caller is to delete this field using decrRef() as it is no more needed.
6441 * \throw If the MED file is not readable.
6442 * \throw If there is no mesh named \a mName in the MED file.
6443 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6444 * \throw If \a this field has not been constructed via file reading.
6445 * \throw If no field of \a this is lying on the mesh named \a mName.
6446 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6447 * \sa getFieldAtLevel()
6449 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
6451 if(getFileName().empty())
6452 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6453 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6454 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
6455 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6460 * Returns values and a profile of the field of a given type lying on a given support.
6461 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6462 * \param [in] type - a spatial discretization of the field.
6463 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6464 * \param [in] mesh - the supporting mesh.
6465 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6466 * field of interest lies on. If the field lies on all entities of the given
6467 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6468 * using decrRef() as it is no more needed.
6469 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6470 * field. The caller is to delete this array using decrRef() as it is no more needed.
6471 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6472 * \throw If no field of \a this is lying on \a mesh.
6473 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6475 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6477 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6478 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
6482 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6483 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6484 * "Sort By Type"), if not, an exception is thrown.
6485 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6486 * \param [in] field - the field to add to \a this.
6487 * \throw If the name of \a field is empty.
6488 * \throw If the data array of \a field is not set.
6489 * \throw If the data array is already allocated but has different number of components
6491 * \throw If the underlying mesh of \a field has no name.
6492 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6494 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
6497 contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
6501 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6502 * can be an aggregation of several MEDCouplingFieldDouble instances.
6503 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6504 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6507 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6508 * A new profile is added only if no equal profile is missing.
6509 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6510 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
6511 * \param [in] mesh - the supporting mesh of \a field.
6512 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6513 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6514 * \throw If either \a field or \a mesh or \a profile has an empty name.
6515 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6516 * \throw If the data array of \a field is not set.
6517 * \throw If the data array of \a this is already allocated but has different number of
6518 * components than \a field.
6519 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6520 * \sa setFieldNoProfileSBT()
6522 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6525 contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6528 MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const
6530 return new MEDFileField1TS(*this);
6533 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const
6535 return contentNotNull()->getUndergroundDataArrayDouble();
6538 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
6540 return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
6543 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6544 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6546 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6549 //= MEDFileIntField1TS
6551 MEDFileIntField1TS *MEDFileIntField1TS::New()
6553 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS;
6554 ret->contentNotNull();
6558 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll)
6560 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,loadAll,0));
6561 ret->contentNotNull();
6565 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6567 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,fieldName,loadAll,0));
6568 ret->contentNotNull();
6572 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6574 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,fieldName,iteration,order,loadAll,0));
6575 ret->contentNotNull();
6579 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6581 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6582 ret->contentNotNull();
6586 MEDFileIntField1TS::MEDFileIntField1TS()
6588 _content=new MEDFileIntField1TSWithoutSDA;
6591 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
6592 try:MEDFileAnyTypeField1TS(fileName,loadAll,ms)
6595 catch(INTERP_KERNEL::Exception& e)
6598 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6599 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll,ms)
6602 catch(INTERP_KERNEL::Exception& e)
6605 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6606 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll,ms)
6609 catch(INTERP_KERNEL::Exception& e)
6613 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6614 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6616 * \warning this is a shallow copy constructor
6618 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6622 MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const
6624 return new MEDFileIntField1TS(*this);
6628 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
6629 * following the given input policy.
6631 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6632 * By default (true) the globals are deeply copied.
6633 * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
6635 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const
6637 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret;
6638 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6641 const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
6643 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
6644 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
6645 ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc,getFileName()));
6648 ret=MEDFileField1TS::New();
6650 ret->deepCpyGlobs(*this);
6652 ret->shallowCpyGlobs(*this);
6657 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6658 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6659 * "Sort By Type"), if not, an exception is thrown.
6660 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6661 * \param [in] field - the field to add to \a this. The field double values are ignored.
6662 * \param [in] arrOfVals - the values of the field \a field used.
6663 * \throw If the name of \a field is empty.
6664 * \throw If the data array of \a field is not set.
6665 * \throw If the data array is already allocated but has different number of components
6667 * \throw If the underlying mesh of \a field has no name.
6668 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6670 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals)
6673 contentNotNull()->setFieldNoProfileSBT(field,arrOfVals,*this,*contentNotNull());
6677 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6678 * can be an aggregation of several MEDCouplingFieldDouble instances.
6679 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6680 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6683 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6684 * A new profile is added only if no equal profile is missing.
6685 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6686 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
6687 * \param [in] arrOfVals - the values of the field \a field used.
6688 * \param [in] mesh - the supporting mesh of \a field.
6689 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6690 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6691 * \throw If either \a field or \a mesh or \a profile has an empty name.
6692 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6693 * \throw If the data array of \a field is not set.
6694 * \throw If the data array of \a this is already allocated but has different number of
6695 * components than \a field.
6696 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6697 * \sa setFieldNoProfileSBT()
6699 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6702 contentNotNull()->setFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6705 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const
6707 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6709 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
6710 const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
6712 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 !");
6716 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
6718 if(getFileName().empty())
6719 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6720 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut2;
6721 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut2,*contentNotNull());
6722 DataArrayInt *arrOutC=dynamic_cast<DataArrayInt *>((DataArray *)arrOut2);
6724 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : mismatch between dataArrays type and MEDFileIntField1TS ! Expected int32 !");
6729 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr)
6731 if(!((DataArray *)arr))
6732 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
6733 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>((DataArray *)arr);
6735 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
6741 * Returns a new MEDCouplingFieldDouble of a given type lying on
6742 * the top level cells of the first mesh in MED file. If \a this field
6743 * has not been constructed via file reading, an exception is thrown.
6744 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6745 * \param [in] type - a spatial discretization of interest.
6746 * \param [out] arrOut - the DataArrayInt containing values of field.
6747 * \param [in] renumPol - specifies how to permute values of the result field according to
6748 * the optional numbers of cells and nodes, if any. The valid values are
6749 * - 0 - do not permute.
6750 * - 1 - permute cells.
6751 * - 2 - permute nodes.
6752 * - 3 - permute cells and nodes.
6754 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6755 * caller is to delete this field using decrRef() as it is no more needed.
6756 * \throw If \a this field has not been constructed via file reading.
6757 * \throw If the MED file is not readable.
6758 * \throw If there is no mesh in the MED file.
6759 * \throw If no field values of the given \a type.
6760 * \throw If no field values lying on the top level support.
6761 * \sa getFieldAtLevel()
6763 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, DataArrayInt* &arrOut, int renumPol) const
6765 if(getFileName().empty())
6766 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6767 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6768 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNull());
6769 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6774 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6775 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6776 * \param [in] type - a spatial discretization of the new field.
6777 * \param [in] mesh - the supporting mesh.
6778 * \param [out] arrOut - the DataArrayInt containing values of field.
6779 * \param [in] renumPol - specifies how to permute values of the result field according to
6780 * the optional numbers of cells and nodes, if any. The valid values are
6781 * - 0 - do not permute.
6782 * - 1 - permute cells.
6783 * - 2 - permute nodes.
6784 * - 3 - permute cells and nodes.
6786 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6787 * caller is to delete this field using decrRef() as it is no more needed.
6788 * \throw If no field of \a this is lying on \a mesh.
6789 * \throw If the mesh is empty.
6790 * \throw If no field values of the given \a type are available.
6791 * \sa getFieldAtLevel()
6792 * \sa getFieldOnMeshAtLevel()
6794 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
6796 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6797 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNull());
6798 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6803 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6804 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6805 * \param [in] type - a spatial discretization of interest.
6806 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6807 * \param [out] arrOut - the DataArrayInt containing values of field.
6808 * \param [in] mesh - the supporting mesh.
6809 * \param [in] renumPol - specifies how to permute values of the result field according to
6810 * the optional numbers of cells and nodes, if any. The valid values are
6811 * - 0 - do not permute.
6812 * - 1 - permute cells.
6813 * - 2 - permute nodes.
6814 * - 3 - permute cells and nodes.
6816 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6817 * caller is to delete this field using decrRef() as it is no more needed.
6818 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6819 * \throw If no field of \a this is lying on \a mesh.
6820 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6821 * \sa getFieldAtLevel()
6822 * \sa getFieldOnMeshAtLevel()
6824 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
6826 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6827 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNull());
6828 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6833 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6834 * This method is called "Old" because in MED3 norm a field has only one meshName
6835 * attached, so this method is for readers of MED2 files. If \a this field
6836 * has not been constructed via file reading, an exception is thrown.
6837 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6838 * \param [in] type - a spatial discretization of interest.
6839 * \param [in] mName - a name of the supporting mesh.
6840 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6841 * \param [out] arrOut - the DataArrayInt containing values of field.
6842 * \param [in] renumPol - specifies how to permute values of the result field according to
6843 * the optional numbers of cells and nodes, if any. The valid values are
6844 * - 0 - do not permute.
6845 * - 1 - permute cells.
6846 * - 2 - permute nodes.
6847 * - 3 - permute cells and nodes.
6849 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6850 * caller is to delete this field using decrRef() as it is no more needed.
6851 * \throw If the MED file is not readable.
6852 * \throw If there is no mesh named \a mName in the MED file.
6853 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6854 * \throw If \a this field has not been constructed via file reading.
6855 * \throw If no field of \a this is lying on the mesh named \a mName.
6856 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6857 * \sa getFieldAtLevel()
6859 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
6861 if(getFileName().empty())
6862 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6863 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6864 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNull());
6865 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6870 * Returns values and a profile of the field of a given type lying on a given support.
6871 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6872 * \param [in] type - a spatial discretization of the field.
6873 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6874 * \param [in] mesh - the supporting mesh.
6875 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6876 * field of interest lies on. If the field lies on all entities of the given
6877 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6878 * using decrRef() as it is no more needed.
6879 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
6880 * field. The caller is to delete this array using decrRef() as it is no more needed.
6881 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6882 * \throw If no field of \a this is lying on \a mesh.
6883 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6885 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6887 MEDCouplingAutoRefCountObjectPtr<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6888 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6891 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull()
6893 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6895 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
6896 MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
6898 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 !");
6902 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const
6904 return contentNotNull()->getUndergroundDataArrayInt();
6907 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
6909 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
6913 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileFieldNameScope(fieldName)
6918 * \param [in] fieldId field id in C mode
6920 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms)
6922 med_field_type typcha;
6923 std::string dtunitOut;
6924 int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,"",fieldId,false,_name,typcha,_infos,dtunitOut);
6925 setDtUnit(dtunitOut.c_str());
6926 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms);
6929 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)
6930 try:MEDFileFieldNameScope(fieldName),_infos(infos)
6932 setDtUnit(dtunit.c_str());
6933 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms);
6935 catch(INTERP_KERNEL::Exception& e)
6940 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
6942 std::size_t ret(_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA>));
6943 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
6944 ret+=(*it).capacity();
6948 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
6950 std::vector<const BigMemoryObject *> ret;
6951 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6952 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
6957 * 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
6960 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
6962 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6963 ret->setInfo(_infos);
6964 int sz=(int)_time_steps.size();
6965 for(const int *id=startIds;id!=endIds;id++)
6967 if(*id>=0 && *id<sz)
6969 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
6970 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6974 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6976 ret->pushBackTimeStep(tse2);
6980 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
6981 oss << " ! Should be in [0," << sz << ") !";
6982 throw INTERP_KERNEL::Exception(oss.str().c_str());
6985 if(ret->getNumberOfTS()>0)
6986 ret->synchronizeNameScope();
6987 ret->copyNameScope(*this);
6992 * 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
6995 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
6997 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
6998 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
6999 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7000 ret->setInfo(_infos);
7001 int sz=(int)_time_steps.size();
7003 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
7007 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
7008 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7012 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7014 ret->pushBackTimeStep(tse2);
7018 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
7019 oss << " ! Should be in [0," << sz << ") !";
7020 throw INTERP_KERNEL::Exception(oss.str().c_str());
7023 if(ret->getNumberOfTS()>0)
7024 ret->synchronizeNameScope();
7025 ret->copyNameScope(*this);
7029 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7032 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7033 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7035 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7038 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7039 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
7040 ids->pushBackSilent(id);
7042 return buildFromTimeStepIds(ids->begin(),ids->end());
7045 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7048 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7049 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7051 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7054 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7055 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
7056 ids->pushBackSilent(id);
7058 return buildFromTimeStepIds(ids->begin(),ids->end());
7061 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
7063 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7065 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7068 if(cur->presenceOfMultiDiscPerGeoType())
7074 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
7079 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
7084 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
7087 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7089 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
7090 if(pt->isDealingTS(iteration,order))
7093 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
7094 std::vector< std::pair<int,int> > vp=getIterations();
7095 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
7096 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
7097 throw INTERP_KERNEL::Exception(oss.str().c_str());
7100 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
7102 return *_time_steps[getTimeStepPos(iteration,order)];
7105 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
7107 return *_time_steps[getTimeStepPos(iteration,order)];
7110 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const
7112 if(_time_steps.empty())
7113 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
7114 return _time_steps[0]->getMeshName();
7117 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const std::string& newMeshName)
7119 std::string oldName(getMeshName());
7120 std::vector< std::pair<std::string,std::string> > v(1);
7121 v[0].first=oldName; v[0].second=newMeshName;
7125 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
7128 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7130 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7132 ret=cur->changeMeshNames(modifTab) || ret;
7138 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
7140 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
7142 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
7146 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
7148 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7150 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
7153 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
7154 MEDFileFieldGlobsReal& glob)
7157 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7159 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
7161 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
7166 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7168 std::string startLine(bkOffset,' ');
7169 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
7171 oss << " (" << fmtsId << ")";
7172 oss << " has the following name: \"" << _name << "\"." << std::endl;
7173 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
7174 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7176 oss << startLine << " - \"" << *it << "\"" << std::endl;
7179 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7181 std::string chapter(17,'0'+i);
7182 oss << startLine << chapter << std::endl;
7183 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7185 cur->simpleRepr(bkOffset+2,oss,i);
7187 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
7188 oss << startLine << chapter << std::endl;
7192 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
7194 std::size_t sz=_time_steps.size();
7195 std::vector< std::pair<int,int> > ret(sz);
7197 for(std::size_t i=0;i<sz;i++)
7199 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
7202 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
7206 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
7207 throw INTERP_KERNEL::Exception(oss.str().c_str());
7213 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>& tse)
7215 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
7217 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
7218 checkCoherencyOfType(tse2);
7219 if(_time_steps.empty())
7221 setName(tse2->getName().c_str());
7222 setInfo(tse2->getInfo());
7224 checkThatComponentsMatch(tse2->getInfo());
7225 _time_steps.push_back(tse);
7228 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
7230 std::size_t nbOfCompo=_infos.size();
7231 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7233 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7236 if((cur->getInfo()).size()!=nbOfCompo)
7238 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
7239 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
7240 throw INTERP_KERNEL::Exception(oss.str().c_str());
7242 cur->copyNameScope(*this);
7247 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms)
7249 _time_steps.resize(nbPdt);
7250 for(int i=0;i<nbPdt;i++)
7252 std::vector< std::pair<int,int> > ts;
7253 med_int numdt=0,numo=0;
7254 med_int meshIt=0,meshOrder=0;
7256 MEDfieldComputingStepMeshInfo(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder);
7261 _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7266 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7270 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
7273 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms);
7275 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms);
7279 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
7281 if(_time_steps.empty())
7282 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
7283 checkThatNbOfCompoOfTSMatchThis();
7284 std::vector<std::string> infos(getInfo());
7285 int nbComp=infos.size();
7286 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7287 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7288 for(int i=0;i<nbComp;i++)
7290 std::string info=infos[i];
7292 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7293 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7294 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7297 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7298 MEDfieldCr(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
7299 int nbOfTS=_time_steps.size();
7300 for(int i=0;i<nbOfTS;i++)
7301 _time_steps[i]->writeLL(fid,opts,*this);
7304 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
7306 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7308 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7310 elt->loadBigArraysRecursively(fid,nasc);
7314 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
7316 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7318 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7320 elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7324 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
7326 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7328 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7330 elt->unloadArrays();
7334 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7336 return _time_steps.size();
7339 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
7341 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7342 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7344 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7346 newTS.push_back(*it);
7351 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
7353 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7354 int maxId=(int)_time_steps.size();
7356 std::set<int> idsToDel;
7357 for(const int *id=startIds;id!=endIds;id++,ii++)
7359 if(*id>=0 && *id<maxId)
7361 idsToDel.insert(*id);
7365 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7366 throw INTERP_KERNEL::Exception(oss.str().c_str());
7369 for(int iii=0;iii<maxId;iii++)
7370 if(idsToDel.find(iii)==idsToDel.end())
7371 newTS.push_back(_time_steps[iii]);
7375 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
7377 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7378 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7379 if(nbOfEntriesToKill==0)
7381 std::size_t sz=_time_steps.size();
7382 std::vector<bool> b(sz,true);
7384 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7386 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7387 for(std::size_t i=0;i<sz;i++)
7389 newTS.push_back(_time_steps[i]);
7393 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
7396 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
7397 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7399 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7403 tmp->getTime(it2,ord);
7404 if(it2==iteration && order==ord)
7407 oss << "(" << it2 << "," << ord << "), ";
7410 throw INTERP_KERNEL::Exception(oss.str().c_str());
7413 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
7416 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
7418 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7420 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7424 double ti=tmp->getTime(it2,ord);
7425 if(fabs(time-ti)<eps)
7431 throw INTERP_KERNEL::Exception(oss.str().c_str());
7434 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
7436 int lgth=_time_steps.size();
7437 std::vector< std::pair<int,int> > ret(lgth);
7438 for(int i=0;i<lgth;i++)
7439 _time_steps[i]->fillIteration(ret[i]);
7444 * 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'
7445 * This method returns two things.
7446 * - The absolute dimension of 'this' in first parameter.
7447 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7448 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
7450 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7451 * Only these 3 discretizations will be taken into account here.
7453 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7454 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7455 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7457 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7458 * 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'.
7460 * Let's consider the typical following case :
7461 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7462 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7463 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7465 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7467 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7469 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7470 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7471 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7472 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7474 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
7476 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7479 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
7481 if(pos<0 || pos>=(int)_time_steps.size())
7483 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7484 throw INTERP_KERNEL::Exception(oss.str().c_str());
7486 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7489 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7490 oss << "\nTry to use following method eraseEmptyTS !";
7491 throw INTERP_KERNEL::Exception(oss.str().c_str());
7496 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
7498 if(pos<0 || pos>=(int)_time_steps.size())
7500 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7501 throw INTERP_KERNEL::Exception(oss.str().c_str());
7503 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7506 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7507 oss << "\nTry to use following method eraseEmptyTS !";
7508 throw INTERP_KERNEL::Exception(oss.str().c_str());
7513 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
7515 std::vector<std::string> ret;
7516 std::set<std::string> ret2;
7517 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7519 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
7520 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7521 if(ret2.find(*it2)==ret2.end())
7523 ret.push_back(*it2);
7530 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
7532 std::vector<std::string> ret;
7533 std::set<std::string> ret2;
7534 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7536 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
7537 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7538 if(ret2.find(*it2)==ret2.end())
7540 ret.push_back(*it2);
7547 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
7549 std::vector<std::string> ret;
7550 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7552 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
7553 ret.insert(ret.end(),tmp.begin(),tmp.end());
7558 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
7560 std::vector<std::string> ret;
7561 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7563 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
7564 ret.insert(ret.end(),tmp.begin(),tmp.end());
7569 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7571 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7572 (*it)->changePflsRefsNamesGen2(mapOfModif);
7575 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7577 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7578 (*it)->changeLocsRefsNamesGen2(mapOfModif);
7581 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
7583 int lgth=_time_steps.size();
7584 std::vector< std::vector<TypeOfField> > ret(lgth);
7585 for(int i=0;i<lgth;i++)
7586 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
7591 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
7593 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
7595 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
7598 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCpy() const
7600 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
7602 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7604 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
7605 ret->_time_steps[i]=(*it)->deepCpy();
7610 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
7612 std::size_t sz(_infos.size()),sz2(_time_steps.size());
7613 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7614 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7615 for(std::size_t i=0;i<sz;i++)
7617 ret[i]=shallowCpy();
7618 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7620 for(std::size_t i=0;i<sz2;i++)
7622 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7625 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7626 throw INTERP_KERNEL::Exception(oss.str().c_str());
7630 for(std::size_t i=0;i<sz;i++)
7631 for(std::size_t j=0;j<sz2;j++)
7632 ret[i]->_time_steps[j]=ts[j][i];
7637 * This method splits into discretization each time steps in \a this.
7638 * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
7640 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
7642 std::size_t sz(_time_steps.size());
7643 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7644 for(std::size_t i=0;i<sz;i++)
7646 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7649 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
7650 throw INTERP_KERNEL::Exception(oss.str().c_str());
7652 items[i]=timeStep->splitDiscretizations();
7655 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
7656 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
7657 std::vector< TypeOfField > types;
7658 for(std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7659 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7661 std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
7663 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
7664 std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
7665 if(it2==types.end())
7666 types.push_back(ts[0]);
7668 ret.resize(types.size()); ret2.resize(types.size());
7669 for(std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7670 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7672 TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
7673 std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
7674 ret2[pos].push_back(*it1);
7676 for(std::size_t i=0;i<types.size();i++)
7678 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7679 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
7680 elt->pushBackTimeStep(*it1);//also updates infos in elt
7682 elt->MEDFileFieldNameScope::operator=(*this);
7688 * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
7690 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
7692 std::size_t sz(_time_steps.size());
7693 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7694 std::size_t szOut(std::numeric_limits<std::size_t>::max());
7695 for(std::size_t i=0;i<sz;i++)
7697 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7700 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
7701 throw INTERP_KERNEL::Exception(oss.str().c_str());
7703 items[i]=timeStep->splitMultiDiscrPerGeoTypes();
7704 if(szOut==std::numeric_limits<std::size_t>::max())
7705 szOut=items[i].size();
7707 if(items[i].size()!=szOut)
7708 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
7710 if(szOut==std::numeric_limits<std::size_t>::max())
7711 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
7712 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
7713 for(std::size_t i=0;i<szOut;i++)
7715 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7716 for(std::size_t j=0;j<sz;j++)
7717 elt->pushBackTimeStep(items[i][j]);
7719 elt->MEDFileFieldNameScope::operator=(*this);
7724 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
7726 _name=field->getName();
7728 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
7730 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
7731 _infos=arr->getInfoOnComponents();
7734 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
7736 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
7737 if(_name!=field->getName())
7739 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
7740 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
7741 throw INTERP_KERNEL::Exception(oss.str().c_str());
7744 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
7745 checkThatComponentsMatch(arr->getInfoOnComponents());
7748 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
7750 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
7751 if(getInfo().size()!=compos.size())
7753 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
7754 oss << " number of components of element to append (" << compos.size() << ") !";
7755 throw INTERP_KERNEL::Exception(oss.str().c_str());
7759 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
7760 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
7761 oss << " But compo in input fields are : ";
7762 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
7764 throw INTERP_KERNEL::Exception(oss.str().c_str());
7768 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
7770 std::size_t sz=_infos.size();
7772 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
7774 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7776 if(elt->getInfo().size()!=sz)
7778 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
7779 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
7780 throw INTERP_KERNEL::Exception(oss.str().c_str());
7785 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
7788 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7789 if(!_time_steps.empty())
7790 checkCoherencyOfTinyInfo(field,arr);
7791 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
7792 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7793 objC->setFieldNoProfileSBT(field,arr,glob,*this);
7794 copyTinyInfoFrom(field,arr);
7795 _time_steps.push_back(obj);
7798 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
7801 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7802 if(!_time_steps.empty())
7803 checkCoherencyOfTinyInfo(field,arr);
7804 MEDFileField1TSWithoutSDA *objC=new MEDFileField1TSWithoutSDA;
7805 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7806 objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
7807 copyTinyInfoFrom(field,arr);
7808 _time_steps.push_back(obj);
7811 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ts)
7813 int sz=(int)_time_steps.size();
7816 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
7817 throw INTERP_KERNEL::Exception(oss.str().c_str());
7819 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
7822 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
7824 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
7825 throw INTERP_KERNEL::Exception(oss.str().c_str());
7831 //= MEDFileFieldMultiTSWithoutSDA
7833 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)
7835 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms);
7838 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
7842 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7847 * \param [in] fieldId field id in C mode
7849 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms)
7850 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms)
7853 catch(INTERP_KERNEL::Exception& e)
7856 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)
7857 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms)
7860 catch(INTERP_KERNEL::Exception& e)
7863 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
7865 return new MEDFileField1TSWithoutSDA;
7868 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
7871 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7872 const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
7874 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
7877 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const
7879 return MEDFileField1TSWithoutSDA::TYPE_STR;
7882 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const
7884 return new MEDFileFieldMultiTSWithoutSDA(*this);
7887 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const
7889 return new MEDFileFieldMultiTSWithoutSDA;
7893 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
7894 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
7896 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
7898 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
7899 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
7901 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
7902 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
7905 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
7907 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
7908 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
7910 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7912 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
7915 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
7917 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
7918 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
7919 ret->setIteration(i,elt);
7925 //= MEDFileAnyTypeFieldMultiTS
7927 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
7931 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
7932 try:MEDFileFieldGlobsReal(fileName)
7934 MEDFileUtilities::CheckFileForRead(fileName);
7935 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
7936 _content=BuildContentFrom(fid,fileName,loadAll,ms);
7939 catch(INTERP_KERNEL::Exception& e)
7944 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
7946 med_field_type typcha;
7947 std::vector<std::string> infos;
7950 MEDFileAnyTypeField1TS::LocateField(fid,fileName,fieldName,i,typcha,infos,dtunit);
7951 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7956 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms);
7961 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms);
7966 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] !";
7967 throw INTERP_KERNEL::Exception(oss.str().c_str());
7970 ret->setDtUnit(dtunit.c_str());
7974 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
7976 med_field_type typcha;
7978 std::vector<std::string> infos;
7979 std::string dtunit,fieldName;
7980 MEDFileAnyTypeField1TS::LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
7981 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7986 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms);
7991 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms);
7996 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] !";
7997 throw INTERP_KERNEL::Exception(oss.str().c_str());
8000 ret->setDtUnit(dtunit.c_str());
8004 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, const std::string& fileName)
8007 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
8008 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
8010 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=MEDFileFieldMultiTS::New();
8011 ret->setFileName(fileName);
8012 ret->_content=c; c->incrRef();
8015 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
8017 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=MEDFileIntFieldMultiTS::New();
8018 ret->setFileName(fileName);
8019 ret->_content=c; c->incrRef();
8022 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
8025 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
8026 try:MEDFileFieldGlobsReal(fileName)
8028 MEDFileUtilities::CheckFileForRead(fileName);
8029 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8030 _content=BuildContentFrom(fid,fileName,fieldName,loadAll,ms);
8033 catch(INTERP_KERNEL::Exception& e)
8038 //= MEDFileIntFieldMultiTSWithoutSDA
8040 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)
8042 return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms);
8045 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
8049 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8053 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)
8054 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms)
8057 catch(INTERP_KERNEL::Exception& e)
8061 * \param [in] fieldId field id in C mode
8063 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms)
8064 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms)
8067 catch(INTERP_KERNEL::Exception& e)
8070 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8072 return new MEDFileIntField1TSWithoutSDA;
8075 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8078 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8079 const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
8081 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8084 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const
8086 return MEDFileIntField1TSWithoutSDA::TYPE_STR;
8089 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const
8091 return new MEDFileIntFieldMultiTSWithoutSDA(*this);
8094 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const
8096 return new MEDFileIntFieldMultiTSWithoutSDA;
8099 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const
8101 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
8102 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8104 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8106 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8109 const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
8111 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
8112 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
8113 ret->setIteration(i,elt);
8119 //= MEDFileAnyTypeFieldMultiTS
8122 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
8123 * that has been read from a specified MED file.
8124 * \param [in] fileName - the name of the MED file to read.
8125 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8126 * is to delete this field using decrRef() as it is no more needed.
8127 * \throw If reading the file fails.
8129 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
8131 MEDFileUtilities::CheckFileForRead(fileName);
8132 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8133 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll,0);
8134 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
8135 ret->loadGlobals(fid);
8140 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
8141 * that has been read from a specified MED file.
8142 * \param [in] fileName - the name of the MED file to read.
8143 * \param [in] fieldName - the name of the field to read.
8144 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8145 * is to delete this field using decrRef() as it is no more needed.
8146 * \throw If reading the file fails.
8147 * \throw If there is no field named \a fieldName in the file.
8149 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8151 MEDFileUtilities::CheckFileForRead(fileName);
8152 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8153 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll,0);
8154 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
8155 ret->loadGlobals(fid);
8160 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8161 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8163 * \warning this is a shallow copy constructor
8165 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8167 if(!shallowCopyOfContent)
8169 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
8170 otherPtr->incrRef();
8171 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
8175 _content=other.shallowCpy();
8179 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
8181 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8183 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
8187 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
8189 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8191 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
8195 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
8197 return contentNotNullBase()->getPflsReallyUsed2();
8200 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
8202 return contentNotNullBase()->getLocsReallyUsed2();
8205 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
8207 return contentNotNullBase()->getPflsReallyUsedMulti2();
8210 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
8212 return contentNotNullBase()->getLocsReallyUsedMulti2();
8215 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8217 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
8220 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8222 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
8225 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
8227 return contentNotNullBase()->getNumberOfTS();
8230 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
8232 contentNotNullBase()->eraseEmptyTS();
8235 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
8237 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
8240 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
8242 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
8245 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
8247 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
8248 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8253 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
8255 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
8256 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8261 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
8263 return contentNotNullBase()->getIterations();
8266 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
8268 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
8269 pushBackTimeStep(*it);
8272 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
8275 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
8276 checkCoherencyOfType(f1ts);
8278 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
8279 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
8281 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
8282 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
8283 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
8284 _content->pushBackTimeStep(cSafe);
8285 appendGlobs(*f1ts,1e-12);
8288 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
8290 contentNotNullBase()->synchronizeNameScope();
8293 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
8295 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
8298 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
8300 return contentNotNullBase()->getPosGivenTime(time,eps);
8303 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8305 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
8308 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
8310 return contentNotNullBase()->getTypesOfFieldAvailable();
8313 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
8315 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
8318 std::string MEDFileAnyTypeFieldMultiTS::getName() const
8320 return contentNotNullBase()->getName();
8323 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
8325 contentNotNullBase()->setName(name);
8328 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
8330 return contentNotNullBase()->getDtUnit();
8333 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
8335 contentNotNullBase()->setDtUnit(dtUnit);
8338 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8340 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
8343 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
8345 return contentNotNullBase()->getTimeSteps(ret1);
8348 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
8350 return contentNotNullBase()->getMeshName();
8353 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
8355 contentNotNullBase()->setMeshName(newMeshName);
8358 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
8360 return contentNotNullBase()->changeMeshNames(modifTab);
8363 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
8365 return contentNotNullBase()->getInfo();
8368 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
8370 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
8373 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
8375 return contentNotNullBase()->setInfo(info);
8378 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
8380 const std::vector<std::string> ret=getInfo();
8381 return (int)ret.size();
8384 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
8386 writeGlobals(fid,*this);
8387 contentNotNullBase()->writeLL(fid,*this);
8391 * Writes \a this field into a MED file specified by its name.
8392 * \param [in] fileName - the MED file name.
8393 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
8394 * - 2 - erase; an existing file is removed.
8395 * - 1 - append; same data should not be present in an existing file.
8396 * - 0 - overwrite; same data present in an existing file is overwritten.
8397 * \throw If the field name is not set.
8398 * \throw If no field data is set.
8399 * \throw If \a mode == 1 and the same data is present in an existing file.
8401 void MEDFileAnyTypeFieldMultiTS::write(const std::string& fileName, int mode) const
8403 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
8404 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
8409 * This method alloc the arrays and load potentially huge arrays contained in this field.
8410 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
8411 * This method can be also called to refresh or reinit values from a file.
8413 * \throw If the fileName is not set or points to a non readable MED file.
8415 void MEDFileAnyTypeFieldMultiTS::loadArrays()
8417 if(getFileName().empty())
8418 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
8419 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
8420 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
8424 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
8425 * But once data loaded once, this method does nothing.
8427 * \throw If the fileName is not set or points to a non readable MED file.
8428 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
8430 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
8432 if(!getFileName().empty())
8434 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
8435 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
8440 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
8441 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
8442 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
8444 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
8446 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
8448 contentNotNullBase()->unloadArrays();
8452 * 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.
8453 * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
8454 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
8456 * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
8458 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
8460 if(!getFileName().empty())
8461 contentNotNullBase()->unloadArrays();
8464 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
8466 std::ostringstream oss;
8467 contentNotNullBase()->simpleRepr(0,oss,-1);
8468 simpleReprGlobs(oss);
8472 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
8474 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
8477 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
8479 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
8480 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
8485 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
8486 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8487 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
8489 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
8491 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8493 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
8494 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
8495 std::size_t sz(contentsSplit.size());
8496 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8497 for(std::size_t i=0;i<sz;i++)
8499 ret[i]=shallowCpy();
8500 ret[i]->_content=contentsSplit[i];
8506 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
8507 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8509 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
8511 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8513 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
8514 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
8515 std::size_t sz(contentsSplit.size());
8516 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8517 for(std::size_t i=0;i<sz;i++)
8519 ret[i]=shallowCpy();
8520 ret[i]->_content=contentsSplit[i];
8526 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
8527 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8529 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
8531 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8533 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
8534 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
8535 std::size_t sz(contentsSplit.size());
8536 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8537 for(std::size_t i=0;i<sz;i++)
8539 ret[i]=shallowCpy();
8540 ret[i]->_content=contentsSplit[i];
8545 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCpy() const
8547 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8548 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
8549 ret->_content=_content->deepCpy();
8550 ret->deepCpyGlobs(*this);
8554 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
8560 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8561 * \param [in] iteration - the iteration number of a required time step.
8562 * \param [in] order - the iteration order number of required time step.
8563 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
8564 * delete this field using decrRef() as it is no more needed.
8565 * \throw If there is no required time step in \a this field.
8567 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
8569 int pos=getPosOfTimeStep(iteration,order);
8570 return getTimeStepAtPos(pos);
8574 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8575 * \param [in] time - the time of the time step of interest.
8576 * \param [in] eps - a precision used to compare time values.
8577 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8578 * delete this field using decrRef() as it is no more needed.
8579 * \throw If there is no required time step in \a this field.
8581 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
8583 int pos=getPosGivenTime(time,eps);
8584 return getTimeStepAtPos(pos);
8588 * 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.
8589 * The float64 value of time attached to the pair of integers are not considered here.
8590 * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
8592 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
8593 * \throw If there is a null pointer in \a vectFMTS.
8595 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
8597 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
8598 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8599 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8600 while(!lstFMTS.empty())
8602 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8603 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8605 throw INTERP_KERNEL::Exception(msg);
8606 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
8607 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8608 elt.push_back(curIt); it=lstFMTS.erase(it);
8609 while(it!=lstFMTS.end())
8613 throw INTERP_KERNEL::Exception(msg);
8614 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
8616 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8626 * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
8627 * All returned instances in a subvector can be safely loaded, rendered along time
8628 * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
8629 * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
8630 * 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).
8631 * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
8632 * 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.
8634 * \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().
8635 * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
8636 * \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.
8637 * \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.
8639 * \throw If an element in \a vectFMTS has not only one spatial discretization set.
8640 * \throw If an element in \a vectFMTS change of spatial discretization along time.
8641 * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
8642 * \thorw If some elements in \a vectFMTS do not have the same times steps.
8643 * \throw If mesh is null.
8644 * \throw If an element in \a vectFMTS is null.
8645 * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
8647 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> >& fsc)
8649 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
8651 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
8652 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8653 if(vectFMTS.empty())
8655 std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
8656 MEDFileAnyTypeFieldMultiTS *frstElt(*it);
8658 throw INTERP_KERNEL::Exception(msg);
8660 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
8661 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
8662 for(;it!=vectFMTS.end();it++,i++)
8665 throw INTERP_KERNEL::Exception(msg);
8666 TypeOfField tof0,tof1;
8667 if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
8670 vectFMTSNotNodes.push_back(*it);
8672 vectFMTSNodes.push_back(*it);
8675 vectFMTSNotNodes.push_back(*it);
8677 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> > cmps;
8678 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
8680 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
8683 bool isFetched(false);
8684 for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
8687 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
8688 if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
8689 { ret[i].push_back(*it2); isFetched=true; }
8693 std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
8694 MEDCouplingAutoRefCountObjectPtr<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
8695 ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
8703 * 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.
8704 * \param [out] cmps - same size than the returned vector.
8706 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> >& cmps)
8708 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8709 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8710 while(!lstFMTS.empty())
8712 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8713 MEDFileAnyTypeFieldMultiTS *ref(*it);
8714 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8715 elt.push_back(ref); it=lstFMTS.erase(it);
8716 MEDCouplingAutoRefCountObjectPtr<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
8717 MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
8718 while(it!=lstFMTS.end())
8720 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8721 if(cmp->isEqual(curIt))
8722 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8726 ret.push_back(elt); cmps.push_back(cmp);
8732 * 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.
8733 * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
8735 * \throw If \a f0 or \a f1 has not only one spatial discretization set.
8736 * \throw If \a f0 or \a f1 change of spatial discretization along time.
8737 * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
8738 * \thorw If \a f0 and \a f1 do not have the same times steps.
8739 * \throw If mesh is null.
8740 * \throw If \a f0 or \a f1 is null.
8741 * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
8743 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
8746 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
8748 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
8749 if(f0->getMeshName()!=mesh->getName())
8751 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8752 throw INTERP_KERNEL::Exception(oss.str().c_str());
8754 if(f1->getMeshName()!=mesh->getName())
8756 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8757 throw INTERP_KERNEL::Exception(oss.str().c_str());
8759 int nts=f0->getNumberOfTS();
8760 if(nts!=f1->getNumberOfTS())
8761 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
8764 for(int i=0;i<nts;i++)
8766 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
8767 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
8768 std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
8769 if(tofs0.size()!=1 || tofs1.size()!=1)
8770 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
8773 if(tof0!=tofs0[0] || tof1!=tofs1[0])
8774 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
8777 { tof0=tofs0[0]; tof1=tofs1[0]; }
8778 if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
8780 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() << ") !";
8781 throw INTERP_KERNEL::Exception(oss.str().c_str());
8783 if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
8785 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() << ") !";
8786 throw INTERP_KERNEL::Exception(oss.str().c_str());
8788 if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
8790 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() << ") !";
8791 throw INTERP_KERNEL::Exception(oss.str().c_str());
8797 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
8799 return new MEDFileAnyTypeFieldMultiTSIterator(this);
8802 //= MEDFileFieldMultiTS
8805 * Returns a new empty instance of MEDFileFieldMultiTS.
8806 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8807 * is to delete this field using decrRef() as it is no more needed.
8809 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
8811 return new MEDFileFieldMultiTS;
8815 * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
8816 * that has been read from a specified MED file.
8817 * \param [in] fileName - the name of the MED file to read.
8818 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8819 * is to delete this field using decrRef() as it is no more needed.
8820 * \throw If reading the file fails.
8822 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll)
8824 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,loadAll,0);
8825 ret->contentNotNull();//to check that content type matches with \a this type.
8830 * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
8831 * that has been read from a specified MED file.
8832 * \param [in] fileName - the name of the MED file to read.
8833 * \param [in] fieldName - the name of the field to read.
8834 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8835 * is to delete this field using decrRef() as it is no more needed.
8836 * \throw If reading the file fails.
8837 * \throw If there is no field named \a fieldName in the file.
8839 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8841 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,fieldName,loadAll,0);
8842 ret->contentNotNull();//to check that content type matches with \a this type.
8847 * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8848 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8850 * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
8851 * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
8852 * \warning this is a shallow copy constructor
8853 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
8854 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
8855 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8856 * is to delete this field using decrRef() as it is no more needed.
8858 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8860 return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
8863 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
8865 return new MEDFileFieldMultiTS(*this);
8868 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
8871 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8872 const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
8874 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8878 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
8879 * following the given input policy.
8881 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
8882 * By default (true) the globals are deeply copied.
8883 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
8885 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
8887 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret;
8888 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8891 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
8893 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
8894 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
8895 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc,getFileName()));
8898 ret=MEDFileIntFieldMultiTS::New();
8900 ret->deepCpyGlobs(*this);
8902 ret->shallowCpyGlobs(*this);
8907 * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
8908 * \param [in] pos - a time step id.
8909 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8910 * delete this field using decrRef() as it is no more needed.
8911 * \throw If \a pos is not a valid time step id.
8913 MEDFileAnyTypeField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const
8915 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
8918 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
8919 throw INTERP_KERNEL::Exception(oss.str().c_str());
8921 const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
8924 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
8925 ret->shallowCpyGlobs(*this);
8928 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
8929 throw INTERP_KERNEL::Exception(oss.str().c_str());
8933 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8934 * mesh entities of a given dimension of the first mesh in MED file.
8935 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8936 * \param [in] type - a spatial discretization of interest.
8937 * \param [in] iteration - the iteration number of a required time step.
8938 * \param [in] order - the iteration order number of required time step.
8939 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8940 * \param [in] renumPol - specifies how to permute values of the result field according to
8941 * the optional numbers of cells and nodes, if any. The valid values are
8942 * - 0 - do not permute.
8943 * - 1 - permute cells.
8944 * - 2 - permute nodes.
8945 * - 3 - permute cells and nodes.
8947 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8948 * caller is to delete this field using decrRef() as it is no more needed.
8949 * \throw If the MED file is not readable.
8950 * \throw If there is no mesh in the MED file.
8951 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8952 * \throw If no field values of the required parameters are available.
8954 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
8956 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8957 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8959 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
8960 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8961 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase());
8962 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8967 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8968 * the top level cells of the first mesh in MED file.
8969 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8970 * \param [in] type - a spatial discretization of interest.
8971 * \param [in] iteration - the iteration number of a required time step.
8972 * \param [in] order - the iteration order number of required time step.
8973 * \param [in] renumPol - specifies how to permute values of the result field according to
8974 * the optional numbers of cells and nodes, if any. The valid values are
8975 * - 0 - do not permute.
8976 * - 1 - permute cells.
8977 * - 2 - permute nodes.
8978 * - 3 - permute cells and nodes.
8980 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8981 * caller is to delete this field using decrRef() as it is no more needed.
8982 * \throw If the MED file is not readable.
8983 * \throw If there is no mesh in the MED file.
8984 * \throw If no field values of the required parameters are available.
8986 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
8988 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8989 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8991 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
8992 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8993 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase());
8994 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8999 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9001 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9002 * \param [in] type - a spatial discretization of interest.
9003 * \param [in] iteration - the iteration number of a required time step.
9004 * \param [in] order - the iteration order number of required time step.
9005 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9006 * \param [in] mesh - the supporting mesh.
9007 * \param [in] renumPol - specifies how to permute values of the result field according to
9008 * the optional numbers of cells and nodes, if any. The valid values are
9009 * - 0 - do not permute.
9010 * - 1 - permute cells.
9011 * - 2 - permute nodes.
9012 * - 3 - permute cells and nodes.
9014 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9015 * caller is to delete this field using decrRef() as it is no more needed.
9016 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9017 * \throw If no field of \a this is lying on \a mesh.
9018 * \throw If no field values of the required parameters are available.
9020 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9022 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9023 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9025 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9026 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
9027 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
9028 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9033 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9035 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9036 * \param [in] type - a spatial discretization of the new field.
9037 * \param [in] iteration - the iteration number of a required time step.
9038 * \param [in] order - the iteration order number of required time step.
9039 * \param [in] mesh - the supporting mesh.
9040 * \param [in] renumPol - specifies how to permute values of the result field according to
9041 * the optional numbers of cells and nodes, if any. The valid values are
9042 * - 0 - do not permute.
9043 * - 1 - permute cells.
9044 * - 2 - permute nodes.
9045 * - 3 - permute cells and nodes.
9047 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9048 * caller is to delete this field using decrRef() as it is no more needed.
9049 * \throw If no field of \a this is lying on \a mesh.
9050 * \throw If no field values of the required parameters are available.
9052 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
9054 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9055 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9057 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9058 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
9059 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
9060 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9065 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
9066 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9067 * This method is useful for MED2 file format when field on different mesh was autorized.
9069 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
9071 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9072 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9074 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
9075 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
9076 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
9077 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9082 * Returns values and a profile of the field of a given type, of a given time step,
9083 * lying on a given support.
9084 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9085 * \param [in] type - a spatial discretization of the field.
9086 * \param [in] iteration - the iteration number of a required time step.
9087 * \param [in] order - the iteration order number of required time step.
9088 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9089 * \param [in] mesh - the supporting mesh.
9090 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9091 * field of interest lies on. If the field lies on all entities of the given
9092 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9093 * using decrRef() as it is no more needed.
9094 * \param [in] glob - the global data storing profiles and localization.
9095 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
9096 * field. The caller is to delete this array using decrRef() as it is no more needed.
9097 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9098 * \throw If no field of \a this is lying on \a mesh.
9099 * \throw If no field values of the required parameters are available.
9101 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9103 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9104 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9106 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
9107 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9108 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
9111 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const
9113 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9115 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
9116 const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
9118 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 !");
9122 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull()
9124 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9126 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
9127 MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
9129 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 !");
9134 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9135 * the given field is checked if its elements are sorted suitable for writing to MED file
9136 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9137 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9138 * \param [in] field - the field to add to \a this.
9139 * \throw If the name of \a field is empty.
9140 * \throw If the data array of \a field is not set.
9141 * \throw If existing time steps have different name or number of components than \a field.
9142 * \throw If the underlying mesh of \a field has no name.
9143 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9145 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
9147 const DataArrayDouble *arr=0;
9149 arr=field->getArray();
9150 contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
9154 * Adds a MEDCouplingFieldDouble to \a this as another time step.
9155 * The mesh support of input parameter \a field is ignored here, it can be NULL.
9156 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9159 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9160 * A new profile is added only if no equal profile is missing.
9161 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9162 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
9163 * \param [in] mesh - the supporting mesh of \a field.
9164 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9165 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
9166 * \throw If either \a field or \a mesh or \a profile has an empty name.
9167 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9168 * \throw If the data array of \a field is not set.
9169 * \throw If the data array of \a this is already allocated but has different number of
9170 * components than \a field.
9171 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9172 * \sa setFieldNoProfileSBT()
9174 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9176 const DataArrayDouble *arr=0;
9178 arr=field->getArray();
9179 contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
9182 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
9184 _content=new MEDFileFieldMultiTSWithoutSDA;
9187 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9188 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll,ms)
9191 catch(INTERP_KERNEL::Exception& e)
9194 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
9195 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll,ms)
9198 catch(INTERP_KERNEL::Exception& e)
9201 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9205 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
9207 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
9210 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9212 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9215 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
9217 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
9220 //= MEDFileAnyTypeFieldMultiTSIterator
9222 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
9227 _nb_iter=fmts->getNumberOfTS();
9231 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
9235 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
9237 if(_iter_id<_nb_iter)
9239 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
9241 return fmts->getTimeStepAtPos(_iter_id++);
9249 //= MEDFileIntFieldMultiTS
9252 * Returns a new empty instance of MEDFileFieldMultiTS.
9253 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9254 * is to delete this field using decrRef() as it is no more needed.
9256 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
9258 return new MEDFileIntFieldMultiTS;
9262 * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
9263 * that has been read from a specified MED file.
9264 * \param [in] fileName - the name of the MED file to read.
9265 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9266 * is to delete this field using decrRef() as it is no more needed.
9267 * \throw If reading the file fails.
9269 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll)
9271 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,loadAll,0);
9272 ret->contentNotNull();//to check that content type matches with \a this type.
9277 * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
9278 * that has been read from a specified MED file.
9279 * \param [in] fileName - the name of the MED file to read.
9280 * \param [in] fieldName - the name of the field to read.
9281 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9282 * is to delete this field using decrRef() as it is no more needed.
9283 * \throw If reading the file fails.
9284 * \throw If there is no field named \a fieldName in the file.
9286 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9288 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll,0);
9289 ret->contentNotNull();//to check that content type matches with \a this type.
9294 * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9295 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9297 * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
9298 * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9299 * \warning this is a shallow copy constructor
9300 * \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
9301 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9302 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9303 * is to delete this field using decrRef() as it is no more needed.
9305 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9307 return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
9311 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
9312 * following the given input policy.
9314 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9315 * By default (true) the globals are deeply copied.
9316 * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
9318 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const
9320 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret;
9321 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9324 const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
9326 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
9327 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
9328 ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc,getFileName()));
9331 ret=MEDFileFieldMultiTS::New();
9333 ret->deepCpyGlobs(*this);
9335 ret->shallowCpyGlobs(*this);
9339 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const
9341 return new MEDFileIntFieldMultiTS(*this);
9344 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9347 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9348 const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
9350 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
9354 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9355 * mesh entities of a given dimension of the first mesh in MED file.
9356 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9357 * \param [in] type - a spatial discretization of interest.
9358 * \param [in] iteration - the iteration number of a required time step.
9359 * \param [in] order - the iteration order number of required time step.
9360 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9361 * \param [out] arrOut - the DataArrayInt containing values of field.
9362 * \param [in] renumPol - specifies how to permute values of the result field according to
9363 * the optional numbers of cells and nodes, if any. The valid values are
9364 * - 0 - do not permute.
9365 * - 1 - permute cells.
9366 * - 2 - permute nodes.
9367 * - 3 - permute cells and nodes.
9369 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9370 * caller is to delete this field using decrRef() as it is no more needed.
9371 * \throw If the MED file is not readable.
9372 * \throw If there is no mesh in the MED file.
9373 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9374 * \throw If no field values of the required parameters are available.
9376 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
9378 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9379 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9381 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
9382 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9383 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase());
9384 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9389 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9390 * the top level cells of the first mesh in MED file.
9391 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9392 * \param [in] type - a spatial discretization of interest.
9393 * \param [in] iteration - the iteration number of a required time step.
9394 * \param [in] order - the iteration order number of required time step.
9395 * \param [out] arrOut - the DataArrayInt containing values of field.
9396 * \param [in] renumPol - specifies how to permute values of the result field according to
9397 * the optional numbers of cells and nodes, if any. The valid values are
9398 * - 0 - do not permute.
9399 * - 1 - permute cells.
9400 * - 2 - permute nodes.
9401 * - 3 - permute cells and nodes.
9403 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9404 * caller is to delete this field using decrRef() as it is no more needed.
9405 * \throw If the MED file is not readable.
9406 * \throw If there is no mesh in the MED file.
9407 * \throw If no field values of the required parameters are available.
9409 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, DataArrayInt* &arrOut, int renumPol) const
9411 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9412 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9414 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
9415 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9416 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase());
9417 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9422 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9424 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9425 * \param [in] type - a spatial discretization of interest.
9426 * \param [in] iteration - the iteration number of a required time step.
9427 * \param [in] order - the iteration order number of required time step.
9428 * \param [out] arrOut - the DataArrayInt containing values of field.
9429 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9430 * \param [in] mesh - the supporting mesh.
9431 * \param [in] renumPol - specifies how to permute values of the result field according to
9432 * the optional numbers of cells and nodes, if any. The valid values are
9433 * - 0 - do not permute.
9434 * - 1 - permute cells.
9435 * - 2 - permute nodes.
9436 * - 3 - permute cells and nodes.
9438 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9439 * caller is to delete this field using decrRef() as it is no more needed.
9440 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9441 * \throw If no field of \a this is lying on \a mesh.
9442 * \throw If no field values of the required parameters are available.
9444 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
9446 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9447 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9449 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9450 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9451 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase());
9452 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9457 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9459 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9460 * \param [in] type - a spatial discretization of the new field.
9461 * \param [in] iteration - the iteration number of a required time step.
9462 * \param [in] order - the iteration order number of required time step.
9463 * \param [in] mesh - the supporting mesh.
9464 * \param [out] arrOut - the DataArrayInt containing values of field.
9465 * \param [in] renumPol - specifies how to permute values of the result field according to
9466 * the optional numbers of cells and nodes, if any. The valid values are
9467 * - 0 - do not permute.
9468 * - 1 - permute cells.
9469 * - 2 - permute nodes.
9470 * - 3 - permute cells and nodes.
9472 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9473 * caller is to delete this field using decrRef() as it is no more needed.
9474 * \throw If no field of \a this is lying on \a mesh.
9475 * \throw If no field values of the required parameters are available.
9477 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
9479 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9480 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9482 throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9483 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9484 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase());
9485 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9490 * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
9491 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9492 * This method is useful for MED2 file format when field on different mesh was autorized.
9494 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
9496 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9497 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9499 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9500 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9501 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase());
9502 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9507 * Returns values and a profile of the field of a given type, of a given time step,
9508 * lying on a given support.
9509 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9510 * \param [in] type - a spatial discretization of the field.
9511 * \param [in] iteration - the iteration number of a required time step.
9512 * \param [in] order - the iteration order number of required time step.
9513 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9514 * \param [in] mesh - the supporting mesh.
9515 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9516 * field of interest lies on. If the field lies on all entities of the given
9517 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9518 * using decrRef() as it is no more needed.
9519 * \param [in] glob - the global data storing profiles and localization.
9520 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
9521 * field. The caller is to delete this array using decrRef() as it is no more needed.
9522 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9523 * \throw If no field of \a this is lying on \a mesh.
9524 * \throw If no field values of the required parameters are available.
9526 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9528 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9529 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9531 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
9532 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9533 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
9537 * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
9538 * \param [in] pos - a time step id.
9539 * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
9540 * delete this field using decrRef() as it is no more needed.
9541 * \throw If \a pos is not a valid time step id.
9543 MEDFileAnyTypeField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
9545 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9548 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9549 throw INTERP_KERNEL::Exception(oss.str().c_str());
9551 const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
9554 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
9555 ret->shallowCpyGlobs(*this);
9558 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
9559 throw INTERP_KERNEL::Exception(oss.str().c_str());
9563 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9564 * the given field is checked if its elements are sorted suitable for writing to MED file
9565 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9566 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9567 * \param [in] field - the field to add to \a this.
9568 * \throw If the name of \a field is empty.
9569 * \throw If the data array of \a field is not set.
9570 * \throw If existing time steps have different name or number of components than \a field.
9571 * \throw If the underlying mesh of \a field has no name.
9572 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9574 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals)
9576 contentNotNull()->appendFieldNoProfileSBT(field,arrOfVals,*this);
9580 * Adds a MEDCouplingFieldDouble to \a this as another time step.
9581 * The mesh support of input parameter \a field is ignored here, it can be NULL.
9582 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9585 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9586 * A new profile is added only if no equal profile is missing.
9587 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9588 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
9589 * \param [in] arrOfVals - the values of the field \a field used.
9590 * \param [in] mesh - the supporting mesh of \a field.
9591 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9592 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
9593 * \throw If either \a field or \a mesh or \a profile has an empty name.
9594 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9595 * \throw If the data array of \a field is not set.
9596 * \throw If the data array of \a this is already allocated but has different number of
9597 * components than \a field.
9598 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9599 * \sa setFieldNoProfileSBT()
9601 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9603 contentNotNull()->appendFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this);
9606 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const
9608 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9610 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
9611 const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9613 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 !");
9617 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull()
9619 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9621 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
9622 MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9624 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 !");
9628 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
9630 _content=new MEDFileIntFieldMultiTSWithoutSDA;
9633 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9637 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9638 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll,ms)
9641 catch(INTERP_KERNEL::Exception& e)
9644 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
9645 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll,ms)
9648 catch(INTERP_KERNEL::Exception& e)
9651 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9653 return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9658 MEDFileFields *MEDFileFields::New()
9660 return new MEDFileFields;
9663 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
9665 return new MEDFileFields(fileName,loadAll,0);
9668 MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9670 return new MEDFileFields(fileName,loadAll,ms);
9673 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
9675 std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
9676 ret+=_fields.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
9680 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
9682 std::vector<const BigMemoryObject *> ret;
9683 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9684 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
9688 MEDFileFields *MEDFileFields::deepCpy() const
9690 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
9692 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9694 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9695 ret->_fields[i]=(*it)->deepCpy();
9697 ret->deepCpyGlobs(*this);
9701 MEDFileFields *MEDFileFields::shallowCpy() const
9703 return new MEDFileFields(*this);
9707 * 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
9708 * 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.
9709 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
9711 * \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.
9712 * \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.
9714 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9716 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
9718 std::set< std::pair<int,int> > s;
9719 bool firstShot=true;
9720 areThereSomeForgottenTS=false;
9721 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9723 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9725 std::vector< std::pair<int,int> > v=(*it)->getIterations();
9726 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
9728 { s=s1; firstShot=false; }
9731 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
9733 areThereSomeForgottenTS=true;
9737 std::vector< std::pair<int,int> > ret;
9738 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
9742 int MEDFileFields::getNumberOfFields() const
9744 return _fields.size();
9747 std::vector<std::string> MEDFileFields::getFieldsNames() const
9749 std::vector<std::string> ret(_fields.size());
9751 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9753 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
9756 ret[i]=f->getName();
9760 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
9761 throw INTERP_KERNEL::Exception(oss.str().c_str());
9767 std::vector<std::string> MEDFileFields::getMeshesNames() const
9769 std::vector<std::string> ret;
9770 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9772 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9774 ret.push_back(cur->getMeshName());
9779 std::string MEDFileFields::simpleRepr() const
9781 std::ostringstream oss;
9782 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
9787 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
9789 int nbOfFields=getNumberOfFields();
9790 std::string startLine(bkOffset,' ');
9791 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
9793 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9795 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9798 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
9802 oss << startLine << " - not defined !" << std::endl;
9806 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9808 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9809 std::string chapter(17,'0'+i);
9810 oss << startLine << chapter << std::endl;
9813 cur->simpleRepr(bkOffset+2,oss,i);
9817 oss << startLine << " - not defined !" << std::endl;
9819 oss << startLine << chapter << std::endl;
9821 simpleReprGlobs(oss);
9824 MEDFileFields::MEDFileFields()
9828 MEDFileFields::MEDFileFields(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9829 try:MEDFileFieldGlobsReal(fileName)
9831 MEDFileUtilities::CheckFileForRead(fileName);
9832 MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY));
9833 int nbFields(MEDnField(fid));
9834 _fields.resize(nbFields);
9835 med_field_type typcha;
9836 for(int i=0;i<nbFields;i++)
9838 std::vector<std::string> infos;
9839 std::string fieldName,dtunit;
9840 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fileName,i,false,fieldName,typcha,infos,dtunit));
9845 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms);
9850 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms);
9855 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] !";
9856 throw INTERP_KERNEL::Exception(oss.str().c_str());
9860 loadAllGlobals(fid);
9862 catch(INTERP_KERNEL::Exception& e)
9867 void MEDFileFields::writeLL(med_idt fid) const
9870 writeGlobals(fid,*this);
9871 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9873 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
9876 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
9877 throw INTERP_KERNEL::Exception(oss.str().c_str());
9879 elt->writeLL(fid,*this);
9883 void MEDFileFields::write(const std::string& fileName, int mode) const
9885 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
9886 MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),medmod));
9891 * This method alloc the arrays and load potentially huge arrays contained in this field.
9892 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
9893 * This method can be also called to refresh or reinit values from a file.
9895 * \throw If the fileName is not set or points to a non readable MED file.
9897 void MEDFileFields::loadArrays()
9899 if(getFileName().empty())
9900 throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
9901 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
9902 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9904 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9906 elt->loadBigArraysRecursively(fid,*elt);
9911 * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
9912 * But once data loaded once, this method does nothing.
9914 * \throw If the fileName is not set or points to a non readable MED file.
9915 * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
9917 void MEDFileFields::loadArraysIfNecessary()
9919 if(!getFileName().empty())
9921 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
9922 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9924 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9926 elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
9932 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
9933 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
9934 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
9936 * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
9938 void MEDFileFields::unloadArrays()
9940 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9942 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9944 elt->unloadArrays();
9949 * 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.
9950 * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
9951 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
9953 * \sa MEDFileFields::loadArraysIfNecessary
9955 void MEDFileFields::unloadArraysWithoutDataLoss()
9957 if(!getFileName().empty())
9961 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
9963 std::vector<std::string> ret;
9964 std::set<std::string> ret2;
9965 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9967 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
9968 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
9969 if(ret2.find(*it2)==ret2.end())
9971 ret.push_back(*it2);
9978 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
9980 std::vector<std::string> ret;
9981 std::set<std::string> ret2;
9982 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9984 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
9985 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
9986 if(ret2.find(*it2)==ret2.end())
9988 ret.push_back(*it2);
9995 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
9997 std::vector<std::string> ret;
9998 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10000 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
10001 ret.insert(ret.end(),tmp.begin(),tmp.end());
10006 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
10008 std::vector<std::string> ret;
10009 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10011 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
10012 ret.insert(ret.end(),tmp.begin(),tmp.end());
10017 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10019 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10020 (*it)->changePflsRefsNamesGen2(mapOfModif);
10023 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10025 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10026 (*it)->changeLocsRefsNamesGen2(mapOfModif);
10029 void MEDFileFields::resize(int newSize)
10031 _fields.resize(newSize);
10034 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
10036 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
10040 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
10043 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
10044 _fields.push_back(field->getContent());
10045 appendGlobs(*field,1e-12);
10048 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
10051 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
10052 if(i>=(int)_fields.size())
10053 _fields.resize(i+1);
10054 _fields[i]=field->getContent();
10055 appendGlobs(*field,1e-12);
10058 void MEDFileFields::destroyFieldAtPos(int i)
10060 destroyFieldsAtPos(&i,&i+1);
10063 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
10065 std::vector<bool> b(_fields.size(),true);
10066 for(const int *i=startIds;i!=endIds;i++)
10068 if(*i<0 || *i>=(int)_fields.size())
10070 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10071 throw INTERP_KERNEL::Exception(oss.str().c_str());
10075 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10077 for(std::size_t i=0;i<_fields.size();i++)
10079 fields[j++]=_fields[i];
10083 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
10085 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
10086 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
10087 std::vector<bool> b(_fields.size(),true);
10089 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
10091 if(k<0 || k>=(int)_fields.size())
10093 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
10094 throw INTERP_KERNEL::Exception(oss.str().c_str());
10098 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10100 for(std::size_t i=0;i<_fields.size();i++)
10102 fields[j++]=_fields[i];
10106 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
10109 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10111 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10113 ret=cur->changeMeshNames(modifTab) || ret;
10119 * \param [in] meshName the name of the mesh that will be renumbered.
10120 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
10121 * This code corresponds to the distribution of types in the corresponding mesh.
10122 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
10123 * \param [in] renumO2N the old to new renumber array.
10124 * \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
10125 * field in \a this.
10127 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
10130 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10132 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
10135 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
10141 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
10143 if(i<0 || i>=(int)_fields.size())
10145 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
10146 throw INTERP_KERNEL::Exception(oss.str().c_str());
10148 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
10151 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret;
10152 const MEDFileFieldMultiTSWithoutSDA *fmtsC=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts);
10153 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts);
10155 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
10157 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
10160 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
10161 throw INTERP_KERNEL::Exception(oss.str().c_str());
10163 ret->shallowCpyGlobs(*this);
10168 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
10169 * This method is accessible in python using __getitem__ with a list in input.
10170 * \return a new object that the caller should deal with.
10172 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
10174 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
10175 std::size_t sz=std::distance(startIds,endIds);
10176 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
10178 for(const int *i=startIds;i!=endIds;i++,j++)
10180 if(*i<0 || *i>=(int)_fields.size())
10182 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10183 throw INTERP_KERNEL::Exception(oss.str().c_str());
10185 fields[j]=_fields[*i];
10187 ret->_fields=fields;
10191 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
10193 return getFieldAtPos(getPosFromFieldName(fieldName));
10197 * This method removes, if any, fields in \a this having no time steps.
10198 * 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.
10200 * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
10202 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
10204 std::vector<MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
10205 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10207 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10210 if(elt->getNumberOfTS()>0)
10211 newFields.push_back(*it);
10214 if(_fields.size()==newFields.size())
10221 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
10222 * This method can be seen as a filter applied on \a this, that returns an object containing
10223 * 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
10224 * shallow copied from \a this.
10226 * \param [in] meshName - the name of the mesh on w
10227 * \return a new object that the caller should deal with.
10229 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
10231 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
10232 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10234 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10237 if(cur->getMeshName()==meshName)
10240 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
10241 ret->_fields.push_back(cur2);
10244 ret->shallowCpyOnlyUsedGlobs(*this);
10249 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
10250 * Input time steps are specified using a pair of integer (iteration, order).
10251 * 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,
10252 * but for each multitimestep only the time steps in \a timeSteps are kept.
10253 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
10255 * The returned object points to shallow copy of elements in \a this.
10257 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
10258 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
10259 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10261 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10263 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
10264 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10266 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10269 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
10270 ret->_fields.push_back(elt);
10272 ret->shallowCpyOnlyUsedGlobs(*this);
10277 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
10279 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10281 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
10282 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10284 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10287 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
10288 if(elt->getNumberOfTS()!=0)
10289 ret->_fields.push_back(elt);
10291 ret->shallowCpyOnlyUsedGlobs(*this);
10295 MEDFileFieldsIterator *MEDFileFields::iterator()
10297 return new MEDFileFieldsIterator(this);
10300 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
10302 std::string tmp(fieldName);
10303 std::vector<std::string> poss;
10304 for(std::size_t i=0;i<_fields.size();i++)
10306 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=_fields[i];
10309 std::string fname(f->getName());
10313 poss.push_back(fname);
10316 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
10317 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
10319 throw INTERP_KERNEL::Exception(oss.str().c_str());
10322 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
10327 _nb_iter=fs->getNumberOfFields();
10331 MEDFileFieldsIterator::~MEDFileFieldsIterator()
10335 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
10337 if(_iter_id<_nb_iter)
10339 MEDFileFields *fs(_fs);
10341 return fs->getFieldAtPos(_iter_id++);