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 DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray()
1342 return _father->getOrCreateAndGetArray();
1345 const DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray() const
1347 const MEDFileFieldPerMesh *fath=_father;
1348 return fath->getOrCreateAndGetArray();
1351 const std::vector<std::string>& MEDFileFieldPerMeshPerType::getInfo() const
1353 return _father->getInfo();
1356 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsed() const
1358 std::vector<std::string> ret;
1359 std::set<std::string> ret2;
1360 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1362 std::string tmp=(*it1)->getProfile();
1364 if(ret2.find(tmp)==ret2.end())
1373 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsed() const
1375 std::vector<std::string> ret;
1376 std::set<std::string> ret2;
1377 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1379 std::string tmp=(*it1)->getLocalization();
1380 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1381 if(ret2.find(tmp)==ret2.end())
1390 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsedMulti() const
1392 std::vector<std::string> ret;
1393 std::set<std::string> ret2;
1394 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1396 std::string tmp=(*it1)->getProfile();
1403 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsedMulti() const
1405 std::vector<std::string> ret;
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)->getLocalization();
1409 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1415 void MEDFileFieldPerMeshPerType::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1417 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1418 (*it1)->changePflsRefsNamesGen(mapOfModif);
1421 void MEDFileFieldPerMeshPerType::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1423 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1424 (*it1)->changeLocsRefsNamesGen(mapOfModif);
1427 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId)
1429 if(_field_pm_pt_pd.empty())
1431 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1432 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1433 throw INTERP_KERNEL::Exception(oss.str().c_str());
1435 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1436 return _field_pm_pt_pd[locId];
1437 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1438 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1439 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1440 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1441 return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1444 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) const
1446 if(_field_pm_pt_pd.empty())
1448 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1449 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1450 throw INTERP_KERNEL::Exception(oss.str().c_str());
1452 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1453 return _field_pm_pt_pd[locId];
1454 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1455 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1456 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1457 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1458 return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1461 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
1463 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1465 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1466 if(meshDim!=(int)cm.getDimension())
1469 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1470 (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1473 void MEDFileFieldPerMeshPerType::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1476 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1478 (*it)->fillValues(i,startEntryId,entries);
1482 void MEDFileFieldPerMeshPerType::setLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
1484 _field_pm_pt_pd=leaves;
1485 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1486 (*it)->setFather(this);
1490 * \param [in,out] globalNum a global numbering counter for the renumbering.
1491 * \param [out] its - list of pair (start,stop) kept
1492 * \return bool - false if the type of field \a tof is not contained in \a this.
1494 bool MEDFileFieldPerMeshPerType::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
1497 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1498 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1499 if((*it)->getType()==tof)
1501 newPmPtPd.push_back(*it);
1502 std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1503 (*it)->setNewStart(globalNum);
1504 globalNum=(*it)->getEnd();
1505 its.push_back(bgEnd);
1509 _field_pm_pt_pd=newPmPtPd;
1513 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType):_father(fath),_geo_type(geoType)
1517 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):_father(fath),_geo_type(geoType)
1519 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1520 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1521 med_geometry_type mgeoti;
1522 med_entity_type menti(ConvertIntoMEDFileType(type,geoType,mgeoti));
1523 int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName));
1524 _field_pm_pt_pd.resize(nbProfiles);
1525 for(int i=0;i<nbProfiles;i++)
1527 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i,pd);
1531 int nbProfiles2=MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName);
1532 for(int i=0;i<nbProfiles2;i++)
1533 _field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i,pd));
1537 void MEDFileFieldPerMeshPerType::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
1539 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1540 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1543 void MEDFileFieldPerMeshPerType::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1545 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1546 (*it)->loadBigArray(fid,nasc);
1549 void MEDFileFieldPerMeshPerType::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1551 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1553 (*it)->copyOptionsFrom(*this);
1554 (*it)->writeLL(fid,nasc);
1558 med_entity_type MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1563 medfGeoType=typmai3[(int)ikGeoType];
1566 medfGeoType=MED_NONE;
1569 medfGeoType=typmai3[(int)ikGeoType];
1570 return MED_NODE_ELEMENT;
1572 medfGeoType=typmai3[(int)ikGeoType];
1575 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1577 return MED_UNDEF_ENTITY_TYPE;
1580 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm)
1582 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm);
1585 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1587 return new MEDFileFieldPerMesh(fath,mesh);
1590 std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
1592 return _mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType >);
1595 std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildrenWithNull() const
1597 std::vector<const BigMemoryObject *> ret;
1598 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1599 ret.push_back((const MEDFileFieldPerMeshPerType *)*it);
1603 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCpy(MEDFileAnyTypeField1TSWithoutSDA *father) const
1605 MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1606 ret->_father=father;
1608 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1610 if((const MEDFileFieldPerMeshPerType *)*it)
1611 ret->_field_pm_pt[i]=(*it)->deepCpy((MEDFileFieldPerMesh *)(ret));
1616 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1618 std::string startLine(bkOffset,' ');
1619 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1620 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1622 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1624 const MEDFileFieldPerMeshPerType *cur=*it;
1626 cur->simpleRepr(bkOffset,oss,i);
1629 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1634 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh)
1636 _mesh_name=mesh->getName();
1637 mesh->getTime(_mesh_iteration,_mesh_order);
1640 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1642 int nbOfTypes=code.size()/3;
1644 for(int i=0;i<nbOfTypes;i++)
1646 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1647 int nbOfCells=code[3*i+1];
1648 int pos=addNewEntryIfNecessary(type);
1649 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1655 * This method is the most general one. No optimization is done here.
1656 * \param [in] multiTypePfl is the end user profile specified in high level API
1657 * \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].
1658 * \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.
1659 * \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.
1660 * \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.
1661 * \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.
1663 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)
1665 int nbOfTypes(code.size()/3);
1666 for(int i=0;i<nbOfTypes;i++)
1668 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1669 int pos=addNewEntryIfNecessary(type);
1670 DataArrayInt *pfl=0;
1672 pfl=idsPerType[code[3*i+2]];
1673 int nbOfTupes2=code2.size()/3;
1675 for(;found<nbOfTupes2;found++)
1676 if(code[3*i]==code2[3*found])
1678 if(found==nbOfTupes2)
1679 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1680 _field_pm_pt[pos]->assignFieldProfile(nbOfTypes==1,start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1684 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1686 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1687 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1690 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1692 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1693 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1696 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
1698 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1699 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1702 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1704 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1705 (*it)->loadBigArraysRecursively(fid,nasc);
1708 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1710 int nbOfTypes=_field_pm_pt.size();
1711 for(int i=0;i<nbOfTypes;i++)
1713 _field_pm_pt[i]->copyOptionsFrom(*this);
1714 _field_pm_pt[i]->writeLL(fid,nasc);
1718 void MEDFileFieldPerMesh::getDimension(int& dim) const
1720 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1721 (*it)->getDimension(dim);
1724 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1726 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1727 (*it)->fillTypesOfFieldAvailable(types);
1730 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
1732 int sz=_field_pm_pt.size();
1733 std::vector< std::vector<std::pair<int,int> > > ret(sz);
1734 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1735 for(int i=0;i<sz;i++)
1737 types[i]=_field_pm_pt[i]->getGeoType();
1738 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1743 double MEDFileFieldPerMesh::getTime() const
1746 return _father->getTime(tmp1,tmp2);
1749 int MEDFileFieldPerMesh::getIteration() const
1751 return _father->getIteration();
1754 int MEDFileFieldPerMesh::getOrder() const
1756 return _father->getOrder();
1759 int MEDFileFieldPerMesh::getNumberOfComponents() const
1761 return _father->getNumberOfComponents();
1764 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
1767 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1768 return _father->getOrCreateAndGetArray();
1771 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
1774 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1775 return _father->getOrCreateAndGetArray();
1778 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1780 return _father->getInfo();
1784 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
1785 * 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.
1786 * It returns 2 output vectors :
1787 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
1788 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
1789 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
1791 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)
1793 int notNullPflsSz=0;
1794 int nbOfArrs=geoTypes.size();
1795 for(int i=0;i<nbOfArrs;i++)
1798 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
1799 int nbOfDiffGeoTypes=geoTypes3.size();
1800 code.resize(3*nbOfDiffGeoTypes);
1801 notNullPfls.resize(notNullPflsSz);
1804 for(int i=0;i<nbOfDiffGeoTypes;i++)
1807 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
1808 std::vector<const DataArrayInt *> notNullTmp;
1810 notNullTmp.push_back(pfls[j]);
1812 for(;j<nbOfArrs;j++)
1813 if(geoTypes[j]==refType)
1816 notNullTmp.push_back(pfls[j]);
1820 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
1821 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
1822 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
1823 code[3*i]=(int)refType;
1824 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
1825 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
1826 if(notNullTmp.empty())
1830 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
1831 code[3*i+2]=notNullPflsSz++;
1837 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
1839 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)
1843 for(int i=0;i<sz;i++)
1847 if(type!=ON_GAUSS_NE)
1848 ret+=dads[i].second-dads[i].first;
1851 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
1852 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
1857 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
1858 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
1864 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
1866 std::vector<std::string> ret;
1867 std::set<std::string> ret2;
1868 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1870 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
1871 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1872 if(ret2.find(*it2)==ret2.end())
1874 ret.push_back(*it2);
1881 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
1883 std::vector<std::string> ret;
1884 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1886 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
1887 ret.insert(ret.end(),tmp.begin(),tmp.end());
1892 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
1894 std::vector<std::string> ret;
1895 std::set<std::string> ret2;
1896 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1898 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
1899 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1900 if(ret2.find(*it2)==ret2.end())
1902 ret.push_back(*it2);
1909 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
1911 std::vector<std::string> ret;
1912 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1914 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
1915 ret.insert(ret.end(),tmp.begin(),tmp.end());
1920 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
1922 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
1924 if((*it).first==_mesh_name)
1926 _mesh_name=(*it).second;
1933 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
1934 MEDFileFieldGlobsReal& glob)
1936 if(_mesh_name!=meshName)
1938 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
1939 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
1940 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
1941 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
1942 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
1943 getUndergroundDataArrayExt(entries);
1944 DataArray *arr0=getOrCreateAndGetArray();//tony
1946 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
1947 DataArrayDouble *arr=dynamic_cast<DataArrayDouble *>(arr0);//tony
1949 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
1952 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
1953 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
1955 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
1957 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1958 sz+=(*it).second.second-(*it).second.first;
1961 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1963 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
1964 ////////////////////
1965 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
1966 int *workI2=explicitIdsOldInMesh->getPointer();
1967 int sz1=0,sz2=0,sid=1;
1968 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
1969 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
1970 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
1972 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
1973 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
1974 int *workI=explicitIdsOldInArr->getPointer();
1975 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
1977 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
1978 (*itL2)->setLocId(sz2);
1979 (*itL2)->_tmp_work1=(*itL2)->getStart();
1980 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
1982 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
1984 explicitIdsOldInMesh->reAlloc(sz2);
1985 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
1986 ////////////////////
1987 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
1988 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
1989 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
1990 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
1992 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
1993 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
1994 otherEntriesNew.back()->setLocId((*it)->getGeoType());
1996 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
1997 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
1998 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
2000 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
2001 int newStart=elt->getLocId();
2002 elt->setLocId((*it)->getGeoType());
2003 elt->setNewStart(newStart);
2004 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
2005 entriesKeptNew.push_back(elt);
2006 entriesKeptNew2.push_back(elt);
2008 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
2009 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
2010 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
2011 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
2013 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
2016 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
2018 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
2019 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
2021 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
2022 glob,arr2,otherEntriesNew) || ret;
2026 // Assign new dispatching
2027 assignNewLeaves(otherEntriesNew);
2028 arr->cpyFrom(*arr2);
2033 * \param [in,out] globalNum a global numbering counter for the renumbering.
2034 * \param [out] its - list of pair (start,stop) kept
2036 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
2038 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > ret;
2039 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2041 std::vector< std::pair<int,int> > its2;
2042 if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
2045 its.insert(its.end(),its2.begin(),its2.end());
2051 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
2053 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > > types;
2054 for( std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
2055 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
2057 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > fieldPmPt(types.size());
2058 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
2059 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=fieldPmPt.begin();
2060 for(;it1!=types.end();it1++,it2++)
2062 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
2063 elt->setLeaves((*it1).second);
2066 _field_pm_pt=fieldPmPt;
2069 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2071 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2072 (*it)->changePflsRefsNamesGen(mapOfModif);
2075 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2077 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2078 (*it)->changeLocsRefsNamesGen(mapOfModif);
2082 * \param [in] mesh is the whole mesh
2084 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2086 if(_field_pm_pt.empty())
2087 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2089 std::vector< std::pair<int,int> > dads;
2090 std::vector<const DataArrayInt *> pfls;
2091 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2092 std::vector<int> locs,code;
2093 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2094 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2095 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2097 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2100 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2101 throw INTERP_KERNEL::Exception(oss.str().c_str());
2104 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2105 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2108 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2110 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2113 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr);
2114 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2120 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2124 if(nb!=mesh->getNumberOfNodes())
2126 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2127 oss << " nodes in mesh !";
2128 throw INTERP_KERNEL::Exception(oss.str().c_str());
2130 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2133 return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2137 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
2139 if(_field_pm_pt.empty())
2140 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2142 std::vector<std::pair<int,int> > dads;
2143 std::vector<const DataArrayInt *> pfls;
2144 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2145 std::vector<int> locs,code;
2146 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2147 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2148 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2150 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2153 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2154 throw INTERP_KERNEL::Exception(oss.str().c_str());
2156 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2157 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2160 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2161 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2166 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2170 if(nb!=mesh->getNumberOfNodes())
2172 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2173 oss << " nodes in mesh !";
2174 throw INTERP_KERNEL::Exception(oss.str().c_str());
2177 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2183 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
2187 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2189 (*it)->getSizes(globalSz,nbOfEntries);
2191 entries.resize(nbOfEntries);
2193 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2195 (*it)->fillValues(nbOfEntries,entries);
2199 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
2201 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2203 if((*it)->getGeoType()==typ)
2204 return (*it)->getLeafGivenLocId(locId);
2206 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2207 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2208 oss << "Possiblities are : ";
2209 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2211 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2212 oss << "\"" << cm2.getRepr() << "\", ";
2214 throw INTERP_KERNEL::Exception(oss.str().c_str());
2217 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
2219 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2221 if((*it)->getGeoType()==typ)
2222 return (*it)->getLeafGivenLocId(locId);
2224 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2225 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2226 oss << "Possiblities are : ";
2227 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2229 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2230 oss << "\"" << cm2.getRepr() << "\", ";
2232 throw INTERP_KERNEL::Exception(oss.str().c_str());
2235 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2238 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2239 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=_field_pm_pt.begin();
2240 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2242 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2247 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2252 int ret=std::distance(_field_pm_pt.begin(),it2);
2253 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2258 * 'dads' and 'locs' input parameters have the same number of elements
2259 * \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
2261 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2262 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2263 const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2266 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2267 ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2268 MEDCouplingAutoRefCountObjectPtr<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2269 const std::vector<std::string>& infos=getInfo();
2270 da->setInfoOnComponents(infos);
2272 if(type==ON_GAUSS_PT)
2275 int nbOfArrs=dads.size();
2276 for(int i=0;i<nbOfArrs;i++)
2278 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2279 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2280 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2281 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> di=DataArrayInt::New();
2282 di->alloc(nbOfElems,1);
2284 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2285 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2294 * 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.
2295 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2296 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2297 * The order of cells in the returned field is those imposed by the profile.
2298 * \param [in] mesh is the global mesh.
2300 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2301 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2302 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2303 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2305 if(da->isIdentity())
2307 int nbOfTuples=da->getNumberOfTuples();
2308 if(nbOfTuples==mesh->getNumberOfCells())
2309 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2311 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2312 m2->setName(mesh->getName().c_str());
2313 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2319 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2321 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2322 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2323 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2325 if(da->isIdentity())
2327 int nbOfTuples=da->getNumberOfTuples();
2328 if(nbOfTuples==mesh->getNumberOfNodes())//No problem for NORM_ERROR because it is in context of node
2329 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2331 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2332 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2335 if(meshu->getNodalConnectivity()==0)
2337 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2338 int nb=da->getNbOfElems();
2339 const int *ptr=da->getConstPointer();
2340 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2341 meshuc->allocateCells(nb);
2342 for(int i=0;i<nb;i++)
2343 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2344 meshuc->finishInsertingCells();
2345 ret->setMesh(meshuc);
2346 const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2347 if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2348 disc->checkCoherencyBetween(meshuc,arrOut);
2353 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2355 DataArrayInt *arr2=0;
2356 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2357 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2358 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3(arr2);
2359 int nnodes=mesh2->getNumberOfNodes();
2360 if(nnodes==(int)da->getNbOfElems())
2362 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2363 arrOut->renumberInPlace(da3->getConstPointer());
2364 mesh2->setName(mesh->getName().c_str());
2365 ret->setMesh(mesh2);
2370 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 !!!";
2371 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2372 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2373 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2374 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2375 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2376 throw INTERP_KERNEL::Exception(oss.str().c_str());
2382 * This method is the most light method of field retrieving.
2384 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
2388 pflOut=DataArrayInt::New();
2389 pflOut->alloc(nbOfElems,1);
2394 pflOut=const_cast<DataArrayInt*>(pflIn);
2397 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> safePfl(pflOut);
2398 MEDCouplingAutoRefCountObjectPtr<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2399 const std::vector<std::string>& infos=getInfo();
2400 int nbOfComp=infos.size();
2401 for(int i=0;i<nbOfComp;i++)
2402 da->setInfoOnComponent(i,infos[i].c_str());
2407 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),
2410 INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2411 INTERP_KERNEL::AutoPtr<char> pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2412 INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2413 const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
2414 for(int i=0;i<MED_N_CELL_FIXED_GEO;i++)
2416 int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL ,typmai[i],meshCsit+1,meshName,pflName,locName));
2417 std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2418 int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[i],meshCsit+1,meshName,pflName,locName));
2419 std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2420 if(nbProfile>0 || nbProfile2>0)
2422 const PartDefinition *pd(0);
2424 pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[i]),typmai2[i]);
2425 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[i],nasc,pd));
2432 int nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName);
2435 const PartDefinition *pd(0);
2437 pd=mmu->getPartDefAtLevel(1,INTERP_KERNEL::NORM_ERROR);
2438 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd));
2439 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2443 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2445 copyTinyInfoFrom(mesh);
2448 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
2450 if(id>=(int)_pfls.size())
2452 _pfls[id]=DataArrayInt::New();
2453 int lgth=MEDprofileSizeByName(fid,pflName.c_str());
2454 _pfls[id]->setName(pflName);
2455 _pfls[id]->alloc(lgth,1);
2456 MEDprofileRd(fid,pflName.c_str(),_pfls[id]->getPointer());
2457 _pfls[id]->applyLin(1,-1,0);//Converting into C format
2460 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2462 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2464 MEDprofileInfo(fid,i+1,pflName,&sz);
2465 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2466 if(i>=(int)_pfls.size())
2468 _pfls[i]=DataArrayInt::New();
2469 _pfls[i]->alloc(sz,1);
2470 _pfls[i]->setName(pflCpp.c_str());
2471 MEDprofileRd(fid,pflName,_pfls[i]->getPointer());
2472 _pfls[i]->applyLin(1,-1,0);//Converting into C format
2475 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
2477 int nbOfPfls=_pfls.size();
2478 for(int i=0;i<nbOfPfls;i++)
2480 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cpy=_pfls[i]->deepCpy();
2481 cpy->applyLin(1,1,0);
2482 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2483 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2484 MEDprofileWr(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer());
2487 int nbOfLocs=_locs.size();
2488 for(int i=0;i<nbOfLocs;i++)
2489 _locs[i]->writeLL(fid);
2492 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
2494 std::vector<std::string> pfls=getPfls();
2495 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2497 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2500 _pfls.push_back(*it);
2504 int id=std::distance(pfls.begin(),it2);
2505 if(!(*it)->isEqual(*_pfls[id]))
2507 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2508 throw INTERP_KERNEL::Exception(oss.str().c_str());
2512 std::vector<std::string> locs=getLocs();
2513 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
2515 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2518 _locs.push_back(*it);
2522 int id=std::distance(locs.begin(),it2);
2523 if(!(*it)->isEqual(*_locs[id],eps))
2525 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2526 throw INTERP_KERNEL::Exception(oss.str().c_str());
2532 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
2534 for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
2535 getProfile((*it).c_str());
2538 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
2540 for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
2541 getLocalization((*it).c_str());
2544 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
2546 std::vector<std::string> profiles=real.getPflsReallyUsed();
2547 int sz=profiles.size();
2549 for(int i=0;i<sz;i++)
2550 loadProfileInFile(fid,i,profiles[i].c_str());
2552 std::vector<std::string> locs=real.getLocsReallyUsed();
2555 for(int i=0;i<sz;i++)
2556 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2559 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid)
2561 int nProfil=MEDnProfile(fid);
2562 for(int i=0;i<nProfil;i++)
2563 loadProfileInFile(fid,i);
2564 int sz=MEDnLocalization(fid);
2566 for(int i=0;i<sz;i++)
2568 _locs[i]=MEDFileFieldLoc::New(fid,i);
2572 MEDFileFieldGlobs *MEDFileFieldGlobs::New(const std::string& fname)
2574 return new MEDFileFieldGlobs(fname);
2577 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2579 return new MEDFileFieldGlobs;
2582 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
2584 return _file_name.capacity()+_pfls.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<DataArrayInt>)+_locs.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>);
2587 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildrenWithNull() const
2589 std::vector<const BigMemoryObject *> ret;
2590 for(std::vector< MEDCouplingAutoRefCountObjectPtr< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2591 ret.push_back((const DataArrayInt *)*it);
2592 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2593 ret.push_back((const MEDFileFieldLoc *)*it);
2597 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpy() const
2599 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
2601 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2603 if((const DataArrayInt *)*it)
2604 ret->_pfls[i]=(*it)->deepCpy();
2607 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2609 if((const MEDFileFieldLoc*)*it)
2610 ret->_locs[i]=(*it)->deepCpy();
2616 * \throw if a profile in \a pfls in not in \a this.
2617 * \throw if a localization in \a locs in not in \a this.
2618 * \sa MEDFileFieldGlobs::deepCpyPart
2620 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2622 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2623 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2625 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2627 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
2629 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2(pfl);
2630 ret->_pfls.push_back(pfl2);
2632 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2634 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2636 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
2638 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> loc2(loc);
2639 ret->_locs.push_back(loc2);
2641 ret->setFileName(getFileName());
2646 * \throw if a profile in \a pfls in not in \a this.
2647 * \throw if a localization in \a locs in not in \a this.
2648 * \sa MEDFileFieldGlobs::shallowCpyPart
2650 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2652 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2653 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2655 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2657 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
2658 ret->_pfls.push_back(pfl->deepCpy());
2660 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2662 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2664 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
2665 ret->_locs.push_back(loc->deepCpy());
2667 ret->setFileName(getFileName());
2671 MEDFileFieldGlobs::MEDFileFieldGlobs(const std::string& fname):_file_name(fname)
2675 MEDFileFieldGlobs::MEDFileFieldGlobs()
2679 MEDFileFieldGlobs::~MEDFileFieldGlobs()
2683 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
2685 oss << "Profiles :\n";
2686 std::size_t n=_pfls.size();
2687 for(std::size_t i=0;i<n;i++)
2689 oss << " - #" << i << " ";
2690 const DataArrayInt *pfl=_pfls[i];
2692 oss << "\"" << pfl->getName() << "\"\n";
2697 oss << "Localizations :\n";
2698 for(std::size_t i=0;i<n;i++)
2700 oss << " - #" << i << " ";
2701 const MEDFileFieldLoc *loc=_locs[i];
2703 loc->simpleRepr(oss);
2709 void MEDFileFieldGlobs::setFileName(const std::string& fileName)
2711 _file_name=fileName;
2714 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2716 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
2718 DataArrayInt *elt(*it);
2721 std::string name(elt->getName());
2722 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2724 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2726 elt->setName((*it2).second.c_str());
2734 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2736 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
2738 MEDFileFieldLoc *elt(*it);
2741 std::string name(elt->getName());
2742 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2744 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2746 elt->setName((*it2).second.c_str());
2754 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
2756 if(locId<0 || locId>=(int)_locs.size())
2757 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
2758 return _locs[locId]->getNbOfGaussPtPerCell();
2761 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
2763 return getLocalizationFromId(getLocalizationId(locName));
2766 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
2768 if(locId<0 || locId>=(int)_locs.size())
2769 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2770 return *_locs[locId];
2773 namespace ParaMEDMEMImpl
2778 LocFinder(const std::string& loc):_loc(loc) { }
2779 bool operator() (const MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
2781 const std::string &_loc;
2787 PflFinder(const std::string& pfl):_pfl(pfl) { }
2788 bool operator() (const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
2790 const std::string& _pfl;
2794 int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
2796 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),ParaMEDMEMImpl::LocFinder(loc));
2799 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
2800 for(it=_locs.begin();it!=_locs.end();it++)
2801 oss << "\"" << (*it)->getName() << "\", ";
2802 throw INTERP_KERNEL::Exception(oss.str().c_str());
2804 return std::distance(_locs.begin(),it);
2808 * The returned value is never null.
2810 const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
2812 std::string pflNameCpp(pflName);
2813 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2816 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2817 for(it=_pfls.begin();it!=_pfls.end();it++)
2818 oss << "\"" << (*it)->getName() << "\", ";
2819 throw INTERP_KERNEL::Exception(oss.str().c_str());
2824 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
2826 if(pflId<0 || pflId>=(int)_pfls.size())
2827 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2828 return _pfls[pflId];
2831 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
2833 if(locId<0 || locId>=(int)_locs.size())
2834 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2835 return *_locs[locId];
2838 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
2840 return getLocalizationFromId(getLocalizationId(locName));
2844 * The returned value is never null.
2846 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
2848 std::string pflNameCpp(pflName);
2849 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2852 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2853 for(it=_pfls.begin();it!=_pfls.end();it++)
2854 oss << "\"" << (*it)->getName() << "\", ";
2855 throw INTERP_KERNEL::Exception(oss.str().c_str());
2860 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
2862 if(pflId<0 || pflId>=(int)_pfls.size())
2863 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2864 return _pfls[pflId];
2867 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
2869 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newPfls;
2871 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2873 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
2874 newPfls.push_back(*it);
2879 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
2881 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> > newLocs;
2883 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2885 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
2886 newLocs.push_back(*it);
2891 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
2893 int sz=_pfls.size();
2894 std::vector<std::string> ret(sz);
2895 for(int i=0;i<sz;i++)
2896 ret[i]=_pfls[i]->getName();
2900 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
2902 int sz=_locs.size();
2903 std::vector<std::string> ret(sz);
2904 for(int i=0;i<sz;i++)
2905 ret[i]=_locs[i]->getName();
2909 bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
2911 std::vector<std::string> v=getPfls();
2912 std::string s(pflName);
2913 return std::find(v.begin(),v.end(),s)!=v.end();
2916 bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
2918 std::vector<std::string> v=getLocs();
2919 std::string s(locName);
2920 return std::find(v.begin(),v.end(),s)!=v.end();
2923 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
2925 std::map<int,std::vector<int> > m;
2927 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2929 const DataArrayInt *tmp=(*it);
2932 m[tmp->getHashCode()].push_back(i);
2935 std::vector< std::vector<int> > ret;
2936 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
2938 if((*it2).second.size()>1)
2940 std::vector<int> ret0;
2941 bool equalityOrNot=false;
2942 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
2944 std::vector<int>::const_iterator it4=it3; it4++;
2945 for(;it4!=(*it2).second.end();it4++)
2947 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
2950 ret0.push_back(*it3);
2951 ret0.push_back(*it4);
2957 ret.push_back(ret0);
2963 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
2965 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
2968 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
2970 std::string name(pfl->getName());
2972 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
2973 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2974 if(name==(*it)->getName())
2976 if(!pfl->isEqual(*(*it)))
2978 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
2979 throw INTERP_KERNEL::Exception(oss.str().c_str());
2983 _pfls.push_back(pfl);
2986 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)
2988 std::string name(locName);
2990 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
2991 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
2992 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2993 if((*it)->isName(locName))
2995 if(!(*it)->isEqual(*obj,1e-12))
2997 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
2998 throw INTERP_KERNEL::Exception(oss.str().c_str());
3001 _locs.push_back(obj);
3004 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
3006 std::vector<std::string> names=getPfls();
3007 return CreateNewNameNotIn("NewPfl_",names);
3010 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
3012 std::vector<std::string> names=getLocs();
3013 return CreateNewNameNotIn("NewLoc_",names);
3016 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
3018 for(std::size_t sz=0;sz<100000;sz++)
3020 std::ostringstream tryName;
3021 tryName << prefix << sz;
3022 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
3023 return tryName.str();
3025 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
3029 * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
3030 * \param [in] fname - the file name.
3032 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(const std::string& fname):_globals(MEDFileFieldGlobs::New(fname))
3037 * Creates an empty MEDFileFieldGlobsReal.
3039 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
3043 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
3048 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildrenWithNull() const
3050 std::vector<const BigMemoryObject *> ret;
3051 ret.push_back((const MEDFileFieldGlobs *)_globals);
3056 * Returns a string describing profiles and Gauss points held in \a this.
3057 * \return std::string - the description string.
3059 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
3061 const MEDFileFieldGlobs *glob=_globals;
3062 std::ostringstream oss2; oss2 << glob;
3063 std::string stars(oss2.str().length(),'*');
3064 oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n";
3066 glob->simpleRepr(oss);
3068 oss << "NO GLOBAL INFORMATION !\n";
3071 void MEDFileFieldGlobsReal::resetContent()
3073 _globals=MEDFileFieldGlobs::New();
3076 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
3081 * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
3082 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3084 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3086 _globals=other._globals;
3090 * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3091 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3093 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3095 const MEDFileFieldGlobs *otherg(other._globals);
3098 _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3102 * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3103 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3105 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3107 const MEDFileFieldGlobs *otherg(other._globals);
3110 _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3113 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3115 _globals=other._globals;
3116 if((const MEDFileFieldGlobs *)_globals)
3117 _globals=other._globals->deepCpy();
3121 * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3122 * \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3123 * \param [in] eps - a precision used to compare Gauss points with same name held by
3124 * \a this and \a other MEDFileFieldGlobsReal.
3125 * \throw If \a this and \a other hold profiles with equal names but different ids.
3126 * \throw If \a this and \a other hold different Gauss points with equal names.
3128 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
3130 const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3131 if(thisGlobals==otherGlobals)
3135 _globals=other._globals;
3138 _globals->appendGlobs(*other._globals,eps);
3141 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
3143 checkGlobsPflsPartCoherency();
3144 checkGlobsLocsPartCoherency();
3147 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
3149 contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3152 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
3154 contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3157 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3159 contentNotNull()->loadProfileInFile(fid,id,pflName);
3162 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3164 contentNotNull()->loadProfileInFile(fid,id);
3167 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
3169 contentNotNull()->loadGlobals(fid,*this);
3172 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid)
3174 contentNotNull()->loadAllGlobals(fid);
3177 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3179 contentNotNull()->writeGlobals(fid,opt);
3183 * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3184 * or getPflsReallyUsedMulti().
3185 * \return std::vector<std::string> - a sequence of names of all profiles.
3187 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3189 return contentNotNull()->getPfls();
3193 * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3194 * or getLocsReallyUsedMulti().
3195 * \return std::vector<std::string> - a sequence of names of all localizations.
3197 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3199 return contentNotNull()->getLocs();
3203 * Checks if the profile with a given name exists.
3204 * \param [in] pflName - the profile name of interest.
3205 * \return bool - \c true if the profile named \a pflName exists.
3207 bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
3209 return contentNotNull()->existsPfl(pflName);
3213 * Checks if the localization with a given name exists.
3214 * \param [in] locName - the localization name of interest.
3215 * \return bool - \c true if the localization named \a locName exists.
3217 bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
3219 return contentNotNull()->existsLoc(locName);
3222 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
3224 return contentNotNull()->createNewNameOfPfl();
3227 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
3229 return contentNotNull()->createNewNameOfLoc();
3233 * Sets the name of a MED file.
3234 * \param [inout] fileName - the file name.
3236 void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
3238 contentNotNull()->setFileName(fileName);
3242 * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3243 * in the same order.
3244 * \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3245 * Each item of this sequence is a vector containing ids of equal profiles.
3247 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3249 return contentNotNull()->whichAreEqualProfiles();
3253 * Finds equal localizations.
3254 * \param [in] eps - a precision used to compare real values of the localizations.
3255 * \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3256 * Each item of this sequence is a vector containing ids of equal localizations.
3258 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3260 return contentNotNull()->whichAreEqualLocs(eps);
3264 * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3265 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3266 * this sequence is a pair whose
3267 * - the first item is a vector of profile names to replace by the second item,
3268 * - the second item is a profile name to replace every profile name of the first item.
3270 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3272 contentNotNull()->changePflsNamesInStruct(mapOfModif);
3276 * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3277 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3278 * this sequence is a pair whose
3279 * - the first item is a vector of localization names to replace by the second item,
3280 * - the second item is a localization name to replace every localization name of the first item.
3282 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3284 contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3288 * Replaces references to some profiles (a reference is a profile name) by references
3289 * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3290 * them-selves accordingly. <br>
3291 * This method is a generalization of changePflName().
3292 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3293 * this sequence is a pair whose
3294 * - the first item is a vector of profile names to replace by the second item,
3295 * - the second item is a profile name to replace every profile of the first item.
3296 * \sa changePflsRefsNamesGen()
3297 * \sa changePflName()
3299 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3301 changePflsRefsNamesGen(mapOfModif);
3302 changePflsNamesInStruct(mapOfModif);
3306 * Replaces references to some localizations (a reference is a localization name) by references
3307 * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3308 * them-selves accordingly. <br>
3309 * This method is a generalization of changeLocName().
3310 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3311 * this sequence is a pair whose
3312 * - the first item is a vector of localization names to replace by the second item,
3313 * - the second item is a localization name to replace every localization of the first item.
3314 * \sa changeLocsRefsNamesGen()
3315 * \sa changeLocName()
3317 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3319 changeLocsRefsNamesGen(mapOfModif);
3320 changeLocsNamesInStruct(mapOfModif);
3324 * Renames the profile having a given name and updates references to this profile.
3325 * \param [in] oldName - the name of the profile to rename.
3326 * \param [in] newName - a new name of the profile.
3327 * \sa changePflsNames().
3329 void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
3331 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3332 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3334 changePflsNames(mapOfModif);
3338 * Renames the localization having a given name and updates references to this localization.
3339 * \param [in] oldName - the name of the localization to rename.
3340 * \param [in] newName - a new name of the localization.
3341 * \sa changeLocsNames().
3343 void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
3345 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3346 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3348 changeLocsNames(mapOfModif);
3352 * Removes duplicated profiles. Returns a map used to update references to removed
3353 * profiles via changePflsRefsNamesGen().
3354 * Equal profiles are found using whichAreEqualProfiles().
3355 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3356 * a sequence describing the performed replacements of profiles. Each element of
3357 * this sequence is a pair whose
3358 * - the first item is a vector of profile names replaced by the second item,
3359 * - the second item is a profile name replacing every profile of the first item.
3361 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
3363 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3364 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3366 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3368 std::vector< std::string > tmp((*it).size());
3370 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3371 tmp[j]=std::string(getProfileFromId(*it2)->getName());
3372 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3374 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3375 killProfileIds(tmp2);
3377 changePflsRefsNamesGen(ret);
3382 * Removes duplicated localizations. Returns a map used to update references to removed
3383 * localizations via changeLocsRefsNamesGen().
3384 * Equal localizations are found using whichAreEqualLocs().
3385 * \param [in] eps - a precision used to compare real values of the localizations.
3386 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3387 * a sequence describing the performed replacements of localizations. Each element of
3388 * this sequence is a pair whose
3389 * - the first item is a vector of localization names replaced by the second item,
3390 * - the second item is a localization name replacing every localization of the first item.
3392 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
3394 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3395 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3397 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3399 std::vector< std::string > tmp((*it).size());
3401 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3402 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3403 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3405 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3406 killLocalizationIds(tmp2);
3408 changeLocsRefsNamesGen(ret);
3413 * Returns number of Gauss points per cell in a given localization.
3414 * \param [in] locId - an id of the localization of interest.
3415 * \return int - the number of the Gauss points per cell.
3417 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
3419 return contentNotNull()->getNbOfGaussPtPerCell(locId);
3423 * Returns an id of a localization by its name.
3424 * \param [in] loc - the localization name of interest.
3425 * \return int - the id of the localization.
3426 * \throw If there is no a localization named \a loc.
3428 int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
3430 return contentNotNull()->getLocalizationId(loc);
3434 * Returns the name of the MED file.
3435 * \return const std::string& - the MED file name.
3437 std::string MEDFileFieldGlobsReal::getFileName() const
3439 return contentNotNull()->getFileName();
3443 * Returns a localization object by its name.
3444 * \param [in] locName - the name of the localization of interest.
3445 * \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3446 * \throw If there is no a localization named \a locName.
3448 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
3450 return contentNotNull()->getLocalization(locName);
3454 * Returns a localization object by its id.
3455 * \param [in] locId - the id of the localization of interest.
3456 * \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3457 * \throw If there is no a localization with id \a locId.
3459 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
3461 return contentNotNull()->getLocalizationFromId(locId);
3465 * Returns a profile array by its name.
3466 * \param [in] pflName - the name of the profile of interest.
3467 * \return const DataArrayInt * - the profile array having the name \a pflName.
3468 * \throw If there is no a profile named \a pflName.
3470 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
3472 return contentNotNull()->getProfile(pflName);
3476 * Returns a profile array by its id.
3477 * \param [in] pflId - the id of the profile of interest.
3478 * \return const DataArrayInt * - the profile array having the id \a pflId.
3479 * \throw If there is no a profile with id \a pflId.
3481 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
3483 return contentNotNull()->getProfileFromId(pflId);
3487 * Returns a localization object, apt for modification, by its id.
3488 * \param [in] locId - the id of the localization of interest.
3489 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3490 * having the id \a locId.
3491 * \throw If there is no a localization with id \a locId.
3493 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
3495 return contentNotNull()->getLocalizationFromId(locId);
3499 * Returns a localization object, apt for modification, by its name.
3500 * \param [in] locName - the name of the localization of interest.
3501 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3502 * having the name \a locName.
3503 * \throw If there is no a localization named \a locName.
3505 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
3507 return contentNotNull()->getLocalization(locName);
3511 * Returns a profile array, apt for modification, by its name.
3512 * \param [in] pflName - the name of the profile of interest.
3513 * \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3514 * \throw If there is no a profile named \a pflName.
3516 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
3518 return contentNotNull()->getProfile(pflName);
3522 * Returns a profile array, apt for modification, by its id.
3523 * \param [in] pflId - the id of the profile of interest.
3524 * \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3525 * \throw If there is no a profile with id \a pflId.
3527 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
3529 return contentNotNull()->getProfileFromId(pflId);
3533 * Removes profiles given by their ids. No data is updated to track this removal.
3534 * \param [in] pflIds - a sequence of ids of the profiles to remove.
3536 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
3538 contentNotNull()->killProfileIds(pflIds);
3542 * Removes localizations given by their ids. No data is updated to track this removal.
3543 * \param [in] locIds - a sequence of ids of the localizations to remove.
3545 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
3547 contentNotNull()->killLocalizationIds(locIds);
3551 * Stores a profile array.
3552 * \param [in] pfl - the profile array to store.
3553 * \throw If the name of \a pfl is empty.
3554 * \throw If a profile with the same name as that of \a pfl already exists but contains
3557 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
3559 contentNotNull()->appendProfile(pfl);
3563 * Adds a new localization of Gauss points.
3564 * \param [in] locName - the name of the new localization.
3565 * \param [in] geoType - a geometrical type of the reference cell.
3566 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
3567 * must be \c nbOfNodesPerCell * \c dimOfType.
3568 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
3569 * must be _wg_.size() * \c dimOfType.
3570 * \param [in] w - the weights of Gauss points.
3571 * \throw If \a locName is empty.
3572 * \throw If a localization with the name \a locName already exists but is
3573 * different form the new one.
3575 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)
3577 contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
3580 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
3582 MEDFileFieldGlobs *g(_globals);
3584 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
3588 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
3590 const MEDFileFieldGlobs *g(_globals);
3592 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
3596 //= MEDFileFieldNameScope
3598 MEDFileFieldNameScope::MEDFileFieldNameScope()
3602 MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName):_name(fieldName)
3607 * Returns the name of \a this field.
3608 * \return std::string - a string containing the field name.
3610 std::string MEDFileFieldNameScope::getName() const
3616 * Sets name of \a this field
3617 * \param [in] name - the new field name.
3619 void MEDFileFieldNameScope::setName(const std::string& fieldName)
3624 std::string MEDFileFieldNameScope::getDtUnit() const
3629 void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
3634 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
3637 _dt_unit=other._dt_unit;
3640 //= MEDFileAnyTypeField1TSWithoutSDA
3642 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
3644 _field_per_mesh.resize(other._field_per_mesh.size());
3646 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
3648 if((const MEDFileFieldPerMesh *)*it)
3649 _field_per_mesh[i]=(*it)->deepCpy(this);
3654 * Prints a string describing \a this field into a stream. This string is outputted
3655 * by \c print Python command.
3656 * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
3657 * \param [in,out] oss - the out stream.
3658 * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
3659 * info id printed, else, not.
3661 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
3663 std::string startOfLine(bkOffset,' ');
3664 oss << startOfLine << "Field ";
3666 oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
3667 oss << "on one time Step ";
3669 oss << "(" << f1tsId << ") ";
3670 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
3671 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
3672 const DataArray *arr=getUndergroundDataArray();
3675 const std::vector<std::string> &comps=arr->getInfoOnComponents();
3678 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
3679 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
3680 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
3682 if(arr->isAllocated())
3684 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
3687 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
3691 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
3693 oss << startOfLine << "----------------------" << std::endl;
3694 if(!_field_per_mesh.empty())
3697 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
3699 const MEDFileFieldPerMesh *cur=(*it2);
3701 cur->simpleRepr(bkOffset,oss,i);
3703 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
3708 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
3710 oss << startOfLine << "----------------------" << std::endl;
3713 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
3715 const DataArray *arr(getUndergroundDataArray());
3717 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
3718 int nbOfCompo=arr->getNumberOfComponents();
3719 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
3720 for(int i=0;i<nbOfCompo;i++)
3723 std::vector<int> v(1,i);
3724 MEDCouplingAutoRefCountObjectPtr<DataArray> arr2=arr->keepSelectedComponents(v);
3725 ret[i]->setArray(arr2);
3730 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)
3734 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
3739 * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
3740 * empty. Returns -1 if this in on nodes.
3741 * \return int - the dimension of \a this.
3743 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
3746 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3747 (*it)->getDimension(ret);
3752 * Returns the mesh name.
3753 * \return std::string - a string holding the mesh name.
3754 * \throw If \c _field_per_mesh.empty()
3756 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const
3758 if(_field_per_mesh.empty())
3759 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
3760 return _field_per_mesh[0]->getMeshName();
3763 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const std::string& newMeshName)
3765 std::string oldName(getMeshName());
3766 std::vector< std::pair<std::string,std::string> > v(1);
3767 v[0].first=oldName; v[0].second=newMeshName;
3771 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
3774 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3776 MEDFileFieldPerMesh *cur(*it);
3778 ret=cur->changeMeshNames(modifTab) || ret;
3784 * Returns the number of iteration of the state of underlying mesh.
3785 * \return int - the iteration number.
3786 * \throw If \c _field_per_mesh.empty()
3788 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
3790 if(_field_per_mesh.empty())
3791 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
3792 return _field_per_mesh[0]->getMeshIteration();
3796 * Returns the order number of iteration of the state of underlying mesh.
3797 * \return int - the order number.
3798 * \throw If \c _field_per_mesh.empty()
3800 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
3802 if(_field_per_mesh.empty())
3803 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
3804 return _field_per_mesh[0]->getMeshOrder();
3808 * Checks if \a this field is tagged by a given iteration number and a given
3809 * iteration order number.
3810 * \param [in] iteration - the iteration number of interest.
3811 * \param [in] order - the iteration order number of interest.
3812 * \return bool - \c true if \a this->getIteration() == \a iteration &&
3813 * \a this->getOrder() == \a order.
3815 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
3817 return iteration==_iteration && order==_order;
3821 * Returns number of iteration and order number of iteration when
3822 * \a this field has been calculated.
3823 * \return std::pair<int,int> - a pair of the iteration number and the iteration
3826 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
3828 std::pair<int,int> p;
3834 * Returns number of iteration and order number of iteration when
3835 * \a this field has been calculated.
3836 * \param [in,out] p - a pair returning the iteration number and the iteration
3839 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
3846 * Returns all types of spatial discretization of \a this field.
3847 * \param [in,out] types - a sequence of types of \a this field.
3849 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
3851 std::set<TypeOfField> types2;
3852 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3854 (*it)->fillTypesOfFieldAvailable(types2);
3856 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
3857 std::copy(types2.begin(),types2.end(),bi);
3861 * Returns all types of spatial discretization of \a this field.
3862 * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
3865 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
3867 std::vector<TypeOfField> ret;
3868 fillTypesOfFieldAvailable(ret);
3872 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
3874 std::vector<std::string> ret;
3875 std::set<std::string> ret2;
3876 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3878 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
3879 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3880 if(ret2.find(*it2)==ret2.end())
3882 ret.push_back(*it2);
3889 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
3891 std::vector<std::string> ret;
3892 std::set<std::string> ret2;
3893 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3895 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
3896 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3897 if(ret2.find(*it2)==ret2.end())
3899 ret.push_back(*it2);
3906 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
3908 std::vector<std::string> ret;
3909 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3911 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
3912 ret.insert(ret.end(),tmp.begin(),tmp.end());
3917 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
3919 std::vector<std::string> ret;
3920 std::set<std::string> ret2;
3921 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3923 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
3924 ret.insert(ret.end(),tmp.begin(),tmp.end());
3929 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3931 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3932 (*it)->changePflsRefsNamesGen(mapOfModif);
3935 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3937 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3938 (*it)->changeLocsRefsNamesGen(mapOfModif);
3942 * Returns all attributes of parts of \a this field lying on a given mesh.
3943 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
3944 * item of every of returned sequences refers to the _i_-th part of \a this field.
3945 * Thus all sequences returned by this method are of the same length equal to number
3946 * of different types of supporting entities.<br>
3947 * A field part can include sub-parts with several different spatial discretizations,
3948 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
3949 * for example. Hence, some of the returned sequences contains nested sequences, and an item
3950 * of a nested sequence corresponds to a type of spatial discretization.<br>
3951 * This method allows for iteration over MEDFile DataStructure without any overhead.
3952 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
3953 * for the case with only one underlying mesh. (Actually, the number of meshes is
3954 * not checked if \a mname == \c NULL).
3955 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
3956 * a field part is returned.
3957 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
3958 * This sequence is of the same length as \a types.
3959 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
3960 * discretization. A profile name can be empty.
3961 * Length of this and of nested sequences is the same as that of \a typesF.
3962 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
3963 * discretization. A localization name can be empty.
3964 * Length of this and of nested sequences is the same as that of \a typesF.
3965 * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
3966 * of ids of tuples within the data array, per each type of spatial
3967 * discretization within one mesh entity type.
3968 * Length of this and of nested sequences is the same as that of \a typesF.
3969 * \throw If no field is lying on \a mname.
3971 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
3975 meshId=getMeshIdFromMeshName(mname);
3977 if(_field_per_mesh.empty())
3978 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
3979 return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3983 * Returns dimensions of mesh elements \a this field lies on. The returned value is a
3984 * maximal absolute dimension and values returned via the out parameter \a levs are
3985 * dimensions relative to the maximal absolute dimension. <br>
3986 * This method is designed for MEDFileField1TS instances that have a discretization
3987 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS",
3988 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT",
3989 * \ref ParaMEDMEM::ON_GAUSS_NE "ON_GAUSS_NE".
3990 * Only these 3 discretizations will be taken into account here. If \a this is
3991 * \ref ParaMEDMEM::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
3992 * This method is useful to make the link between the dimension of the underlying mesh
3993 * and the levels of \a this, because it is possible that the highest dimension of \a this
3994 * field is not equal to the dimension of the underlying mesh.
3996 * Let's consider the following case:
3997 * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
3998 * TETRA4, HEXA8, TRI3 and SEG2.
3999 * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
4000 * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
4002 * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
4003 * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
4004 * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
4005 * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
4006 * parameter of getFieldAtLevel() is computed basing on the returned values as this:
4007 * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
4009 * to retrieve the highest level of
4010 * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br>
4011 * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
4012 * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
4013 * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
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] levs - a sequence returning the dimensions relative to the maximal
4018 * absolute one. They are in decreasing order. This sequence is cleared before
4020 * \return int - the maximal absolute dimension of elements \a this fields lies on.
4021 * \throw If no field is lying on \a mname.
4023 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
4026 int meshId=getMeshIdFromMeshName(mname);
4027 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4028 std::vector< std::vector<TypeOfField> > typesF;
4029 std::vector< std::vector<std::string> > pfls, locs;
4030 _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4032 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
4033 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
4034 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
4036 st.erase(INTERP_KERNEL::NORM_ERROR);
4038 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
4040 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
4041 ret1.insert((int)cm.getDimension());
4043 int ret=*std::max_element(ret1.begin(),ret1.end());
4044 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
4045 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
4050 * \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.
4051 * \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.
4052 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4053 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4055 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
4057 int mid=getMeshIdFromMeshName(mName);
4058 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4062 * \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.
4063 * \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.
4064 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4065 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4067 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
4069 int mid=getMeshIdFromMeshName(mName);
4070 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4074 * \param [in] mName specifies the underlying mesh name. This value can be pointer 0 for users that do not deal with fields on multi mesh.
4076 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
4078 if(_field_per_mesh.empty())
4079 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4082 std::string mName2(mName);
4084 std::vector<std::string> msg;
4085 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4086 if(mName2==(*it)->getMeshName())
4089 msg.push_back((*it)->getMeshName());
4090 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4091 oss << "Possible meshes are : ";
4092 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4093 oss << "\"" << (*it2) << "\" ";
4094 throw INTERP_KERNEL::Exception(oss.str().c_str());
4097 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
4100 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4101 std::string tmp(mesh->getName());
4103 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4104 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4106 for(;it!=_field_per_mesh.end();it++,i++)
4108 if((*it)->getMeshName()==tmp)
4111 int sz=_field_per_mesh.size();
4112 _field_per_mesh.resize(sz+1);
4113 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4117 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4118 MEDFileFieldGlobsReal& glob)
4121 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4123 MEDFileFieldPerMesh *fpm(*it);
4125 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4130 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
4132 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4133 std::vector< std::vector<TypeOfField> > typesF;
4134 std::vector< std::vector<std::string> > pfls,locs;
4135 std::vector< std::vector<std::pair<int,int> > > bgEnd=getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs);
4136 std::set<TypeOfField> allEnt;
4137 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4138 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4139 allEnt.insert(*it2);
4140 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4141 std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4142 for(std::size_t i=0;i<allEnt.size();i++,it3++)
4144 std::vector< std::pair<int,int> > its;
4145 ret[i]=shallowCpy();
4146 int newLgth=ret[i]->keepOnlySpatialDiscretization(*it3,its);
4147 ret[i]->updateData(newLgth,its);
4152 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
4154 int globalCounter=0;
4155 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4156 (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4157 return globalCounter;
4160 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
4162 if(_nb_of_tuples_to_be_allocated>=0)
4164 _nb_of_tuples_to_be_allocated=newLgth;
4165 const DataArray *oldArr(getUndergroundDataArray());
4168 MEDCouplingAutoRefCountObjectPtr<DataArray> newArr(createNewEmptyDataArrayInstance());
4169 newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
4171 _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
4175 if(_nb_of_tuples_to_be_allocated==-1)
4177 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4179 const DataArray *oldArr(getUndergroundDataArray());
4180 if(!oldArr || !oldArr->isAllocated())
4181 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4182 MEDCouplingAutoRefCountObjectPtr<DataArray> newArr(createNewEmptyDataArrayInstance());
4183 newArr->alloc(newLgth,getNumberOfComponents());
4185 newArr->copyStringInfoFrom(*oldArr);
4187 for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4189 if((*it).second<(*it).first)
4190 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4191 newArr->setContigPartOfSelectedValues2(pos,oldArr,(*it).first,(*it).second,1);
4192 pos+=(*it).second-(*it).first;
4197 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4200 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
4202 if(_field_per_mesh.empty())
4203 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4204 if(_field_per_mesh.size()>1)
4205 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4206 _field_per_mesh[0]->copyOptionsFrom(opts);
4207 _field_per_mesh[0]->writeLL(fid,nasc);
4211 * 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.
4212 * If false is returned the memory allocation is not required.
4214 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
4216 if(_nb_of_tuples_to_be_allocated>=0)
4218 getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4219 _nb_of_tuples_to_be_allocated=-2;
4222 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4224 if(_nb_of_tuples_to_be_allocated==-1)
4225 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4226 if(_nb_of_tuples_to_be_allocated<-3)
4227 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4228 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4231 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms)
4233 med_int numdt,numit;
4237 med_int meshnumdt,meshnumit;
4238 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4239 MEDfieldComputingStepInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt);
4240 MEDfield23ComputingStepMeshInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit);
4241 if(_iteration!=numdt || _order!=numit)
4242 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4243 _field_per_mesh.resize(nmesh);
4248 std::string meshNameCpp(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
4249 mm=ms->getMeshWithName(meshNameCpp);
4252 for(int i=0;i<nmesh;i++)
4253 _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i,meshnumdt,meshnumit,nasc,mm);
4254 _nb_of_tuples_to_be_allocated=0;
4255 for(int i=0;i<nmesh;i++)
4256 _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4259 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
4261 allocIfNecessaryTheArrayToReceiveDataFromFile();
4262 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4263 (*it)->loadBigArraysRecursively(fid,nasc);
4266 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
4268 if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4269 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4270 (*it)->loadBigArraysRecursively(fid,nasc);
4273 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms)
4275 loadOnlyStructureOfDataRecursively(fid,nasc,ms);
4276 loadBigArraysRecursively(fid,nasc);
4279 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
4281 DataArray *thisArr(getUndergroundDataArray());
4282 if(thisArr && thisArr->isAllocated())
4284 _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
4285 thisArr->desallocate();
4289 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
4291 return _dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh >);
4294 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
4296 std::vector<const BigMemoryObject *> ret;
4297 if(getUndergroundDataArray())
4298 ret.push_back(getUndergroundDataArray());
4299 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4300 ret.push_back((const MEDFileFieldPerMesh *)*it);
4305 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4306 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4307 * "Sort By Type"), if not, an exception is thrown.
4308 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
4309 * \param [in] arr - the array of values.
4310 * \param [in,out] glob - the global data where profiles and localization present in
4311 * \a field, if any, are added.
4312 * \throw If the name of \a field is empty.
4313 * \throw If the data array of \a field is not set.
4314 * \throw If \a this->_arr is already allocated but has different number of components
4316 * \throw If the underlying mesh of \a field has no name.
4317 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4319 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4321 const MEDCouplingMesh *mesh=field->getMesh();
4323 TypeOfField type=field->getTypeOfField();
4324 std::vector<DataArrayInt *> dummy;
4325 int start=copyTinyInfoFrom(field,arr);
4326 int pos=addNewEntryIfNecessary(mesh);
4329 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4330 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4333 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4337 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4338 * of a given mesh are used as the support of the given field (a real support is not used).
4339 * Elements of the given mesh must be sorted suitable for writing to MED file.
4340 * Order of underlying mesh entities of the given field specified by \a profile parameter
4341 * is not prescribed; this method permutes field values to have them sorted by element
4342 * type as required for writing to MED file. A new profile is added only if no equal
4343 * profile is missing.
4344 * \param [in] field - the field to add to \a this. The field double values are ignored.
4345 * \param [in] arrOfVals - the values of the field \a field used.
4346 * \param [in] mesh - the supporting mesh of \a field.
4347 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4348 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
4349 * \param [in,out] glob - the global data where profiles and localization present in
4350 * \a field, if any, are added.
4351 * \throw If either \a field or \a mesh or \a profile has an empty name.
4352 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4353 * \throw If the data array of \a field is not set.
4354 * \throw If \a this->_arr is already allocated but has different number of components
4356 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4357 * \sa setFieldNoProfileSBT()
4359 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4362 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
4363 if(!arrOfVals || !arrOfVals->isAllocated())
4364 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
4365 TypeOfField type=field->getTypeOfField();
4366 std::vector<DataArrayInt *> idsInPflPerType;
4367 std::vector<DataArrayInt *> idsPerType;
4368 std::vector<int> code,code2;
4369 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4372 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4373 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
4374 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin());
4375 std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
4377 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> field2=field->clone(false);
4378 int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
4379 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4381 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4382 throw INTERP_KERNEL::Exception(oss.str().c_str());
4385 int start=copyTinyInfoFrom(field,arrOfVals);
4386 code2=m->getDistributionOfTypes();
4388 int pos=addNewEntryIfNecessary(m);
4389 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4393 if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
4394 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
4395 std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
4396 std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
4397 int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
4398 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4400 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4401 throw INTERP_KERNEL::Exception(oss.str().c_str());
4403 int start=copyTinyInfoFrom(field,arrOfVals);
4404 int pos=addNewEntryIfNecessary(m);
4405 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4410 * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
4412 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
4414 if(_nb_of_tuples_to_be_allocated>=0)
4415 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 !");
4416 DataArray *arr(getOrCreateAndGetArray());
4417 arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
4418 _nb_of_tuples_to_be_allocated=-3;
4422 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4423 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4424 * larger by the size of \a field. Returns an id of the first not filled
4425 * tuple of \a this->_arr.
4426 * \param [in] field - the field to copy the info on components and the name from.
4427 * \return int - the id of first not initialized tuple of \a this->_arr.
4428 * \throw If the name of \a field is empty.
4429 * \throw If the data array of \a field is not set.
4430 * \throw If \a this->_arr is already allocated but has different number of components
4433 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
4436 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4437 std::string name(field->getName());
4438 setName(name.c_str());
4439 setDtUnit(field->getTimeUnit());
4441 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4443 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4444 if(!arr->isAllocated())
4445 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
4446 _dt=field->getTime(_iteration,_order);
4447 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4448 if(!getOrCreateAndGetArray()->isAllocated())
4450 allocNotFromFile(arr->getNumberOfTuples());
4455 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4456 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4457 getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
4458 _nb_of_tuples_to_be_allocated=-3;
4459 return oldNbOfTuples;
4464 * Returns number of components in \a this field
4465 * \return int - the number of components.
4467 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4469 return getOrCreateAndGetArray()->getNumberOfComponents();
4473 * Change info on components in \a this.
4474 * \throw If size of \a infos is not equal to the number of components already in \a this.
4476 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
4478 DataArray *arr=getOrCreateAndGetArray();
4479 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
4483 * Returns info on components of \a this field.
4484 * \return const std::vector<std::string>& - a sequence of strings each being an
4485 * information on _i_-th component.
4487 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
4489 const DataArray *arr=getOrCreateAndGetArray();
4490 return arr->getInfoOnComponents();
4494 * Returns a mutable info on components of \a this field.
4495 * \return std::vector<std::string>& - a sequence of strings each being an
4496 * information on _i_-th component.
4498 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
4500 DataArray *arr=getOrCreateAndGetArray();
4501 return arr->getInfoOnComponents();
4505 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4506 * \param [in] type - a spatial discretization of the new field.
4507 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4508 * \param [in] mName - a name of the supporting mesh.
4509 * \param [in] renumPol - specifies how to permute values of the result field according to
4510 * the optional numbers of cells and nodes, if any. The valid values are
4511 * - 0 - do not permute.
4512 * - 1 - permute cells.
4513 * - 2 - permute nodes.
4514 * - 3 - permute cells and nodes.
4516 * \param [in] glob - the global data storing profiles and localization.
4517 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4518 * caller is to delete this field using decrRef() as it is no more needed.
4519 * \throw If the MED file is not readable.
4520 * \throw If there is no mesh named \a mName in the MED file.
4521 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4522 * \throw If no field of \a this is lying on the mesh \a mName.
4523 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4525 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4527 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4529 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4531 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4532 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4536 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4537 * \param [in] type - a spatial discretization of the new field.
4538 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4539 * \param [in] renumPol - specifies how to permute values of the result field according to
4540 * the optional numbers of cells and nodes, if any. The valid values are
4541 * - 0 - do not permute.
4542 * - 1 - permute cells.
4543 * - 2 - permute nodes.
4544 * - 3 - permute cells and nodes.
4546 * \param [in] glob - the global data storing profiles and localization.
4547 * \param [in] mesh - the supporting mesh.
4548 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4549 * caller is to delete this field using decrRef() as it is no more needed.
4550 * \throw If the MED file is not readable.
4551 * \throw If no field of \a this is lying on \a mesh.
4552 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4553 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4555 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4557 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax,false);
4558 const DataArrayInt *d=mesh->getNumberFieldAtLevel(meshDimRelToMax);
4559 const DataArrayInt *e=mesh->getNumberFieldAtLevel(1);
4560 if(meshDimRelToMax==1)
4561 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
4562 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
4566 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
4568 * \param [in] type - a spatial discretization of the new field.
4569 * \param [in] mName - a name of the supporting mesh.
4570 * \param [in] renumPol - specifies how to permute values of the result field according to
4571 * the optional numbers of cells and nodes, if any. The valid values are
4572 * - 0 - do not permute.
4573 * - 1 - permute cells.
4574 * - 2 - permute nodes.
4575 * - 3 - permute cells and nodes.
4577 * \param [in] glob - the global data storing profiles and localization.
4578 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4579 * caller is to delete this field using decrRef() as it is no more needed.
4580 * \throw If the MED file is not readable.
4581 * \throw If there is no mesh named \a mName in the MED file.
4582 * \throw If there are no mesh entities in the mesh.
4583 * \throw If no field values of the given \a type are available.
4585 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4587 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4589 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4591 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4592 int absDim=getDimension();
4593 int meshDimRelToMax=absDim-mm->getMeshDimension();
4594 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4598 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4599 * \param [in] type - a spatial discretization of the new field.
4600 * \param [in] renumPol - specifies how to permute values of the result field according to
4601 * the optional numbers of cells and nodes, if any. The valid values are
4602 * - 0 - do not permute.
4603 * - 1 - permute cells.
4604 * - 2 - permute nodes.
4605 * - 3 - permute cells and nodes.
4607 * \param [in] glob - the global data storing profiles and localization.
4608 * \param [in] mesh - the supporting mesh.
4609 * \param [in] cellRenum - the cell numbers array used for permutation of the result
4610 * field according to \a renumPol.
4611 * \param [in] nodeRenum - the node numbers array used for permutation of the result
4612 * field according to \a renumPol.
4613 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4614 * caller is to delete this field using decrRef() as it is no more needed.
4615 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4616 * \throw If no field of \a this is lying on \a mesh.
4617 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4619 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
4621 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
4622 int meshId=getMeshIdFromMeshName(mesh->getName());
4624 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
4629 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4636 throw INTERP_KERNEL::Exception(msg1);
4637 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4640 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
4642 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4643 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
4644 throw INTERP_KERNEL::Exception(oss.str().c_str());
4646 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
4647 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
4648 std::vector<DataArray *> arrOut2(1,arrOut);
4649 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
4650 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
4651 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
4658 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4660 throw INTERP_KERNEL::Exception(msg1);
4663 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
4665 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4666 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
4667 throw INTERP_KERNEL::Exception(oss.str().c_str());
4669 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
4670 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
4671 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
4672 ret->renumberNodes(nodeRenumSafe->getConstPointer());
4677 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
4682 * Returns values and a profile of the field of a given type lying on a given support.
4683 * \param [in] type - a spatial discretization of the field.
4684 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4685 * \param [in] mesh - the supporting mesh.
4686 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
4687 * field of interest lies on. If the field lies on all entities of the given
4688 * dimension, all ids in \a pfl are zero. The caller is to delete this array
4689 * using decrRef() as it is no more needed.
4690 * \param [in] glob - the global data storing profiles and localization.
4691 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
4692 * field. The caller is to delete this array using decrRef() as it is no more needed.
4693 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4694 * \throw If no field of \a this is lying on \a mesh.
4695 * \throw If no field values of the given \a type are available.
4697 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
4699 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4700 int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
4701 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
4702 ret->setName(nasc.getName().c_str());
4706 //= MEDFileField1TSWithoutSDA
4709 * Throws if a given value is not a valid (non-extended) relative dimension.
4710 * \param [in] meshDimRelToMax - the relative dimension value.
4711 * \throw If \a meshDimRelToMax > 0.
4713 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
4715 if(meshDimRelToMax>0)
4716 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
4720 * Checks if elements of a given mesh are in the order suitable for writing
4721 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
4722 * vector describing types of elements and their number.
4723 * \param [in] mesh - the mesh to check.
4724 * \return std::vector<int> - a vector holding for each element type (1) item of
4725 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
4726 * These values are in full-interlace mode.
4727 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4729 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
4732 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
4733 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
4734 int nbOfTypes=geoTypes.size();
4735 std::vector<int> code(3*nbOfTypes);
4736 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr1=DataArrayInt::New();
4737 arr1->alloc(nbOfTypes,1);
4738 int *arrPtr=arr1->getPointer();
4739 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
4740 for(int i=0;i<nbOfTypes;i++,it++)
4741 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
4742 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
4743 const int *arrPtr2=arr2->getConstPointer();
4745 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
4748 int nbCells=mesh->getNumberOfCellsWithType(*it);
4749 code[3*pos]=(int)(*it);
4750 code[3*pos+1]=nbCells;
4751 code[3*pos+2]=-1;//no profiles
4753 std::vector<const DataArrayInt *> idsPerType;//no profiles
4754 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
4758 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
4763 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
4765 return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
4769 * Returns all attributes and values of parts of \a this field lying on a given mesh.
4770 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4771 * item of every of returned sequences refers to the _i_-th part of \a this field.
4772 * Thus all sequences returned by this method are of the same length equal to number
4773 * of different types of supporting entities.<br>
4774 * A field part can include sub-parts with several different spatial discretizations,
4775 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
4776 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4777 * of a nested sequence corresponds to a type of spatial discretization.<br>
4778 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
4779 * The overhead is due to selecting values into new instances of DataArrayDouble.
4780 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4781 * for the case with only one underlying mesh. (Actually, the number of meshes is
4782 * not checked if \a mname == \c NULL).
4783 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4784 * a field part is returned.
4785 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4786 * A field part can include sub-parts with several different spatial discretizations,
4787 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and
4788 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT" for example.
4789 * This sequence is of the same length as \a types.
4790 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4791 * discretization. A profile name can be empty.
4792 * Length of this and of nested sequences is the same as that of \a typesF.
4793 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4794 * discretization. A localization name can be empty.
4795 * Length of this and of nested sequences is the same as that of \a typesF.
4796 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
4797 * per each type of spatial discretization within one mesh entity type.
4798 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
4799 * Length of this and of nested sequences is the same as that of \a typesF.
4800 * \throw If no field is lying on \a mname.
4802 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
4806 meshId=getMeshIdFromMeshName(mname);
4808 if(_field_per_mesh.empty())
4809 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4810 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4811 int nbOfRet=ret0.size();
4812 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
4813 for(int i=0;i<nbOfRet;i++)
4815 const std::vector< std::pair<int,int> >& p=ret0[i];
4816 int nbOfRet1=p.size();
4817 ret[i].resize(nbOfRet1);
4818 for(int j=0;j<nbOfRet1;j++)
4820 DataArrayDouble *tmp=_arr->selectByTupleId2(p[j].first,p[j].second,1);
4828 * Returns a pointer to the underground DataArrayDouble instance. So the
4829 * caller should not decrRef() it. This method allows for a direct access to the field
4830 * values. This method is quite unusable if there is more than a nodal field or a cell
4831 * field on single geometric cell type.
4832 * \return DataArrayDouble * - the pointer to the field values array.
4834 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDouble() const
4836 const DataArrayDouble *ret=_arr;
4838 return const_cast<DataArrayDouble *>(ret);
4843 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
4848 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
4850 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
4851 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
4852 ret->deepCpyLeavesFrom(*this);
4853 const DataArrayDouble *arr(_arr);
4856 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr->convertToIntArr());
4857 ret->setArray(arr2);
4863 * Returns a pointer to the underground DataArrayDouble instance. So the
4864 * caller should not decrRef() it. This method allows for a direct access to the field
4865 * values. This method is quite unusable if there is more than a nodal field or a cell
4866 * field on single geometric cell type.
4867 * \return DataArrayDouble * - the pointer to the field values array.
4869 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArray() const
4871 return getUndergroundDataArrayDouble();
4875 * Returns a pointer to the underground DataArrayDouble instance and a
4876 * sequence describing parameters of a support of each part of \a this field. The
4877 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
4878 * direct access to the field values. This method is intended for the field lying on one
4880 * \param [in,out] entries - the sequence describing parameters of a support of each
4881 * part of \a this field. Each item of this sequence consists of two parts. The
4882 * first part describes a type of mesh entity and an id of discretization of a
4883 * current field part. The second part describes a range of values [begin,end)
4884 * within the returned array relating to the current field part.
4885 * \return DataArrayDouble * - the pointer to the field values array.
4886 * \throw If the number of underlying meshes is not equal to 1.
4887 * \throw If no field values are available.
4888 * \sa getUndergroundDataArray()
4890 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
4892 if(_field_per_mesh.size()!=1)
4893 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
4894 if(_field_per_mesh[0]==0)
4895 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
4896 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
4897 return getUndergroundDataArrayDouble();
4901 * Returns a pointer to the underground DataArrayDouble instance and a
4902 * sequence describing parameters of a support of each part of \a this field. The
4903 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
4904 * direct access to the field values. This method is intended for the field lying on one
4906 * \param [in,out] entries - the sequence describing parameters of a support of each
4907 * part of \a this field. Each item of this sequence consists of two parts. The
4908 * first part describes a type of mesh entity and an id of discretization of a
4909 * current field part. The second part describes a range of values [begin,end)
4910 * within the returned array relating to the current field part.
4911 * \return DataArrayDouble * - the pointer to the field values array.
4912 * \throw If the number of underlying meshes is not equal to 1.
4913 * \throw If no field values are available.
4914 * \sa getUndergroundDataArray()
4916 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
4918 return getUndergroundDataArrayDoubleExt(entries);
4921 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
4923 DataArrayDouble *arr(getOrCreateAndGetArrayDouble());
4924 arr->setInfoAndChangeNbOfCompo(infos);
4927 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
4931 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
4933 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
4934 ret->deepCpyLeavesFrom(*this);
4938 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCpy() const
4940 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret=static_cast<MEDFileField1TSWithoutSDA *>(shallowCpy());
4941 if((const DataArrayDouble *)_arr)
4942 ret->_arr=_arr->deepCpy();
4946 void MEDFileField1TSWithoutSDA::setArray(DataArray *arr)
4950 _nb_of_tuples_to_be_allocated=-1;
4954 DataArrayDouble *arrC=dynamic_cast<DataArrayDouble *>(arr);
4956 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayDouble !");
4958 _nb_of_tuples_to_be_allocated=-3;
4963 DataArray *MEDFileField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
4965 return DataArrayDouble::New();
4968 DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble()
4970 DataArrayDouble *ret=_arr;
4973 _arr=DataArrayDouble::New();
4977 DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray()
4979 return getOrCreateAndGetArrayDouble();
4982 const DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble() const
4984 const DataArrayDouble *ret=_arr;
4987 DataArrayDouble *ret2=DataArrayDouble::New();
4988 const_cast<MEDFileField1TSWithoutSDA *>(this)->_arr=DataArrayDouble::New();
4992 const DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray() const
4994 return getOrCreateAndGetArrayDouble();
4997 //= MEDFileIntField1TSWithoutSDA
4999 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5001 return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5004 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
5008 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order,
5009 const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
5011 DataArrayInt *arr(getOrCreateAndGetArrayInt());
5012 arr->setInfoAndChangeNbOfCompo(infos);
5015 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
5020 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const
5022 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
5023 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5024 ret->deepCpyLeavesFrom(*this);
5025 const DataArrayInt *arr(_arr);
5028 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2(arr->convertToDblArr());
5029 ret->setArray(arr2);
5035 * Returns a pointer to the underground DataArrayInt instance. So the
5036 * caller should not decrRef() it. This method allows for a direct access to the field
5037 * values. This method is quite unusable if there is more than a nodal field or a cell
5038 * field on single geometric cell type.
5039 * \return DataArrayInt * - the pointer to the field values array.
5041 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArray() const
5043 return getUndergroundDataArrayInt();
5047 * Returns a pointer to the underground DataArrayInt instance. So the
5048 * caller should not decrRef() it. This method allows for a direct access to the field
5049 * values. This method is quite unusable if there is more than a nodal field or a cell
5050 * field on single geometric cell type.
5051 * \return DataArrayInt * - the pointer to the field values array.
5053 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayInt() const
5055 const DataArrayInt *ret=_arr;
5057 return const_cast<DataArrayInt *>(ret);
5063 * Returns a pointer to the underground DataArrayInt instance and a
5064 * sequence describing parameters of a support of each part of \a this field. The
5065 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5066 * direct access to the field values. This method is intended for the field lying on one
5068 * \param [in,out] entries - the sequence describing parameters of a support of each
5069 * part of \a this field. Each item of this sequence consists of two parts. The
5070 * first part describes a type of mesh entity and an id of discretization of a
5071 * current field part. The second part describes a range of values [begin,end)
5072 * within the returned array relating to the current field part.
5073 * \return DataArrayInt * - the pointer to the field values array.
5074 * \throw If the number of underlying meshes is not equal to 1.
5075 * \throw If no field values are available.
5076 * \sa getUndergroundDataArray()
5078 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5080 return getUndergroundDataArrayIntExt(entries);
5084 * Returns a pointer to the underground DataArrayInt instance and a
5085 * sequence describing parameters of a support of each part of \a this field. The
5086 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5087 * direct access to the field values. This method is intended for the field lying on one
5089 * \param [in,out] entries - the sequence describing parameters of a support of each
5090 * part of \a this field. Each item of this sequence consists of two parts. The
5091 * first part describes a type of mesh entity and an id of discretization of a
5092 * current field part. The second part describes a range of values [begin,end)
5093 * within the returned array relating to the current field part.
5094 * \return DataArrayInt * - the pointer to the field values array.
5095 * \throw If the number of underlying meshes is not equal to 1.
5096 * \throw If no field values are available.
5097 * \sa getUndergroundDataArray()
5099 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5101 if(_field_per_mesh.size()!=1)
5102 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5103 if(_field_per_mesh[0]==0)
5104 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5105 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5106 return getUndergroundDataArrayInt();
5109 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5111 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5112 ret->deepCpyLeavesFrom(*this);
5116 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCpy() const
5118 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret=static_cast<MEDFileIntField1TSWithoutSDA *>(shallowCpy());
5119 if((const DataArrayInt *)_arr)
5120 ret->_arr=_arr->deepCpy();
5124 void MEDFileIntField1TSWithoutSDA::setArray(DataArray *arr)
5128 _nb_of_tuples_to_be_allocated=-1;
5132 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>(arr);
5134 throw INTERP_KERNEL::Exception("MEDFileIntField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayInt !");
5136 _nb_of_tuples_to_be_allocated=-3;
5141 DataArray *MEDFileIntField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
5143 return DataArrayInt::New();
5146 DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt()
5148 DataArrayInt *ret=_arr;
5151 _arr=DataArrayInt::New();
5155 DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray()
5157 return getOrCreateAndGetArrayInt();
5160 const DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt() const
5162 const DataArrayInt *ret=_arr;
5165 DataArrayInt *ret2=DataArrayInt::New();
5166 const_cast<MEDFileIntField1TSWithoutSDA *>(this)->_arr=DataArrayInt::New();
5170 const DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray() const
5172 return getOrCreateAndGetArrayInt();
5175 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5179 //= MEDFileAnyTypeField1TS
5181 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
5183 med_field_type typcha;
5185 std::vector<std::string> infos;
5186 std::string dtunit,fieldName;
5187 LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
5188 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5193 ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5198 ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5203 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] !";
5204 throw INTERP_KERNEL::Exception(oss.str().c_str());
5207 ret->setDtUnit(dtunit.c_str());
5208 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5210 med_int numdt,numit;
5212 MEDfieldComputingStepInfo(fid,fieldName.c_str(),1,&numdt,&numit,&dt);
5213 ret->setTime(numdt,numit,dt);
5216 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms);
5218 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms);
5222 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
5223 try:MEDFileFieldGlobsReal(fileName)
5225 MEDFileUtilities::CheckFileForRead(fileName);
5226 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5227 _content=BuildContentFrom(fid,fileName,loadAll,ms);
5230 catch(INTERP_KERNEL::Exception& e)
5235 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5237 med_field_type typcha;
5238 std::vector<std::string> infos;
5241 int nbSteps=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5242 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5247 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5252 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5257 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] !";
5258 throw INTERP_KERNEL::Exception(oss.str().c_str());
5261 ret->setDtUnit(dtunit.c_str());
5262 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5266 std::ostringstream oss; oss << "MEDFileField1TS(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5267 throw INTERP_KERNEL::Exception(oss.str().c_str());
5270 med_int numdt,numit;
5272 MEDfieldComputingStepInfo(fid,fieldName.c_str(),1,&numdt,&numit,&dt);
5273 ret->setTime(numdt,numit,dt);
5276 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms);
5278 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms);
5282 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5283 try:MEDFileFieldGlobsReal(fileName)
5285 MEDFileUtilities::CheckFileForRead(fileName);
5286 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5287 _content=BuildContentFrom(fid,fileName,fieldName,loadAll,ms);
5290 catch(INTERP_KERNEL::Exception& e)
5295 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, const std::string& fileName)
5298 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5299 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5301 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New();
5302 ret->setFileName(fileName);
5303 ret->_content=c; c->incrRef();
5306 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5308 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New();
5309 ret->setFileName(fileName);
5310 ret->_content=c; c->incrRef();
5313 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5316 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
5318 MEDFileUtilities::CheckFileForRead(fileName);
5319 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5320 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll,0);
5321 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5322 ret->loadGlobals(fid);
5326 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
5328 MEDFileUtilities::CheckFileForRead(fileName);
5329 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5330 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll,0);
5331 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5332 ret->loadGlobals(fid);
5336 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
5338 MEDFileUtilities::CheckFileForRead(fileName);
5339 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5340 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,iteration,order,loadAll,0);
5341 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5342 ret->loadGlobals(fid);
5346 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5348 med_field_type typcha;
5349 std::vector<std::string> infos;
5352 int nbOfStep2=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5353 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5358 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5363 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5368 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] !";
5369 throw INTERP_KERNEL::Exception(oss.str().c_str());
5372 ret->setDtUnit(dtunit.c_str());
5373 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5376 std::vector< std::pair<int,int> > dtits(nbOfStep2);
5377 for(int i=0;i<nbOfStep2 && !found;i++)
5379 med_int numdt,numit;
5381 MEDfieldComputingStepInfo(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt);
5382 if(numdt==iteration && numit==order)
5388 dtits[i]=std::pair<int,int>(numdt,numit);
5392 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << fileName << "' ! Available iterations are : ";
5393 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5394 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5395 throw INTERP_KERNEL::Exception(oss.str().c_str());
5398 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms);
5400 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms);
5404 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5405 try:MEDFileFieldGlobsReal(fileName)
5407 MEDFileUtilities::CheckFileForRead(fileName);
5408 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5409 _content=BuildContentFrom(fid,fileName.c_str(),fieldName.c_str(),iteration,order,loadAll,ms);
5412 catch(INTERP_KERNEL::Exception& e)
5418 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5419 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5421 * \warning this is a shallow copy constructor
5423 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5425 if(!shallowCopyOfContent)
5427 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5428 otherPtr->incrRef();
5429 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5433 _content=other.shallowCpy();
5437 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)
5441 int nbFields=MEDnField(fid);
5442 if(fieldIdCFormat>=nbFields)
5444 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << fileName << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5445 throw INTERP_KERNEL::Exception(oss.str().c_str());
5448 int ncomp=MEDfieldnComponent(fid,fieldIdCFormat+1);
5449 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5450 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5451 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5452 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5453 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5456 MEDfieldInfo(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
5457 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5458 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5459 infos.clear(); infos.resize(ncomp);
5460 for(int j=0;j<ncomp;j++)
5461 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5466 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5469 * \return in case of success the number of time steps available for the field with name \a fieldName.
5471 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)
5473 int nbFields=MEDnField(fid);
5475 std::vector<std::string> fns(nbFields);
5477 for(int i=0;i<nbFields && !found;i++)
5480 nbOfStep2=LocateField2(fid,fileName,i,false,tmp,typcha,infos,dtunitOut);
5482 found=(tmp==fieldName);
5488 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
5489 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5490 oss << "\"" << *it << "\" ";
5491 throw INTERP_KERNEL::Exception(oss.str().c_str());
5497 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5498 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5499 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5500 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5501 * to keep a valid instance.
5502 * 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.
5503 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5504 * 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.
5506 * \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.
5507 * \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.
5508 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5509 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5510 * \param [in] newLocName is the new localization name.
5511 * \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.
5512 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5514 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
5516 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5517 std::string oldPflName=disc->getProfile();
5518 std::vector<std::string> vv=getPflsReallyUsedMulti();
5519 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5520 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5522 disc->setProfile(newPflName);
5523 DataArrayInt *pfl=getProfile(oldPflName.c_str());
5524 pfl->setName(newPflName);
5528 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5529 throw INTERP_KERNEL::Exception(oss.str().c_str());
5534 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5535 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5536 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5537 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5538 * to keep a valid instance.
5539 * 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.
5540 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5541 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5542 * 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.
5544 * \param [in] mName specifies the underlying mesh name. This value can be pointer 0 for users that do not deal with fields on multi mesh.
5545 * \param [in] typ is for the geometric cell type (or INTERP_KERNEL::NORM_ERROR for node field) entry to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set.
5546 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5547 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5548 * \param [in] newLocName is the new localization name.
5549 * \param [in] forceRenameOnGlob specifies the behaviour in case of profile \b newLocName already exists. If true, the renaming is done without check. It can lead to major bug.
5550 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
5552 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
5554 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5555 std::string oldLocName=disc->getLocalization();
5556 std::vector<std::string> vv=getLocsReallyUsedMulti();
5557 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
5558 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
5560 disc->setLocalization(newLocName);
5561 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
5562 loc.setName(newLocName);
5566 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
5567 throw INTERP_KERNEL::Exception(oss.str().c_str());
5571 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
5573 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5575 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
5579 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
5581 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5583 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
5588 * Writes \a this field into a MED file specified by its name.
5589 * \param [in] fileName - the MED file name.
5590 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
5591 * - 2 - erase; an existing file is removed.
5592 * - 1 - append; same data should not be present in an existing file.
5593 * - 0 - overwrite; same data present in an existing file is overwritten.
5594 * \throw If the field name is not set.
5595 * \throw If no field data is set.
5596 * \throw If \a mode == 1 and the same data is present in an existing file.
5598 void MEDFileAnyTypeField1TS::write(const std::string& fileName, int mode) const
5600 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
5601 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
5606 * This method alloc the arrays and load potentially huge arrays contained in this field.
5607 * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
5608 * This method can be also called to refresh or reinit values from a file.
5610 * \throw If the fileName is not set or points to a non readable MED file.
5611 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5613 void MEDFileAnyTypeField1TS::loadArrays()
5615 if(getFileName().empty())
5616 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
5617 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
5618 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
5622 * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
5623 * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
5624 * this method does not throw if \a this does not come from file read.
5626 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
5628 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
5630 if(!getFileName().empty())
5632 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
5633 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
5638 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
5639 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
5640 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
5642 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
5644 void MEDFileAnyTypeField1TS::unloadArrays()
5646 contentNotNullBase()->unloadArrays();
5650 * 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.
5651 * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
5652 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
5654 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5656 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
5658 if(!getFileName().empty())
5659 contentNotNullBase()->unloadArrays();
5662 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
5664 int nbComp=getNumberOfComponents();
5665 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5666 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5667 for(int i=0;i<nbComp;i++)
5669 std::string info=getInfo()[i];
5671 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
5672 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
5673 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
5675 if(getName().empty())
5676 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
5677 MEDfieldCr(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
5678 writeGlobals(fid,*this);
5679 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
5682 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
5684 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
5687 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
5689 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
5690 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
5695 * Returns a string describing \a this field. This string is outputted
5696 * by \c print Python command.
5698 std::string MEDFileAnyTypeField1TS::simpleRepr() const
5700 std::ostringstream oss;
5701 contentNotNullBase()->simpleRepr(0,oss,-1);
5702 simpleReprGlobs(oss);
5707 * This method returns all profiles whose name is non empty used.
5708 * \b WARNING If profile is used several times it will be reported \b only \b once.
5709 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
5711 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
5713 return contentNotNullBase()->getPflsReallyUsed2();
5717 * This method returns all localizations whose name is non empty used.
5718 * \b WARNING If localization is used several times it will be reported \b only \b once.
5720 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
5722 return contentNotNullBase()->getLocsReallyUsed2();
5726 * This method returns all profiles whose name is non empty used.
5727 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
5729 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
5731 return contentNotNullBase()->getPflsReallyUsedMulti2();
5735 * This method returns all localizations whose name is non empty used.
5736 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
5738 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
5740 return contentNotNullBase()->getLocsReallyUsedMulti2();
5743 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5745 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
5748 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5750 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
5753 int MEDFileAnyTypeField1TS::getDimension() const
5755 return contentNotNullBase()->getDimension();
5758 int MEDFileAnyTypeField1TS::getIteration() const
5760 return contentNotNullBase()->getIteration();
5763 int MEDFileAnyTypeField1TS::getOrder() const
5765 return contentNotNullBase()->getOrder();
5768 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
5770 return contentNotNullBase()->getTime(iteration,order);
5773 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
5775 contentNotNullBase()->setTime(iteration,order,val);
5778 std::string MEDFileAnyTypeField1TS::getName() const
5780 return contentNotNullBase()->getName();
5783 void MEDFileAnyTypeField1TS::setName(const std::string& name)
5785 contentNotNullBase()->setName(name);
5788 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
5790 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
5793 std::string MEDFileAnyTypeField1TS::getDtUnit() const
5795 return contentNotNullBase()->getDtUnit();
5798 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
5800 contentNotNullBase()->setDtUnit(dtUnit);
5803 std::string MEDFileAnyTypeField1TS::getMeshName() const
5805 return contentNotNullBase()->getMeshName();
5808 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
5810 contentNotNullBase()->setMeshName(newMeshName);
5813 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
5815 return contentNotNullBase()->changeMeshNames(modifTab);
5818 int MEDFileAnyTypeField1TS::getMeshIteration() const
5820 return contentNotNullBase()->getMeshIteration();
5823 int MEDFileAnyTypeField1TS::getMeshOrder() const
5825 return contentNotNullBase()->getMeshOrder();
5828 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
5830 return contentNotNullBase()->getNumberOfComponents();
5833 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
5835 return contentNotNullBase()->isDealingTS(iteration,order);
5838 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
5840 return contentNotNullBase()->getDtIt();
5843 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
5845 contentNotNullBase()->fillIteration(p);
5848 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
5850 contentNotNullBase()->fillTypesOfFieldAvailable(types);
5853 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
5855 contentNotNullBase()->setInfo(infos);
5858 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
5860 return contentNotNullBase()->getInfo();
5862 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
5864 return contentNotNullBase()->getInfo();
5867 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
5869 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5872 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
5874 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5877 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
5879 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
5882 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
5884 return contentNotNullBase()->getTypesOfFieldAvailable();
5887 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,
5888 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
5890 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
5894 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
5895 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
5896 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
5898 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
5900 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5902 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
5903 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
5904 std::size_t sz(contentsSplit.size());
5905 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
5906 for(std::size_t i=0;i<sz;i++)
5908 ret[i]=shallowCpy();
5909 ret[i]->_content=contentsSplit[i];
5915 * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
5916 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
5918 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
5920 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5922 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
5923 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitDiscretizations();
5924 std::size_t sz(contentsSplit.size());
5925 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
5926 for(std::size_t i=0;i<sz;i++)
5928 ret[i]=shallowCpy();
5929 ret[i]->_content=contentsSplit[i];
5934 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCpy() const
5936 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=shallowCpy();
5937 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
5938 ret->_content=_content->deepCpy();
5939 ret->deepCpyGlobs(*this);
5943 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
5945 return contentNotNullBase()->copyTinyInfoFrom(field,arr);
5951 * Returns a new instance of MEDFileField1TS holding data of the first time step of
5952 * the first field that has been read from a specified MED file.
5953 * \param [in] fileName - the name of the MED file to read.
5954 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5955 * is to delete this field using decrRef() as it is no more needed.
5956 * \throw If reading the file fails.
5958 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll)
5960 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret(new MEDFileField1TS(fileName,loadAll,0));
5961 ret->contentNotNull();
5966 * Returns a new instance of MEDFileField1TS holding data of the first time step of
5967 * a given field that has been read from a specified MED file.
5968 * \param [in] fileName - the name of the MED file to read.
5969 * \param [in] fieldName - the name of the field to read.
5970 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5971 * is to delete this field using decrRef() as it is no more needed.
5972 * \throw If reading the file fails.
5973 * \throw If there is no field named \a fieldName in the file.
5975 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
5977 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret(new MEDFileField1TS(fileName,fieldName,loadAll,0));
5978 ret->contentNotNull();
5983 * Returns a new instance of MEDFileField1TS holding data of a given time step of
5984 * a given field that has been read from a specified MED file.
5985 * \param [in] fileName - the name of the MED file to read.
5986 * \param [in] fieldName - the name of the field to read.
5987 * \param [in] iteration - the iteration number of a required time step.
5988 * \param [in] order - the iteration order number of required time step.
5989 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5990 * is to delete this field using decrRef() as it is no more needed.
5991 * \throw If reading the file fails.
5992 * \throw If there is no field named \a fieldName in the file.
5993 * \throw If the required time step is missing from the file.
5995 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
5997 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret(new MEDFileField1TS(fileName,fieldName,iteration,order,loadAll,0));
5998 ret->contentNotNull();
6003 * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6004 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6006 * Returns a new instance of MEDFileField1TS holding either a shallow copy
6007 * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
6008 * \warning this is a shallow copy constructor
6009 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
6010 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
6011 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6012 * is to delete this field using decrRef() as it is no more needed.
6014 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6016 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(other,shallowCopyOfContent);
6017 ret->contentNotNull();
6022 * Returns a new empty instance of MEDFileField1TS.
6023 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6024 * is to delete this field using decrRef() as it is no more needed.
6026 MEDFileField1TS *MEDFileField1TS::New()
6028 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS;
6029 ret->contentNotNull();
6034 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
6035 * following the given input policy.
6037 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6038 * By default (true) the globals are deeply copied.
6039 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
6041 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
6043 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret;
6044 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6047 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
6049 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
6050 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
6051 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc,getFileName()));
6054 ret=MEDFileIntField1TS::New();
6056 ret->deepCpyGlobs(*this);
6058 ret->shallowCpyGlobs(*this);
6062 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const
6064 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6066 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
6067 const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
6069 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 !");
6073 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull()
6075 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6077 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
6078 MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
6080 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 !");
6084 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MEDCouplingAutoRefCountObjectPtr<DataArray>& arr)
6087 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
6088 if(!((DataArray*)arr))
6089 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
6090 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
6092 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6093 f->setArray(arrOutC);
6096 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr)
6098 if(!((DataArray*)arr))
6099 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
6100 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
6102 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6107 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
6108 try:MEDFileAnyTypeField1TS(fileName,loadAll,ms)
6111 catch(INTERP_KERNEL::Exception& e)
6114 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6115 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll,ms)
6118 catch(INTERP_KERNEL::Exception& e)
6121 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6122 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll,ms)
6125 catch(INTERP_KERNEL::Exception& e)
6129 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6130 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6132 * \warning this is a shallow copy constructor
6134 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6135 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6138 catch(INTERP_KERNEL::Exception& e)
6141 MEDFileField1TS::MEDFileField1TS()
6143 _content=new MEDFileField1TSWithoutSDA;
6147 * Returns a new MEDCouplingFieldDouble of a given type lying on
6148 * mesh entities of a given dimension of the first mesh in MED file. If \a this field
6149 * has not been constructed via file reading, an exception is thrown.
6150 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6151 * \param [in] type - a spatial discretization of interest.
6152 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6153 * \param [in] renumPol - specifies how to permute values of the result field according to
6154 * the optional numbers of cells and nodes, if any. The valid values are
6155 * - 0 - do not permute.
6156 * - 1 - permute cells.
6157 * - 2 - permute nodes.
6158 * - 3 - permute cells and nodes.
6160 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6161 * caller is to delete this field using decrRef() as it is no more needed.
6162 * \throw If \a this field has not been constructed via file reading.
6163 * \throw If the MED file is not readable.
6164 * \throw If there is no mesh in the MED file.
6165 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6166 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6167 * \sa getFieldOnMeshAtLevel()
6169 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6171 if(getFileName().empty())
6172 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6173 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6174 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull());
6175 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6180 * Returns a new MEDCouplingFieldDouble of a given type lying on
6181 * the top level cells of the first mesh in MED file. If \a this field
6182 * has not been constructed via file reading, an exception is thrown.
6183 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6184 * \param [in] type - a spatial discretization of interest.
6185 * \param [in] renumPol - specifies how to permute values of the result field according to
6186 * the optional numbers of cells and nodes, if any. The valid values are
6187 * - 0 - do not permute.
6188 * - 1 - permute cells.
6189 * - 2 - permute nodes.
6190 * - 3 - permute cells and nodes.
6192 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6193 * caller is to delete this field using decrRef() as it is no more needed.
6194 * \throw If \a this field has not been constructed via file reading.
6195 * \throw If the MED file is not readable.
6196 * \throw If there is no mesh in the MED file.
6197 * \throw If no field values of the given \a type.
6198 * \throw If no field values lying on the top level support.
6199 * \sa getFieldAtLevel()
6201 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
6203 if(getFileName().empty())
6204 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6205 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6206 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull());
6207 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6212 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6213 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6214 * \param [in] type - a spatial discretization of the new field.
6215 * \param [in] mesh - the supporting mesh.
6216 * \param [in] renumPol - specifies how to permute values of the result field according to
6217 * the optional numbers of cells and nodes, if any. The valid values are
6218 * - 0 - do not permute.
6219 * - 1 - permute cells.
6220 * - 2 - permute nodes.
6221 * - 3 - permute cells and nodes.
6223 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6224 * caller is to delete this field using decrRef() as it is no more needed.
6225 * \throw If no field of \a this is lying on \a mesh.
6226 * \throw If the mesh is empty.
6227 * \throw If no field values of the given \a type are available.
6228 * \sa getFieldAtLevel()
6229 * \sa getFieldOnMeshAtLevel()
6231 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
6233 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6234 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull());
6235 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6240 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6241 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6242 * \param [in] type - a spatial discretization of interest.
6243 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6244 * \param [in] mesh - the supporting mesh.
6245 * \param [in] renumPol - specifies how to permute values of the result field according to
6246 * the optional numbers of cells and nodes, if any. The valid values are
6247 * - 0 - do not permute.
6248 * - 1 - permute cells.
6249 * - 2 - permute nodes.
6250 * - 3 - permute cells and nodes.
6252 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6253 * caller is to delete this field using decrRef() as it is no more needed.
6254 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6255 * \throw If no field of \a this is lying on \a mesh.
6256 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6257 * \sa getFieldAtLevel()
6258 * \sa getFieldOnMeshAtLevel()
6260 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
6262 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6263 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull());
6264 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6269 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6270 * This method is called "Old" because in MED3 norm a field has only one meshName
6271 * attached, so this method is for readers of MED2 files. If \a this field
6272 * has not been constructed via file reading, an exception is thrown.
6273 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6274 * \param [in] type - a spatial discretization of interest.
6275 * \param [in] mName - a name of the supporting mesh.
6276 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6277 * \param [in] renumPol - specifies how to permute values of the result field according to
6278 * the optional numbers of cells and nodes, if any. The valid values are
6279 * - 0 - do not permute.
6280 * - 1 - permute cells.
6281 * - 2 - permute nodes.
6282 * - 3 - permute cells and nodes.
6284 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6285 * caller is to delete this field using decrRef() as it is no more needed.
6286 * \throw If the MED file is not readable.
6287 * \throw If there is no mesh named \a mName in the MED file.
6288 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6289 * \throw If \a this field has not been constructed via file reading.
6290 * \throw If no field of \a this is lying on the mesh named \a mName.
6291 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6292 * \sa getFieldAtLevel()
6294 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
6296 if(getFileName().empty())
6297 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6298 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6299 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
6300 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6305 * Returns values and a profile of the field of a given type lying on a given support.
6306 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6307 * \param [in] type - a spatial discretization of the field.
6308 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6309 * \param [in] mesh - the supporting mesh.
6310 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6311 * field of interest lies on. If the field lies on all entities of the given
6312 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6313 * using decrRef() as it is no more needed.
6314 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6315 * field. The caller is to delete this array using decrRef() as it is no more needed.
6316 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6317 * \throw If no field of \a this is lying on \a mesh.
6318 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6320 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6322 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6323 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
6327 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6328 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6329 * "Sort By Type"), if not, an exception is thrown.
6330 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6331 * \param [in] field - the field to add to \a this.
6332 * \throw If the name of \a field is empty.
6333 * \throw If the data array of \a field is not set.
6334 * \throw If the data array is already allocated but has different number of components
6336 * \throw If the underlying mesh of \a field has no name.
6337 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6339 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
6342 contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
6346 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6347 * can be an aggregation of several MEDCouplingFieldDouble instances.
6348 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6349 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6352 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6353 * A new profile is added only if no equal profile is missing.
6354 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6355 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
6356 * \param [in] mesh - the supporting mesh of \a field.
6357 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6358 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6359 * \throw If either \a field or \a mesh or \a profile has an empty name.
6360 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6361 * \throw If the data array of \a field is not set.
6362 * \throw If the data array of \a this is already allocated but has different number of
6363 * components than \a field.
6364 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6365 * \sa setFieldNoProfileSBT()
6367 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6370 contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6373 MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const
6375 return new MEDFileField1TS(*this);
6378 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const
6380 return contentNotNull()->getUndergroundDataArrayDouble();
6383 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
6385 return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
6388 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6389 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6391 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6394 //= MEDFileIntField1TS
6396 MEDFileIntField1TS *MEDFileIntField1TS::New()
6398 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS;
6399 ret->contentNotNull();
6403 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll)
6405 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,loadAll,0));
6406 ret->contentNotNull();
6410 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6412 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,fieldName,loadAll,0));
6413 ret->contentNotNull();
6417 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6419 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,fieldName,iteration,order,loadAll,0));
6420 ret->contentNotNull();
6424 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6426 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6427 ret->contentNotNull();
6431 MEDFileIntField1TS::MEDFileIntField1TS()
6433 _content=new MEDFileIntField1TSWithoutSDA;
6436 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
6437 try:MEDFileAnyTypeField1TS(fileName,loadAll,ms)
6440 catch(INTERP_KERNEL::Exception& e)
6443 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6444 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll,ms)
6447 catch(INTERP_KERNEL::Exception& e)
6450 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6451 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll,ms)
6454 catch(INTERP_KERNEL::Exception& e)
6458 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6459 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6461 * \warning this is a shallow copy constructor
6463 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6467 MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const
6469 return new MEDFileIntField1TS(*this);
6473 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
6474 * following the given input policy.
6476 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6477 * By default (true) the globals are deeply copied.
6478 * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
6480 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const
6482 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret;
6483 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6486 const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
6488 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
6489 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
6490 ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc,getFileName()));
6493 ret=MEDFileField1TS::New();
6495 ret->deepCpyGlobs(*this);
6497 ret->shallowCpyGlobs(*this);
6502 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6503 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6504 * "Sort By Type"), if not, an exception is thrown.
6505 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6506 * \param [in] field - the field to add to \a this. The field double values are ignored.
6507 * \param [in] arrOfVals - the values of the field \a field used.
6508 * \throw If the name of \a field is empty.
6509 * \throw If the data array of \a field is not set.
6510 * \throw If the data array is already allocated but has different number of components
6512 * \throw If the underlying mesh of \a field has no name.
6513 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6515 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals)
6518 contentNotNull()->setFieldNoProfileSBT(field,arrOfVals,*this,*contentNotNull());
6522 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6523 * can be an aggregation of several MEDCouplingFieldDouble instances.
6524 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6525 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6528 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6529 * A new profile is added only if no equal profile is missing.
6530 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6531 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
6532 * \param [in] arrOfVals - the values of the field \a field used.
6533 * \param [in] mesh - the supporting mesh of \a field.
6534 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6535 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6536 * \throw If either \a field or \a mesh or \a profile has an empty name.
6537 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6538 * \throw If the data array of \a field is not set.
6539 * \throw If the data array of \a this is already allocated but has different number of
6540 * components than \a field.
6541 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6542 * \sa setFieldNoProfileSBT()
6544 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6547 contentNotNull()->setFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6550 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const
6552 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6554 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
6555 const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
6557 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 !");
6561 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
6563 if(getFileName().empty())
6564 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6565 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut2;
6566 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut2,*contentNotNull());
6567 DataArrayInt *arrOutC=dynamic_cast<DataArrayInt *>((DataArray *)arrOut2);
6569 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : mismatch between dataArrays type and MEDFileIntField1TS ! Expected int32 !");
6574 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr)
6576 if(!((DataArray *)arr))
6577 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
6578 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>((DataArray *)arr);
6580 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
6586 * Returns a new MEDCouplingFieldDouble of a given type lying on
6587 * the top level cells of the first mesh in MED file. If \a this field
6588 * has not been constructed via file reading, an exception is thrown.
6589 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6590 * \param [in] type - a spatial discretization of interest.
6591 * \param [out] arrOut - the DataArrayInt containing values of field.
6592 * \param [in] renumPol - specifies how to permute values of the result field according to
6593 * the optional numbers of cells and nodes, if any. The valid values are
6594 * - 0 - do not permute.
6595 * - 1 - permute cells.
6596 * - 2 - permute nodes.
6597 * - 3 - permute cells and nodes.
6599 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6600 * caller is to delete this field using decrRef() as it is no more needed.
6601 * \throw If \a this field has not been constructed via file reading.
6602 * \throw If the MED file is not readable.
6603 * \throw If there is no mesh in the MED file.
6604 * \throw If no field values of the given \a type.
6605 * \throw If no field values lying on the top level support.
6606 * \sa getFieldAtLevel()
6608 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, DataArrayInt* &arrOut, int renumPol) const
6610 if(getFileName().empty())
6611 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6612 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6613 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNull());
6614 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6619 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6620 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6621 * \param [in] type - a spatial discretization of the new field.
6622 * \param [in] mesh - the supporting mesh.
6623 * \param [out] arrOut - the DataArrayInt containing values of field.
6624 * \param [in] renumPol - specifies how to permute values of the result field according to
6625 * the optional numbers of cells and nodes, if any. The valid values are
6626 * - 0 - do not permute.
6627 * - 1 - permute cells.
6628 * - 2 - permute nodes.
6629 * - 3 - permute cells and nodes.
6631 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6632 * caller is to delete this field using decrRef() as it is no more needed.
6633 * \throw If no field of \a this is lying on \a mesh.
6634 * \throw If the mesh is empty.
6635 * \throw If no field values of the given \a type are available.
6636 * \sa getFieldAtLevel()
6637 * \sa getFieldOnMeshAtLevel()
6639 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
6641 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6642 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNull());
6643 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6648 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6649 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6650 * \param [in] type - a spatial discretization of interest.
6651 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6652 * \param [out] arrOut - the DataArrayInt containing values of field.
6653 * \param [in] mesh - the supporting mesh.
6654 * \param [in] renumPol - specifies how to permute values of the result field according to
6655 * the optional numbers of cells and nodes, if any. The valid values are
6656 * - 0 - do not permute.
6657 * - 1 - permute cells.
6658 * - 2 - permute nodes.
6659 * - 3 - permute cells and nodes.
6661 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6662 * caller is to delete this field using decrRef() as it is no more needed.
6663 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6664 * \throw If no field of \a this is lying on \a mesh.
6665 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6666 * \sa getFieldAtLevel()
6667 * \sa getFieldOnMeshAtLevel()
6669 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
6671 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6672 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNull());
6673 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6678 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6679 * This method is called "Old" because in MED3 norm a field has only one meshName
6680 * attached, so this method is for readers of MED2 files. If \a this field
6681 * has not been constructed via file reading, an exception is thrown.
6682 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6683 * \param [in] type - a spatial discretization of interest.
6684 * \param [in] mName - a name of the supporting mesh.
6685 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6686 * \param [out] arrOut - the DataArrayInt containing values of field.
6687 * \param [in] renumPol - specifies how to permute values of the result field according to
6688 * the optional numbers of cells and nodes, if any. The valid values are
6689 * - 0 - do not permute.
6690 * - 1 - permute cells.
6691 * - 2 - permute nodes.
6692 * - 3 - permute cells and nodes.
6694 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6695 * caller is to delete this field using decrRef() as it is no more needed.
6696 * \throw If the MED file is not readable.
6697 * \throw If there is no mesh named \a mName in the MED file.
6698 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6699 * \throw If \a this field has not been constructed via file reading.
6700 * \throw If no field of \a this is lying on the mesh named \a mName.
6701 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6702 * \sa getFieldAtLevel()
6704 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
6706 if(getFileName().empty())
6707 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6708 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6709 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNull());
6710 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6715 * Returns values and a profile of the field of a given type lying on a given support.
6716 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6717 * \param [in] type - a spatial discretization of the field.
6718 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6719 * \param [in] mesh - the supporting mesh.
6720 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6721 * field of interest lies on. If the field lies on all entities of the given
6722 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6723 * using decrRef() as it is no more needed.
6724 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
6725 * field. The caller is to delete this array using decrRef() as it is no more needed.
6726 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6727 * \throw If no field of \a this is lying on \a mesh.
6728 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6730 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6732 MEDCouplingAutoRefCountObjectPtr<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6733 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6736 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull()
6738 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6740 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
6741 MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
6743 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 !");
6747 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const
6749 return contentNotNull()->getUndergroundDataArrayInt();
6752 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
6754 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
6758 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileFieldNameScope(fieldName)
6763 * \param [in] fieldId field id in C mode
6765 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms)
6767 med_field_type typcha;
6768 std::string dtunitOut;
6769 int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,"",fieldId,false,_name,typcha,_infos,dtunitOut);
6770 setDtUnit(dtunitOut.c_str());
6771 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms);
6774 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)
6775 try:MEDFileFieldNameScope(fieldName),_infos(infos)
6777 setDtUnit(dtunit.c_str());
6778 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms);
6780 catch(INTERP_KERNEL::Exception& e)
6785 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
6787 std::size_t ret(_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA>));
6788 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
6789 ret+=(*it).capacity();
6793 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
6795 std::vector<const BigMemoryObject *> ret;
6796 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6797 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
6802 * 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
6805 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
6807 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6808 ret->setInfo(_infos);
6809 int sz=(int)_time_steps.size();
6810 for(const int *id=startIds;id!=endIds;id++)
6812 if(*id>=0 && *id<sz)
6814 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
6815 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6819 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6821 ret->pushBackTimeStep(tse2);
6825 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
6826 oss << " ! Should be in [0," << sz << ") !";
6827 throw INTERP_KERNEL::Exception(oss.str().c_str());
6830 if(ret->getNumberOfTS()>0)
6831 ret->synchronizeNameScope();
6832 ret->copyNameScope(*this);
6837 * 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
6840 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
6842 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
6843 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
6844 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6845 ret->setInfo(_infos);
6846 int sz=(int)_time_steps.size();
6848 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
6852 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
6853 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6857 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6859 ret->pushBackTimeStep(tse2);
6863 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
6864 oss << " ! Should be in [0," << sz << ") !";
6865 throw INTERP_KERNEL::Exception(oss.str().c_str());
6868 if(ret->getNumberOfTS()>0)
6869 ret->synchronizeNameScope();
6870 ret->copyNameScope(*this);
6874 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
6877 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
6878 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
6880 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6883 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
6884 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
6885 ids->pushBackSilent(id);
6887 return buildFromTimeStepIds(ids->begin(),ids->end());
6890 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
6893 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
6894 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
6896 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6899 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
6900 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
6901 ids->pushBackSilent(id);
6903 return buildFromTimeStepIds(ids->begin(),ids->end());
6906 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
6911 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
6916 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
6919 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
6921 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
6922 if(pt->isDealingTS(iteration,order))
6925 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
6926 std::vector< std::pair<int,int> > vp=getIterations();
6927 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
6928 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
6929 throw INTERP_KERNEL::Exception(oss.str().c_str());
6932 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
6934 return *_time_steps[getTimeStepPos(iteration,order)];
6937 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
6939 return *_time_steps[getTimeStepPos(iteration,order)];
6942 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const
6944 if(_time_steps.empty())
6945 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
6946 return _time_steps[0]->getMeshName();
6949 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const std::string& newMeshName)
6951 std::string oldName(getMeshName());
6952 std::vector< std::pair<std::string,std::string> > v(1);
6953 v[0].first=oldName; v[0].second=newMeshName;
6957 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
6960 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6962 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6964 ret=cur->changeMeshNames(modifTab) || ret;
6970 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
6972 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
6974 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
6978 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
6980 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
6982 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
6985 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
6986 MEDFileFieldGlobsReal& glob)
6989 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6991 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
6993 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
6998 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7000 std::string startLine(bkOffset,' ');
7001 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
7003 oss << " (" << fmtsId << ")";
7004 oss << " has the following name: \"" << _name << "\"." << std::endl;
7005 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
7006 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7008 oss << startLine << " - \"" << *it << "\"" << std::endl;
7011 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7013 std::string chapter(17,'0'+i);
7014 oss << startLine << chapter << std::endl;
7015 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7017 cur->simpleRepr(bkOffset+2,oss,i);
7019 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
7020 oss << startLine << chapter << std::endl;
7024 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
7026 std::size_t sz=_time_steps.size();
7027 std::vector< std::pair<int,int> > ret(sz);
7029 for(std::size_t i=0;i<sz;i++)
7031 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
7034 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
7038 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
7039 throw INTERP_KERNEL::Exception(oss.str().c_str());
7045 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>& tse)
7047 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
7049 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
7050 checkCoherencyOfType(tse2);
7051 if(_time_steps.empty())
7053 setName(tse2->getName().c_str());
7054 setInfo(tse2->getInfo());
7056 checkThatComponentsMatch(tse2->getInfo());
7057 _time_steps.push_back(tse);
7060 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
7062 std::size_t nbOfCompo=_infos.size();
7063 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7065 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7068 if((cur->getInfo()).size()!=nbOfCompo)
7070 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
7071 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
7072 throw INTERP_KERNEL::Exception(oss.str().c_str());
7074 cur->copyNameScope(*this);
7079 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms)
7081 _time_steps.resize(nbPdt);
7082 for(int i=0;i<nbPdt;i++)
7084 std::vector< std::pair<int,int> > ts;
7085 med_int numdt=0,numo=0;
7086 med_int meshIt=0,meshOrder=0;
7088 MEDfieldComputingStepMeshInfo(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder);
7093 _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7098 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7102 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
7105 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms);
7107 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms);
7111 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
7113 if(_time_steps.empty())
7114 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
7115 checkThatNbOfCompoOfTSMatchThis();
7116 std::vector<std::string> infos(getInfo());
7117 int nbComp=infos.size();
7118 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7119 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7120 for(int i=0;i<nbComp;i++)
7122 std::string info=infos[i];
7124 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7125 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7126 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7129 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7130 MEDfieldCr(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
7131 int nbOfTS=_time_steps.size();
7132 for(int i=0;i<nbOfTS;i++)
7133 _time_steps[i]->writeLL(fid,opts,*this);
7136 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
7138 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7140 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7142 elt->loadBigArraysRecursively(fid,nasc);
7146 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
7148 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7150 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7152 elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7156 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
7158 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7160 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7162 elt->unloadArrays();
7166 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7168 return _time_steps.size();
7171 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
7173 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7174 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7176 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7178 newTS.push_back(*it);
7183 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
7185 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7186 int maxId=(int)_time_steps.size();
7188 std::set<int> idsToDel;
7189 for(const int *id=startIds;id!=endIds;id++,ii++)
7191 if(*id>=0 && *id<maxId)
7193 idsToDel.insert(*id);
7197 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7198 throw INTERP_KERNEL::Exception(oss.str().c_str());
7201 for(int iii=0;iii<maxId;iii++)
7202 if(idsToDel.find(iii)==idsToDel.end())
7203 newTS.push_back(_time_steps[iii]);
7207 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
7209 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7210 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7211 if(nbOfEntriesToKill==0)
7213 std::size_t sz=_time_steps.size();
7214 std::vector<bool> b(sz,true);
7216 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7218 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7219 for(std::size_t i=0;i<sz;i++)
7221 newTS.push_back(_time_steps[i]);
7225 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
7228 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
7229 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7231 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7235 tmp->getTime(it2,ord);
7236 if(it2==iteration && order==ord)
7239 oss << "(" << it2 << "," << ord << "), ";
7242 throw INTERP_KERNEL::Exception(oss.str().c_str());
7245 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
7248 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
7250 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7252 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7256 double ti=tmp->getTime(it2,ord);
7257 if(fabs(time-ti)<eps)
7263 throw INTERP_KERNEL::Exception(oss.str().c_str());
7266 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
7268 int lgth=_time_steps.size();
7269 std::vector< std::pair<int,int> > ret(lgth);
7270 for(int i=0;i<lgth;i++)
7271 _time_steps[i]->fillIteration(ret[i]);
7276 * 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'
7277 * This method returns two things.
7278 * - The absolute dimension of 'this' in first parameter.
7279 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7280 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
7282 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7283 * Only these 3 discretizations will be taken into account here.
7285 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7286 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7287 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7289 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7290 * 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'.
7292 * Let's consider the typical following case :
7293 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7294 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7295 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7297 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7299 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7301 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7302 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7303 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7304 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7306 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
7308 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7311 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
7313 if(pos<0 || pos>=(int)_time_steps.size())
7315 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7316 throw INTERP_KERNEL::Exception(oss.str().c_str());
7318 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7321 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7322 oss << "\nTry to use following method eraseEmptyTS !";
7323 throw INTERP_KERNEL::Exception(oss.str().c_str());
7328 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
7330 if(pos<0 || pos>=(int)_time_steps.size())
7332 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7333 throw INTERP_KERNEL::Exception(oss.str().c_str());
7335 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7338 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7339 oss << "\nTry to use following method eraseEmptyTS !";
7340 throw INTERP_KERNEL::Exception(oss.str().c_str());
7345 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
7347 std::vector<std::string> ret;
7348 std::set<std::string> ret2;
7349 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7351 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
7352 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7353 if(ret2.find(*it2)==ret2.end())
7355 ret.push_back(*it2);
7362 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
7364 std::vector<std::string> ret;
7365 std::set<std::string> ret2;
7366 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7368 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
7369 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7370 if(ret2.find(*it2)==ret2.end())
7372 ret.push_back(*it2);
7379 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
7381 std::vector<std::string> ret;
7382 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7384 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
7385 ret.insert(ret.end(),tmp.begin(),tmp.end());
7390 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
7392 std::vector<std::string> ret;
7393 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7395 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
7396 ret.insert(ret.end(),tmp.begin(),tmp.end());
7401 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7403 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7404 (*it)->changePflsRefsNamesGen2(mapOfModif);
7407 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7409 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7410 (*it)->changeLocsRefsNamesGen2(mapOfModif);
7413 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
7415 int lgth=_time_steps.size();
7416 std::vector< std::vector<TypeOfField> > ret(lgth);
7417 for(int i=0;i<lgth;i++)
7418 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
7423 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
7425 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
7427 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
7430 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCpy() const
7432 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
7434 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7436 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
7437 ret->_time_steps[i]=(*it)->deepCpy();
7442 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
7444 std::size_t sz(_infos.size()),sz2(_time_steps.size());
7445 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7446 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7447 for(std::size_t i=0;i<sz;i++)
7449 ret[i]=shallowCpy();
7450 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7452 for(std::size_t i=0;i<sz2;i++)
7454 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7457 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7458 throw INTERP_KERNEL::Exception(oss.str().c_str());
7462 for(std::size_t i=0;i<sz;i++)
7463 for(std::size_t j=0;j<sz2;j++)
7464 ret[i]->_time_steps[j]=ts[j][i];
7469 * This method splits into discretization each time steps in \a this.
7470 * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
7472 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
7474 std::size_t sz(_time_steps.size());
7475 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7476 for(std::size_t i=0;i<sz;i++)
7478 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7481 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
7482 throw INTERP_KERNEL::Exception(oss.str().c_str());
7484 items[i]=timeStep->splitDiscretizations();
7487 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
7488 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
7489 std::vector< TypeOfField > types;
7490 for(std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7491 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7493 std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
7495 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
7496 std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
7497 if(it2==types.end())
7498 types.push_back(ts[0]);
7500 ret.resize(types.size()); ret2.resize(types.size());
7501 for(std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7502 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7504 TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
7505 std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
7506 ret2[pos].push_back(*it1);
7508 for(std::size_t i=0;i<types.size();i++)
7510 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=createNew();
7511 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
7512 elt->pushBackTimeStep(*it1);//also updates infos in elt
7514 elt->MEDFileFieldNameScope::operator=(*this);
7519 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
7521 _name=field->getName();
7523 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
7525 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
7526 _infos=arr->getInfoOnComponents();
7529 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
7531 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
7532 if(_name!=field->getName())
7534 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
7535 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
7536 throw INTERP_KERNEL::Exception(oss.str().c_str());
7539 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
7540 checkThatComponentsMatch(arr->getInfoOnComponents());
7543 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
7545 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
7546 if(getInfo().size()!=compos.size())
7548 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
7549 oss << " number of components of element to append (" << compos.size() << ") !";
7550 throw INTERP_KERNEL::Exception(oss.str().c_str());
7554 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
7555 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
7556 oss << " But compo in input fields are : ";
7557 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
7559 throw INTERP_KERNEL::Exception(oss.str().c_str());
7563 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
7565 std::size_t sz=_infos.size();
7567 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
7569 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7571 if(elt->getInfo().size()!=sz)
7573 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
7574 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
7575 throw INTERP_KERNEL::Exception(oss.str().c_str());
7580 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
7583 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7584 if(!_time_steps.empty())
7585 checkCoherencyOfTinyInfo(field,arr);
7586 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
7587 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7588 objC->setFieldNoProfileSBT(field,arr,glob,*this);
7589 copyTinyInfoFrom(field,arr);
7590 _time_steps.push_back(obj);
7593 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
7596 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7597 if(!_time_steps.empty())
7598 checkCoherencyOfTinyInfo(field,arr);
7599 MEDFileField1TSWithoutSDA *objC=new MEDFileField1TSWithoutSDA;
7600 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7601 objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
7602 copyTinyInfoFrom(field,arr);
7603 _time_steps.push_back(obj);
7606 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ts)
7608 int sz=(int)_time_steps.size();
7611 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
7612 throw INTERP_KERNEL::Exception(oss.str().c_str());
7614 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
7617 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
7619 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
7620 throw INTERP_KERNEL::Exception(oss.str().c_str());
7626 //= MEDFileFieldMultiTSWithoutSDA
7628 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)
7630 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms);
7633 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
7637 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7642 * \param [in] fieldId field id in C mode
7644 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms)
7645 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms)
7648 catch(INTERP_KERNEL::Exception& e)
7651 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)
7652 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms)
7655 catch(INTERP_KERNEL::Exception& e)
7658 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
7660 return new MEDFileField1TSWithoutSDA;
7663 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
7666 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7667 const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
7669 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
7672 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const
7674 return MEDFileField1TSWithoutSDA::TYPE_STR;
7677 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const
7679 return new MEDFileFieldMultiTSWithoutSDA(*this);
7682 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const
7684 return new MEDFileFieldMultiTSWithoutSDA;
7688 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
7689 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
7691 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
7693 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
7694 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
7696 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
7697 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
7700 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
7702 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
7703 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
7705 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7707 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
7710 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
7712 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
7713 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
7714 ret->setIteration(i,elt);
7720 //= MEDFileAnyTypeFieldMultiTS
7722 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
7726 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
7727 try:MEDFileFieldGlobsReal(fileName)
7729 MEDFileUtilities::CheckFileForRead(fileName);
7730 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
7731 _content=BuildContentFrom(fid,fileName,loadAll,ms);
7734 catch(INTERP_KERNEL::Exception& e)
7739 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
7741 med_field_type typcha;
7742 std::vector<std::string> infos;
7745 MEDFileAnyTypeField1TS::LocateField(fid,fileName,fieldName,i,typcha,infos,dtunit);
7746 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7751 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms);
7756 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms);
7761 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] !";
7762 throw INTERP_KERNEL::Exception(oss.str().c_str());
7765 ret->setDtUnit(dtunit.c_str());
7769 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
7771 med_field_type typcha;
7773 std::vector<std::string> infos;
7774 std::string dtunit,fieldName;
7775 MEDFileAnyTypeField1TS::LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
7776 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7781 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms);
7786 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms);
7791 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] !";
7792 throw INTERP_KERNEL::Exception(oss.str().c_str());
7795 ret->setDtUnit(dtunit.c_str());
7799 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, const std::string& fileName)
7802 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
7803 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
7805 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=MEDFileFieldMultiTS::New();
7806 ret->setFileName(fileName);
7807 ret->_content=c; c->incrRef();
7810 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
7812 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=MEDFileIntFieldMultiTS::New();
7813 ret->setFileName(fileName);
7814 ret->_content=c; c->incrRef();
7817 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
7820 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
7821 try:MEDFileFieldGlobsReal(fileName)
7823 MEDFileUtilities::CheckFileForRead(fileName);
7824 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
7825 _content=BuildContentFrom(fid,fileName,fieldName,loadAll,ms);
7828 catch(INTERP_KERNEL::Exception& e)
7833 //= MEDFileIntFieldMultiTSWithoutSDA
7835 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)
7837 return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms);
7840 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
7844 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7848 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)
7849 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms)
7852 catch(INTERP_KERNEL::Exception& e)
7856 * \param [in] fieldId field id in C mode
7858 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms)
7859 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms)
7862 catch(INTERP_KERNEL::Exception& e)
7865 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
7867 return new MEDFileIntField1TSWithoutSDA;
7870 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
7873 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7874 const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
7876 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
7879 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const
7881 return MEDFileIntField1TSWithoutSDA::TYPE_STR;
7884 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const
7886 return new MEDFileIntFieldMultiTSWithoutSDA(*this);
7889 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const
7891 return new MEDFileIntFieldMultiTSWithoutSDA;
7894 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const
7896 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
7897 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
7899 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7901 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
7904 const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
7906 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
7907 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
7908 ret->setIteration(i,elt);
7914 //= MEDFileAnyTypeFieldMultiTS
7917 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
7918 * that has been read from a specified MED file.
7919 * \param [in] fileName - the name of the MED file to read.
7920 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
7921 * is to delete this field using decrRef() as it is no more needed.
7922 * \throw If reading the file fails.
7924 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
7926 MEDFileUtilities::CheckFileForRead(fileName);
7927 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
7928 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll,0);
7929 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
7930 ret->loadGlobals(fid);
7935 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
7936 * that has been read from a specified MED file.
7937 * \param [in] fileName - the name of the MED file to read.
7938 * \param [in] fieldName - the name of the field to read.
7939 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
7940 * is to delete this field using decrRef() as it is no more needed.
7941 * \throw If reading the file fails.
7942 * \throw If there is no field named \a fieldName in the file.
7944 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
7946 MEDFileUtilities::CheckFileForRead(fileName);
7947 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
7948 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll,0);
7949 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
7950 ret->loadGlobals(fid);
7955 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
7956 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
7958 * \warning this is a shallow copy constructor
7960 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
7962 if(!shallowCopyOfContent)
7964 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
7965 otherPtr->incrRef();
7966 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
7970 _content=other.shallowCpy();
7974 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
7976 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
7978 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
7982 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
7984 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
7986 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
7990 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
7992 return contentNotNullBase()->getPflsReallyUsed2();
7995 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
7997 return contentNotNullBase()->getLocsReallyUsed2();
8000 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
8002 return contentNotNullBase()->getPflsReallyUsedMulti2();
8005 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
8007 return contentNotNullBase()->getLocsReallyUsedMulti2();
8010 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8012 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
8015 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8017 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
8020 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
8022 return contentNotNullBase()->getNumberOfTS();
8025 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
8027 contentNotNullBase()->eraseEmptyTS();
8030 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
8032 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
8035 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
8037 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
8040 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
8042 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
8043 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8048 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
8050 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
8051 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8056 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
8058 return contentNotNullBase()->getIterations();
8061 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
8063 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
8064 pushBackTimeStep(*it);
8067 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
8070 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
8071 checkCoherencyOfType(f1ts);
8073 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
8074 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
8076 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
8077 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
8078 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
8079 _content->pushBackTimeStep(cSafe);
8080 appendGlobs(*f1ts,1e-12);
8083 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
8085 contentNotNullBase()->synchronizeNameScope();
8088 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
8090 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
8093 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
8095 return contentNotNullBase()->getPosGivenTime(time,eps);
8098 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8100 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
8103 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
8105 return contentNotNullBase()->getTypesOfFieldAvailable();
8108 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
8110 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
8113 std::string MEDFileAnyTypeFieldMultiTS::getName() const
8115 return contentNotNullBase()->getName();
8118 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
8120 contentNotNullBase()->setName(name);
8123 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
8125 return contentNotNullBase()->getDtUnit();
8128 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
8130 contentNotNullBase()->setDtUnit(dtUnit);
8133 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8135 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
8138 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
8140 return contentNotNullBase()->getTimeSteps(ret1);
8143 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
8145 return contentNotNullBase()->getMeshName();
8148 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
8150 contentNotNullBase()->setMeshName(newMeshName);
8153 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
8155 return contentNotNullBase()->changeMeshNames(modifTab);
8158 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
8160 return contentNotNullBase()->getInfo();
8163 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
8165 return contentNotNullBase()->setInfo(info);
8168 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
8170 const std::vector<std::string> ret=getInfo();
8171 return (int)ret.size();
8174 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
8176 writeGlobals(fid,*this);
8177 contentNotNullBase()->writeLL(fid,*this);
8181 * Writes \a this field into a MED file specified by its name.
8182 * \param [in] fileName - the MED file name.
8183 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
8184 * - 2 - erase; an existing file is removed.
8185 * - 1 - append; same data should not be present in an existing file.
8186 * - 0 - overwrite; same data present in an existing file is overwritten.
8187 * \throw If the field name is not set.
8188 * \throw If no field data is set.
8189 * \throw If \a mode == 1 and the same data is present in an existing file.
8191 void MEDFileAnyTypeFieldMultiTS::write(const std::string& fileName, int mode) const
8193 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
8194 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
8199 * This method alloc the arrays and load potentially huge arrays contained in this field.
8200 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
8201 * This method can be also called to refresh or reinit values from a file.
8203 * \throw If the fileName is not set or points to a non readable MED file.
8205 void MEDFileAnyTypeFieldMultiTS::loadArrays()
8207 if(getFileName().empty())
8208 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
8209 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
8210 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
8214 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
8215 * But once data loaded once, this method does nothing.
8217 * \throw If the fileName is not set or points to a non readable MED file.
8218 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
8220 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
8222 if(!getFileName().empty())
8224 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
8225 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
8230 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
8231 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
8232 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
8234 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
8236 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
8238 contentNotNullBase()->unloadArrays();
8242 * 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.
8243 * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
8244 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
8246 * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
8248 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
8250 if(!getFileName().empty())
8251 contentNotNullBase()->unloadArrays();
8254 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
8256 std::ostringstream oss;
8257 contentNotNullBase()->simpleRepr(0,oss,-1);
8258 simpleReprGlobs(oss);
8262 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
8264 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
8267 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
8269 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
8270 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
8275 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
8276 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8277 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
8279 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
8281 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8283 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
8284 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
8285 std::size_t sz(contentsSplit.size());
8286 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8287 for(std::size_t i=0;i<sz;i++)
8289 ret[i]=shallowCpy();
8290 ret[i]->_content=contentsSplit[i];
8296 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
8297 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8299 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
8301 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8303 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
8304 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitDiscretizations();
8305 std::size_t sz(contentsSplit.size());
8306 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8307 for(std::size_t i=0;i<sz;i++)
8309 ret[i]=shallowCpy();
8310 ret[i]->_content=contentsSplit[i];
8315 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCpy() const
8317 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8318 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
8319 ret->_content=_content->deepCpy();
8320 ret->deepCpyGlobs(*this);
8324 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
8330 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8331 * \param [in] iteration - the iteration number of a required time step.
8332 * \param [in] order - the iteration order number of required time step.
8333 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
8334 * delete this field using decrRef() as it is no more needed.
8335 * \throw If there is no required time step in \a this field.
8337 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
8339 int pos=getPosOfTimeStep(iteration,order);
8340 return getTimeStepAtPos(pos);
8344 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8345 * \param [in] time - the time of the time step of interest.
8346 * \param [in] eps - a precision used to compare time values.
8347 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8348 * delete this field using decrRef() as it is no more needed.
8349 * \throw If there is no required time step in \a this field.
8351 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
8353 int pos=getPosGivenTime(time,eps);
8354 return getTimeStepAtPos(pos);
8358 * 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.
8359 * The float64 value of time attached to the pair of integers are not considered here.
8360 * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
8362 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
8363 * \throw If there is a null pointer in \a vectFMTS.
8365 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
8367 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
8368 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8369 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8370 while(!lstFMTS.empty())
8372 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8373 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8375 throw INTERP_KERNEL::Exception(msg);
8376 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
8377 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8378 elt.push_back(curIt); it=lstFMTS.erase(it);
8379 while(it!=lstFMTS.end())
8383 throw INTERP_KERNEL::Exception(msg);
8384 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
8386 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8396 * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
8397 * All returned instances in a subvector can be safely loaded, rendered along time
8398 * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
8399 * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
8400 * 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).
8401 * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
8402 * 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.
8404 * \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().
8405 * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
8406 * \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.
8407 * \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.
8409 * \throw If an element in \a vectFMTS has not only one spatial discretization set.
8410 * \throw If an element in \a vectFMTS change of spatial discretization along time.
8411 * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
8412 * \thorw If some elements in \a vectFMTS do not have the same times steps.
8413 * \throw If mesh is null.
8414 * \throw If an element in \a vectFMTS is null.
8415 * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
8417 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> >& fsc)
8419 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
8421 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
8422 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8423 if(vectFMTS.empty())
8425 std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
8426 MEDFileAnyTypeFieldMultiTS *frstElt(*it);
8428 throw INTERP_KERNEL::Exception(msg);
8430 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
8431 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
8432 for(;it!=vectFMTS.end();it++,i++)
8435 throw INTERP_KERNEL::Exception(msg);
8436 TypeOfField tof0,tof1;
8437 if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
8440 vectFMTSNotNodes.push_back(*it);
8442 vectFMTSNodes.push_back(*it);
8445 vectFMTSNotNodes.push_back(*it);
8447 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> > cmps;
8448 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
8450 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
8453 bool isFetched(false);
8454 for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
8457 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
8458 if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
8459 { ret[i].push_back(*it2); isFetched=true; }
8463 std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
8464 MEDCouplingAutoRefCountObjectPtr<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
8465 ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
8473 * 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.
8474 * \param [out] cmps - same size than the returned vector.
8476 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> >& cmps)
8478 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8479 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8480 while(!lstFMTS.empty())
8482 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8483 MEDFileAnyTypeFieldMultiTS *ref(*it);
8484 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8485 elt.push_back(ref); it=lstFMTS.erase(it);
8486 MEDCouplingAutoRefCountObjectPtr<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
8487 MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
8488 while(it!=lstFMTS.end())
8490 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8491 if(cmp->isEqual(curIt))
8492 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8496 ret.push_back(elt); cmps.push_back(cmp);
8502 * 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.
8503 * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
8505 * \throw If \a f0 or \a f1 has not only one spatial discretization set.
8506 * \throw If \a f0 or \a f1 change of spatial discretization along time.
8507 * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
8508 * \thorw If \a f0 and \a f1 do not have the same times steps.
8509 * \throw If mesh is null.
8510 * \throw If \a f0 or \a f1 is null.
8511 * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
8513 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
8516 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
8518 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
8519 if(f0->getMeshName()!=mesh->getName())
8521 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8522 throw INTERP_KERNEL::Exception(oss.str().c_str());
8524 if(f1->getMeshName()!=mesh->getName())
8526 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8527 throw INTERP_KERNEL::Exception(oss.str().c_str());
8529 int nts=f0->getNumberOfTS();
8530 if(nts!=f1->getNumberOfTS())
8531 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
8534 for(int i=0;i<nts;i++)
8536 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
8537 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
8538 std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
8539 if(tofs0.size()!=1 || tofs1.size()!=1)
8540 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
8543 if(tof0!=tofs0[0] || tof1!=tofs1[0])
8544 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
8547 { tof0=tofs0[0]; tof1=tofs1[0]; }
8548 if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
8550 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() << ") !";
8551 throw INTERP_KERNEL::Exception(oss.str().c_str());
8553 if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
8555 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() << ") !";
8556 throw INTERP_KERNEL::Exception(oss.str().c_str());
8558 if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
8560 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() << ") !";
8561 throw INTERP_KERNEL::Exception(oss.str().c_str());
8567 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
8569 return new MEDFileAnyTypeFieldMultiTSIterator(this);
8572 //= MEDFileFieldMultiTS
8575 * Returns a new empty instance of MEDFileFieldMultiTS.
8576 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8577 * is to delete this field using decrRef() as it is no more needed.
8579 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
8581 return new MEDFileFieldMultiTS;
8585 * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
8586 * that has been read from a specified MED file.
8587 * \param [in] fileName - the name of the MED file to read.
8588 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8589 * is to delete this field using decrRef() as it is no more needed.
8590 * \throw If reading the file fails.
8592 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll)
8594 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,loadAll,0);
8595 ret->contentNotNull();//to check that content type matches with \a this type.
8600 * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
8601 * that has been read from a specified MED file.
8602 * \param [in] fileName - the name of the MED file to read.
8603 * \param [in] fieldName - the name of the field to read.
8604 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8605 * is to delete this field using decrRef() as it is no more needed.
8606 * \throw If reading the file fails.
8607 * \throw If there is no field named \a fieldName in the file.
8609 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8611 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,fieldName,loadAll,0);
8612 ret->contentNotNull();//to check that content type matches with \a this type.
8617 * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8618 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8620 * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
8621 * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
8622 * \warning this is a shallow copy constructor
8623 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
8624 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
8625 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8626 * is to delete this field using decrRef() as it is no more needed.
8628 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8630 return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
8633 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
8635 return new MEDFileFieldMultiTS(*this);
8638 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
8641 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8642 const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
8644 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8648 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
8649 * following the given input policy.
8651 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
8652 * By default (true) the globals are deeply copied.
8653 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
8655 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
8657 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret;
8658 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8661 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
8663 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
8664 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
8665 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc,getFileName()));
8668 ret=MEDFileIntFieldMultiTS::New();
8670 ret->deepCpyGlobs(*this);
8672 ret->shallowCpyGlobs(*this);
8677 * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
8678 * \param [in] pos - a time step id.
8679 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8680 * delete this field using decrRef() as it is no more needed.
8681 * \throw If \a pos is not a valid time step id.
8683 MEDFileAnyTypeField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const
8685 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
8688 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
8689 throw INTERP_KERNEL::Exception(oss.str().c_str());
8691 const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
8694 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
8695 ret->shallowCpyGlobs(*this);
8698 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
8699 throw INTERP_KERNEL::Exception(oss.str().c_str());
8703 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8704 * mesh entities of a given dimension of the first mesh in MED file.
8705 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8706 * \param [in] type - a spatial discretization of interest.
8707 * \param [in] iteration - the iteration number of a required time step.
8708 * \param [in] order - the iteration order number of required time step.
8709 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8710 * \param [in] renumPol - specifies how to permute values of the result field according to
8711 * the optional numbers of cells and nodes, if any. The valid values are
8712 * - 0 - do not permute.
8713 * - 1 - permute cells.
8714 * - 2 - permute nodes.
8715 * - 3 - permute cells and nodes.
8717 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8718 * caller is to delete this field using decrRef() as it is no more needed.
8719 * \throw If the MED file is not readable.
8720 * \throw If there is no mesh in the MED file.
8721 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8722 * \throw If no field values of the required parameters are available.
8724 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
8726 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8727 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8729 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
8730 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8731 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase());
8732 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8737 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8738 * the top level cells of the first mesh in MED file.
8739 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8740 * \param [in] type - a spatial discretization of interest.
8741 * \param [in] iteration - the iteration number of a required time step.
8742 * \param [in] order - the iteration order number of required time step.
8743 * \param [in] renumPol - specifies how to permute values of the result field according to
8744 * the optional numbers of cells and nodes, if any. The valid values are
8745 * - 0 - do not permute.
8746 * - 1 - permute cells.
8747 * - 2 - permute nodes.
8748 * - 3 - permute cells and nodes.
8750 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8751 * caller is to delete this field using decrRef() as it is no more needed.
8752 * \throw If the MED file is not readable.
8753 * \throw If there is no mesh in the MED file.
8754 * \throw If no field values of the required parameters are available.
8756 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
8758 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8759 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8761 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
8762 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8763 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase());
8764 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8769 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8771 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8772 * \param [in] type - a spatial discretization of interest.
8773 * \param [in] iteration - the iteration number of a required time step.
8774 * \param [in] order - the iteration order number of required time step.
8775 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8776 * \param [in] mesh - the supporting mesh.
8777 * \param [in] renumPol - specifies how to permute values of the result field according to
8778 * the optional numbers of cells and nodes, if any. The valid values are
8779 * - 0 - do not permute.
8780 * - 1 - permute cells.
8781 * - 2 - permute nodes.
8782 * - 3 - permute cells and nodes.
8784 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8785 * caller is to delete this field using decrRef() as it is no more needed.
8786 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8787 * \throw If no field of \a this is lying on \a mesh.
8788 * \throw If no field values of the required parameters are available.
8790 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
8792 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8793 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8795 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
8796 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8797 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
8798 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8803 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
8805 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8806 * \param [in] type - a spatial discretization of the new field.
8807 * \param [in] iteration - the iteration number of a required time step.
8808 * \param [in] order - the iteration order number of required time step.
8809 * \param [in] mesh - the supporting mesh.
8810 * \param [in] renumPol - specifies how to permute values of the result field according to
8811 * the optional numbers of cells and nodes, if any. The valid values are
8812 * - 0 - do not permute.
8813 * - 1 - permute cells.
8814 * - 2 - permute nodes.
8815 * - 3 - permute cells and nodes.
8817 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8818 * caller is to delete this field using decrRef() as it is no more needed.
8819 * \throw If no field of \a this is lying on \a mesh.
8820 * \throw If no field values of the required parameters are available.
8822 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
8824 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8825 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8827 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
8828 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8829 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
8830 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8835 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
8836 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
8837 * This method is useful for MED2 file format when field on different mesh was autorized.
8839 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
8841 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8842 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8844 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
8845 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8846 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
8847 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8852 * Returns values and a profile of the field of a given type, of a given time step,
8853 * lying on a given support.
8854 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8855 * \param [in] type - a spatial discretization of the field.
8856 * \param [in] iteration - the iteration number of a required time step.
8857 * \param [in] order - the iteration order number of required time step.
8858 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8859 * \param [in] mesh - the supporting mesh.
8860 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
8861 * field of interest lies on. If the field lies on all entities of the given
8862 * dimension, all ids in \a pfl are zero. The caller is to delete this array
8863 * using decrRef() as it is no more needed.
8864 * \param [in] glob - the global data storing profiles and localization.
8865 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
8866 * field. The caller is to delete this array using decrRef() as it is no more needed.
8867 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8868 * \throw If no field of \a this is lying on \a mesh.
8869 * \throw If no field values of the required parameters are available.
8871 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
8873 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8874 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8876 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
8877 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
8878 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
8881 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const
8883 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8885 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
8886 const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
8888 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 !");
8892 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull()
8894 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8896 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
8897 MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
8899 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 !");
8904 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
8905 * the given field is checked if its elements are sorted suitable for writing to MED file
8906 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
8907 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8908 * \param [in] field - the field to add to \a this.
8909 * \throw If the name of \a field is empty.
8910 * \throw If the data array of \a field is not set.
8911 * \throw If existing time steps have different name or number of components than \a field.
8912 * \throw If the underlying mesh of \a field has no name.
8913 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
8915 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
8917 const DataArrayDouble *arr=0;
8919 arr=field->getArray();
8920 contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
8924 * Adds a MEDCouplingFieldDouble to \a this as another time step.
8925 * The mesh support of input parameter \a field is ignored here, it can be NULL.
8926 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
8929 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
8930 * A new profile is added only if no equal profile is missing.
8931 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8932 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
8933 * \param [in] mesh - the supporting mesh of \a field.
8934 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
8935 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
8936 * \throw If either \a field or \a mesh or \a profile has an empty name.
8937 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8938 * \throw If the data array of \a field is not set.
8939 * \throw If the data array of \a this is already allocated but has different number of
8940 * components than \a field.
8941 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
8942 * \sa setFieldNoProfileSBT()
8944 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
8946 const DataArrayDouble *arr=0;
8948 arr=field->getArray();
8949 contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
8952 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
8954 _content=new MEDFileFieldMultiTSWithoutSDA;
8957 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
8958 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll,ms)
8961 catch(INTERP_KERNEL::Exception& e)
8964 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
8965 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll,ms)
8968 catch(INTERP_KERNEL::Exception& e)
8971 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
8975 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
8977 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
8980 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
8982 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
8985 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
8987 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
8990 //= MEDFileAnyTypeFieldMultiTSIterator
8992 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
8997 _nb_iter=fmts->getNumberOfTS();
9001 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
9005 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
9007 if(_iter_id<_nb_iter)
9009 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
9011 return fmts->getTimeStepAtPos(_iter_id++);
9019 //= MEDFileIntFieldMultiTS
9022 * Returns a new empty instance of MEDFileFieldMultiTS.
9023 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9024 * is to delete this field using decrRef() as it is no more needed.
9026 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
9028 return new MEDFileIntFieldMultiTS;
9032 * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
9033 * that has been read from a specified MED file.
9034 * \param [in] fileName - the name of the MED file to read.
9035 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9036 * is to delete this field using decrRef() as it is no more needed.
9037 * \throw If reading the file fails.
9039 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll)
9041 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,loadAll,0);
9042 ret->contentNotNull();//to check that content type matches with \a this type.
9047 * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
9048 * that has been read from a specified MED file.
9049 * \param [in] fileName - the name of the MED file to read.
9050 * \param [in] fieldName - the name of the field to read.
9051 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9052 * is to delete this field using decrRef() as it is no more needed.
9053 * \throw If reading the file fails.
9054 * \throw If there is no field named \a fieldName in the file.
9056 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9058 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll,0);
9059 ret->contentNotNull();//to check that content type matches with \a this type.
9064 * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9065 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9067 * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
9068 * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9069 * \warning this is a shallow copy constructor
9070 * \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
9071 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9072 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9073 * is to delete this field using decrRef() as it is no more needed.
9075 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9077 return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
9081 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
9082 * following the given input policy.
9084 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9085 * By default (true) the globals are deeply copied.
9086 * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
9088 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const
9090 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret;
9091 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9094 const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
9096 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
9097 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
9098 ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc,getFileName()));
9101 ret=MEDFileFieldMultiTS::New();
9103 ret->deepCpyGlobs(*this);
9105 ret->shallowCpyGlobs(*this);
9109 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const
9111 return new MEDFileIntFieldMultiTS(*this);
9114 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9117 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9118 const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
9120 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
9124 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9125 * mesh entities of a given dimension of the first mesh in MED file.
9126 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9127 * \param [in] type - a spatial discretization of interest.
9128 * \param [in] iteration - the iteration number of a required time step.
9129 * \param [in] order - the iteration order number of required time step.
9130 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9131 * \param [out] arrOut - the DataArrayInt containing values of field.
9132 * \param [in] renumPol - specifies how to permute values of the result field according to
9133 * the optional numbers of cells and nodes, if any. The valid values are
9134 * - 0 - do not permute.
9135 * - 1 - permute cells.
9136 * - 2 - permute nodes.
9137 * - 3 - permute cells and nodes.
9139 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9140 * caller is to delete this field using decrRef() as it is no more needed.
9141 * \throw If the MED file is not readable.
9142 * \throw If there is no mesh in the MED file.
9143 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9144 * \throw If no field values of the required parameters are available.
9146 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
9148 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9149 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9151 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
9152 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9153 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase());
9154 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9159 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9160 * the top level cells of the first mesh in MED file.
9161 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9162 * \param [in] type - a spatial discretization of interest.
9163 * \param [in] iteration - the iteration number of a required time step.
9164 * \param [in] order - the iteration order number of required time step.
9165 * \param [out] arrOut - the DataArrayInt containing values of field.
9166 * \param [in] renumPol - specifies how to permute values of the result field according to
9167 * the optional numbers of cells and nodes, if any. The valid values are
9168 * - 0 - do not permute.
9169 * - 1 - permute cells.
9170 * - 2 - permute nodes.
9171 * - 3 - permute cells and nodes.
9173 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9174 * caller is to delete this field using decrRef() as it is no more needed.
9175 * \throw If the MED file is not readable.
9176 * \throw If there is no mesh in the MED file.
9177 * \throw If no field values of the required parameters are available.
9179 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, DataArrayInt* &arrOut, int renumPol) const
9181 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9182 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9184 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
9185 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9186 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase());
9187 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9192 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9194 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9195 * \param [in] type - a spatial discretization of interest.
9196 * \param [in] iteration - the iteration number of a required time step.
9197 * \param [in] order - the iteration order number of required time step.
9198 * \param [out] arrOut - the DataArrayInt containing values of field.
9199 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9200 * \param [in] mesh - the supporting mesh.
9201 * \param [in] renumPol - specifies how to permute values of the result field according to
9202 * the optional numbers of cells and nodes, if any. The valid values are
9203 * - 0 - do not permute.
9204 * - 1 - permute cells.
9205 * - 2 - permute nodes.
9206 * - 3 - permute cells and nodes.
9208 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9209 * caller is to delete this field using decrRef() as it is no more needed.
9210 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9211 * \throw If no field of \a this is lying on \a mesh.
9212 * \throw If no field values of the required parameters are available.
9214 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
9216 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9217 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9219 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9220 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9221 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase());
9222 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9227 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9229 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9230 * \param [in] type - a spatial discretization of the new field.
9231 * \param [in] iteration - the iteration number of a required time step.
9232 * \param [in] order - the iteration order number of required time step.
9233 * \param [in] mesh - the supporting mesh.
9234 * \param [out] arrOut - the DataArrayInt containing values of field.
9235 * \param [in] renumPol - specifies how to permute values of the result field according to
9236 * the optional numbers of cells and nodes, if any. The valid values are
9237 * - 0 - do not permute.
9238 * - 1 - permute cells.
9239 * - 2 - permute nodes.
9240 * - 3 - permute cells and nodes.
9242 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9243 * caller is to delete this field using decrRef() as it is no more needed.
9244 * \throw If no field of \a this is lying on \a mesh.
9245 * \throw If no field values of the required parameters are available.
9247 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
9249 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9250 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9252 throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9253 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9254 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase());
9255 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9260 * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
9261 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9262 * This method is useful for MED2 file format when field on different mesh was autorized.
9264 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
9266 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9267 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9269 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9270 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9271 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase());
9272 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9277 * Returns values and a profile of the field of a given type, of a given time step,
9278 * lying on a given support.
9279 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9280 * \param [in] type - a spatial discretization of the field.
9281 * \param [in] iteration - the iteration number of a required time step.
9282 * \param [in] order - the iteration order number of required time step.
9283 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9284 * \param [in] mesh - the supporting mesh.
9285 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9286 * field of interest lies on. If the field lies on all entities of the given
9287 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9288 * using decrRef() as it is no more needed.
9289 * \param [in] glob - the global data storing profiles and localization.
9290 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
9291 * field. The caller is to delete this array using decrRef() as it is no more needed.
9292 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9293 * \throw If no field of \a this is lying on \a mesh.
9294 * \throw If no field values of the required parameters are available.
9296 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9298 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9299 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9301 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
9302 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9303 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
9307 * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
9308 * \param [in] pos - a time step id.
9309 * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
9310 * delete this field using decrRef() as it is no more needed.
9311 * \throw If \a pos is not a valid time step id.
9313 MEDFileAnyTypeField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
9315 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9318 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9319 throw INTERP_KERNEL::Exception(oss.str().c_str());
9321 const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
9324 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
9325 ret->shallowCpyGlobs(*this);
9328 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
9329 throw INTERP_KERNEL::Exception(oss.str().c_str());
9333 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9334 * the given field is checked if its elements are sorted suitable for writing to MED file
9335 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9336 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9337 * \param [in] field - the field to add to \a this.
9338 * \throw If the name of \a field is empty.
9339 * \throw If the data array of \a field is not set.
9340 * \throw If existing time steps have different name or number of components than \a field.
9341 * \throw If the underlying mesh of \a field has no name.
9342 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9344 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals)
9346 contentNotNull()->appendFieldNoProfileSBT(field,arrOfVals,*this);
9350 * Adds a MEDCouplingFieldDouble to \a this as another time step.
9351 * The mesh support of input parameter \a field is ignored here, it can be NULL.
9352 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9355 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9356 * A new profile is added only if no equal profile is missing.
9357 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9358 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
9359 * \param [in] arrOfVals - the values of the field \a field used.
9360 * \param [in] mesh - the supporting mesh of \a field.
9361 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9362 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
9363 * \throw If either \a field or \a mesh or \a profile has an empty name.
9364 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9365 * \throw If the data array of \a field is not set.
9366 * \throw If the data array of \a this is already allocated but has different number of
9367 * components than \a field.
9368 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9369 * \sa setFieldNoProfileSBT()
9371 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9373 contentNotNull()->appendFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this);
9376 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const
9378 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9380 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
9381 const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9383 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 !");
9387 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull()
9389 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9391 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
9392 MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9394 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 !");
9398 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
9400 _content=new MEDFileIntFieldMultiTSWithoutSDA;
9403 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9407 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9408 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll,ms)
9411 catch(INTERP_KERNEL::Exception& e)
9414 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
9415 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll,ms)
9418 catch(INTERP_KERNEL::Exception& e)
9421 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9423 return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9428 MEDFileFields *MEDFileFields::New()
9430 return new MEDFileFields;
9433 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
9435 return new MEDFileFields(fileName,loadAll,0);
9438 MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9440 return new MEDFileFields(fileName,loadAll,ms);
9443 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
9445 std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
9446 ret+=_fields.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
9450 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
9452 std::vector<const BigMemoryObject *> ret;
9453 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9454 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
9458 MEDFileFields *MEDFileFields::deepCpy() const
9460 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
9462 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9464 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9465 ret->_fields[i]=(*it)->deepCpy();
9467 ret->deepCpyGlobs(*this);
9471 MEDFileFields *MEDFileFields::shallowCpy() const
9473 return new MEDFileFields(*this);
9477 * 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
9478 * 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.
9479 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
9481 * \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.
9482 * \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.
9484 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9486 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
9488 std::set< std::pair<int,int> > s;
9489 bool firstShot=true;
9490 areThereSomeForgottenTS=false;
9491 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9493 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9495 std::vector< std::pair<int,int> > v=(*it)->getIterations();
9496 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
9498 { s=s1; firstShot=false; }
9501 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
9503 areThereSomeForgottenTS=true;
9507 std::vector< std::pair<int,int> > ret;
9508 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
9512 int MEDFileFields::getNumberOfFields() const
9514 return _fields.size();
9517 std::vector<std::string> MEDFileFields::getFieldsNames() const
9519 std::vector<std::string> ret(_fields.size());
9521 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9523 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
9526 ret[i]=f->getName();
9530 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
9531 throw INTERP_KERNEL::Exception(oss.str().c_str());
9537 std::vector<std::string> MEDFileFields::getMeshesNames() const
9539 std::vector<std::string> ret;
9540 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9542 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9544 ret.push_back(cur->getMeshName());
9549 std::string MEDFileFields::simpleRepr() const
9551 std::ostringstream oss;
9552 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
9557 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
9559 int nbOfFields=getNumberOfFields();
9560 std::string startLine(bkOffset,' ');
9561 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
9563 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9565 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9568 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
9572 oss << startLine << " - not defined !" << std::endl;
9576 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9578 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9579 std::string chapter(17,'0'+i);
9580 oss << startLine << chapter << std::endl;
9583 cur->simpleRepr(bkOffset+2,oss,i);
9587 oss << startLine << " - not defined !" << std::endl;
9589 oss << startLine << chapter << std::endl;
9591 simpleReprGlobs(oss);
9594 MEDFileFields::MEDFileFields()
9598 MEDFileFields::MEDFileFields(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9599 try:MEDFileFieldGlobsReal(fileName)
9601 MEDFileUtilities::CheckFileForRead(fileName);
9602 MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY));
9603 int nbFields(MEDnField(fid));
9604 _fields.resize(nbFields);
9605 med_field_type typcha;
9606 for(int i=0;i<nbFields;i++)
9608 std::vector<std::string> infos;
9609 std::string fieldName,dtunit;
9610 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fileName,i,false,fieldName,typcha,infos,dtunit));
9615 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms);
9620 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms);
9625 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] !";
9626 throw INTERP_KERNEL::Exception(oss.str().c_str());
9630 loadAllGlobals(fid);
9632 catch(INTERP_KERNEL::Exception& e)
9637 void MEDFileFields::writeLL(med_idt fid) const
9640 writeGlobals(fid,*this);
9641 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9643 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
9646 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
9647 throw INTERP_KERNEL::Exception(oss.str().c_str());
9649 elt->writeLL(fid,*this);
9653 void MEDFileFields::write(const std::string& fileName, int mode) const
9655 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
9656 MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),medmod));
9661 * This method alloc the arrays and load potentially huge arrays contained in this field.
9662 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
9663 * This method can be also called to refresh or reinit values from a file.
9665 * \throw If the fileName is not set or points to a non readable MED file.
9667 void MEDFileFields::loadArrays()
9669 if(getFileName().empty())
9670 throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
9671 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
9672 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9674 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9676 elt->loadBigArraysRecursively(fid,*elt);
9681 * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
9682 * But once data loaded once, this method does nothing.
9684 * \throw If the fileName is not set or points to a non readable MED file.
9685 * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
9687 void MEDFileFields::loadArraysIfNecessary()
9689 if(!getFileName().empty())
9691 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
9692 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9694 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9696 elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
9702 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
9703 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
9704 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
9706 * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
9708 void MEDFileFields::unloadArrays()
9710 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9712 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9714 elt->unloadArrays();
9719 * 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.
9720 * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
9721 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
9723 * \sa MEDFileFields::loadArraysIfNecessary
9725 void MEDFileFields::unloadArraysWithoutDataLoss()
9727 if(!getFileName().empty())
9731 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
9733 std::vector<std::string> ret;
9734 std::set<std::string> ret2;
9735 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9737 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
9738 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
9739 if(ret2.find(*it2)==ret2.end())
9741 ret.push_back(*it2);
9748 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
9750 std::vector<std::string> ret;
9751 std::set<std::string> ret2;
9752 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9754 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
9755 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
9756 if(ret2.find(*it2)==ret2.end())
9758 ret.push_back(*it2);
9765 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
9767 std::vector<std::string> ret;
9768 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9770 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
9771 ret.insert(ret.end(),tmp.begin(),tmp.end());
9776 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
9778 std::vector<std::string> ret;
9779 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9781 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
9782 ret.insert(ret.end(),tmp.begin(),tmp.end());
9787 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
9789 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
9790 (*it)->changePflsRefsNamesGen2(mapOfModif);
9793 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
9795 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
9796 (*it)->changeLocsRefsNamesGen2(mapOfModif);
9799 void MEDFileFields::resize(int newSize)
9801 _fields.resize(newSize);
9804 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
9806 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
9810 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
9813 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
9814 _fields.push_back(field->getContent());
9815 appendGlobs(*field,1e-12);
9818 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
9821 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
9822 if(i>=(int)_fields.size())
9823 _fields.resize(i+1);
9824 _fields[i]=field->getContent();
9825 appendGlobs(*field,1e-12);
9828 void MEDFileFields::destroyFieldAtPos(int i)
9830 destroyFieldsAtPos(&i,&i+1);
9833 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
9835 std::vector<bool> b(_fields.size(),true);
9836 for(const int *i=startIds;i!=endIds;i++)
9838 if(*i<0 || *i>=(int)_fields.size())
9840 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
9841 throw INTERP_KERNEL::Exception(oss.str().c_str());
9845 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
9847 for(std::size_t i=0;i<_fields.size();i++)
9849 fields[j++]=_fields[i];
9853 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
9855 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
9856 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
9857 std::vector<bool> b(_fields.size(),true);
9859 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
9861 if(k<0 || k>=(int)_fields.size())
9863 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
9864 throw INTERP_KERNEL::Exception(oss.str().c_str());
9868 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
9870 for(std::size_t i=0;i<_fields.size();i++)
9872 fields[j++]=_fields[i];
9876 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
9879 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9881 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9883 ret=cur->changeMeshNames(modifTab) || ret;
9889 * \param [in] meshName the name of the mesh that will be renumbered.
9890 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
9891 * This code corresponds to the distribution of types in the corresponding mesh.
9892 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
9893 * \param [in] renumO2N the old to new renumber array.
9894 * \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
9897 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
9900 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9902 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
9905 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
9911 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
9913 if(i<0 || i>=(int)_fields.size())
9915 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
9916 throw INTERP_KERNEL::Exception(oss.str().c_str());
9918 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
9921 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret;
9922 const MEDFileFieldMultiTSWithoutSDA *fmtsC=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts);
9923 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts);
9925 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
9927 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
9930 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
9931 throw INTERP_KERNEL::Exception(oss.str().c_str());
9933 ret->shallowCpyGlobs(*this);
9938 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
9939 * This method is accessible in python using __getitem__ with a list in input.
9940 * \return a new object that the caller should deal with.
9942 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
9944 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
9945 std::size_t sz=std::distance(startIds,endIds);
9946 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
9948 for(const int *i=startIds;i!=endIds;i++,j++)
9950 if(*i<0 || *i>=(int)_fields.size())
9952 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
9953 throw INTERP_KERNEL::Exception(oss.str().c_str());
9955 fields[j]=_fields[*i];
9957 ret->_fields=fields;
9961 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
9963 return getFieldAtPos(getPosFromFieldName(fieldName));
9967 * This method removes, if any, fields in \a this having no time steps.
9968 * 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.
9970 * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
9972 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
9974 std::vector<MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
9975 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9977 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9980 if(elt->getNumberOfTS()>0)
9981 newFields.push_back(*it);
9984 if(_fields.size()==newFields.size())
9991 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
9992 * This method can be seen as a filter applied on \a this, that returns an object containing
9993 * 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
9994 * shallow copied from \a this.
9996 * \param [in] meshName - the name of the mesh on w
9997 * \return a new object that the caller should deal with.
9999 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
10001 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
10002 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10004 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10007 if(cur->getMeshName()==meshName)
10010 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
10011 ret->_fields.push_back(cur2);
10014 ret->shallowCpyOnlyUsedGlobs(*this);
10019 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
10020 * Input time steps are specified using a pair of integer (iteration, order).
10021 * 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,
10022 * but for each multitimestep only the time steps in \a timeSteps are kept.
10023 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
10025 * The returned object points to shallow copy of elements in \a this.
10027 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
10028 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
10029 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10031 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10033 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
10034 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10036 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10039 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
10040 ret->_fields.push_back(elt);
10042 ret->shallowCpyOnlyUsedGlobs(*this);
10047 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
10049 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10051 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
10052 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10054 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10057 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
10058 if(elt->getNumberOfTS()!=0)
10059 ret->_fields.push_back(elt);
10061 ret->shallowCpyOnlyUsedGlobs(*this);
10065 MEDFileFieldsIterator *MEDFileFields::iterator()
10067 return new MEDFileFieldsIterator(this);
10070 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
10072 std::string tmp(fieldName);
10073 std::vector<std::string> poss;
10074 for(std::size_t i=0;i<_fields.size();i++)
10076 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=_fields[i];
10079 std::string fname(f->getName());
10083 poss.push_back(fname);
10086 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
10087 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
10089 throw INTERP_KERNEL::Exception(oss.str().c_str());
10092 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
10097 _nb_iter=fs->getNumberOfFields();
10101 MEDFileFieldsIterator::~MEDFileFieldsIterator()
10105 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
10107 if(_iter_id<_nb_iter)
10109 MEDFileFields *fs(_fs);
10111 return fs->getFieldAtPos(_iter_id++);