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 !");
532 spd->getSlice(start,stop,step);
533 _nval=DataArray::GetNumberOfItemGivenBES(start,stop,step,"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());
574 int nbOfCompo(arr->getNumberOfComponents());
575 DataArrayDouble *arrD(dynamic_cast<DataArrayDouble *>(arr));
578 double *startFeeding(arrD->getPointer()+_start*nbOfCompo);
579 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
582 DataArrayInt *arrI(dynamic_cast<DataArrayInt *>(arr));
585 int *startFeeding(arrI->getPointer()+_start*nbOfCompo);
586 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
589 throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
593 * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
595 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart)
597 int delta=_end-_start;
598 _start=newValueOfStart;
602 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
604 return _father->getIteration();
607 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
609 return _father->getOrder();
612 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
614 return _father->getTime();
617 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
619 return _father->getMeshName();
622 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
624 const char startLine[]=" ## ";
625 std::string startLine2(bkOffset,' ');
626 startLine2+=startLine;
627 MEDCouplingFieldDiscretization *tmp=MEDCouplingFieldDiscretization::New(_type);
628 oss << startLine2 << "Localization #" << id << "." << std::endl;
629 oss << startLine2 << " Type=" << tmp->getRepr() << "." << std::endl;
631 oss << startLine2 << " This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
632 oss << startLine2 << " This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
633 oss << startLine2 << " This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
636 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
641 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
646 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
651 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
653 return _father->getGeoType();
656 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
658 return _father->getNumberOfComponents();
661 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
666 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray()
668 return _father->getOrCreateAndGetArray();
671 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const
673 const MEDFileFieldPerMeshPerType *fath=_father;
674 return fath->getOrCreateAndGetArray();
677 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
679 return _father->getInfo();
682 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
687 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const std::string& newPflName)
692 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
694 return _localization;
697 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const std::string& newLocName)
699 _localization=newLocName;
702 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
704 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
706 if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
708 _profile=(*it2).second;
714 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
716 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
718 if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
720 _localization=(*it2).second;
726 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
730 dads.push_back(std::pair<int,int>(_start,_end));
731 geoTypes.push_back(getGeoType());
736 pfls.push_back(glob->getProfile(_profile.c_str()));
738 if(_localization.empty())
742 locs.push_back(glob->getLocalizationId(_localization.c_str()));
746 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
748 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));
752 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
754 TypeOfField type=getType();
755 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
756 med_geometry_type mgeoti;
757 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
758 const DataArray *arr=getOrCreateAndGetArray();
760 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
761 const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
762 const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
763 const unsigned char *locToWrite=0;
765 locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
767 locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
769 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
770 MEDfieldValueWithProfileWr(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
771 MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
775 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const
780 dad.first=_start; dad.second=_end;
784 * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
785 * This code corresponds to the distribution of types in the corresponding mesh.
786 * \param [out] ptToFill memory zone where the output will be stored.
787 * \return the size of data pushed into output param \a ptToFill
789 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const
792 std::ostringstream oss;
793 std::size_t nbOfType=codeOfMesh.size()/3;
795 for(std::size_t i=0;i<nbOfType && found==-1;i++)
796 if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
800 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
801 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
802 throw INTERP_KERNEL::Exception(oss.str().c_str());
807 if(_nval!=codeOfMesh[3*found+1])
809 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
810 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
811 oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
812 throw INTERP_KERNEL::Exception(oss.str().c_str());
814 for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
819 const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
820 if(pfl->getNumberOfTuples()!=_nval)
822 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
823 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
825 oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
826 throw INTERP_KERNEL::Exception(oss.str().c_str());
828 int offset2=codeOfMesh[3*found+2];
829 for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
831 if(*pflId<codeOfMesh[3*found+1])
832 *work++=offset2+*pflId;
838 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const
840 for(int i=_start;i<_end;i++)
845 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId)
856 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
860 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
863 std::map<std::pair<std::string,TypeOfField>,int> m;
864 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
865 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
866 if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
867 m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
869 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
870 ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
875 * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
877 * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
878 * \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.
879 * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
880 * \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)
881 * \param [in,out] glob if necessary by the method, new profiles can be added to it
882 * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
883 * \param [out] result All new entries will be appended on it.
884 * \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 !)
886 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
887 const DataArrayInt *explicitIdsInMesh,
888 const std::vector<int>& newCode,
889 MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
890 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >& result)
892 if(entriesOnSameDisc.empty())
894 TypeOfField type=entriesOnSameDisc[0]->getType();
895 int szEntities=0,szTuples=0;
896 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
897 { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
898 int nbi=szTuples/szEntities;
899 if(szTuples%szEntities!=0)
900 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
901 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
902 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
903 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
904 std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
905 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
906 std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
907 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
909 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
911 int startOfEltIdOfChunk=(*it)->_start;
912 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newEltIds=explicitIdsInMesh->substr(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
913 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
914 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
916 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
917 newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
919 newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
920 newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
922 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
923 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
924 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
925 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
927 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
929 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arrPart=arr->substr(offset,offset+szTuples);
930 arrPart->renumberInPlace(renumTupleIds->begin());
931 arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
933 const int *idIt=diffVals->begin();
934 std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
936 for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
938 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=newGeoTypesEltIdsAllGather->getIdsEqual(*idIt);
939 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
940 int nbEntityElts=subIds->getNumberOfTuples();
942 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
943 NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIdentity() || nbEntityElts!=newCode[3*(*idIt)+1],nbi,
947 result.push_back(eltToAdd);
948 offset2+=nbEntityElts*nbi;
950 ret=ret || li.empty();
955 * \param [in] typeF type of field of new chunk
956 * \param [in] geoType the geometric type of the chunk
957 * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
958 * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
959 * \param [in] nbi number of integration points
960 * \param [in] offset The offset in the **global array of data**.
961 * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
962 * to the new chunk to create.
963 * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
964 * \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
965 * and corresponding entry erased from \a entriesOnSameDisc.
966 * \return a newly allocated chunk
968 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
969 bool isPfl, int nbi, int offset,
970 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
971 MEDFileFieldGlobsReal& glob,
974 int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
975 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
976 for(;it!=entriesOnSameDisc.end();it++)
978 if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
982 if((*it)->_profile.empty())
985 if(!(*it)->_profile.empty())
987 const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
988 if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
994 if(it==entriesOnSameDisc.end())
997 MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
999 ret->_loc_id=(int)geoType;
1000 ret->_nval=nbMeshEntities;
1002 ret->_end=ret->_start+ret->_nval*nbi;
1005 idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
1006 glob.appendProfile(idsOfMeshElt);
1007 ret->_profile=idsOfMeshElt->getName();
1009 //tony treatment of localization
1014 notInExisting=false;
1015 MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1016 ret->_loc_id=(int)geoType;
1017 ret->setNewStart(offset);
1018 entriesOnSameDisc.erase(it);
1024 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd)
1026 return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc,pd);
1029 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType)
1031 return new MEDFileFieldPerMeshPerType(fath,geoType);
1034 std::size_t MEDFileFieldPerMeshPerType::getHeapMemorySizeWithoutChildren() const
1036 return _field_pm_pt_pd.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc>);
1039 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerType::getDirectChildrenWithNull() const
1041 std::vector<const BigMemoryObject *> ret;
1042 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1043 ret.push_back((const MEDFileFieldPerMeshPerTypePerDisc *)*it);
1047 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCpy(MEDFileFieldPerMesh *father) const
1049 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
1050 ret->_father=father;
1052 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1054 if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
1055 ret->_field_pm_pt_pd[i]=(*it)->deepCpy((MEDFileFieldPerMeshPerType *)ret);
1060 void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1062 std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
1063 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1064 _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1068 * This method is the most general one. No optimization is done here.
1069 * \param [in] multiTypePfl is the end user profile specified in high level API
1070 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1071 * \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.
1072 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1073 * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1074 * \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.
1076 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)
1078 std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1079 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1080 _field_pm_pt_pd[*it]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1083 void MEDFileFieldPerMeshPerType::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1085 _field_pm_pt_pd.resize(1);
1086 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1087 _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1090 void MEDFileFieldPerMeshPerType::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1092 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2=pfl->deepCpy();
1093 if(!arr || !arr->isAllocated())
1094 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::assignNodeFieldProfile : input array is null, or not allocated !");
1095 _field_pm_pt_pd.resize(1);
1096 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1097 _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.
1100 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1102 TypeOfField type=field->getTypeOfField();
1103 if(type!=ON_GAUSS_PT)
1105 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1106 int sz=_field_pm_pt_pd.size();
1108 for(int j=0;j<sz && !found;j++)
1110 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1112 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1118 _field_pm_pt_pd.resize(sz+1);
1119 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1121 std::vector<int> ret(1,(int)sz);
1126 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1127 int sz2=ret2.size();
1128 std::vector<int> ret3(sz2);
1130 for(int i=0;i<sz2;i++)
1132 int sz=_field_pm_pt_pd.size();
1133 int locIdToFind=ret2[i];
1135 for(int j=0;j<sz && !found;j++)
1137 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1139 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1146 _field_pm_pt_pd.resize(sz+1);
1147 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1155 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1157 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1158 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1160 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1161 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1163 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1164 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleId2(offset,offset+nbOfCells,1);
1165 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1166 if(retTmp->presenceOfValue(-1))
1167 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1168 std::vector<int> ret(retTmp->begin(),retTmp->end());
1172 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1174 TypeOfField type=field->getTypeOfField();
1175 if(type!=ON_GAUSS_PT)
1177 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1178 int sz=_field_pm_pt_pd.size();
1180 for(int j=0;j<sz && !found;j++)
1182 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1184 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1190 _field_pm_pt_pd.resize(sz+1);
1191 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1193 std::vector<int> ret(1,0);
1198 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1199 int sz2=ret2.size();
1200 std::vector<int> ret3(sz2);
1202 for(int i=0;i<sz2;i++)
1204 int sz=_field_pm_pt_pd.size();
1205 int locIdToFind=ret2[i];
1207 for(int j=0;j<sz && !found;j++)
1209 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1211 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1218 _field_pm_pt_pd.resize(sz+1);
1219 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1227 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1229 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1230 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1232 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1233 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1235 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1236 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1237 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1238 if(retTmp->presenceOfValue(-1))
1239 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1240 std::vector<int> ret(retTmp->begin(),retTmp->end());
1244 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerType::getFather() const
1249 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1251 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1252 int curDim=(int)cm.getDimension();
1253 dim=std::max(dim,curDim);
1256 void MEDFileFieldPerMeshPerType::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1258 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1260 (*it)->fillTypesOfFieldAvailable(types);
1264 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
1266 int sz=_field_pm_pt_pd.size();
1267 dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1268 for(int i=0;i<sz;i++)
1270 _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1274 int MEDFileFieldPerMeshPerType::getIteration() const
1276 return _father->getIteration();
1279 int MEDFileFieldPerMeshPerType::getOrder() const
1281 return _father->getOrder();
1284 double MEDFileFieldPerMeshPerType::getTime() const
1286 return _father->getTime();
1289 std::string MEDFileFieldPerMeshPerType::getMeshName() const
1291 return _father->getMeshName();
1294 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1296 const char startLine[]=" ## ";
1297 std::string startLine2(bkOffset,' ');
1298 std::string startLine3(startLine2);
1299 startLine3+=startLine;
1300 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1302 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1303 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1306 oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1307 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1309 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1311 const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1313 cur->simpleRepr(bkOffset,oss,i);
1316 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1321 void MEDFileFieldPerMeshPerType::getSizes(int& globalSz, int& nbOfEntries) const
1323 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1325 globalSz+=(*it)->getNumberOfTuples();
1327 nbOfEntries+=(int)_field_pm_pt_pd.size();
1330 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1336 int MEDFileFieldPerMeshPerType::getNumberOfComponents() const
1338 return _father->getNumberOfComponents();
1341 DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray()
1343 return _father->getOrCreateAndGetArray();
1346 const DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray() const
1348 const MEDFileFieldPerMesh *fath=_father;
1349 return fath->getOrCreateAndGetArray();
1352 const std::vector<std::string>& MEDFileFieldPerMeshPerType::getInfo() const
1354 return _father->getInfo();
1357 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsed() const
1359 std::vector<std::string> ret;
1360 std::set<std::string> ret2;
1361 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1363 std::string tmp=(*it1)->getProfile();
1365 if(ret2.find(tmp)==ret2.end())
1374 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsed() const
1376 std::vector<std::string> ret;
1377 std::set<std::string> ret2;
1378 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1380 std::string tmp=(*it1)->getLocalization();
1381 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1382 if(ret2.find(tmp)==ret2.end())
1391 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsedMulti() const
1393 std::vector<std::string> ret;
1394 std::set<std::string> ret2;
1395 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1397 std::string tmp=(*it1)->getProfile();
1404 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsedMulti() const
1406 std::vector<std::string> ret;
1407 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1409 std::string tmp=(*it1)->getLocalization();
1410 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1416 void MEDFileFieldPerMeshPerType::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1418 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1419 (*it1)->changePflsRefsNamesGen(mapOfModif);
1422 void MEDFileFieldPerMeshPerType::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1424 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1425 (*it1)->changeLocsRefsNamesGen(mapOfModif);
1428 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId)
1430 if(_field_pm_pt_pd.empty())
1432 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1433 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1434 throw INTERP_KERNEL::Exception(oss.str().c_str());
1436 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1437 return _field_pm_pt_pd[locId];
1438 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1439 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1440 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1441 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1442 return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1445 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) const
1447 if(_field_pm_pt_pd.empty())
1449 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1450 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1451 throw INTERP_KERNEL::Exception(oss.str().c_str());
1453 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1454 return _field_pm_pt_pd[locId];
1455 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1456 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1457 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1458 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1459 return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1462 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
1464 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1466 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1467 if(meshDim!=(int)cm.getDimension())
1470 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1471 (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1474 void MEDFileFieldPerMeshPerType::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1477 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1479 (*it)->fillValues(i,startEntryId,entries);
1483 void MEDFileFieldPerMeshPerType::setLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
1485 _field_pm_pt_pd=leaves;
1486 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1487 (*it)->setFather(this);
1491 * \param [in,out] globalNum a global numbering counter for the renumbering.
1492 * \param [out] its - list of pair (start,stop) kept
1493 * \return bool - false if the type of field \a tof is not contained in \a this.
1495 bool MEDFileFieldPerMeshPerType::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
1498 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1499 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1500 if((*it)->getType()==tof)
1502 newPmPtPd.push_back(*it);
1503 std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1504 (*it)->setNewStart(globalNum);
1505 globalNum=(*it)->getEnd();
1506 its.push_back(bgEnd);
1510 _field_pm_pt_pd=newPmPtPd;
1514 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType):_father(fath),_geo_type(geoType)
1518 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):_father(fath),_geo_type(geoType)
1520 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1521 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1522 med_geometry_type mgeoti;
1523 med_entity_type menti(ConvertIntoMEDFileType(type,geoType,mgeoti));
1524 int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName));
1525 _field_pm_pt_pd.resize(nbProfiles);
1526 for(int i=0;i<nbProfiles;i++)
1528 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i,pd);
1532 int nbProfiles2=MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName);
1533 for(int i=0;i<nbProfiles2;i++)
1534 _field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i,pd));
1538 void MEDFileFieldPerMeshPerType::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
1540 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1541 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1544 void MEDFileFieldPerMeshPerType::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1546 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1547 (*it)->loadBigArray(fid,nasc);
1550 void MEDFileFieldPerMeshPerType::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1552 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1554 (*it)->copyOptionsFrom(*this);
1555 (*it)->writeLL(fid,nasc);
1559 med_entity_type MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1564 medfGeoType=typmai3[(int)ikGeoType];
1567 medfGeoType=MED_NONE;
1570 medfGeoType=typmai3[(int)ikGeoType];
1571 return MED_NODE_ELEMENT;
1573 medfGeoType=typmai3[(int)ikGeoType];
1576 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1578 return MED_UNDEF_ENTITY_TYPE;
1581 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm)
1583 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm);
1586 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1588 return new MEDFileFieldPerMesh(fath,mesh);
1591 std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
1593 return _mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType >);
1596 std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildrenWithNull() const
1598 std::vector<const BigMemoryObject *> ret;
1599 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1600 ret.push_back((const MEDFileFieldPerMeshPerType *)*it);
1604 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCpy(MEDFileAnyTypeField1TSWithoutSDA *father) const
1606 MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1607 ret->_father=father;
1609 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1611 if((const MEDFileFieldPerMeshPerType *)*it)
1612 ret->_field_pm_pt[i]=(*it)->deepCpy((MEDFileFieldPerMesh *)(ret));
1617 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1619 std::string startLine(bkOffset,' ');
1620 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1621 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1623 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1625 const MEDFileFieldPerMeshPerType *cur=*it;
1627 cur->simpleRepr(bkOffset,oss,i);
1630 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1635 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh)
1637 _mesh_name=mesh->getName();
1638 mesh->getTime(_mesh_iteration,_mesh_order);
1641 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1643 int nbOfTypes=code.size()/3;
1645 for(int i=0;i<nbOfTypes;i++)
1647 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1648 int nbOfCells=code[3*i+1];
1649 int pos=addNewEntryIfNecessary(type);
1650 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1656 * This method is the most general one. No optimization is done here.
1657 * \param [in] multiTypePfl is the end user profile specified in high level API
1658 * \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].
1659 * \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.
1660 * \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.
1661 * \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.
1662 * \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.
1664 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)
1666 int nbOfTypes(code.size()/3);
1667 for(int i=0;i<nbOfTypes;i++)
1669 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1670 int pos=addNewEntryIfNecessary(type);
1671 DataArrayInt *pfl=0;
1673 pfl=idsPerType[code[3*i+2]];
1674 int nbOfTupes2=code2.size()/3;
1676 for(;found<nbOfTupes2;found++)
1677 if(code[3*i]==code2[3*found])
1679 if(found==nbOfTupes2)
1680 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1681 _field_pm_pt[pos]->assignFieldProfile(nbOfTypes==1,start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1685 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1687 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1688 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1691 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1693 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1694 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1697 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
1699 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1700 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1703 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1705 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1706 (*it)->loadBigArraysRecursively(fid,nasc);
1709 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1711 int nbOfTypes=_field_pm_pt.size();
1712 for(int i=0;i<nbOfTypes;i++)
1714 _field_pm_pt[i]->copyOptionsFrom(*this);
1715 _field_pm_pt[i]->writeLL(fid,nasc);
1719 void MEDFileFieldPerMesh::getDimension(int& dim) const
1721 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1722 (*it)->getDimension(dim);
1725 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1727 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1728 (*it)->fillTypesOfFieldAvailable(types);
1731 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
1733 int sz=_field_pm_pt.size();
1734 std::vector< std::vector<std::pair<int,int> > > ret(sz);
1735 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1736 for(int i=0;i<sz;i++)
1738 types[i]=_field_pm_pt[i]->getGeoType();
1739 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1744 double MEDFileFieldPerMesh::getTime() const
1747 return _father->getTime(tmp1,tmp2);
1750 int MEDFileFieldPerMesh::getIteration() const
1752 return _father->getIteration();
1755 int MEDFileFieldPerMesh::getOrder() const
1757 return _father->getOrder();
1760 int MEDFileFieldPerMesh::getNumberOfComponents() const
1762 return _father->getNumberOfComponents();
1765 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
1768 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1769 return _father->getOrCreateAndGetArray();
1772 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
1775 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1776 return _father->getOrCreateAndGetArray();
1779 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1781 return _father->getInfo();
1785 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
1786 * 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.
1787 * It returns 2 output vectors :
1788 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
1789 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
1790 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
1792 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)
1794 int notNullPflsSz=0;
1795 int nbOfArrs=geoTypes.size();
1796 for(int i=0;i<nbOfArrs;i++)
1799 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
1800 int nbOfDiffGeoTypes=geoTypes3.size();
1801 code.resize(3*nbOfDiffGeoTypes);
1802 notNullPfls.resize(notNullPflsSz);
1805 for(int i=0;i<nbOfDiffGeoTypes;i++)
1808 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
1809 std::vector<const DataArrayInt *> notNullTmp;
1811 notNullTmp.push_back(pfls[j]);
1813 for(;j<nbOfArrs;j++)
1814 if(geoTypes[j]==refType)
1817 notNullTmp.push_back(pfls[j]);
1821 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
1822 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
1823 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
1824 code[3*i]=(int)refType;
1825 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
1826 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
1827 if(notNullTmp.empty())
1831 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
1832 code[3*i+2]=notNullPflsSz++;
1838 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
1840 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)
1844 for(int i=0;i<sz;i++)
1848 if(type!=ON_GAUSS_NE)
1849 ret+=dads[i].second-dads[i].first;
1852 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
1853 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
1858 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
1859 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
1865 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
1867 std::vector<std::string> ret;
1868 std::set<std::string> ret2;
1869 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1871 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
1872 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1873 if(ret2.find(*it2)==ret2.end())
1875 ret.push_back(*it2);
1882 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
1884 std::vector<std::string> ret;
1885 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1887 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
1888 ret.insert(ret.end(),tmp.begin(),tmp.end());
1893 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
1895 std::vector<std::string> ret;
1896 std::set<std::string> ret2;
1897 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1899 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
1900 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1901 if(ret2.find(*it2)==ret2.end())
1903 ret.push_back(*it2);
1910 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
1912 std::vector<std::string> ret;
1913 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1915 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
1916 ret.insert(ret.end(),tmp.begin(),tmp.end());
1921 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
1923 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
1925 if((*it).first==_mesh_name)
1927 _mesh_name=(*it).second;
1934 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
1935 MEDFileFieldGlobsReal& glob)
1937 if(_mesh_name!=meshName)
1939 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
1940 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
1941 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
1942 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
1943 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
1944 getUndergroundDataArrayExt(entries);
1945 DataArray *arr0=getOrCreateAndGetArray();//tony
1947 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
1948 DataArrayDouble *arr=dynamic_cast<DataArrayDouble *>(arr0);//tony
1950 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
1953 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
1954 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
1956 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
1958 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1959 sz+=(*it).second.second-(*it).second.first;
1962 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1964 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
1965 ////////////////////
1966 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
1967 int *workI2=explicitIdsOldInMesh->getPointer();
1968 int sz1=0,sz2=0,sid=1;
1969 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
1970 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
1971 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
1973 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
1974 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
1975 int *workI=explicitIdsOldInArr->getPointer();
1976 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
1978 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
1979 (*itL2)->setLocId(sz2);
1980 (*itL2)->_tmp_work1=(*itL2)->getStart();
1981 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
1983 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
1985 explicitIdsOldInMesh->reAlloc(sz2);
1986 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
1987 ////////////////////
1988 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
1989 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
1990 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
1991 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
1993 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
1994 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
1995 otherEntriesNew.back()->setLocId((*it)->getGeoType());
1997 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
1998 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
1999 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
2001 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
2002 int newStart=elt->getLocId();
2003 elt->setLocId((*it)->getGeoType());
2004 elt->setNewStart(newStart);
2005 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
2006 entriesKeptNew.push_back(elt);
2007 entriesKeptNew2.push_back(elt);
2009 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
2010 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
2011 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
2012 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
2014 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
2017 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
2019 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
2020 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
2022 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
2023 glob,arr2,otherEntriesNew) || ret;
2027 // Assign new dispatching
2028 assignNewLeaves(otherEntriesNew);
2029 arr->cpyFrom(*arr2);
2034 * \param [in,out] globalNum a global numbering counter for the renumbering.
2035 * \param [out] its - list of pair (start,stop) kept
2037 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
2039 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > ret;
2040 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2042 std::vector< std::pair<int,int> > its2;
2043 if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
2046 its.insert(its.end(),its2.begin(),its2.end());
2052 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
2054 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > > types;
2055 for( std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
2056 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
2058 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > fieldPmPt(types.size());
2059 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
2060 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=fieldPmPt.begin();
2061 for(;it1!=types.end();it1++,it2++)
2063 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
2064 elt->setLeaves((*it1).second);
2067 _field_pm_pt=fieldPmPt;
2070 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2072 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2073 (*it)->changePflsRefsNamesGen(mapOfModif);
2076 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2078 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2079 (*it)->changeLocsRefsNamesGen(mapOfModif);
2083 * \param [in] mesh is the whole mesh
2085 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2087 if(_field_pm_pt.empty())
2088 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2090 std::vector< std::pair<int,int> > dads;
2091 std::vector<const DataArrayInt *> pfls;
2092 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2093 std::vector<int> locs,code;
2094 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2095 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2096 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2098 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2101 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2102 throw INTERP_KERNEL::Exception(oss.str().c_str());
2105 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2106 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2109 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2111 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2114 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr);
2115 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2121 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2125 if(nb!=mesh->getNumberOfNodes())
2127 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2128 oss << " nodes in mesh !";
2129 throw INTERP_KERNEL::Exception(oss.str().c_str());
2131 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2134 return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2138 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
2140 if(_field_pm_pt.empty())
2141 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2143 std::vector<std::pair<int,int> > dads;
2144 std::vector<const DataArrayInt *> pfls;
2145 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2146 std::vector<int> locs,code;
2147 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2148 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2149 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2151 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2154 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2155 throw INTERP_KERNEL::Exception(oss.str().c_str());
2157 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2158 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2161 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2162 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2167 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2171 if(nb!=mesh->getNumberOfNodes())
2173 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2174 oss << " nodes in mesh !";
2175 throw INTERP_KERNEL::Exception(oss.str().c_str());
2178 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2184 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
2188 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2190 (*it)->getSizes(globalSz,nbOfEntries);
2192 entries.resize(nbOfEntries);
2194 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2196 (*it)->fillValues(nbOfEntries,entries);
2200 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
2202 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2204 if((*it)->getGeoType()==typ)
2205 return (*it)->getLeafGivenLocId(locId);
2207 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2208 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2209 oss << "Possiblities are : ";
2210 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2212 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2213 oss << "\"" << cm2.getRepr() << "\", ";
2215 throw INTERP_KERNEL::Exception(oss.str().c_str());
2218 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
2220 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2222 if((*it)->getGeoType()==typ)
2223 return (*it)->getLeafGivenLocId(locId);
2225 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2226 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2227 oss << "Possiblities are : ";
2228 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2230 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2231 oss << "\"" << cm2.getRepr() << "\", ";
2233 throw INTERP_KERNEL::Exception(oss.str().c_str());
2236 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2239 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2240 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=_field_pm_pt.begin();
2241 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2243 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2248 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2253 int ret=std::distance(_field_pm_pt.begin(),it2);
2254 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2259 * 'dads' and 'locs' input parameters have the same number of elements
2260 * \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
2262 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2263 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2264 const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2267 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2268 ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2269 MEDCouplingAutoRefCountObjectPtr<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2270 const std::vector<std::string>& infos=getInfo();
2271 da->setInfoOnComponents(infos);
2273 if(type==ON_GAUSS_PT)
2276 int nbOfArrs=dads.size();
2277 for(int i=0;i<nbOfArrs;i++)
2279 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2280 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2281 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2282 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> di=DataArrayInt::New();
2283 di->alloc(nbOfElems,1);
2285 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2286 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2295 * 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.
2296 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2297 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2298 * The order of cells in the returned field is those imposed by the profile.
2299 * \param [in] mesh is the global mesh.
2301 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2302 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2303 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2304 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2306 if(da->isIdentity())
2308 int nbOfTuples=da->getNumberOfTuples();
2309 if(nbOfTuples==mesh->getNumberOfCells())
2310 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2312 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2313 m2->setName(mesh->getName().c_str());
2314 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2320 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2322 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2323 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2324 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2326 if(da->isIdentity())
2328 int nbOfTuples=da->getNumberOfTuples();
2329 if(nbOfTuples==mesh->getNumberOfNodes())//No problem for NORM_ERROR because it is in context of node
2330 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2332 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2333 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2336 if(meshu->getNodalConnectivity()==0)
2338 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2339 int nb=da->getNbOfElems();
2340 const int *ptr=da->getConstPointer();
2341 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2342 meshuc->allocateCells(nb);
2343 for(int i=0;i<nb;i++)
2344 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2345 meshuc->finishInsertingCells();
2346 ret->setMesh(meshuc);
2347 const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2348 if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2349 disc->checkCoherencyBetween(meshuc,arrOut);
2354 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2356 DataArrayInt *arr2=0;
2357 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2358 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2359 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3(arr2);
2360 int nnodes=mesh2->getNumberOfNodes();
2361 if(nnodes==(int)da->getNbOfElems())
2363 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2364 arrOut->renumberInPlace(da3->getConstPointer());
2365 mesh2->setName(mesh->getName().c_str());
2366 ret->setMesh(mesh2);
2371 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 !!!";
2372 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2373 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2374 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2375 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2376 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2377 throw INTERP_KERNEL::Exception(oss.str().c_str());
2383 * This method is the most light method of field retrieving.
2385 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
2389 pflOut=DataArrayInt::New();
2390 pflOut->alloc(nbOfElems,1);
2395 pflOut=const_cast<DataArrayInt*>(pflIn);
2398 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> safePfl(pflOut);
2399 MEDCouplingAutoRefCountObjectPtr<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2400 const std::vector<std::string>& infos=getInfo();
2401 int nbOfComp=infos.size();
2402 for(int i=0;i<nbOfComp;i++)
2403 da->setInfoOnComponent(i,infos[i].c_str());
2408 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),
2411 INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2412 INTERP_KERNEL::AutoPtr<char> pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2413 INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2414 const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
2415 for(int i=0;i<MED_N_CELL_FIXED_GEO;i++)
2417 int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL ,typmai[i],meshCsit+1,meshName,pflName,locName));
2418 std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2419 int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[i],meshCsit+1,meshName,pflName,locName));
2420 std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2421 if(nbProfile>0 || nbProfile2>0)
2423 const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
2424 const PartDefinition *pd(0);
2426 pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[i]),typmai2[i]);
2427 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[i],nasc,pd));
2434 int nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName);
2437 const PartDefinition *pd(0);
2439 pd=mmu->getPartDefAtLevel(1,INTERP_KERNEL::NORM_ERROR);
2440 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd));
2441 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2445 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2447 copyTinyInfoFrom(mesh);
2450 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
2452 if(id>=(int)_pfls.size())
2454 _pfls[id]=DataArrayInt::New();
2455 int lgth=MEDprofileSizeByName(fid,pflName.c_str());
2456 _pfls[id]->setName(pflName);
2457 _pfls[id]->alloc(lgth,1);
2458 MEDprofileRd(fid,pflName.c_str(),_pfls[id]->getPointer());
2459 _pfls[id]->applyLin(1,-1,0);//Converting into C format
2462 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2464 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2466 MEDprofileInfo(fid,i+1,pflName,&sz);
2467 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2468 if(i>=(int)_pfls.size())
2470 _pfls[i]=DataArrayInt::New();
2471 _pfls[i]->alloc(sz,1);
2472 _pfls[i]->setName(pflCpp.c_str());
2473 MEDprofileRd(fid,pflName,_pfls[i]->getPointer());
2474 _pfls[i]->applyLin(1,-1,0);//Converting into C format
2477 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
2479 int nbOfPfls=_pfls.size();
2480 for(int i=0;i<nbOfPfls;i++)
2482 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cpy=_pfls[i]->deepCpy();
2483 cpy->applyLin(1,1,0);
2484 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2485 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2486 MEDprofileWr(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer());
2489 int nbOfLocs=_locs.size();
2490 for(int i=0;i<nbOfLocs;i++)
2491 _locs[i]->writeLL(fid);
2494 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
2496 std::vector<std::string> pfls=getPfls();
2497 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2499 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2502 _pfls.push_back(*it);
2506 int id=std::distance(pfls.begin(),it2);
2507 if(!(*it)->isEqual(*_pfls[id]))
2509 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2510 throw INTERP_KERNEL::Exception(oss.str().c_str());
2514 std::vector<std::string> locs=getLocs();
2515 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
2517 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2520 _locs.push_back(*it);
2524 int id=std::distance(locs.begin(),it2);
2525 if(!(*it)->isEqual(*_locs[id],eps))
2527 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2528 throw INTERP_KERNEL::Exception(oss.str().c_str());
2534 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
2536 for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
2537 getProfile((*it).c_str());
2540 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
2542 for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
2543 getLocalization((*it).c_str());
2546 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
2548 std::vector<std::string> profiles=real.getPflsReallyUsed();
2549 int sz=profiles.size();
2551 for(int i=0;i<sz;i++)
2552 loadProfileInFile(fid,i,profiles[i].c_str());
2554 std::vector<std::string> locs=real.getLocsReallyUsed();
2557 for(int i=0;i<sz;i++)
2558 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2561 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid)
2563 int nProfil=MEDnProfile(fid);
2564 for(int i=0;i<nProfil;i++)
2565 loadProfileInFile(fid,i);
2566 int sz=MEDnLocalization(fid);
2568 for(int i=0;i<sz;i++)
2570 _locs[i]=MEDFileFieldLoc::New(fid,i);
2574 MEDFileFieldGlobs *MEDFileFieldGlobs::New(const std::string& fname)
2576 return new MEDFileFieldGlobs(fname);
2579 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2581 return new MEDFileFieldGlobs;
2584 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
2586 return _file_name.capacity()+_pfls.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<DataArrayInt>)+_locs.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>);
2589 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildrenWithNull() const
2591 std::vector<const BigMemoryObject *> ret;
2592 for(std::vector< MEDCouplingAutoRefCountObjectPtr< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2593 ret.push_back((const DataArrayInt *)*it);
2594 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2595 ret.push_back((const MEDFileFieldLoc *)*it);
2599 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpy() const
2601 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
2603 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2605 if((const DataArrayInt *)*it)
2606 ret->_pfls[i]=(*it)->deepCpy();
2609 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2611 if((const MEDFileFieldLoc*)*it)
2612 ret->_locs[i]=(*it)->deepCpy();
2618 * \throw if a profile in \a pfls in not in \a this.
2619 * \throw if a localization in \a locs in not in \a this.
2620 * \sa MEDFileFieldGlobs::deepCpyPart
2622 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2624 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2625 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2627 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2629 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
2631 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2(pfl);
2632 ret->_pfls.push_back(pfl2);
2634 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2636 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2638 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
2640 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> loc2(loc);
2641 ret->_locs.push_back(loc2);
2643 ret->setFileName(getFileName());
2648 * \throw if a profile in \a pfls in not in \a this.
2649 * \throw if a localization in \a locs in not in \a this.
2650 * \sa MEDFileFieldGlobs::shallowCpyPart
2652 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2654 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2655 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2657 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2659 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
2660 ret->_pfls.push_back(pfl->deepCpy());
2662 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2664 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2666 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
2667 ret->_locs.push_back(loc->deepCpy());
2669 ret->setFileName(getFileName());
2673 MEDFileFieldGlobs::MEDFileFieldGlobs(const std::string& fname):_file_name(fname)
2677 MEDFileFieldGlobs::MEDFileFieldGlobs()
2681 MEDFileFieldGlobs::~MEDFileFieldGlobs()
2685 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
2687 oss << "Profiles :\n";
2688 std::size_t n=_pfls.size();
2689 for(std::size_t i=0;i<n;i++)
2691 oss << " - #" << i << " ";
2692 const DataArrayInt *pfl=_pfls[i];
2694 oss << "\"" << pfl->getName() << "\"\n";
2699 oss << "Localizations :\n";
2700 for(std::size_t i=0;i<n;i++)
2702 oss << " - #" << i << " ";
2703 const MEDFileFieldLoc *loc=_locs[i];
2705 loc->simpleRepr(oss);
2711 void MEDFileFieldGlobs::setFileName(const std::string& fileName)
2713 _file_name=fileName;
2716 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2718 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
2720 DataArrayInt *elt(*it);
2723 std::string name(elt->getName());
2724 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2726 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2728 elt->setName((*it2).second.c_str());
2736 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2738 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
2740 MEDFileFieldLoc *elt(*it);
2743 std::string name(elt->getName());
2744 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2746 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2748 elt->setName((*it2).second.c_str());
2756 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
2758 if(locId<0 || locId>=(int)_locs.size())
2759 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
2760 return _locs[locId]->getNbOfGaussPtPerCell();
2763 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
2765 return getLocalizationFromId(getLocalizationId(locName));
2768 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
2770 if(locId<0 || locId>=(int)_locs.size())
2771 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2772 return *_locs[locId];
2775 namespace ParaMEDMEMImpl
2780 LocFinder(const std::string& loc):_loc(loc) { }
2781 bool operator() (const MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
2783 const std::string &_loc;
2789 PflFinder(const std::string& pfl):_pfl(pfl) { }
2790 bool operator() (const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
2792 const std::string& _pfl;
2796 int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
2798 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),ParaMEDMEMImpl::LocFinder(loc));
2801 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
2802 for(it=_locs.begin();it!=_locs.end();it++)
2803 oss << "\"" << (*it)->getName() << "\", ";
2804 throw INTERP_KERNEL::Exception(oss.str().c_str());
2806 return std::distance(_locs.begin(),it);
2810 * The returned value is never null.
2812 const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
2814 std::string pflNameCpp(pflName);
2815 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2818 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2819 for(it=_pfls.begin();it!=_pfls.end();it++)
2820 oss << "\"" << (*it)->getName() << "\", ";
2821 throw INTERP_KERNEL::Exception(oss.str().c_str());
2826 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
2828 if(pflId<0 || pflId>=(int)_pfls.size())
2829 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2830 return _pfls[pflId];
2833 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
2835 if(locId<0 || locId>=(int)_locs.size())
2836 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2837 return *_locs[locId];
2840 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
2842 return getLocalizationFromId(getLocalizationId(locName));
2846 * The returned value is never null.
2848 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
2850 std::string pflNameCpp(pflName);
2851 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2854 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2855 for(it=_pfls.begin();it!=_pfls.end();it++)
2856 oss << "\"" << (*it)->getName() << "\", ";
2857 throw INTERP_KERNEL::Exception(oss.str().c_str());
2862 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
2864 if(pflId<0 || pflId>=(int)_pfls.size())
2865 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2866 return _pfls[pflId];
2869 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
2871 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newPfls;
2873 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2875 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
2876 newPfls.push_back(*it);
2881 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
2883 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> > newLocs;
2885 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2887 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
2888 newLocs.push_back(*it);
2893 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
2895 int sz=_pfls.size();
2896 std::vector<std::string> ret(sz);
2897 for(int i=0;i<sz;i++)
2898 ret[i]=_pfls[i]->getName();
2902 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
2904 int sz=_locs.size();
2905 std::vector<std::string> ret(sz);
2906 for(int i=0;i<sz;i++)
2907 ret[i]=_locs[i]->getName();
2911 bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
2913 std::vector<std::string> v=getPfls();
2914 std::string s(pflName);
2915 return std::find(v.begin(),v.end(),s)!=v.end();
2918 bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
2920 std::vector<std::string> v=getLocs();
2921 std::string s(locName);
2922 return std::find(v.begin(),v.end(),s)!=v.end();
2925 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
2927 std::map<int,std::vector<int> > m;
2929 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2931 const DataArrayInt *tmp=(*it);
2934 m[tmp->getHashCode()].push_back(i);
2937 std::vector< std::vector<int> > ret;
2938 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
2940 if((*it2).second.size()>1)
2942 std::vector<int> ret0;
2943 bool equalityOrNot=false;
2944 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
2946 std::vector<int>::const_iterator it4=it3; it4++;
2947 for(;it4!=(*it2).second.end();it4++)
2949 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
2952 ret0.push_back(*it3);
2953 ret0.push_back(*it4);
2959 ret.push_back(ret0);
2965 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
2967 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
2970 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
2972 std::string name(pfl->getName());
2974 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
2975 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2976 if(name==(*it)->getName())
2978 if(!pfl->isEqual(*(*it)))
2980 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
2981 throw INTERP_KERNEL::Exception(oss.str().c_str());
2985 _pfls.push_back(pfl);
2988 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)
2990 std::string name(locName);
2992 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
2993 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
2994 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2995 if((*it)->isName(locName))
2997 if(!(*it)->isEqual(*obj,1e-12))
2999 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
3000 throw INTERP_KERNEL::Exception(oss.str().c_str());
3003 _locs.push_back(obj);
3006 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
3008 std::vector<std::string> names=getPfls();
3009 return CreateNewNameNotIn("NewPfl_",names);
3012 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
3014 std::vector<std::string> names=getLocs();
3015 return CreateNewNameNotIn("NewLoc_",names);
3018 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
3020 for(std::size_t sz=0;sz<100000;sz++)
3022 std::ostringstream tryName;
3023 tryName << prefix << sz;
3024 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
3025 return tryName.str();
3027 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
3031 * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
3032 * \param [in] fname - the file name.
3034 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(const std::string& fname):_globals(MEDFileFieldGlobs::New(fname))
3039 * Creates an empty MEDFileFieldGlobsReal.
3041 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
3045 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
3050 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildrenWithNull() const
3052 std::vector<const BigMemoryObject *> ret;
3053 ret.push_back((const MEDFileFieldGlobs *)_globals);
3058 * Returns a string describing profiles and Gauss points held in \a this.
3059 * \return std::string - the description string.
3061 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
3063 const MEDFileFieldGlobs *glob=_globals;
3064 std::ostringstream oss2; oss2 << glob;
3065 std::string stars(oss2.str().length(),'*');
3066 oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n";
3068 glob->simpleRepr(oss);
3070 oss << "NO GLOBAL INFORMATION !\n";
3073 void MEDFileFieldGlobsReal::resetContent()
3075 _globals=MEDFileFieldGlobs::New();
3078 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
3083 * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
3084 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3086 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3088 _globals=other._globals;
3092 * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3093 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3095 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3097 const MEDFileFieldGlobs *otherg(other._globals);
3100 _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3104 * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3105 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3107 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3109 const MEDFileFieldGlobs *otherg(other._globals);
3112 _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3115 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3117 _globals=other._globals;
3118 if((const MEDFileFieldGlobs *)_globals)
3119 _globals=other._globals->deepCpy();
3123 * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3124 * \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3125 * \param [in] eps - a precision used to compare Gauss points with same name held by
3126 * \a this and \a other MEDFileFieldGlobsReal.
3127 * \throw If \a this and \a other hold profiles with equal names but different ids.
3128 * \throw If \a this and \a other hold different Gauss points with equal names.
3130 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
3132 const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3133 if(thisGlobals==otherGlobals)
3137 _globals=other._globals;
3140 _globals->appendGlobs(*other._globals,eps);
3143 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
3145 checkGlobsPflsPartCoherency();
3146 checkGlobsLocsPartCoherency();
3149 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
3151 contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3154 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
3156 contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3159 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3161 contentNotNull()->loadProfileInFile(fid,id,pflName);
3164 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3166 contentNotNull()->loadProfileInFile(fid,id);
3169 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
3171 contentNotNull()->loadGlobals(fid,*this);
3174 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid)
3176 contentNotNull()->loadAllGlobals(fid);
3179 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3181 contentNotNull()->writeGlobals(fid,opt);
3185 * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3186 * or getPflsReallyUsedMulti().
3187 * \return std::vector<std::string> - a sequence of names of all profiles.
3189 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3191 return contentNotNull()->getPfls();
3195 * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3196 * or getLocsReallyUsedMulti().
3197 * \return std::vector<std::string> - a sequence of names of all localizations.
3199 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3201 return contentNotNull()->getLocs();
3205 * Checks if the profile with a given name exists.
3206 * \param [in] pflName - the profile name of interest.
3207 * \return bool - \c true if the profile named \a pflName exists.
3209 bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
3211 return contentNotNull()->existsPfl(pflName);
3215 * Checks if the localization with a given name exists.
3216 * \param [in] locName - the localization name of interest.
3217 * \return bool - \c true if the localization named \a locName exists.
3219 bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
3221 return contentNotNull()->existsLoc(locName);
3224 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
3226 return contentNotNull()->createNewNameOfPfl();
3229 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
3231 return contentNotNull()->createNewNameOfLoc();
3235 * Sets the name of a MED file.
3236 * \param [inout] fileName - the file name.
3238 void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
3240 contentNotNull()->setFileName(fileName);
3244 * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3245 * in the same order.
3246 * \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3247 * Each item of this sequence is a vector containing ids of equal profiles.
3249 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3251 return contentNotNull()->whichAreEqualProfiles();
3255 * Finds equal localizations.
3256 * \param [in] eps - a precision used to compare real values of the localizations.
3257 * \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3258 * Each item of this sequence is a vector containing ids of equal localizations.
3260 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3262 return contentNotNull()->whichAreEqualLocs(eps);
3266 * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3267 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3268 * this sequence is a pair whose
3269 * - the first item is a vector of profile names to replace by the second item,
3270 * - the second item is a profile name to replace every profile name of the first item.
3272 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3274 contentNotNull()->changePflsNamesInStruct(mapOfModif);
3278 * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3279 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3280 * this sequence is a pair whose
3281 * - the first item is a vector of localization names to replace by the second item,
3282 * - the second item is a localization name to replace every localization name of the first item.
3284 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3286 contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3290 * Replaces references to some profiles (a reference is a profile name) by references
3291 * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3292 * them-selves accordingly. <br>
3293 * This method is a generalization of changePflName().
3294 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3295 * this sequence is a pair whose
3296 * - the first item is a vector of profile names to replace by the second item,
3297 * - the second item is a profile name to replace every profile of the first item.
3298 * \sa changePflsRefsNamesGen()
3299 * \sa changePflName()
3301 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3303 changePflsRefsNamesGen(mapOfModif);
3304 changePflsNamesInStruct(mapOfModif);
3308 * Replaces references to some localizations (a reference is a localization name) by references
3309 * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3310 * them-selves accordingly. <br>
3311 * This method is a generalization of changeLocName().
3312 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3313 * this sequence is a pair whose
3314 * - the first item is a vector of localization names to replace by the second item,
3315 * - the second item is a localization name to replace every localization of the first item.
3316 * \sa changeLocsRefsNamesGen()
3317 * \sa changeLocName()
3319 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3321 changeLocsRefsNamesGen(mapOfModif);
3322 changeLocsNamesInStruct(mapOfModif);
3326 * Renames the profile having a given name and updates references to this profile.
3327 * \param [in] oldName - the name of the profile to rename.
3328 * \param [in] newName - a new name of the profile.
3329 * \sa changePflsNames().
3331 void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
3333 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3334 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3336 changePflsNames(mapOfModif);
3340 * Renames the localization having a given name and updates references to this localization.
3341 * \param [in] oldName - the name of the localization to rename.
3342 * \param [in] newName - a new name of the localization.
3343 * \sa changeLocsNames().
3345 void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
3347 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3348 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3350 changeLocsNames(mapOfModif);
3354 * Removes duplicated profiles. Returns a map used to update references to removed
3355 * profiles via changePflsRefsNamesGen().
3356 * Equal profiles are found using whichAreEqualProfiles().
3357 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3358 * a sequence describing the performed replacements of profiles. Each element of
3359 * this sequence is a pair whose
3360 * - the first item is a vector of profile names replaced by the second item,
3361 * - the second item is a profile name replacing every profile of the first item.
3363 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
3365 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3366 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3368 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3370 std::vector< std::string > tmp((*it).size());
3372 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3373 tmp[j]=std::string(getProfileFromId(*it2)->getName());
3374 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3376 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3377 killProfileIds(tmp2);
3379 changePflsRefsNamesGen(ret);
3384 * Removes duplicated localizations. Returns a map used to update references to removed
3385 * localizations via changeLocsRefsNamesGen().
3386 * Equal localizations are found using whichAreEqualLocs().
3387 * \param [in] eps - a precision used to compare real values of the localizations.
3388 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3389 * a sequence describing the performed replacements of localizations. Each element of
3390 * this sequence is a pair whose
3391 * - the first item is a vector of localization names replaced by the second item,
3392 * - the second item is a localization name replacing every localization of the first item.
3394 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
3396 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3397 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3399 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3401 std::vector< std::string > tmp((*it).size());
3403 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3404 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3405 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3407 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3408 killLocalizationIds(tmp2);
3410 changeLocsRefsNamesGen(ret);
3415 * Returns number of Gauss points per cell in a given localization.
3416 * \param [in] locId - an id of the localization of interest.
3417 * \return int - the number of the Gauss points per cell.
3419 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
3421 return contentNotNull()->getNbOfGaussPtPerCell(locId);
3425 * Returns an id of a localization by its name.
3426 * \param [in] loc - the localization name of interest.
3427 * \return int - the id of the localization.
3428 * \throw If there is no a localization named \a loc.
3430 int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
3432 return contentNotNull()->getLocalizationId(loc);
3436 * Returns the name of the MED file.
3437 * \return const std::string& - the MED file name.
3439 std::string MEDFileFieldGlobsReal::getFileName() const
3441 return contentNotNull()->getFileName();
3445 * Returns a localization object by its name.
3446 * \param [in] locName - the name of the localization of interest.
3447 * \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3448 * \throw If there is no a localization named \a locName.
3450 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
3452 return contentNotNull()->getLocalization(locName);
3456 * Returns a localization object by its id.
3457 * \param [in] locId - the id of the localization of interest.
3458 * \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3459 * \throw If there is no a localization with id \a locId.
3461 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
3463 return contentNotNull()->getLocalizationFromId(locId);
3467 * Returns a profile array by its name.
3468 * \param [in] pflName - the name of the profile of interest.
3469 * \return const DataArrayInt * - the profile array having the name \a pflName.
3470 * \throw If there is no a profile named \a pflName.
3472 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
3474 return contentNotNull()->getProfile(pflName);
3478 * Returns a profile array by its id.
3479 * \param [in] pflId - the id of the profile of interest.
3480 * \return const DataArrayInt * - the profile array having the id \a pflId.
3481 * \throw If there is no a profile with id \a pflId.
3483 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
3485 return contentNotNull()->getProfileFromId(pflId);
3489 * Returns a localization object, apt for modification, by its id.
3490 * \param [in] locId - the id of the localization of interest.
3491 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3492 * having the id \a locId.
3493 * \throw If there is no a localization with id \a locId.
3495 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
3497 return contentNotNull()->getLocalizationFromId(locId);
3501 * Returns a localization object, apt for modification, by its name.
3502 * \param [in] locName - the name of the localization of interest.
3503 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3504 * having the name \a locName.
3505 * \throw If there is no a localization named \a locName.
3507 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
3509 return contentNotNull()->getLocalization(locName);
3513 * Returns a profile array, apt for modification, by its name.
3514 * \param [in] pflName - the name of the profile of interest.
3515 * \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3516 * \throw If there is no a profile named \a pflName.
3518 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
3520 return contentNotNull()->getProfile(pflName);
3524 * Returns a profile array, apt for modification, by its id.
3525 * \param [in] pflId - the id of the profile of interest.
3526 * \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3527 * \throw If there is no a profile with id \a pflId.
3529 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
3531 return contentNotNull()->getProfileFromId(pflId);
3535 * Removes profiles given by their ids. No data is updated to track this removal.
3536 * \param [in] pflIds - a sequence of ids of the profiles to remove.
3538 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
3540 contentNotNull()->killProfileIds(pflIds);
3544 * Removes localizations given by their ids. No data is updated to track this removal.
3545 * \param [in] locIds - a sequence of ids of the localizations to remove.
3547 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
3549 contentNotNull()->killLocalizationIds(locIds);
3553 * Stores a profile array.
3554 * \param [in] pfl - the profile array to store.
3555 * \throw If the name of \a pfl is empty.
3556 * \throw If a profile with the same name as that of \a pfl already exists but contains
3559 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
3561 contentNotNull()->appendProfile(pfl);
3565 * Adds a new localization of Gauss points.
3566 * \param [in] locName - the name of the new localization.
3567 * \param [in] geoType - a geometrical type of the reference cell.
3568 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
3569 * must be \c nbOfNodesPerCell * \c dimOfType.
3570 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
3571 * must be _wg_.size() * \c dimOfType.
3572 * \param [in] w - the weights of Gauss points.
3573 * \throw If \a locName is empty.
3574 * \throw If a localization with the name \a locName already exists but is
3575 * different form the new one.
3577 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)
3579 contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
3582 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
3584 MEDFileFieldGlobs *g(_globals);
3586 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
3590 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
3592 const MEDFileFieldGlobs *g(_globals);
3594 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
3598 //= MEDFileFieldNameScope
3600 MEDFileFieldNameScope::MEDFileFieldNameScope()
3604 MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName):_name(fieldName)
3609 * Returns the name of \a this field.
3610 * \return std::string - a string containing the field name.
3612 std::string MEDFileFieldNameScope::getName() const
3618 * Sets name of \a this field
3619 * \param [in] name - the new field name.
3621 void MEDFileFieldNameScope::setName(const std::string& fieldName)
3626 std::string MEDFileFieldNameScope::getDtUnit() const
3631 void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
3636 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
3639 _dt_unit=other._dt_unit;
3642 //= MEDFileAnyTypeField1TSWithoutSDA
3644 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
3646 _field_per_mesh.resize(other._field_per_mesh.size());
3648 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
3650 if((const MEDFileFieldPerMesh *)*it)
3651 _field_per_mesh[i]=(*it)->deepCpy(this);
3656 * Prints a string describing \a this field into a stream. This string is outputted
3657 * by \c print Python command.
3658 * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
3659 * \param [in,out] oss - the out stream.
3660 * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
3661 * info id printed, else, not.
3663 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
3665 std::string startOfLine(bkOffset,' ');
3666 oss << startOfLine << "Field ";
3668 oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
3669 oss << "on one time Step ";
3671 oss << "(" << f1tsId << ") ";
3672 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
3673 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
3674 const DataArray *arr=getUndergroundDataArray();
3677 const std::vector<std::string> &comps=arr->getInfoOnComponents();
3680 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
3681 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
3682 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
3684 if(arr->isAllocated())
3686 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
3689 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
3693 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
3695 oss << startOfLine << "----------------------" << std::endl;
3696 if(!_field_per_mesh.empty())
3699 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
3701 const MEDFileFieldPerMesh *cur=(*it2);
3703 cur->simpleRepr(bkOffset,oss,i);
3705 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
3710 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
3712 oss << startOfLine << "----------------------" << std::endl;
3715 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
3717 const DataArray *arr(getUndergroundDataArray());
3719 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
3720 int nbOfCompo=arr->getNumberOfComponents();
3721 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
3722 for(int i=0;i<nbOfCompo;i++)
3725 std::vector<int> v(1,i);
3726 MEDCouplingAutoRefCountObjectPtr<DataArray> arr2=arr->keepSelectedComponents(v);
3727 ret[i]->setArray(arr2);
3732 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)
3736 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
3741 * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
3742 * empty. Returns -1 if this in on nodes.
3743 * \return int - the dimension of \a this.
3745 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
3748 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3749 (*it)->getDimension(ret);
3754 * Returns the mesh name.
3755 * \return std::string - a string holding the mesh name.
3756 * \throw If \c _field_per_mesh.empty()
3758 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const
3760 if(_field_per_mesh.empty())
3761 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
3762 return _field_per_mesh[0]->getMeshName();
3765 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const std::string& newMeshName)
3767 std::string oldName(getMeshName());
3768 std::vector< std::pair<std::string,std::string> > v(1);
3769 v[0].first=oldName; v[0].second=newMeshName;
3773 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
3776 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3778 MEDFileFieldPerMesh *cur(*it);
3780 ret=cur->changeMeshNames(modifTab) || ret;
3786 * Returns the number of iteration of the state of underlying mesh.
3787 * \return int - the iteration number.
3788 * \throw If \c _field_per_mesh.empty()
3790 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
3792 if(_field_per_mesh.empty())
3793 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
3794 return _field_per_mesh[0]->getMeshIteration();
3798 * Returns the order number of iteration of the state of underlying mesh.
3799 * \return int - the order number.
3800 * \throw If \c _field_per_mesh.empty()
3802 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
3804 if(_field_per_mesh.empty())
3805 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
3806 return _field_per_mesh[0]->getMeshOrder();
3810 * Checks if \a this field is tagged by a given iteration number and a given
3811 * iteration order number.
3812 * \param [in] iteration - the iteration number of interest.
3813 * \param [in] order - the iteration order number of interest.
3814 * \return bool - \c true if \a this->getIteration() == \a iteration &&
3815 * \a this->getOrder() == \a order.
3817 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
3819 return iteration==_iteration && order==_order;
3823 * Returns number of iteration and order number of iteration when
3824 * \a this field has been calculated.
3825 * \return std::pair<int,int> - a pair of the iteration number and the iteration
3828 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
3830 std::pair<int,int> p;
3836 * Returns number of iteration and order number of iteration when
3837 * \a this field has been calculated.
3838 * \param [in,out] p - a pair returning the iteration number and the iteration
3841 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
3848 * Returns all types of spatial discretization of \a this field.
3849 * \param [in,out] types - a sequence of types of \a this field.
3851 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
3853 std::set<TypeOfField> types2;
3854 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3856 (*it)->fillTypesOfFieldAvailable(types2);
3858 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
3859 std::copy(types2.begin(),types2.end(),bi);
3863 * Returns all types of spatial discretization of \a this field.
3864 * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
3867 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
3869 std::vector<TypeOfField> ret;
3870 fillTypesOfFieldAvailable(ret);
3874 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
3876 std::vector<std::string> ret;
3877 std::set<std::string> ret2;
3878 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3880 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
3881 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3882 if(ret2.find(*it2)==ret2.end())
3884 ret.push_back(*it2);
3891 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
3893 std::vector<std::string> ret;
3894 std::set<std::string> ret2;
3895 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3897 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
3898 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3899 if(ret2.find(*it2)==ret2.end())
3901 ret.push_back(*it2);
3908 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
3910 std::vector<std::string> ret;
3911 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3913 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
3914 ret.insert(ret.end(),tmp.begin(),tmp.end());
3919 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
3921 std::vector<std::string> ret;
3922 std::set<std::string> ret2;
3923 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3925 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
3926 ret.insert(ret.end(),tmp.begin(),tmp.end());
3931 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3933 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3934 (*it)->changePflsRefsNamesGen(mapOfModif);
3937 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3939 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3940 (*it)->changeLocsRefsNamesGen(mapOfModif);
3944 * Returns all attributes of parts of \a this field lying on a given mesh.
3945 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
3946 * item of every of returned sequences refers to the _i_-th part of \a this field.
3947 * Thus all sequences returned by this method are of the same length equal to number
3948 * of different types of supporting entities.<br>
3949 * A field part can include sub-parts with several different spatial discretizations,
3950 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
3951 * for example. Hence, some of the returned sequences contains nested sequences, and an item
3952 * of a nested sequence corresponds to a type of spatial discretization.<br>
3953 * This method allows for iteration over MEDFile DataStructure without any overhead.
3954 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
3955 * for the case with only one underlying mesh. (Actually, the number of meshes is
3956 * not checked if \a mname == \c NULL).
3957 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
3958 * a field part is returned.
3959 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
3960 * This sequence is of the same length as \a types.
3961 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
3962 * discretization. A profile name can be empty.
3963 * Length of this and of nested sequences is the same as that of \a typesF.
3964 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
3965 * discretization. A localization name can be empty.
3966 * Length of this and of nested sequences is the same as that of \a typesF.
3967 * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
3968 * of ids of tuples within the data array, per each type of spatial
3969 * discretization within one mesh entity type.
3970 * Length of this and of nested sequences is the same as that of \a typesF.
3971 * \throw If no field is lying on \a mname.
3973 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
3977 meshId=getMeshIdFromMeshName(mname);
3979 if(_field_per_mesh.empty())
3980 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
3981 return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3985 * Returns dimensions of mesh elements \a this field lies on. The returned value is a
3986 * maximal absolute dimension and values returned via the out parameter \a levs are
3987 * dimensions relative to the maximal absolute dimension. <br>
3988 * This method is designed for MEDFileField1TS instances that have a discretization
3989 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS",
3990 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT",
3991 * \ref ParaMEDMEM::ON_GAUSS_NE "ON_GAUSS_NE".
3992 * Only these 3 discretizations will be taken into account here. If \a this is
3993 * \ref ParaMEDMEM::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
3994 * This method is useful to make the link between the dimension of the underlying mesh
3995 * and the levels of \a this, because it is possible that the highest dimension of \a this
3996 * field is not equal to the dimension of the underlying mesh.
3998 * Let's consider the following case:
3999 * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
4000 * TETRA4, HEXA8, TRI3 and SEG2.
4001 * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
4002 * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
4004 * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
4005 * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
4006 * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
4007 * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
4008 * parameter of getFieldAtLevel() is computed basing on the returned values as this:
4009 * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
4011 * to retrieve the highest level of
4012 * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br>
4013 * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
4014 * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
4015 * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
4016 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4017 * for the case with only one underlying mesh. (Actually, the number of meshes is
4018 * not checked if \a mname == \c NULL).
4019 * \param [in,out] levs - a sequence returning the dimensions relative to the maximal
4020 * absolute one. They are in decreasing order. This sequence is cleared before
4022 * \return int - the maximal absolute dimension of elements \a this fields lies on.
4023 * \throw If no field is lying on \a mname.
4025 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
4028 int meshId=getMeshIdFromMeshName(mname);
4029 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4030 std::vector< std::vector<TypeOfField> > typesF;
4031 std::vector< std::vector<std::string> > pfls, locs;
4032 _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4034 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
4035 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
4036 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
4038 st.erase(INTERP_KERNEL::NORM_ERROR);
4040 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
4042 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
4043 ret1.insert((int)cm.getDimension());
4045 int ret=*std::max_element(ret1.begin(),ret1.end());
4046 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
4047 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
4052 * \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.
4053 * \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.
4054 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4055 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4057 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
4059 int mid=getMeshIdFromMeshName(mName);
4060 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4064 * \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.
4065 * \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.
4066 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4067 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4069 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
4071 int mid=getMeshIdFromMeshName(mName);
4072 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4076 * \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.
4078 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
4080 if(_field_per_mesh.empty())
4081 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4084 std::string mName2(mName);
4086 std::vector<std::string> msg;
4087 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4088 if(mName2==(*it)->getMeshName())
4091 msg.push_back((*it)->getMeshName());
4092 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4093 oss << "Possible meshes are : ";
4094 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4095 oss << "\"" << (*it2) << "\" ";
4096 throw INTERP_KERNEL::Exception(oss.str().c_str());
4099 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
4102 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4103 std::string tmp(mesh->getName());
4105 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4106 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4108 for(;it!=_field_per_mesh.end();it++,i++)
4110 if((*it)->getMeshName()==tmp)
4113 int sz=_field_per_mesh.size();
4114 _field_per_mesh.resize(sz+1);
4115 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4119 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4120 MEDFileFieldGlobsReal& glob)
4123 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4125 MEDFileFieldPerMesh *fpm(*it);
4127 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4132 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
4134 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4135 std::vector< std::vector<TypeOfField> > typesF;
4136 std::vector< std::vector<std::string> > pfls,locs;
4137 std::vector< std::vector<std::pair<int,int> > > bgEnd=getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs);
4138 std::set<TypeOfField> allEnt;
4139 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4140 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4141 allEnt.insert(*it2);
4142 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4143 std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4144 for(std::size_t i=0;i<allEnt.size();i++,it3++)
4146 std::vector< std::pair<int,int> > its;
4147 ret[i]=shallowCpy();
4148 int newLgth=ret[i]->keepOnlySpatialDiscretization(*it3,its);
4149 ret[i]->updateData(newLgth,its);
4154 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
4156 int globalCounter=0;
4157 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4158 (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4159 return globalCounter;
4162 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
4164 if(_nb_of_tuples_to_be_allocated>=0)
4166 _nb_of_tuples_to_be_allocated=newLgth;
4167 const DataArray *oldArr(getUndergroundDataArray());
4170 MEDCouplingAutoRefCountObjectPtr<DataArray> newArr(createNewEmptyDataArrayInstance());
4171 newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
4173 _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
4177 if(_nb_of_tuples_to_be_allocated==-1)
4179 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4181 const DataArray *oldArr(getUndergroundDataArray());
4182 if(!oldArr || !oldArr->isAllocated())
4183 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4184 MEDCouplingAutoRefCountObjectPtr<DataArray> newArr(createNewEmptyDataArrayInstance());
4185 newArr->alloc(newLgth,getNumberOfComponents());
4187 newArr->copyStringInfoFrom(*oldArr);
4189 for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4191 if((*it).second<(*it).first)
4192 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4193 newArr->setContigPartOfSelectedValues2(pos,oldArr,(*it).first,(*it).second,1);
4194 pos+=(*it).second-(*it).first;
4199 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4202 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
4204 if(_field_per_mesh.empty())
4205 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4206 if(_field_per_mesh.size()>1)
4207 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4208 _field_per_mesh[0]->copyOptionsFrom(opts);
4209 _field_per_mesh[0]->writeLL(fid,nasc);
4213 * 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.
4214 * If false is returned the memory allocation is not required.
4216 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
4218 if(_nb_of_tuples_to_be_allocated>=0)
4220 getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4221 _nb_of_tuples_to_be_allocated=-2;
4224 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4226 if(_nb_of_tuples_to_be_allocated==-1)
4227 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4228 if(_nb_of_tuples_to_be_allocated<-3)
4229 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4230 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4233 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms)
4235 med_int numdt,numit;
4239 med_int meshnumdt,meshnumit;
4240 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4241 MEDfieldComputingStepInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt);
4242 MEDfield23ComputingStepMeshInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit);
4243 if(_iteration!=numdt || _order!=numit)
4244 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4245 _field_per_mesh.resize(nmesh);
4250 std::string meshNameCpp(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
4251 mm=ms->getMeshWithName(meshNameCpp);
4254 for(int i=0;i<nmesh;i++)
4255 _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i,meshnumdt,meshnumit,nasc,mm);
4256 _nb_of_tuples_to_be_allocated=0;
4257 for(int i=0;i<nmesh;i++)
4258 _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4261 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
4263 allocIfNecessaryTheArrayToReceiveDataFromFile();
4264 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4265 (*it)->loadBigArraysRecursively(fid,nasc);
4268 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
4270 if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4271 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4272 (*it)->loadBigArraysRecursively(fid,nasc);
4275 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms)
4277 loadOnlyStructureOfDataRecursively(fid,nasc,ms);
4278 loadBigArraysRecursively(fid,nasc);
4281 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
4283 DataArray *thisArr(getUndergroundDataArray());
4284 if(thisArr && thisArr->isAllocated())
4286 _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
4287 thisArr->desallocate();
4291 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
4293 return _dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh >);
4296 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
4298 std::vector<const BigMemoryObject *> ret;
4299 if(getUndergroundDataArray())
4300 ret.push_back(getUndergroundDataArray());
4301 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4302 ret.push_back((const MEDFileFieldPerMesh *)*it);
4307 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4308 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4309 * "Sort By Type"), if not, an exception is thrown.
4310 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
4311 * \param [in] arr - the array of values.
4312 * \param [in,out] glob - the global data where profiles and localization present in
4313 * \a field, if any, are added.
4314 * \throw If the name of \a field is empty.
4315 * \throw If the data array of \a field is not set.
4316 * \throw If \a this->_arr is already allocated but has different number of components
4318 * \throw If the underlying mesh of \a field has no name.
4319 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4321 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4323 const MEDCouplingMesh *mesh=field->getMesh();
4325 TypeOfField type=field->getTypeOfField();
4326 std::vector<DataArrayInt *> dummy;
4327 int start=copyTinyInfoFrom(field,arr);
4328 int pos=addNewEntryIfNecessary(mesh);
4331 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4332 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4335 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4339 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4340 * of a given mesh are used as the support of the given field (a real support is not used).
4341 * Elements of the given mesh must be sorted suitable for writing to MED file.
4342 * Order of underlying mesh entities of the given field specified by \a profile parameter
4343 * is not prescribed; this method permutes field values to have them sorted by element
4344 * type as required for writing to MED file. A new profile is added only if no equal
4345 * profile is missing.
4346 * \param [in] field - the field to add to \a this. The field double values are ignored.
4347 * \param [in] arrOfVals - the values of the field \a field used.
4348 * \param [in] mesh - the supporting mesh of \a field.
4349 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4350 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
4351 * \param [in,out] glob - the global data where profiles and localization present in
4352 * \a field, if any, are added.
4353 * \throw If either \a field or \a mesh or \a profile has an empty name.
4354 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4355 * \throw If the data array of \a field is not set.
4356 * \throw If \a this->_arr is already allocated but has different number of components
4358 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4359 * \sa setFieldNoProfileSBT()
4361 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4364 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
4365 if(!arrOfVals || !arrOfVals->isAllocated())
4366 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
4367 TypeOfField type=field->getTypeOfField();
4368 std::vector<DataArrayInt *> idsInPflPerType;
4369 std::vector<DataArrayInt *> idsPerType;
4370 std::vector<int> code,code2;
4371 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4374 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4375 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
4376 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin());
4377 std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
4379 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> field2=field->clone(false);
4380 int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
4381 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4383 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4384 throw INTERP_KERNEL::Exception(oss.str().c_str());
4387 int start=copyTinyInfoFrom(field,arrOfVals);
4388 code2=m->getDistributionOfTypes();
4390 int pos=addNewEntryIfNecessary(m);
4391 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4395 if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
4396 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
4397 std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
4398 std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
4399 int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
4400 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4402 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4403 throw INTERP_KERNEL::Exception(oss.str().c_str());
4405 int start=copyTinyInfoFrom(field,arrOfVals);
4406 int pos=addNewEntryIfNecessary(m);
4407 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4412 * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
4414 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
4416 if(_nb_of_tuples_to_be_allocated>=0)
4417 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 !");
4418 DataArray *arr(getOrCreateAndGetArray());
4419 arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
4420 _nb_of_tuples_to_be_allocated=-3;
4424 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4425 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4426 * larger by the size of \a field. Returns an id of the first not filled
4427 * tuple of \a this->_arr.
4428 * \param [in] field - the field to copy the info on components and the name from.
4429 * \return int - the id of first not initialized tuple of \a this->_arr.
4430 * \throw If the name of \a field is empty.
4431 * \throw If the data array of \a field is not set.
4432 * \throw If \a this->_arr is already allocated but has different number of components
4435 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
4438 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4439 std::string name(field->getName());
4440 setName(name.c_str());
4441 setDtUnit(field->getTimeUnit());
4443 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4445 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4446 if(!arr->isAllocated())
4447 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
4448 _dt=field->getTime(_iteration,_order);
4449 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4450 if(!getOrCreateAndGetArray()->isAllocated())
4452 allocNotFromFile(arr->getNumberOfTuples());
4457 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4458 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4459 getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
4460 _nb_of_tuples_to_be_allocated=-3;
4461 return oldNbOfTuples;
4466 * Returns number of components in \a this field
4467 * \return int - the number of components.
4469 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4471 return getOrCreateAndGetArray()->getNumberOfComponents();
4475 * Change info on components in \a this.
4476 * \throw If size of \a infos is not equal to the number of components already in \a this.
4478 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
4480 DataArray *arr=getOrCreateAndGetArray();
4481 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
4485 * Returns info on components of \a this field.
4486 * \return const std::vector<std::string>& - a sequence of strings each being an
4487 * information on _i_-th component.
4489 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
4491 const DataArray *arr=getOrCreateAndGetArray();
4492 return arr->getInfoOnComponents();
4496 * Returns a mutable info on components of \a this field.
4497 * \return std::vector<std::string>& - a sequence of strings each being an
4498 * information on _i_-th component.
4500 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
4502 DataArray *arr=getOrCreateAndGetArray();
4503 return arr->getInfoOnComponents();
4507 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4508 * \param [in] type - a spatial discretization of the new field.
4509 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4510 * \param [in] mName - a name of the supporting mesh.
4511 * \param [in] renumPol - specifies how to permute values of the result field according to
4512 * the optional numbers of cells and nodes, if any. The valid values are
4513 * - 0 - do not permute.
4514 * - 1 - permute cells.
4515 * - 2 - permute nodes.
4516 * - 3 - permute cells and nodes.
4518 * \param [in] glob - the global data storing profiles and localization.
4519 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4520 * caller is to delete this field using decrRef() as it is no more needed.
4521 * \throw If the MED file is not readable.
4522 * \throw If there is no mesh named \a mName in the MED file.
4523 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4524 * \throw If no field of \a this is lying on the mesh \a mName.
4525 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4527 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4529 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4531 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4533 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4534 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4538 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4539 * \param [in] type - a spatial discretization of the new field.
4540 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4541 * \param [in] renumPol - specifies how to permute values of the result field according to
4542 * the optional numbers of cells and nodes, if any. The valid values are
4543 * - 0 - do not permute.
4544 * - 1 - permute cells.
4545 * - 2 - permute nodes.
4546 * - 3 - permute cells and nodes.
4548 * \param [in] glob - the global data storing profiles and localization.
4549 * \param [in] mesh - the supporting mesh.
4550 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4551 * caller is to delete this field using decrRef() as it is no more needed.
4552 * \throw If the MED file is not readable.
4553 * \throw If no field of \a this is lying on \a mesh.
4554 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4555 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4557 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4559 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax,false);
4560 const DataArrayInt *d=mesh->getNumberFieldAtLevel(meshDimRelToMax);
4561 const DataArrayInt *e=mesh->getNumberFieldAtLevel(1);
4562 if(meshDimRelToMax==1)
4563 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
4564 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
4568 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
4570 * \param [in] type - a spatial discretization of the new field.
4571 * \param [in] mName - a name of the supporting mesh.
4572 * \param [in] renumPol - specifies how to permute values of the result field according to
4573 * the optional numbers of cells and nodes, if any. The valid values are
4574 * - 0 - do not permute.
4575 * - 1 - permute cells.
4576 * - 2 - permute nodes.
4577 * - 3 - permute cells and nodes.
4579 * \param [in] glob - the global data storing profiles and localization.
4580 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4581 * caller is to delete this field using decrRef() as it is no more needed.
4582 * \throw If the MED file is not readable.
4583 * \throw If there is no mesh named \a mName in the MED file.
4584 * \throw If there are no mesh entities in the mesh.
4585 * \throw If no field values of the given \a type are available.
4587 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4589 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4591 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4593 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4594 int absDim=getDimension();
4595 int meshDimRelToMax=absDim-mm->getMeshDimension();
4596 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4600 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4601 * \param [in] type - a spatial discretization of the new field.
4602 * \param [in] renumPol - specifies how to permute values of the result field according to
4603 * the optional numbers of cells and nodes, if any. The valid values are
4604 * - 0 - do not permute.
4605 * - 1 - permute cells.
4606 * - 2 - permute nodes.
4607 * - 3 - permute cells and nodes.
4609 * \param [in] glob - the global data storing profiles and localization.
4610 * \param [in] mesh - the supporting mesh.
4611 * \param [in] cellRenum - the cell numbers array used for permutation of the result
4612 * field according to \a renumPol.
4613 * \param [in] nodeRenum - the node numbers array used for permutation of the result
4614 * field according to \a renumPol.
4615 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4616 * caller is to delete this field using decrRef() as it is no more needed.
4617 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4618 * \throw If no field of \a this is lying on \a mesh.
4619 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4621 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
4623 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
4624 int meshId=getMeshIdFromMeshName(mesh->getName());
4626 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
4631 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4638 throw INTERP_KERNEL::Exception(msg1);
4639 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4642 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
4644 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4645 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
4646 throw INTERP_KERNEL::Exception(oss.str().c_str());
4648 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
4649 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
4650 std::vector<DataArray *> arrOut2(1,arrOut);
4651 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
4652 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
4653 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
4660 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4662 throw INTERP_KERNEL::Exception(msg1);
4665 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
4667 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4668 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
4669 throw INTERP_KERNEL::Exception(oss.str().c_str());
4671 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
4672 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
4673 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
4674 ret->renumberNodes(nodeRenumSafe->getConstPointer());
4679 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
4684 * Returns values and a profile of the field of a given type lying on a given support.
4685 * \param [in] type - a spatial discretization of the field.
4686 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4687 * \param [in] mesh - the supporting mesh.
4688 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
4689 * field of interest lies on. If the field lies on all entities of the given
4690 * dimension, all ids in \a pfl are zero. The caller is to delete this array
4691 * using decrRef() as it is no more needed.
4692 * \param [in] glob - the global data storing profiles and localization.
4693 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
4694 * field. The caller is to delete this array using decrRef() as it is no more needed.
4695 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4696 * \throw If no field of \a this is lying on \a mesh.
4697 * \throw If no field values of the given \a type are available.
4699 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
4701 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4702 int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
4703 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
4704 ret->setName(nasc.getName().c_str());
4708 //= MEDFileField1TSWithoutSDA
4711 * Throws if a given value is not a valid (non-extended) relative dimension.
4712 * \param [in] meshDimRelToMax - the relative dimension value.
4713 * \throw If \a meshDimRelToMax > 0.
4715 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
4717 if(meshDimRelToMax>0)
4718 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
4722 * Checks if elements of a given mesh are in the order suitable for writing
4723 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
4724 * vector describing types of elements and their number.
4725 * \param [in] mesh - the mesh to check.
4726 * \return std::vector<int> - a vector holding for each element type (1) item of
4727 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
4728 * These values are in full-interlace mode.
4729 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4731 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
4734 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
4735 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
4736 int nbOfTypes=geoTypes.size();
4737 std::vector<int> code(3*nbOfTypes);
4738 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr1=DataArrayInt::New();
4739 arr1->alloc(nbOfTypes,1);
4740 int *arrPtr=arr1->getPointer();
4741 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
4742 for(int i=0;i<nbOfTypes;i++,it++)
4743 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
4744 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
4745 const int *arrPtr2=arr2->getConstPointer();
4747 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
4750 int nbCells=mesh->getNumberOfCellsWithType(*it);
4751 code[3*pos]=(int)(*it);
4752 code[3*pos+1]=nbCells;
4753 code[3*pos+2]=-1;//no profiles
4755 std::vector<const DataArrayInt *> idsPerType;//no profiles
4756 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
4760 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
4765 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
4767 return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
4771 * Returns all attributes and values of parts of \a this field lying on a given mesh.
4772 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4773 * item of every of returned sequences refers to the _i_-th part of \a this field.
4774 * Thus all sequences returned by this method are of the same length equal to number
4775 * of different types of supporting entities.<br>
4776 * A field part can include sub-parts with several different spatial discretizations,
4777 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
4778 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4779 * of a nested sequence corresponds to a type of spatial discretization.<br>
4780 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
4781 * The overhead is due to selecting values into new instances of DataArrayDouble.
4782 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4783 * for the case with only one underlying mesh. (Actually, the number of meshes is
4784 * not checked if \a mname == \c NULL).
4785 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4786 * a field part is returned.
4787 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4788 * A field part can include sub-parts with several different spatial discretizations,
4789 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and
4790 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT" for example.
4791 * This sequence is of the same length as \a types.
4792 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4793 * discretization. A profile name can be empty.
4794 * Length of this and of nested sequences is the same as that of \a typesF.
4795 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4796 * discretization. A localization name can be empty.
4797 * Length of this and of nested sequences is the same as that of \a typesF.
4798 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
4799 * per each type of spatial discretization within one mesh entity type.
4800 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
4801 * Length of this and of nested sequences is the same as that of \a typesF.
4802 * \throw If no field is lying on \a mname.
4804 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
4808 meshId=getMeshIdFromMeshName(mname);
4810 if(_field_per_mesh.empty())
4811 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4812 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4813 int nbOfRet=ret0.size();
4814 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
4815 for(int i=0;i<nbOfRet;i++)
4817 const std::vector< std::pair<int,int> >& p=ret0[i];
4818 int nbOfRet1=p.size();
4819 ret[i].resize(nbOfRet1);
4820 for(int j=0;j<nbOfRet1;j++)
4822 DataArrayDouble *tmp=_arr->selectByTupleId2(p[j].first,p[j].second,1);
4830 * Returns a pointer to the underground DataArrayDouble instance. So the
4831 * caller should not decrRef() it. This method allows for a direct access to the field
4832 * values. This method is quite unusable if there is more than a nodal field or a cell
4833 * field on single geometric cell type.
4834 * \return DataArrayDouble * - the pointer to the field values array.
4836 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDouble() const
4838 const DataArrayDouble *ret=_arr;
4840 return const_cast<DataArrayDouble *>(ret);
4845 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
4850 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
4852 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
4853 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
4854 ret->deepCpyLeavesFrom(*this);
4855 const DataArrayDouble *arr(_arr);
4858 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr->convertToIntArr());
4859 ret->setArray(arr2);
4865 * Returns a pointer to the underground DataArrayDouble instance. So the
4866 * caller should not decrRef() it. This method allows for a direct access to the field
4867 * values. This method is quite unusable if there is more than a nodal field or a cell
4868 * field on single geometric cell type.
4869 * \return DataArrayDouble * - the pointer to the field values array.
4871 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArray() const
4873 return getUndergroundDataArrayDouble();
4877 * Returns a pointer to the underground DataArrayDouble instance and a
4878 * sequence describing parameters of a support of each part of \a this field. The
4879 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
4880 * direct access to the field values. This method is intended for the field lying on one
4882 * \param [in,out] entries - the sequence describing parameters of a support of each
4883 * part of \a this field. Each item of this sequence consists of two parts. The
4884 * first part describes a type of mesh entity and an id of discretization of a
4885 * current field part. The second part describes a range of values [begin,end)
4886 * within the returned array relating to the current field part.
4887 * \return DataArrayDouble * - the pointer to the field values array.
4888 * \throw If the number of underlying meshes is not equal to 1.
4889 * \throw If no field values are available.
4890 * \sa getUndergroundDataArray()
4892 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
4894 if(_field_per_mesh.size()!=1)
4895 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
4896 if(_field_per_mesh[0]==0)
4897 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
4898 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
4899 return getUndergroundDataArrayDouble();
4903 * Returns a pointer to the underground DataArrayDouble instance and a
4904 * sequence describing parameters of a support of each part of \a this field. The
4905 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
4906 * direct access to the field values. This method is intended for the field lying on one
4908 * \param [in,out] entries - the sequence describing parameters of a support of each
4909 * part of \a this field. Each item of this sequence consists of two parts. The
4910 * first part describes a type of mesh entity and an id of discretization of a
4911 * current field part. The second part describes a range of values [begin,end)
4912 * within the returned array relating to the current field part.
4913 * \return DataArrayDouble * - the pointer to the field values array.
4914 * \throw If the number of underlying meshes is not equal to 1.
4915 * \throw If no field values are available.
4916 * \sa getUndergroundDataArray()
4918 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
4920 return getUndergroundDataArrayDoubleExt(entries);
4923 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
4925 DataArrayDouble *arr(getOrCreateAndGetArrayDouble());
4926 arr->setInfoAndChangeNbOfCompo(infos);
4929 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
4933 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
4935 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
4936 ret->deepCpyLeavesFrom(*this);
4940 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCpy() const
4942 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret=static_cast<MEDFileField1TSWithoutSDA *>(shallowCpy());
4943 if((const DataArrayDouble *)_arr)
4944 ret->_arr=_arr->deepCpy();
4948 void MEDFileField1TSWithoutSDA::setArray(DataArray *arr)
4952 _nb_of_tuples_to_be_allocated=-1;
4956 DataArrayDouble *arrC=dynamic_cast<DataArrayDouble *>(arr);
4958 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayDouble !");
4960 _nb_of_tuples_to_be_allocated=-3;
4965 DataArray *MEDFileField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
4967 return DataArrayDouble::New();
4970 DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble()
4972 DataArrayDouble *ret=_arr;
4975 _arr=DataArrayDouble::New();
4979 DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray()
4981 return getOrCreateAndGetArrayDouble();
4984 const DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble() const
4986 const DataArrayDouble *ret=_arr;
4989 DataArrayDouble *ret2=DataArrayDouble::New();
4990 const_cast<MEDFileField1TSWithoutSDA *>(this)->_arr=DataArrayDouble::New();
4994 const DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray() const
4996 return getOrCreateAndGetArrayDouble();
4999 //= MEDFileIntField1TSWithoutSDA
5001 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5003 return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5006 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
5010 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order,
5011 const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
5013 DataArrayInt *arr(getOrCreateAndGetArrayInt());
5014 arr->setInfoAndChangeNbOfCompo(infos);
5017 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
5022 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const
5024 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
5025 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5026 ret->deepCpyLeavesFrom(*this);
5027 const DataArrayInt *arr(_arr);
5030 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2(arr->convertToDblArr());
5031 ret->setArray(arr2);
5037 * Returns a pointer to the underground DataArrayInt instance. So the
5038 * caller should not decrRef() it. This method allows for a direct access to the field
5039 * values. This method is quite unusable if there is more than a nodal field or a cell
5040 * field on single geometric cell type.
5041 * \return DataArrayInt * - the pointer to the field values array.
5043 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArray() const
5045 return getUndergroundDataArrayInt();
5049 * Returns a pointer to the underground DataArrayInt instance. So the
5050 * caller should not decrRef() it. This method allows for a direct access to the field
5051 * values. This method is quite unusable if there is more than a nodal field or a cell
5052 * field on single geometric cell type.
5053 * \return DataArrayInt * - the pointer to the field values array.
5055 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayInt() const
5057 const DataArrayInt *ret=_arr;
5059 return const_cast<DataArrayInt *>(ret);
5065 * Returns a pointer to the underground DataArrayInt instance and a
5066 * sequence describing parameters of a support of each part of \a this field. The
5067 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5068 * direct access to the field values. This method is intended for the field lying on one
5070 * \param [in,out] entries - the sequence describing parameters of a support of each
5071 * part of \a this field. Each item of this sequence consists of two parts. The
5072 * first part describes a type of mesh entity and an id of discretization of a
5073 * current field part. The second part describes a range of values [begin,end)
5074 * within the returned array relating to the current field part.
5075 * \return DataArrayInt * - the pointer to the field values array.
5076 * \throw If the number of underlying meshes is not equal to 1.
5077 * \throw If no field values are available.
5078 * \sa getUndergroundDataArray()
5080 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5082 return getUndergroundDataArrayIntExt(entries);
5086 * Returns a pointer to the underground DataArrayInt instance and a
5087 * sequence describing parameters of a support of each part of \a this field. The
5088 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5089 * direct access to the field values. This method is intended for the field lying on one
5091 * \param [in,out] entries - the sequence describing parameters of a support of each
5092 * part of \a this field. Each item of this sequence consists of two parts. The
5093 * first part describes a type of mesh entity and an id of discretization of a
5094 * current field part. The second part describes a range of values [begin,end)
5095 * within the returned array relating to the current field part.
5096 * \return DataArrayInt * - the pointer to the field values array.
5097 * \throw If the number of underlying meshes is not equal to 1.
5098 * \throw If no field values are available.
5099 * \sa getUndergroundDataArray()
5101 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5103 if(_field_per_mesh.size()!=1)
5104 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5105 if(_field_per_mesh[0]==0)
5106 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5107 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5108 return getUndergroundDataArrayInt();
5111 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5113 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5114 ret->deepCpyLeavesFrom(*this);
5118 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCpy() const
5120 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret=static_cast<MEDFileIntField1TSWithoutSDA *>(shallowCpy());
5121 if((const DataArrayInt *)_arr)
5122 ret->_arr=_arr->deepCpy();
5126 void MEDFileIntField1TSWithoutSDA::setArray(DataArray *arr)
5130 _nb_of_tuples_to_be_allocated=-1;
5134 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>(arr);
5136 throw INTERP_KERNEL::Exception("MEDFileIntField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayInt !");
5138 _nb_of_tuples_to_be_allocated=-3;
5143 DataArray *MEDFileIntField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
5145 return DataArrayInt::New();
5148 DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt()
5150 DataArrayInt *ret=_arr;
5153 _arr=DataArrayInt::New();
5157 DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray()
5159 return getOrCreateAndGetArrayInt();
5162 const DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt() const
5164 const DataArrayInt *ret=_arr;
5167 DataArrayInt *ret2=DataArrayInt::New();
5168 const_cast<MEDFileIntField1TSWithoutSDA *>(this)->_arr=DataArrayInt::New();
5172 const DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray() const
5174 return getOrCreateAndGetArrayInt();
5177 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5181 //= MEDFileAnyTypeField1TS
5183 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
5185 med_field_type typcha;
5187 std::vector<std::string> infos;
5188 std::string dtunit,fieldName;
5189 LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
5190 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5195 ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5200 ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5205 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] !";
5206 throw INTERP_KERNEL::Exception(oss.str().c_str());
5209 ret->setDtUnit(dtunit.c_str());
5210 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5212 med_int numdt,numit;
5214 MEDfieldComputingStepInfo(fid,fieldName.c_str(),1,&numdt,&numit,&dt);
5215 ret->setTime(numdt,numit,dt);
5218 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms);
5220 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms);
5224 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
5225 try:MEDFileFieldGlobsReal(fileName)
5227 MEDFileUtilities::CheckFileForRead(fileName);
5228 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5229 _content=BuildContentFrom(fid,fileName,loadAll,ms);
5232 catch(INTERP_KERNEL::Exception& e)
5237 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5239 med_field_type typcha;
5240 std::vector<std::string> infos;
5243 int nbSteps=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5244 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5249 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5254 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5259 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] !";
5260 throw INTERP_KERNEL::Exception(oss.str().c_str());
5263 ret->setDtUnit(dtunit.c_str());
5264 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5268 std::ostringstream oss; oss << "MEDFileField1TS(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5269 throw INTERP_KERNEL::Exception(oss.str().c_str());
5272 med_int numdt,numit;
5274 MEDfieldComputingStepInfo(fid,fieldName.c_str(),1,&numdt,&numit,&dt);
5275 ret->setTime(numdt,numit,dt);
5278 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms);
5280 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms);
5284 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5285 try:MEDFileFieldGlobsReal(fileName)
5287 MEDFileUtilities::CheckFileForRead(fileName);
5288 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5289 _content=BuildContentFrom(fid,fileName,fieldName,loadAll,ms);
5292 catch(INTERP_KERNEL::Exception& e)
5297 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, const std::string& fileName)
5300 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5301 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5303 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New();
5304 ret->setFileName(fileName);
5305 ret->_content=c; c->incrRef();
5308 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5310 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New();
5311 ret->setFileName(fileName);
5312 ret->_content=c; c->incrRef();
5315 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5318 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
5320 MEDFileUtilities::CheckFileForRead(fileName);
5321 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5322 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll,0);
5323 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5324 ret->loadGlobals(fid);
5328 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
5330 MEDFileUtilities::CheckFileForRead(fileName);
5331 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5332 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll,0);
5333 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5334 ret->loadGlobals(fid);
5338 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
5340 MEDFileUtilities::CheckFileForRead(fileName);
5341 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5342 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,iteration,order,loadAll,0);
5343 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5344 ret->loadGlobals(fid);
5348 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5350 med_field_type typcha;
5351 std::vector<std::string> infos;
5354 int nbOfStep2=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5355 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5360 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5365 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5370 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] !";
5371 throw INTERP_KERNEL::Exception(oss.str().c_str());
5374 ret->setDtUnit(dtunit.c_str());
5375 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5378 std::vector< std::pair<int,int> > dtits(nbOfStep2);
5379 for(int i=0;i<nbOfStep2 && !found;i++)
5381 med_int numdt,numit;
5383 MEDfieldComputingStepInfo(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt);
5384 if(numdt==iteration && numit==order)
5390 dtits[i]=std::pair<int,int>(numdt,numit);
5394 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << fileName << "' ! Available iterations are : ";
5395 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5396 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5397 throw INTERP_KERNEL::Exception(oss.str().c_str());
5400 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms);
5402 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms);
5406 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5407 try:MEDFileFieldGlobsReal(fileName)
5409 MEDFileUtilities::CheckFileForRead(fileName);
5410 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5411 _content=BuildContentFrom(fid,fileName.c_str(),fieldName.c_str(),iteration,order,loadAll,ms);
5414 catch(INTERP_KERNEL::Exception& e)
5420 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5421 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5423 * \warning this is a shallow copy constructor
5425 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5427 if(!shallowCopyOfContent)
5429 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5430 otherPtr->incrRef();
5431 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5435 _content=other.shallowCpy();
5439 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)
5443 int nbFields=MEDnField(fid);
5444 if(fieldIdCFormat>=nbFields)
5446 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << fileName << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5447 throw INTERP_KERNEL::Exception(oss.str().c_str());
5450 int ncomp=MEDfieldnComponent(fid,fieldIdCFormat+1);
5451 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5452 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5453 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5454 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5455 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5458 MEDfieldInfo(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
5459 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5460 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5461 infos.clear(); infos.resize(ncomp);
5462 for(int j=0;j<ncomp;j++)
5463 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5468 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5471 * \return in case of success the number of time steps available for the field with name \a fieldName.
5473 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)
5475 int nbFields=MEDnField(fid);
5477 std::vector<std::string> fns(nbFields);
5479 for(int i=0;i<nbFields && !found;i++)
5482 nbOfStep2=LocateField2(fid,fileName,i,false,tmp,typcha,infos,dtunitOut);
5484 found=(tmp==fieldName);
5490 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
5491 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5492 oss << "\"" << *it << "\" ";
5493 throw INTERP_KERNEL::Exception(oss.str().c_str());
5499 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5500 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5501 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5502 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5503 * to keep a valid instance.
5504 * 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.
5505 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5506 * 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.
5508 * \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.
5509 * \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.
5510 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5511 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5512 * \param [in] newLocName is the new localization name.
5513 * \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.
5514 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5516 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
5518 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5519 std::string oldPflName=disc->getProfile();
5520 std::vector<std::string> vv=getPflsReallyUsedMulti();
5521 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5522 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5524 disc->setProfile(newPflName);
5525 DataArrayInt *pfl=getProfile(oldPflName.c_str());
5526 pfl->setName(newPflName);
5530 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5531 throw INTERP_KERNEL::Exception(oss.str().c_str());
5536 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5537 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5538 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5539 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5540 * to keep a valid instance.
5541 * 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.
5542 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5543 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5544 * 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.
5546 * \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.
5547 * \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.
5548 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5549 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5550 * \param [in] newLocName is the new localization name.
5551 * \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.
5552 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
5554 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
5556 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5557 std::string oldLocName=disc->getLocalization();
5558 std::vector<std::string> vv=getLocsReallyUsedMulti();
5559 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
5560 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
5562 disc->setLocalization(newLocName);
5563 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
5564 loc.setName(newLocName);
5568 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
5569 throw INTERP_KERNEL::Exception(oss.str().c_str());
5573 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
5575 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5577 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
5581 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
5583 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5585 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
5590 * Writes \a this field into a MED file specified by its name.
5591 * \param [in] fileName - the MED file name.
5592 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
5593 * - 2 - erase; an existing file is removed.
5594 * - 1 - append; same data should not be present in an existing file.
5595 * - 0 - overwrite; same data present in an existing file is overwritten.
5596 * \throw If the field name is not set.
5597 * \throw If no field data is set.
5598 * \throw If \a mode == 1 and the same data is present in an existing file.
5600 void MEDFileAnyTypeField1TS::write(const std::string& fileName, int mode) const
5602 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
5603 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
5608 * This method alloc the arrays and load potentially huge arrays contained in this field.
5609 * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
5610 * This method can be also called to refresh or reinit values from a file.
5612 * \throw If the fileName is not set or points to a non readable MED file.
5613 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5615 void MEDFileAnyTypeField1TS::loadArrays()
5617 if(getFileName().empty())
5618 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
5619 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
5620 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
5624 * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
5625 * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
5626 * this method does not throw if \a this does not come from file read.
5628 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
5630 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
5632 if(!getFileName().empty())
5634 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
5635 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
5640 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
5641 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
5642 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
5644 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
5646 void MEDFileAnyTypeField1TS::unloadArrays()
5648 contentNotNullBase()->unloadArrays();
5652 * 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.
5653 * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
5654 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
5656 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5658 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
5660 if(!getFileName().empty())
5661 contentNotNullBase()->unloadArrays();
5664 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
5666 int nbComp=getNumberOfComponents();
5667 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5668 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5669 for(int i=0;i<nbComp;i++)
5671 std::string info=getInfo()[i];
5673 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
5674 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
5675 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
5677 if(getName().empty())
5678 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
5679 MEDfieldCr(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
5680 writeGlobals(fid,*this);
5681 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
5684 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
5686 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
5689 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
5691 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
5692 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
5697 * Returns a string describing \a this field. This string is outputted
5698 * by \c print Python command.
5700 std::string MEDFileAnyTypeField1TS::simpleRepr() const
5702 std::ostringstream oss;
5703 contentNotNullBase()->simpleRepr(0,oss,-1);
5704 simpleReprGlobs(oss);
5709 * This method returns all profiles whose name is non empty used.
5710 * \b WARNING If profile is used several times it will be reported \b only \b once.
5711 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
5713 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
5715 return contentNotNullBase()->getPflsReallyUsed2();
5719 * This method returns all localizations whose name is non empty used.
5720 * \b WARNING If localization is used several times it will be reported \b only \b once.
5722 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
5724 return contentNotNullBase()->getLocsReallyUsed2();
5728 * This method returns all profiles whose name is non empty used.
5729 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
5731 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
5733 return contentNotNullBase()->getPflsReallyUsedMulti2();
5737 * This method returns all localizations whose name is non empty used.
5738 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
5740 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
5742 return contentNotNullBase()->getLocsReallyUsedMulti2();
5745 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5747 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
5750 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5752 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
5755 int MEDFileAnyTypeField1TS::getDimension() const
5757 return contentNotNullBase()->getDimension();
5760 int MEDFileAnyTypeField1TS::getIteration() const
5762 return contentNotNullBase()->getIteration();
5765 int MEDFileAnyTypeField1TS::getOrder() const
5767 return contentNotNullBase()->getOrder();
5770 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
5772 return contentNotNullBase()->getTime(iteration,order);
5775 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
5777 contentNotNullBase()->setTime(iteration,order,val);
5780 std::string MEDFileAnyTypeField1TS::getName() const
5782 return contentNotNullBase()->getName();
5785 void MEDFileAnyTypeField1TS::setName(const std::string& name)
5787 contentNotNullBase()->setName(name);
5790 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
5792 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
5795 std::string MEDFileAnyTypeField1TS::getDtUnit() const
5797 return contentNotNullBase()->getDtUnit();
5800 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
5802 contentNotNullBase()->setDtUnit(dtUnit);
5805 std::string MEDFileAnyTypeField1TS::getMeshName() const
5807 return contentNotNullBase()->getMeshName();
5810 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
5812 contentNotNullBase()->setMeshName(newMeshName);
5815 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
5817 return contentNotNullBase()->changeMeshNames(modifTab);
5820 int MEDFileAnyTypeField1TS::getMeshIteration() const
5822 return contentNotNullBase()->getMeshIteration();
5825 int MEDFileAnyTypeField1TS::getMeshOrder() const
5827 return contentNotNullBase()->getMeshOrder();
5830 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
5832 return contentNotNullBase()->getNumberOfComponents();
5835 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
5837 return contentNotNullBase()->isDealingTS(iteration,order);
5840 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
5842 return contentNotNullBase()->getDtIt();
5845 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
5847 contentNotNullBase()->fillIteration(p);
5850 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
5852 contentNotNullBase()->fillTypesOfFieldAvailable(types);
5855 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
5857 contentNotNullBase()->setInfo(infos);
5860 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
5862 return contentNotNullBase()->getInfo();
5864 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
5866 return contentNotNullBase()->getInfo();
5869 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
5871 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5874 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
5876 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5879 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
5881 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
5884 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
5886 return contentNotNullBase()->getTypesOfFieldAvailable();
5889 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,
5890 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
5892 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
5896 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
5897 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
5898 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
5900 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
5902 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5904 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
5905 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
5906 std::size_t sz(contentsSplit.size());
5907 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
5908 for(std::size_t i=0;i<sz;i++)
5910 ret[i]=shallowCpy();
5911 ret[i]->_content=contentsSplit[i];
5917 * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
5918 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
5920 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
5922 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5924 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
5925 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitDiscretizations();
5926 std::size_t sz(contentsSplit.size());
5927 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
5928 for(std::size_t i=0;i<sz;i++)
5930 ret[i]=shallowCpy();
5931 ret[i]->_content=contentsSplit[i];
5936 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCpy() const
5938 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=shallowCpy();
5939 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
5940 ret->_content=_content->deepCpy();
5941 ret->deepCpyGlobs(*this);
5945 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
5947 return contentNotNullBase()->copyTinyInfoFrom(field,arr);
5953 * Returns a new instance of MEDFileField1TS holding data of the first time step of
5954 * the first field that has been read from a specified MED file.
5955 * \param [in] fileName - the name of the MED file to read.
5956 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5957 * is to delete this field using decrRef() as it is no more needed.
5958 * \throw If reading the file fails.
5960 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll)
5962 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret(new MEDFileField1TS(fileName,loadAll,0));
5963 ret->contentNotNull();
5968 * Returns a new instance of MEDFileField1TS holding data of the first time step of
5969 * a given field that has been read from a specified MED file.
5970 * \param [in] fileName - the name of the MED file to read.
5971 * \param [in] fieldName - the name of the field to read.
5972 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5973 * is to delete this field using decrRef() as it is no more needed.
5974 * \throw If reading the file fails.
5975 * \throw If there is no field named \a fieldName in the file.
5977 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
5979 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret(new MEDFileField1TS(fileName,fieldName,loadAll,0));
5980 ret->contentNotNull();
5985 * Returns a new instance of MEDFileField1TS holding data of a given time step of
5986 * a given field that has been read from a specified MED file.
5987 * \param [in] fileName - the name of the MED file to read.
5988 * \param [in] fieldName - the name of the field to read.
5989 * \param [in] iteration - the iteration number of a required time step.
5990 * \param [in] order - the iteration order number of required time step.
5991 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5992 * is to delete this field using decrRef() as it is no more needed.
5993 * \throw If reading the file fails.
5994 * \throw If there is no field named \a fieldName in the file.
5995 * \throw If the required time step is missing from the file.
5997 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
5999 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret(new MEDFileField1TS(fileName,fieldName,iteration,order,loadAll,0));
6000 ret->contentNotNull();
6005 * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6006 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6008 * Returns a new instance of MEDFileField1TS holding either a shallow copy
6009 * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
6010 * \warning this is a shallow copy constructor
6011 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
6012 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
6013 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6014 * is to delete this field using decrRef() as it is no more needed.
6016 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6018 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(other,shallowCopyOfContent);
6019 ret->contentNotNull();
6024 * Returns a new empty instance of MEDFileField1TS.
6025 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6026 * is to delete this field using decrRef() as it is no more needed.
6028 MEDFileField1TS *MEDFileField1TS::New()
6030 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS;
6031 ret->contentNotNull();
6036 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
6037 * following the given input policy.
6039 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6040 * By default (true) the globals are deeply copied.
6041 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
6043 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
6045 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret;
6046 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6049 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
6051 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
6052 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
6053 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc,getFileName()));
6056 ret=MEDFileIntField1TS::New();
6058 ret->deepCpyGlobs(*this);
6060 ret->shallowCpyGlobs(*this);
6064 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const
6066 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6068 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
6069 const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
6071 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 !");
6075 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull()
6077 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6079 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
6080 MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
6082 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 !");
6086 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MEDCouplingAutoRefCountObjectPtr<DataArray>& arr)
6089 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
6090 if(!((DataArray*)arr))
6091 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
6092 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
6094 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6095 f->setArray(arrOutC);
6098 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr)
6100 if(!((DataArray*)arr))
6101 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
6102 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
6104 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6109 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
6110 try:MEDFileAnyTypeField1TS(fileName,loadAll,ms)
6113 catch(INTERP_KERNEL::Exception& e)
6116 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6117 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll,ms)
6120 catch(INTERP_KERNEL::Exception& e)
6123 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6124 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll,ms)
6127 catch(INTERP_KERNEL::Exception& e)
6131 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6132 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6134 * \warning this is a shallow copy constructor
6136 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6137 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6140 catch(INTERP_KERNEL::Exception& e)
6143 MEDFileField1TS::MEDFileField1TS()
6145 _content=new MEDFileField1TSWithoutSDA;
6149 * Returns a new MEDCouplingFieldDouble of a given type lying on
6150 * mesh entities of a given dimension of the first mesh in MED file. If \a this field
6151 * has not been constructed via file reading, an exception is thrown.
6152 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6153 * \param [in] type - a spatial discretization of interest.
6154 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6155 * \param [in] renumPol - specifies how to permute values of the result field according to
6156 * the optional numbers of cells and nodes, if any. The valid values are
6157 * - 0 - do not permute.
6158 * - 1 - permute cells.
6159 * - 2 - permute nodes.
6160 * - 3 - permute cells and nodes.
6162 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6163 * caller is to delete this field using decrRef() as it is no more needed.
6164 * \throw If \a this field has not been constructed via file reading.
6165 * \throw If the MED file is not readable.
6166 * \throw If there is no mesh in the MED file.
6167 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6168 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6169 * \sa getFieldOnMeshAtLevel()
6171 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6173 if(getFileName().empty())
6174 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6175 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6176 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull());
6177 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6182 * Returns a new MEDCouplingFieldDouble of a given type lying on
6183 * the top level cells of the first mesh in MED file. If \a this field
6184 * has not been constructed via file reading, an exception is thrown.
6185 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6186 * \param [in] type - a spatial discretization of interest.
6187 * \param [in] renumPol - specifies how to permute values of the result field according to
6188 * the optional numbers of cells and nodes, if any. The valid values are
6189 * - 0 - do not permute.
6190 * - 1 - permute cells.
6191 * - 2 - permute nodes.
6192 * - 3 - permute cells and nodes.
6194 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6195 * caller is to delete this field using decrRef() as it is no more needed.
6196 * \throw If \a this field has not been constructed via file reading.
6197 * \throw If the MED file is not readable.
6198 * \throw If there is no mesh in the MED file.
6199 * \throw If no field values of the given \a type.
6200 * \throw If no field values lying on the top level support.
6201 * \sa getFieldAtLevel()
6203 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
6205 if(getFileName().empty())
6206 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6207 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6208 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull());
6209 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6214 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6215 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6216 * \param [in] type - a spatial discretization of the new field.
6217 * \param [in] mesh - the supporting mesh.
6218 * \param [in] renumPol - specifies how to permute values of the result field according to
6219 * the optional numbers of cells and nodes, if any. The valid values are
6220 * - 0 - do not permute.
6221 * - 1 - permute cells.
6222 * - 2 - permute nodes.
6223 * - 3 - permute cells and nodes.
6225 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6226 * caller is to delete this field using decrRef() as it is no more needed.
6227 * \throw If no field of \a this is lying on \a mesh.
6228 * \throw If the mesh is empty.
6229 * \throw If no field values of the given \a type are available.
6230 * \sa getFieldAtLevel()
6231 * \sa getFieldOnMeshAtLevel()
6233 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
6235 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6236 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull());
6237 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6242 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6243 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6244 * \param [in] type - a spatial discretization of interest.
6245 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6246 * \param [in] mesh - the supporting mesh.
6247 * \param [in] renumPol - specifies how to permute values of the result field according to
6248 * the optional numbers of cells and nodes, if any. The valid values are
6249 * - 0 - do not permute.
6250 * - 1 - permute cells.
6251 * - 2 - permute nodes.
6252 * - 3 - permute cells and nodes.
6254 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6255 * caller is to delete this field using decrRef() as it is no more needed.
6256 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6257 * \throw If no field of \a this is lying on \a mesh.
6258 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6259 * \sa getFieldAtLevel()
6260 * \sa getFieldOnMeshAtLevel()
6262 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
6264 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6265 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull());
6266 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6271 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6272 * This method is called "Old" because in MED3 norm a field has only one meshName
6273 * attached, so this method is for readers of MED2 files. If \a this field
6274 * has not been constructed via file reading, an exception is thrown.
6275 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6276 * \param [in] type - a spatial discretization of interest.
6277 * \param [in] mName - a name of the supporting mesh.
6278 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6279 * \param [in] renumPol - specifies how to permute values of the result field according to
6280 * the optional numbers of cells and nodes, if any. The valid values are
6281 * - 0 - do not permute.
6282 * - 1 - permute cells.
6283 * - 2 - permute nodes.
6284 * - 3 - permute cells and nodes.
6286 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6287 * caller is to delete this field using decrRef() as it is no more needed.
6288 * \throw If the MED file is not readable.
6289 * \throw If there is no mesh named \a mName in the MED file.
6290 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6291 * \throw If \a this field has not been constructed via file reading.
6292 * \throw If no field of \a this is lying on the mesh named \a mName.
6293 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6294 * \sa getFieldAtLevel()
6296 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
6298 if(getFileName().empty())
6299 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6300 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6301 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
6302 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6307 * Returns values and a profile of the field of a given type lying on a given support.
6308 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6309 * \param [in] type - a spatial discretization of the field.
6310 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6311 * \param [in] mesh - the supporting mesh.
6312 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6313 * field of interest lies on. If the field lies on all entities of the given
6314 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6315 * using decrRef() as it is no more needed.
6316 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6317 * field. The caller is to delete this array using decrRef() as it is no more needed.
6318 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6319 * \throw If no field of \a this is lying on \a mesh.
6320 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6322 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6324 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6325 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
6329 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6330 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6331 * "Sort By Type"), if not, an exception is thrown.
6332 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6333 * \param [in] field - the field to add to \a this.
6334 * \throw If the name of \a field is empty.
6335 * \throw If the data array of \a field is not set.
6336 * \throw If the data array is already allocated but has different number of components
6338 * \throw If the underlying mesh of \a field has no name.
6339 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6341 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
6344 contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
6348 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6349 * can be an aggregation of several MEDCouplingFieldDouble instances.
6350 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6351 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6354 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6355 * A new profile is added only if no equal profile is missing.
6356 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6357 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
6358 * \param [in] mesh - the supporting mesh of \a field.
6359 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6360 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6361 * \throw If either \a field or \a mesh or \a profile has an empty name.
6362 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6363 * \throw If the data array of \a field is not set.
6364 * \throw If the data array of \a this is already allocated but has different number of
6365 * components than \a field.
6366 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6367 * \sa setFieldNoProfileSBT()
6369 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6372 contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6375 MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const
6377 return new MEDFileField1TS(*this);
6380 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const
6382 return contentNotNull()->getUndergroundDataArrayDouble();
6385 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
6387 return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
6390 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6391 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6393 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6396 //= MEDFileIntField1TS
6398 MEDFileIntField1TS *MEDFileIntField1TS::New()
6400 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS;
6401 ret->contentNotNull();
6405 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll)
6407 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,loadAll,0));
6408 ret->contentNotNull();
6412 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6414 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,fieldName,loadAll,0));
6415 ret->contentNotNull();
6419 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6421 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,fieldName,iteration,order,loadAll,0));
6422 ret->contentNotNull();
6426 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6428 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6429 ret->contentNotNull();
6433 MEDFileIntField1TS::MEDFileIntField1TS()
6435 _content=new MEDFileIntField1TSWithoutSDA;
6438 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
6439 try:MEDFileAnyTypeField1TS(fileName,loadAll,ms)
6442 catch(INTERP_KERNEL::Exception& e)
6445 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6446 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll,ms)
6449 catch(INTERP_KERNEL::Exception& e)
6452 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6453 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll,ms)
6456 catch(INTERP_KERNEL::Exception& e)
6460 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6461 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6463 * \warning this is a shallow copy constructor
6465 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6469 MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const
6471 return new MEDFileIntField1TS(*this);
6475 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
6476 * following the given input policy.
6478 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6479 * By default (true) the globals are deeply copied.
6480 * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
6482 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const
6484 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret;
6485 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6488 const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
6490 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
6491 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
6492 ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc,getFileName()));
6495 ret=MEDFileField1TS::New();
6497 ret->deepCpyGlobs(*this);
6499 ret->shallowCpyGlobs(*this);
6504 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6505 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6506 * "Sort By Type"), if not, an exception is thrown.
6507 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6508 * \param [in] field - the field to add to \a this. The field double values are ignored.
6509 * \param [in] arrOfVals - the values of the field \a field used.
6510 * \throw If the name of \a field is empty.
6511 * \throw If the data array of \a field is not set.
6512 * \throw If the data array is already allocated but has different number of components
6514 * \throw If the underlying mesh of \a field has no name.
6515 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6517 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals)
6520 contentNotNull()->setFieldNoProfileSBT(field,arrOfVals,*this,*contentNotNull());
6524 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6525 * can be an aggregation of several MEDCouplingFieldDouble instances.
6526 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6527 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6530 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6531 * A new profile is added only if no equal profile is missing.
6532 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6533 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
6534 * \param [in] arrOfVals - the values of the field \a field used.
6535 * \param [in] mesh - the supporting mesh of \a field.
6536 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6537 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6538 * \throw If either \a field or \a mesh or \a profile has an empty name.
6539 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6540 * \throw If the data array of \a field is not set.
6541 * \throw If the data array of \a this is already allocated but has different number of
6542 * components than \a field.
6543 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6544 * \sa setFieldNoProfileSBT()
6546 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6549 contentNotNull()->setFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6552 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const
6554 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6556 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
6557 const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
6559 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 !");
6563 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
6565 if(getFileName().empty())
6566 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6567 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut2;
6568 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut2,*contentNotNull());
6569 DataArrayInt *arrOutC=dynamic_cast<DataArrayInt *>((DataArray *)arrOut2);
6571 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : mismatch between dataArrays type and MEDFileIntField1TS ! Expected int32 !");
6576 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr)
6578 if(!((DataArray *)arr))
6579 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
6580 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>((DataArray *)arr);
6582 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
6588 * Returns a new MEDCouplingFieldDouble of a given type lying on
6589 * the top level cells of the first mesh in MED file. If \a this field
6590 * has not been constructed via file reading, an exception is thrown.
6591 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6592 * \param [in] type - a spatial discretization of interest.
6593 * \param [out] arrOut - the DataArrayInt containing values of field.
6594 * \param [in] renumPol - specifies how to permute values of the result field according to
6595 * the optional numbers of cells and nodes, if any. The valid values are
6596 * - 0 - do not permute.
6597 * - 1 - permute cells.
6598 * - 2 - permute nodes.
6599 * - 3 - permute cells and nodes.
6601 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6602 * caller is to delete this field using decrRef() as it is no more needed.
6603 * \throw If \a this field has not been constructed via file reading.
6604 * \throw If the MED file is not readable.
6605 * \throw If there is no mesh in the MED file.
6606 * \throw If no field values of the given \a type.
6607 * \throw If no field values lying on the top level support.
6608 * \sa getFieldAtLevel()
6610 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, DataArrayInt* &arrOut, int renumPol) const
6612 if(getFileName().empty())
6613 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6614 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6615 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNull());
6616 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6621 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6622 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6623 * \param [in] type - a spatial discretization of the new field.
6624 * \param [in] mesh - the supporting mesh.
6625 * \param [out] arrOut - the DataArrayInt containing values of field.
6626 * \param [in] renumPol - specifies how to permute values of the result field according to
6627 * the optional numbers of cells and nodes, if any. The valid values are
6628 * - 0 - do not permute.
6629 * - 1 - permute cells.
6630 * - 2 - permute nodes.
6631 * - 3 - permute cells and nodes.
6633 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6634 * caller is to delete this field using decrRef() as it is no more needed.
6635 * \throw If no field of \a this is lying on \a mesh.
6636 * \throw If the mesh is empty.
6637 * \throw If no field values of the given \a type are available.
6638 * \sa getFieldAtLevel()
6639 * \sa getFieldOnMeshAtLevel()
6641 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
6643 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6644 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNull());
6645 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6650 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6651 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6652 * \param [in] type - a spatial discretization of interest.
6653 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6654 * \param [out] arrOut - the DataArrayInt containing values of field.
6655 * \param [in] mesh - the supporting mesh.
6656 * \param [in] renumPol - specifies how to permute values of the result field according to
6657 * the optional numbers of cells and nodes, if any. The valid values are
6658 * - 0 - do not permute.
6659 * - 1 - permute cells.
6660 * - 2 - permute nodes.
6661 * - 3 - permute cells and nodes.
6663 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6664 * caller is to delete this field using decrRef() as it is no more needed.
6665 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6666 * \throw If no field of \a this is lying on \a mesh.
6667 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6668 * \sa getFieldAtLevel()
6669 * \sa getFieldOnMeshAtLevel()
6671 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
6673 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6674 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNull());
6675 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6680 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6681 * This method is called "Old" because in MED3 norm a field has only one meshName
6682 * attached, so this method is for readers of MED2 files. If \a this field
6683 * has not been constructed via file reading, an exception is thrown.
6684 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6685 * \param [in] type - a spatial discretization of interest.
6686 * \param [in] mName - a name of the supporting mesh.
6687 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6688 * \param [out] arrOut - the DataArrayInt containing values of field.
6689 * \param [in] renumPol - specifies how to permute values of the result field according to
6690 * the optional numbers of cells and nodes, if any. The valid values are
6691 * - 0 - do not permute.
6692 * - 1 - permute cells.
6693 * - 2 - permute nodes.
6694 * - 3 - permute cells and nodes.
6696 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6697 * caller is to delete this field using decrRef() as it is no more needed.
6698 * \throw If the MED file is not readable.
6699 * \throw If there is no mesh named \a mName in the MED file.
6700 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6701 * \throw If \a this field has not been constructed via file reading.
6702 * \throw If no field of \a this is lying on the mesh named \a mName.
6703 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6704 * \sa getFieldAtLevel()
6706 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
6708 if(getFileName().empty())
6709 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6710 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6711 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNull());
6712 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6717 * Returns values and a profile of the field of a given type lying on a given support.
6718 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6719 * \param [in] type - a spatial discretization of the field.
6720 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6721 * \param [in] mesh - the supporting mesh.
6722 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6723 * field of interest lies on. If the field lies on all entities of the given
6724 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6725 * using decrRef() as it is no more needed.
6726 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
6727 * field. The caller is to delete this array using decrRef() as it is no more needed.
6728 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6729 * \throw If no field of \a this is lying on \a mesh.
6730 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6732 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6734 MEDCouplingAutoRefCountObjectPtr<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6735 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6738 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull()
6740 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6742 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
6743 MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
6745 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 !");
6749 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const
6751 return contentNotNull()->getUndergroundDataArrayInt();
6754 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
6756 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
6760 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileFieldNameScope(fieldName)
6765 * \param [in] fieldId field id in C mode
6767 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms)
6769 med_field_type typcha;
6770 std::string dtunitOut;
6771 int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,"",fieldId,false,_name,typcha,_infos,dtunitOut);
6772 setDtUnit(dtunitOut.c_str());
6773 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms);
6776 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)
6777 try:MEDFileFieldNameScope(fieldName),_infos(infos)
6779 setDtUnit(dtunit.c_str());
6780 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms);
6782 catch(INTERP_KERNEL::Exception& e)
6787 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
6789 std::size_t ret(_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA>));
6790 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
6791 ret+=(*it).capacity();
6795 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
6797 std::vector<const BigMemoryObject *> ret;
6798 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6799 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
6804 * 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
6807 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
6809 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6810 ret->setInfo(_infos);
6811 int sz=(int)_time_steps.size();
6812 for(const int *id=startIds;id!=endIds;id++)
6814 if(*id>=0 && *id<sz)
6816 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
6817 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6821 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6823 ret->pushBackTimeStep(tse2);
6827 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
6828 oss << " ! Should be in [0," << sz << ") !";
6829 throw INTERP_KERNEL::Exception(oss.str().c_str());
6832 if(ret->getNumberOfTS()>0)
6833 ret->synchronizeNameScope();
6834 ret->copyNameScope(*this);
6839 * 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
6842 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
6844 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
6845 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
6846 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6847 ret->setInfo(_infos);
6848 int sz=(int)_time_steps.size();
6850 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
6854 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
6855 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6859 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6861 ret->pushBackTimeStep(tse2);
6865 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
6866 oss << " ! Should be in [0," << sz << ") !";
6867 throw INTERP_KERNEL::Exception(oss.str().c_str());
6870 if(ret->getNumberOfTS()>0)
6871 ret->synchronizeNameScope();
6872 ret->copyNameScope(*this);
6876 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
6879 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
6880 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
6882 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6885 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
6886 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
6887 ids->pushBackSilent(id);
6889 return buildFromTimeStepIds(ids->begin(),ids->end());
6892 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
6895 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
6896 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
6898 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6901 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
6902 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
6903 ids->pushBackSilent(id);
6905 return buildFromTimeStepIds(ids->begin(),ids->end());
6908 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
6913 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
6918 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
6921 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
6923 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
6924 if(pt->isDealingTS(iteration,order))
6927 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
6928 std::vector< std::pair<int,int> > vp=getIterations();
6929 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
6930 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
6931 throw INTERP_KERNEL::Exception(oss.str().c_str());
6934 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
6936 return *_time_steps[getTimeStepPos(iteration,order)];
6939 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
6941 return *_time_steps[getTimeStepPos(iteration,order)];
6944 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const
6946 if(_time_steps.empty())
6947 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
6948 return _time_steps[0]->getMeshName();
6951 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const std::string& newMeshName)
6953 std::string oldName(getMeshName());
6954 std::vector< std::pair<std::string,std::string> > v(1);
6955 v[0].first=oldName; v[0].second=newMeshName;
6959 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
6962 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6964 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6966 ret=cur->changeMeshNames(modifTab) || ret;
6972 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
6974 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
6976 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
6980 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
6982 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
6984 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
6987 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
6988 MEDFileFieldGlobsReal& glob)
6991 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6993 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
6995 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
7000 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7002 std::string startLine(bkOffset,' ');
7003 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
7005 oss << " (" << fmtsId << ")";
7006 oss << " has the following name: \"" << _name << "\"." << std::endl;
7007 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
7008 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7010 oss << startLine << " - \"" << *it << "\"" << std::endl;
7013 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7015 std::string chapter(17,'0'+i);
7016 oss << startLine << chapter << std::endl;
7017 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7019 cur->simpleRepr(bkOffset+2,oss,i);
7021 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
7022 oss << startLine << chapter << std::endl;
7026 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
7028 std::size_t sz=_time_steps.size();
7029 std::vector< std::pair<int,int> > ret(sz);
7031 for(std::size_t i=0;i<sz;i++)
7033 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
7036 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
7040 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
7041 throw INTERP_KERNEL::Exception(oss.str().c_str());
7047 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>& tse)
7049 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
7051 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
7052 checkCoherencyOfType(tse2);
7053 if(_time_steps.empty())
7055 setName(tse2->getName().c_str());
7056 setInfo(tse2->getInfo());
7058 checkThatComponentsMatch(tse2->getInfo());
7059 _time_steps.push_back(tse);
7062 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
7064 std::size_t nbOfCompo=_infos.size();
7065 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7067 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7070 if((cur->getInfo()).size()!=nbOfCompo)
7072 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
7073 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
7074 throw INTERP_KERNEL::Exception(oss.str().c_str());
7076 cur->copyNameScope(*this);
7081 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms)
7083 _time_steps.resize(nbPdt);
7084 for(int i=0;i<nbPdt;i++)
7086 std::vector< std::pair<int,int> > ts;
7087 med_int numdt=0,numo=0;
7088 med_int meshIt=0,meshOrder=0;
7090 MEDfieldComputingStepMeshInfo(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder);
7095 _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7100 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7104 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
7107 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms);
7109 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms);
7113 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
7115 if(_time_steps.empty())
7116 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
7117 checkThatNbOfCompoOfTSMatchThis();
7118 std::vector<std::string> infos(getInfo());
7119 int nbComp=infos.size();
7120 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7121 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7122 for(int i=0;i<nbComp;i++)
7124 std::string info=infos[i];
7126 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7127 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7128 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7131 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7132 MEDfieldCr(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
7133 int nbOfTS=_time_steps.size();
7134 for(int i=0;i<nbOfTS;i++)
7135 _time_steps[i]->writeLL(fid,opts,*this);
7138 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
7140 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7142 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7144 elt->loadBigArraysRecursively(fid,nasc);
7148 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
7150 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7152 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7154 elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7158 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
7160 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7162 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7164 elt->unloadArrays();
7168 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7170 return _time_steps.size();
7173 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
7175 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7176 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7178 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7180 newTS.push_back(*it);
7185 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
7187 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7188 int maxId=(int)_time_steps.size();
7190 std::set<int> idsToDel;
7191 for(const int *id=startIds;id!=endIds;id++,ii++)
7193 if(*id>=0 && *id<maxId)
7195 idsToDel.insert(*id);
7199 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7200 throw INTERP_KERNEL::Exception(oss.str().c_str());
7203 for(int iii=0;iii<maxId;iii++)
7204 if(idsToDel.find(iii)==idsToDel.end())
7205 newTS.push_back(_time_steps[iii]);
7209 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
7211 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7212 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7213 if(nbOfEntriesToKill==0)
7215 std::size_t sz=_time_steps.size();
7216 std::vector<bool> b(sz,true);
7218 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7220 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7221 for(std::size_t i=0;i<sz;i++)
7223 newTS.push_back(_time_steps[i]);
7227 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
7230 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
7231 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7233 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7237 tmp->getTime(it2,ord);
7238 if(it2==iteration && order==ord)
7241 oss << "(" << it2 << "," << ord << "), ";
7244 throw INTERP_KERNEL::Exception(oss.str().c_str());
7247 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
7250 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
7252 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7254 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7258 double ti=tmp->getTime(it2,ord);
7259 if(fabs(time-ti)<eps)
7265 throw INTERP_KERNEL::Exception(oss.str().c_str());
7268 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
7270 int lgth=_time_steps.size();
7271 std::vector< std::pair<int,int> > ret(lgth);
7272 for(int i=0;i<lgth;i++)
7273 _time_steps[i]->fillIteration(ret[i]);
7278 * 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'
7279 * This method returns two things.
7280 * - The absolute dimension of 'this' in first parameter.
7281 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7282 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
7284 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7285 * Only these 3 discretizations will be taken into account here.
7287 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7288 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7289 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7291 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7292 * 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'.
7294 * Let's consider the typical following case :
7295 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7296 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7297 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7299 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7301 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7303 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7304 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7305 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7306 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7308 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
7310 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7313 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
7315 if(pos<0 || pos>=(int)_time_steps.size())
7317 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7318 throw INTERP_KERNEL::Exception(oss.str().c_str());
7320 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7323 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7324 oss << "\nTry to use following method eraseEmptyTS !";
7325 throw INTERP_KERNEL::Exception(oss.str().c_str());
7330 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
7332 if(pos<0 || pos>=(int)_time_steps.size())
7334 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7335 throw INTERP_KERNEL::Exception(oss.str().c_str());
7337 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7340 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7341 oss << "\nTry to use following method eraseEmptyTS !";
7342 throw INTERP_KERNEL::Exception(oss.str().c_str());
7347 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
7349 std::vector<std::string> ret;
7350 std::set<std::string> ret2;
7351 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7353 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
7354 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7355 if(ret2.find(*it2)==ret2.end())
7357 ret.push_back(*it2);
7364 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
7366 std::vector<std::string> ret;
7367 std::set<std::string> ret2;
7368 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7370 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
7371 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7372 if(ret2.find(*it2)==ret2.end())
7374 ret.push_back(*it2);
7381 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
7383 std::vector<std::string> ret;
7384 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7386 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
7387 ret.insert(ret.end(),tmp.begin(),tmp.end());
7392 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
7394 std::vector<std::string> ret;
7395 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7397 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
7398 ret.insert(ret.end(),tmp.begin(),tmp.end());
7403 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7405 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7406 (*it)->changePflsRefsNamesGen2(mapOfModif);
7409 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7411 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7412 (*it)->changeLocsRefsNamesGen2(mapOfModif);
7415 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
7417 int lgth=_time_steps.size();
7418 std::vector< std::vector<TypeOfField> > ret(lgth);
7419 for(int i=0;i<lgth;i++)
7420 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
7425 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
7427 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
7429 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
7432 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCpy() const
7434 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
7436 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7438 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
7439 ret->_time_steps[i]=(*it)->deepCpy();
7444 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
7446 std::size_t sz(_infos.size()),sz2(_time_steps.size());
7447 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7448 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7449 for(std::size_t i=0;i<sz;i++)
7451 ret[i]=shallowCpy();
7452 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7454 for(std::size_t i=0;i<sz2;i++)
7456 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7459 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7460 throw INTERP_KERNEL::Exception(oss.str().c_str());
7464 for(std::size_t i=0;i<sz;i++)
7465 for(std::size_t j=0;j<sz2;j++)
7466 ret[i]->_time_steps[j]=ts[j][i];
7471 * This method splits into discretization each time steps in \a this.
7472 * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
7474 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
7476 std::size_t sz(_time_steps.size());
7477 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7478 for(std::size_t i=0;i<sz;i++)
7480 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7483 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
7484 throw INTERP_KERNEL::Exception(oss.str().c_str());
7486 items[i]=timeStep->splitDiscretizations();
7489 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
7490 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
7491 std::vector< TypeOfField > types;
7492 for(std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7493 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7495 std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
7497 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
7498 std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
7499 if(it2==types.end())
7500 types.push_back(ts[0]);
7502 ret.resize(types.size()); ret2.resize(types.size());
7503 for(std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7504 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7506 TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
7507 std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
7508 ret2[pos].push_back(*it1);
7510 for(std::size_t i=0;i<types.size();i++)
7512 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=createNew();
7513 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
7514 elt->pushBackTimeStep(*it1);//also updates infos in elt
7516 elt->MEDFileFieldNameScope::operator=(*this);
7521 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
7523 _name=field->getName();
7525 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
7527 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
7528 _infos=arr->getInfoOnComponents();
7531 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
7533 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
7534 if(_name!=field->getName())
7536 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
7537 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
7538 throw INTERP_KERNEL::Exception(oss.str().c_str());
7541 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
7542 checkThatComponentsMatch(arr->getInfoOnComponents());
7545 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
7547 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
7548 if(getInfo().size()!=compos.size())
7550 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
7551 oss << " number of components of element to append (" << compos.size() << ") !";
7552 throw INTERP_KERNEL::Exception(oss.str().c_str());
7556 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
7557 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
7558 oss << " But compo in input fields are : ";
7559 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
7561 throw INTERP_KERNEL::Exception(oss.str().c_str());
7565 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
7567 std::size_t sz=_infos.size();
7569 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
7571 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7573 if(elt->getInfo().size()!=sz)
7575 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
7576 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
7577 throw INTERP_KERNEL::Exception(oss.str().c_str());
7582 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
7585 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7586 if(!_time_steps.empty())
7587 checkCoherencyOfTinyInfo(field,arr);
7588 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
7589 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7590 objC->setFieldNoProfileSBT(field,arr,glob,*this);
7591 copyTinyInfoFrom(field,arr);
7592 _time_steps.push_back(obj);
7595 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
7598 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7599 if(!_time_steps.empty())
7600 checkCoherencyOfTinyInfo(field,arr);
7601 MEDFileField1TSWithoutSDA *objC=new MEDFileField1TSWithoutSDA;
7602 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7603 objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
7604 copyTinyInfoFrom(field,arr);
7605 _time_steps.push_back(obj);
7608 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ts)
7610 int sz=(int)_time_steps.size();
7613 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
7614 throw INTERP_KERNEL::Exception(oss.str().c_str());
7616 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
7619 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
7621 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
7622 throw INTERP_KERNEL::Exception(oss.str().c_str());
7628 //= MEDFileFieldMultiTSWithoutSDA
7630 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)
7632 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms);
7635 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
7639 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7644 * \param [in] fieldId field id in C mode
7646 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms)
7647 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms)
7650 catch(INTERP_KERNEL::Exception& e)
7653 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)
7654 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms)
7657 catch(INTERP_KERNEL::Exception& e)
7660 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
7662 return new MEDFileField1TSWithoutSDA;
7665 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
7668 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7669 const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
7671 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
7674 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const
7676 return MEDFileField1TSWithoutSDA::TYPE_STR;
7679 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const
7681 return new MEDFileFieldMultiTSWithoutSDA(*this);
7684 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const
7686 return new MEDFileFieldMultiTSWithoutSDA;
7690 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
7691 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
7693 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
7695 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
7696 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
7698 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
7699 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
7702 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
7704 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
7705 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
7707 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7709 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
7712 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
7714 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
7715 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
7716 ret->setIteration(i,elt);
7722 //= MEDFileAnyTypeFieldMultiTS
7724 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
7728 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
7729 try:MEDFileFieldGlobsReal(fileName)
7731 MEDFileUtilities::CheckFileForRead(fileName);
7732 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
7733 _content=BuildContentFrom(fid,fileName,loadAll,ms);
7736 catch(INTERP_KERNEL::Exception& e)
7741 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
7743 med_field_type typcha;
7744 std::vector<std::string> infos;
7747 MEDFileAnyTypeField1TS::LocateField(fid,fileName,fieldName,i,typcha,infos,dtunit);
7748 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7753 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms);
7758 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms);
7763 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] !";
7764 throw INTERP_KERNEL::Exception(oss.str().c_str());
7767 ret->setDtUnit(dtunit.c_str());
7771 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
7773 med_field_type typcha;
7775 std::vector<std::string> infos;
7776 std::string dtunit,fieldName;
7777 MEDFileAnyTypeField1TS::LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
7778 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7783 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms);
7788 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms);
7793 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] !";
7794 throw INTERP_KERNEL::Exception(oss.str().c_str());
7797 ret->setDtUnit(dtunit.c_str());
7801 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, const std::string& fileName)
7804 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
7805 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
7807 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=MEDFileFieldMultiTS::New();
7808 ret->setFileName(fileName);
7809 ret->_content=c; c->incrRef();
7812 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
7814 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=MEDFileIntFieldMultiTS::New();
7815 ret->setFileName(fileName);
7816 ret->_content=c; c->incrRef();
7819 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
7822 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
7823 try:MEDFileFieldGlobsReal(fileName)
7825 MEDFileUtilities::CheckFileForRead(fileName);
7826 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
7827 _content=BuildContentFrom(fid,fileName,fieldName,loadAll,ms);
7830 catch(INTERP_KERNEL::Exception& e)
7835 //= MEDFileIntFieldMultiTSWithoutSDA
7837 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)
7839 return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms);
7842 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
7846 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7850 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)
7851 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms)
7854 catch(INTERP_KERNEL::Exception& e)
7858 * \param [in] fieldId field id in C mode
7860 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms)
7861 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms)
7864 catch(INTERP_KERNEL::Exception& e)
7867 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
7869 return new MEDFileIntField1TSWithoutSDA;
7872 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
7875 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7876 const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
7878 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
7881 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const
7883 return MEDFileIntField1TSWithoutSDA::TYPE_STR;
7886 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const
7888 return new MEDFileIntFieldMultiTSWithoutSDA(*this);
7891 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const
7893 return new MEDFileIntFieldMultiTSWithoutSDA;
7896 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const
7898 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
7899 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
7901 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7903 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
7906 const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
7908 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
7909 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
7910 ret->setIteration(i,elt);
7916 //= MEDFileAnyTypeFieldMultiTS
7919 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
7920 * that has been read from a specified MED file.
7921 * \param [in] fileName - the name of the MED file to read.
7922 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
7923 * is to delete this field using decrRef() as it is no more needed.
7924 * \throw If reading the file fails.
7926 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
7928 MEDFileUtilities::CheckFileForRead(fileName);
7929 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
7930 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll,0);
7931 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
7932 ret->loadGlobals(fid);
7937 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
7938 * that has been read from a specified MED file.
7939 * \param [in] fileName - the name of the MED file to read.
7940 * \param [in] fieldName - the name of the field to read.
7941 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
7942 * is to delete this field using decrRef() as it is no more needed.
7943 * \throw If reading the file fails.
7944 * \throw If there is no field named \a fieldName in the file.
7946 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
7948 MEDFileUtilities::CheckFileForRead(fileName);
7949 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
7950 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll,0);
7951 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
7952 ret->loadGlobals(fid);
7957 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
7958 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
7960 * \warning this is a shallow copy constructor
7962 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
7964 if(!shallowCopyOfContent)
7966 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
7967 otherPtr->incrRef();
7968 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
7972 _content=other.shallowCpy();
7976 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
7978 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
7980 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
7984 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
7986 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
7988 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
7992 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
7994 return contentNotNullBase()->getPflsReallyUsed2();
7997 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
7999 return contentNotNullBase()->getLocsReallyUsed2();
8002 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
8004 return contentNotNullBase()->getPflsReallyUsedMulti2();
8007 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
8009 return contentNotNullBase()->getLocsReallyUsedMulti2();
8012 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8014 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
8017 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8019 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
8022 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
8024 return contentNotNullBase()->getNumberOfTS();
8027 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
8029 contentNotNullBase()->eraseEmptyTS();
8032 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
8034 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
8037 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
8039 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
8042 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
8044 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
8045 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8050 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
8052 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
8053 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8058 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
8060 return contentNotNullBase()->getIterations();
8063 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
8065 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
8066 pushBackTimeStep(*it);
8069 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
8072 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
8073 checkCoherencyOfType(f1ts);
8075 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
8076 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
8078 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
8079 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
8080 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
8081 _content->pushBackTimeStep(cSafe);
8082 appendGlobs(*f1ts,1e-12);
8085 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
8087 contentNotNullBase()->synchronizeNameScope();
8090 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
8092 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
8095 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
8097 return contentNotNullBase()->getPosGivenTime(time,eps);
8100 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8102 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
8105 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
8107 return contentNotNullBase()->getTypesOfFieldAvailable();
8110 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
8112 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
8115 std::string MEDFileAnyTypeFieldMultiTS::getName() const
8117 return contentNotNullBase()->getName();
8120 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
8122 contentNotNullBase()->setName(name);
8125 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
8127 return contentNotNullBase()->getDtUnit();
8130 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
8132 contentNotNullBase()->setDtUnit(dtUnit);
8135 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8137 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
8140 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
8142 return contentNotNullBase()->getTimeSteps(ret1);
8145 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
8147 return contentNotNullBase()->getMeshName();
8150 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
8152 contentNotNullBase()->setMeshName(newMeshName);
8155 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
8157 return contentNotNullBase()->changeMeshNames(modifTab);
8160 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
8162 return contentNotNullBase()->getInfo();
8165 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
8167 return contentNotNullBase()->setInfo(info);
8170 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
8172 const std::vector<std::string> ret=getInfo();
8173 return (int)ret.size();
8176 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
8178 writeGlobals(fid,*this);
8179 contentNotNullBase()->writeLL(fid,*this);
8183 * Writes \a this field into a MED file specified by its name.
8184 * \param [in] fileName - the MED file name.
8185 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
8186 * - 2 - erase; an existing file is removed.
8187 * - 1 - append; same data should not be present in an existing file.
8188 * - 0 - overwrite; same data present in an existing file is overwritten.
8189 * \throw If the field name is not set.
8190 * \throw If no field data is set.
8191 * \throw If \a mode == 1 and the same data is present in an existing file.
8193 void MEDFileAnyTypeFieldMultiTS::write(const std::string& fileName, int mode) const
8195 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
8196 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
8201 * This method alloc the arrays and load potentially huge arrays contained in this field.
8202 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
8203 * This method can be also called to refresh or reinit values from a file.
8205 * \throw If the fileName is not set or points to a non readable MED file.
8207 void MEDFileAnyTypeFieldMultiTS::loadArrays()
8209 if(getFileName().empty())
8210 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
8211 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
8212 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
8216 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
8217 * But once data loaded once, this method does nothing.
8219 * \throw If the fileName is not set or points to a non readable MED file.
8220 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
8222 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
8224 if(!getFileName().empty())
8226 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
8227 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
8232 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
8233 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
8234 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
8236 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
8238 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
8240 contentNotNullBase()->unloadArrays();
8244 * 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.
8245 * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
8246 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
8248 * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
8250 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
8252 if(!getFileName().empty())
8253 contentNotNullBase()->unloadArrays();
8256 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
8258 std::ostringstream oss;
8259 contentNotNullBase()->simpleRepr(0,oss,-1);
8260 simpleReprGlobs(oss);
8264 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
8266 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
8269 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
8271 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
8272 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
8277 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
8278 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8279 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
8281 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
8283 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8285 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
8286 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
8287 std::size_t sz(contentsSplit.size());
8288 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8289 for(std::size_t i=0;i<sz;i++)
8291 ret[i]=shallowCpy();
8292 ret[i]->_content=contentsSplit[i];
8298 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
8299 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8301 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
8303 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8305 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
8306 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitDiscretizations();
8307 std::size_t sz(contentsSplit.size());
8308 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8309 for(std::size_t i=0;i<sz;i++)
8311 ret[i]=shallowCpy();
8312 ret[i]->_content=contentsSplit[i];
8317 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCpy() const
8319 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8320 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
8321 ret->_content=_content->deepCpy();
8322 ret->deepCpyGlobs(*this);
8326 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
8332 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8333 * \param [in] iteration - the iteration number of a required time step.
8334 * \param [in] order - the iteration order number of required time step.
8335 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
8336 * delete this field using decrRef() as it is no more needed.
8337 * \throw If there is no required time step in \a this field.
8339 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
8341 int pos=getPosOfTimeStep(iteration,order);
8342 return getTimeStepAtPos(pos);
8346 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8347 * \param [in] time - the time of the time step of interest.
8348 * \param [in] eps - a precision used to compare time values.
8349 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8350 * delete this field using decrRef() as it is no more needed.
8351 * \throw If there is no required time step in \a this field.
8353 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
8355 int pos=getPosGivenTime(time,eps);
8356 return getTimeStepAtPos(pos);
8360 * 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.
8361 * The float64 value of time attached to the pair of integers are not considered here.
8362 * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
8364 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
8365 * \throw If there is a null pointer in \a vectFMTS.
8367 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
8369 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
8370 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8371 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8372 while(!lstFMTS.empty())
8374 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8375 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8377 throw INTERP_KERNEL::Exception(msg);
8378 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
8379 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8380 elt.push_back(curIt); it=lstFMTS.erase(it);
8381 while(it!=lstFMTS.end())
8385 throw INTERP_KERNEL::Exception(msg);
8386 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
8388 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8398 * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
8399 * All returned instances in a subvector can be safely loaded, rendered along time
8400 * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
8401 * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
8402 * 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).
8403 * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
8404 * 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.
8406 * \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().
8407 * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
8408 * \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.
8409 * \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.
8411 * \throw If an element in \a vectFMTS has not only one spatial discretization set.
8412 * \throw If an element in \a vectFMTS change of spatial discretization along time.
8413 * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
8414 * \thorw If some elements in \a vectFMTS do not have the same times steps.
8415 * \throw If mesh is null.
8416 * \throw If an element in \a vectFMTS is null.
8417 * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
8419 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> >& fsc)
8421 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
8423 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
8424 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8425 if(vectFMTS.empty())
8427 std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
8428 MEDFileAnyTypeFieldMultiTS *frstElt(*it);
8430 throw INTERP_KERNEL::Exception(msg);
8432 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
8433 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
8434 for(;it!=vectFMTS.end();it++,i++)
8437 throw INTERP_KERNEL::Exception(msg);
8438 TypeOfField tof0,tof1;
8439 if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
8442 vectFMTSNotNodes.push_back(*it);
8444 vectFMTSNodes.push_back(*it);
8447 vectFMTSNotNodes.push_back(*it);
8449 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> > cmps;
8450 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
8452 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
8455 bool isFetched(false);
8456 for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
8459 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
8460 if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
8461 { ret[i].push_back(*it2); isFetched=true; }
8465 std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
8466 MEDCouplingAutoRefCountObjectPtr<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
8467 ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
8475 * 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.
8476 * \param [out] cmps - same size than the returned vector.
8478 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> >& cmps)
8480 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8481 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8482 while(!lstFMTS.empty())
8484 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8485 MEDFileAnyTypeFieldMultiTS *ref(*it);
8486 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8487 elt.push_back(ref); it=lstFMTS.erase(it);
8488 MEDCouplingAutoRefCountObjectPtr<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
8489 MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
8490 while(it!=lstFMTS.end())
8492 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8493 if(cmp->isEqual(curIt))
8494 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8498 ret.push_back(elt); cmps.push_back(cmp);
8504 * 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.
8505 * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
8507 * \throw If \a f0 or \a f1 has not only one spatial discretization set.
8508 * \throw If \a f0 or \a f1 change of spatial discretization along time.
8509 * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
8510 * \thorw If \a f0 and \a f1 do not have the same times steps.
8511 * \throw If mesh is null.
8512 * \throw If \a f0 or \a f1 is null.
8513 * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
8515 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
8518 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
8520 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
8521 if(f0->getMeshName()!=mesh->getName())
8523 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8524 throw INTERP_KERNEL::Exception(oss.str().c_str());
8526 if(f1->getMeshName()!=mesh->getName())
8528 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8529 throw INTERP_KERNEL::Exception(oss.str().c_str());
8531 int nts=f0->getNumberOfTS();
8532 if(nts!=f1->getNumberOfTS())
8533 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
8536 for(int i=0;i<nts;i++)
8538 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
8539 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
8540 std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
8541 if(tofs0.size()!=1 || tofs1.size()!=1)
8542 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
8545 if(tof0!=tofs0[0] || tof1!=tofs1[0])
8546 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
8549 { tof0=tofs0[0]; tof1=tofs1[0]; }
8550 if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
8552 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() << ") !";
8553 throw INTERP_KERNEL::Exception(oss.str().c_str());
8555 if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
8557 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() << ") !";
8558 throw INTERP_KERNEL::Exception(oss.str().c_str());
8560 if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
8562 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() << ") !";
8563 throw INTERP_KERNEL::Exception(oss.str().c_str());
8569 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
8571 return new MEDFileAnyTypeFieldMultiTSIterator(this);
8574 //= MEDFileFieldMultiTS
8577 * Returns a new empty instance of MEDFileFieldMultiTS.
8578 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8579 * is to delete this field using decrRef() as it is no more needed.
8581 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
8583 return new MEDFileFieldMultiTS;
8587 * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
8588 * that has been read from a specified MED file.
8589 * \param [in] fileName - the name of the MED file to read.
8590 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8591 * is to delete this field using decrRef() as it is no more needed.
8592 * \throw If reading the file fails.
8594 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll)
8596 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,loadAll,0);
8597 ret->contentNotNull();//to check that content type matches with \a this type.
8602 * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
8603 * that has been read from a specified MED file.
8604 * \param [in] fileName - the name of the MED file to read.
8605 * \param [in] fieldName - the name of the field to read.
8606 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8607 * is to delete this field using decrRef() as it is no more needed.
8608 * \throw If reading the file fails.
8609 * \throw If there is no field named \a fieldName in the file.
8611 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8613 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,fieldName,loadAll,0);
8614 ret->contentNotNull();//to check that content type matches with \a this type.
8619 * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8620 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8622 * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
8623 * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
8624 * \warning this is a shallow copy constructor
8625 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
8626 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
8627 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8628 * is to delete this field using decrRef() as it is no more needed.
8630 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8632 return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
8635 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
8637 return new MEDFileFieldMultiTS(*this);
8640 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
8643 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8644 const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
8646 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8650 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
8651 * following the given input policy.
8653 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
8654 * By default (true) the globals are deeply copied.
8655 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
8657 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
8659 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret;
8660 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8663 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
8665 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
8666 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
8667 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc,getFileName()));
8670 ret=MEDFileIntFieldMultiTS::New();
8672 ret->deepCpyGlobs(*this);
8674 ret->shallowCpyGlobs(*this);
8679 * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
8680 * \param [in] pos - a time step id.
8681 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8682 * delete this field using decrRef() as it is no more needed.
8683 * \throw If \a pos is not a valid time step id.
8685 MEDFileAnyTypeField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const
8687 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
8690 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
8691 throw INTERP_KERNEL::Exception(oss.str().c_str());
8693 const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
8696 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
8697 ret->shallowCpyGlobs(*this);
8700 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
8701 throw INTERP_KERNEL::Exception(oss.str().c_str());
8705 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8706 * mesh entities of a given dimension of the first mesh in MED file.
8707 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8708 * \param [in] type - a spatial discretization of interest.
8709 * \param [in] iteration - the iteration number of a required time step.
8710 * \param [in] order - the iteration order number of required time step.
8711 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8712 * \param [in] renumPol - specifies how to permute values of the result field according to
8713 * the optional numbers of cells and nodes, if any. The valid values are
8714 * - 0 - do not permute.
8715 * - 1 - permute cells.
8716 * - 2 - permute nodes.
8717 * - 3 - permute cells and nodes.
8719 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8720 * caller is to delete this field using decrRef() as it is no more needed.
8721 * \throw If the MED file is not readable.
8722 * \throw If there is no mesh in the MED file.
8723 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8724 * \throw If no field values of the required parameters are available.
8726 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
8728 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8729 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8731 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
8732 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8733 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase());
8734 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8739 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8740 * the top level cells of the first mesh in MED file.
8741 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8742 * \param [in] type - a spatial discretization of interest.
8743 * \param [in] iteration - the iteration number of a required time step.
8744 * \param [in] order - the iteration order number of required time step.
8745 * \param [in] renumPol - specifies how to permute values of the result field according to
8746 * the optional numbers of cells and nodes, if any. The valid values are
8747 * - 0 - do not permute.
8748 * - 1 - permute cells.
8749 * - 2 - permute nodes.
8750 * - 3 - permute cells and nodes.
8752 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8753 * caller is to delete this field using decrRef() as it is no more needed.
8754 * \throw If the MED file is not readable.
8755 * \throw If there is no mesh in the MED file.
8756 * \throw If no field values of the required parameters are available.
8758 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
8760 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8761 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8763 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
8764 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8765 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase());
8766 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8771 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8773 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8774 * \param [in] type - a spatial discretization of interest.
8775 * \param [in] iteration - the iteration number of a required time step.
8776 * \param [in] order - the iteration order number of required time step.
8777 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8778 * \param [in] mesh - the supporting mesh.
8779 * \param [in] renumPol - specifies how to permute values of the result field according to
8780 * the optional numbers of cells and nodes, if any. The valid values are
8781 * - 0 - do not permute.
8782 * - 1 - permute cells.
8783 * - 2 - permute nodes.
8784 * - 3 - permute cells and nodes.
8786 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8787 * caller is to delete this field using decrRef() as it is no more needed.
8788 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8789 * \throw If no field of \a this is lying on \a mesh.
8790 * \throw If no field values of the required parameters are available.
8792 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
8794 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8795 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8797 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
8798 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8799 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
8800 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8805 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
8807 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8808 * \param [in] type - a spatial discretization of the new field.
8809 * \param [in] iteration - the iteration number of a required time step.
8810 * \param [in] order - the iteration order number of required time step.
8811 * \param [in] mesh - the supporting mesh.
8812 * \param [in] renumPol - specifies how to permute values of the result field according to
8813 * the optional numbers of cells and nodes, if any. The valid values are
8814 * - 0 - do not permute.
8815 * - 1 - permute cells.
8816 * - 2 - permute nodes.
8817 * - 3 - permute cells and nodes.
8819 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8820 * caller is to delete this field using decrRef() as it is no more needed.
8821 * \throw If no field of \a this is lying on \a mesh.
8822 * \throw If no field values of the required parameters are available.
8824 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
8826 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8827 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8829 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
8830 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8831 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
8832 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8837 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
8838 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
8839 * This method is useful for MED2 file format when field on different mesh was autorized.
8841 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
8843 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8844 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8846 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
8847 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8848 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
8849 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8854 * Returns values and a profile of the field of a given type, of a given time step,
8855 * lying on a given support.
8856 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8857 * \param [in] type - a spatial discretization of the field.
8858 * \param [in] iteration - the iteration number of a required time step.
8859 * \param [in] order - the iteration order number of required time step.
8860 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8861 * \param [in] mesh - the supporting mesh.
8862 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
8863 * field of interest lies on. If the field lies on all entities of the given
8864 * dimension, all ids in \a pfl are zero. The caller is to delete this array
8865 * using decrRef() as it is no more needed.
8866 * \param [in] glob - the global data storing profiles and localization.
8867 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
8868 * field. The caller is to delete this array using decrRef() as it is no more needed.
8869 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8870 * \throw If no field of \a this is lying on \a mesh.
8871 * \throw If no field values of the required parameters are available.
8873 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
8875 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8876 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8878 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
8879 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
8880 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
8883 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const
8885 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8887 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
8888 const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
8890 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 !");
8894 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull()
8896 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8898 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
8899 MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
8901 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 !");
8906 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
8907 * the given field is checked if its elements are sorted suitable for writing to MED file
8908 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
8909 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8910 * \param [in] field - the field to add to \a this.
8911 * \throw If the name of \a field is empty.
8912 * \throw If the data array of \a field is not set.
8913 * \throw If existing time steps have different name or number of components than \a field.
8914 * \throw If the underlying mesh of \a field has no name.
8915 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
8917 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
8919 const DataArrayDouble *arr=0;
8921 arr=field->getArray();
8922 contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
8926 * Adds a MEDCouplingFieldDouble to \a this as another time step.
8927 * The mesh support of input parameter \a field is ignored here, it can be NULL.
8928 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
8931 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
8932 * A new profile is added only if no equal profile is missing.
8933 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8934 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
8935 * \param [in] mesh - the supporting mesh of \a field.
8936 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
8937 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
8938 * \throw If either \a field or \a mesh or \a profile has an empty name.
8939 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8940 * \throw If the data array of \a field is not set.
8941 * \throw If the data array of \a this is already allocated but has different number of
8942 * components than \a field.
8943 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
8944 * \sa setFieldNoProfileSBT()
8946 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
8948 const DataArrayDouble *arr=0;
8950 arr=field->getArray();
8951 contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
8954 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
8956 _content=new MEDFileFieldMultiTSWithoutSDA;
8959 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
8960 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll,ms)
8963 catch(INTERP_KERNEL::Exception& e)
8966 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
8967 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll,ms)
8970 catch(INTERP_KERNEL::Exception& e)
8973 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
8977 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
8979 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
8982 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
8984 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
8987 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
8989 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
8992 //= MEDFileAnyTypeFieldMultiTSIterator
8994 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
8999 _nb_iter=fmts->getNumberOfTS();
9003 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
9007 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
9009 if(_iter_id<_nb_iter)
9011 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
9013 return fmts->getTimeStepAtPos(_iter_id++);
9021 //= MEDFileIntFieldMultiTS
9024 * Returns a new empty instance of MEDFileFieldMultiTS.
9025 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9026 * is to delete this field using decrRef() as it is no more needed.
9028 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
9030 return new MEDFileIntFieldMultiTS;
9034 * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
9035 * that has been read from a specified MED file.
9036 * \param [in] fileName - the name of the MED file to read.
9037 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9038 * is to delete this field using decrRef() as it is no more needed.
9039 * \throw If reading the file fails.
9041 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll)
9043 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,loadAll,0);
9044 ret->contentNotNull();//to check that content type matches with \a this type.
9049 * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
9050 * that has been read from a specified MED file.
9051 * \param [in] fileName - the name of the MED file to read.
9052 * \param [in] fieldName - the name of the field to read.
9053 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9054 * is to delete this field using decrRef() as it is no more needed.
9055 * \throw If reading the file fails.
9056 * \throw If there is no field named \a fieldName in the file.
9058 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9060 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll,0);
9061 ret->contentNotNull();//to check that content type matches with \a this type.
9066 * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9067 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9069 * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
9070 * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9071 * \warning this is a shallow copy constructor
9072 * \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
9073 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9074 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9075 * is to delete this field using decrRef() as it is no more needed.
9077 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9079 return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
9083 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
9084 * following the given input policy.
9086 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9087 * By default (true) the globals are deeply copied.
9088 * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
9090 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const
9092 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret;
9093 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9096 const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
9098 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
9099 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
9100 ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc,getFileName()));
9103 ret=MEDFileFieldMultiTS::New();
9105 ret->deepCpyGlobs(*this);
9107 ret->shallowCpyGlobs(*this);
9111 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const
9113 return new MEDFileIntFieldMultiTS(*this);
9116 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9119 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9120 const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
9122 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
9126 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9127 * mesh entities of a given dimension of the first mesh in MED file.
9128 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9129 * \param [in] type - a spatial discretization of interest.
9130 * \param [in] iteration - the iteration number of a required time step.
9131 * \param [in] order - the iteration order number of required time step.
9132 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9133 * \param [out] arrOut - the DataArrayInt containing values of field.
9134 * \param [in] renumPol - specifies how to permute values of the result field according to
9135 * the optional numbers of cells and nodes, if any. The valid values are
9136 * - 0 - do not permute.
9137 * - 1 - permute cells.
9138 * - 2 - permute nodes.
9139 * - 3 - permute cells and nodes.
9141 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9142 * caller is to delete this field using decrRef() as it is no more needed.
9143 * \throw If the MED file is not readable.
9144 * \throw If there is no mesh in the MED file.
9145 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9146 * \throw If no field values of the required parameters are available.
9148 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
9150 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9151 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9153 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
9154 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9155 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase());
9156 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9161 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9162 * the top level cells of the first mesh in MED file.
9163 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9164 * \param [in] type - a spatial discretization of interest.
9165 * \param [in] iteration - the iteration number of a required time step.
9166 * \param [in] order - the iteration order number of required time step.
9167 * \param [out] arrOut - the DataArrayInt containing values of field.
9168 * \param [in] renumPol - specifies how to permute values of the result field according to
9169 * the optional numbers of cells and nodes, if any. The valid values are
9170 * - 0 - do not permute.
9171 * - 1 - permute cells.
9172 * - 2 - permute nodes.
9173 * - 3 - permute cells and nodes.
9175 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9176 * caller is to delete this field using decrRef() as it is no more needed.
9177 * \throw If the MED file is not readable.
9178 * \throw If there is no mesh in the MED file.
9179 * \throw If no field values of the required parameters are available.
9181 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, DataArrayInt* &arrOut, int renumPol) const
9183 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9184 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9186 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
9187 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9188 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase());
9189 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9194 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9196 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9197 * \param [in] type - a spatial discretization of interest.
9198 * \param [in] iteration - the iteration number of a required time step.
9199 * \param [in] order - the iteration order number of required time step.
9200 * \param [out] arrOut - the DataArrayInt containing values of field.
9201 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9202 * \param [in] mesh - the supporting mesh.
9203 * \param [in] renumPol - specifies how to permute values of the result field according to
9204 * the optional numbers of cells and nodes, if any. The valid values are
9205 * - 0 - do not permute.
9206 * - 1 - permute cells.
9207 * - 2 - permute nodes.
9208 * - 3 - permute cells and nodes.
9210 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9211 * caller is to delete this field using decrRef() as it is no more needed.
9212 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9213 * \throw If no field of \a this is lying on \a mesh.
9214 * \throw If no field values of the required parameters are available.
9216 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
9218 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9219 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9221 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9222 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9223 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase());
9224 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9229 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9231 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9232 * \param [in] type - a spatial discretization of the new field.
9233 * \param [in] iteration - the iteration number of a required time step.
9234 * \param [in] order - the iteration order number of required time step.
9235 * \param [in] mesh - the supporting mesh.
9236 * \param [out] arrOut - the DataArrayInt containing values of field.
9237 * \param [in] renumPol - specifies how to permute values of the result field according to
9238 * the optional numbers of cells and nodes, if any. The valid values are
9239 * - 0 - do not permute.
9240 * - 1 - permute cells.
9241 * - 2 - permute nodes.
9242 * - 3 - permute cells and nodes.
9244 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9245 * caller is to delete this field using decrRef() as it is no more needed.
9246 * \throw If no field of \a this is lying on \a mesh.
9247 * \throw If no field values of the required parameters are available.
9249 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
9251 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9252 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9254 throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9255 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9256 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase());
9257 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9262 * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
9263 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9264 * This method is useful for MED2 file format when field on different mesh was autorized.
9266 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
9268 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9269 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9271 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9272 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9273 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase());
9274 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9279 * Returns values and a profile of the field of a given type, of a given time step,
9280 * lying on a given support.
9281 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9282 * \param [in] type - a spatial discretization of the field.
9283 * \param [in] iteration - the iteration number of a required time step.
9284 * \param [in] order - the iteration order number of required time step.
9285 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9286 * \param [in] mesh - the supporting mesh.
9287 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9288 * field of interest lies on. If the field lies on all entities of the given
9289 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9290 * using decrRef() as it is no more needed.
9291 * \param [in] glob - the global data storing profiles and localization.
9292 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
9293 * field. The caller is to delete this array using decrRef() as it is no more needed.
9294 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9295 * \throw If no field of \a this is lying on \a mesh.
9296 * \throw If no field values of the required parameters are available.
9298 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9300 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9301 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9303 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
9304 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9305 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
9309 * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
9310 * \param [in] pos - a time step id.
9311 * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
9312 * delete this field using decrRef() as it is no more needed.
9313 * \throw If \a pos is not a valid time step id.
9315 MEDFileAnyTypeField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
9317 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9320 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9321 throw INTERP_KERNEL::Exception(oss.str().c_str());
9323 const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
9326 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
9327 ret->shallowCpyGlobs(*this);
9330 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
9331 throw INTERP_KERNEL::Exception(oss.str().c_str());
9335 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9336 * the given field is checked if its elements are sorted suitable for writing to MED file
9337 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9338 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9339 * \param [in] field - the field to add to \a this.
9340 * \throw If the name of \a field is empty.
9341 * \throw If the data array of \a field is not set.
9342 * \throw If existing time steps have different name or number of components than \a field.
9343 * \throw If the underlying mesh of \a field has no name.
9344 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9346 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals)
9348 contentNotNull()->appendFieldNoProfileSBT(field,arrOfVals,*this);
9352 * Adds a MEDCouplingFieldDouble to \a this as another time step.
9353 * The mesh support of input parameter \a field is ignored here, it can be NULL.
9354 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9357 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9358 * A new profile is added only if no equal profile is missing.
9359 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9360 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
9361 * \param [in] arrOfVals - the values of the field \a field used.
9362 * \param [in] mesh - the supporting mesh of \a field.
9363 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9364 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
9365 * \throw If either \a field or \a mesh or \a profile has an empty name.
9366 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9367 * \throw If the data array of \a field is not set.
9368 * \throw If the data array of \a this is already allocated but has different number of
9369 * components than \a field.
9370 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9371 * \sa setFieldNoProfileSBT()
9373 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9375 contentNotNull()->appendFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this);
9378 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const
9380 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9382 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
9383 const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9385 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 !");
9389 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull()
9391 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9393 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
9394 MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9396 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 !");
9400 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
9402 _content=new MEDFileIntFieldMultiTSWithoutSDA;
9405 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9409 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9410 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll,ms)
9413 catch(INTERP_KERNEL::Exception& e)
9416 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
9417 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll,ms)
9420 catch(INTERP_KERNEL::Exception& e)
9423 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9425 return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9430 MEDFileFields *MEDFileFields::New()
9432 return new MEDFileFields;
9435 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
9437 return new MEDFileFields(fileName,loadAll,0);
9440 MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9442 return new MEDFileFields(fileName,loadAll,ms);
9445 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
9447 std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
9448 ret+=_fields.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
9452 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
9454 std::vector<const BigMemoryObject *> ret;
9455 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9456 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
9460 MEDFileFields *MEDFileFields::deepCpy() const
9462 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
9464 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9466 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9467 ret->_fields[i]=(*it)->deepCpy();
9469 ret->deepCpyGlobs(*this);
9473 MEDFileFields *MEDFileFields::shallowCpy() const
9475 return new MEDFileFields(*this);
9479 * 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
9480 * 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.
9481 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
9483 * \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.
9484 * \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.
9486 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9488 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
9490 std::set< std::pair<int,int> > s;
9491 bool firstShot=true;
9492 areThereSomeForgottenTS=false;
9493 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9495 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9497 std::vector< std::pair<int,int> > v=(*it)->getIterations();
9498 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
9500 { s=s1; firstShot=false; }
9503 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
9505 areThereSomeForgottenTS=true;
9509 std::vector< std::pair<int,int> > ret;
9510 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
9514 int MEDFileFields::getNumberOfFields() const
9516 return _fields.size();
9519 std::vector<std::string> MEDFileFields::getFieldsNames() const
9521 std::vector<std::string> ret(_fields.size());
9523 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9525 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
9528 ret[i]=f->getName();
9532 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
9533 throw INTERP_KERNEL::Exception(oss.str().c_str());
9539 std::vector<std::string> MEDFileFields::getMeshesNames() const
9541 std::vector<std::string> ret;
9542 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9544 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9546 ret.push_back(cur->getMeshName());
9551 std::string MEDFileFields::simpleRepr() const
9553 std::ostringstream oss;
9554 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
9559 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
9561 int nbOfFields=getNumberOfFields();
9562 std::string startLine(bkOffset,' ');
9563 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
9565 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9567 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9570 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
9574 oss << startLine << " - not defined !" << std::endl;
9578 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9580 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9581 std::string chapter(17,'0'+i);
9582 oss << startLine << chapter << std::endl;
9585 cur->simpleRepr(bkOffset+2,oss,i);
9589 oss << startLine << " - not defined !" << std::endl;
9591 oss << startLine << chapter << std::endl;
9593 simpleReprGlobs(oss);
9596 MEDFileFields::MEDFileFields()
9600 MEDFileFields::MEDFileFields(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9601 try:MEDFileFieldGlobsReal(fileName)
9603 MEDFileUtilities::CheckFileForRead(fileName);
9604 MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY));
9605 int nbFields(MEDnField(fid));
9606 _fields.resize(nbFields);
9607 med_field_type typcha;
9608 for(int i=0;i<nbFields;i++)
9610 std::vector<std::string> infos;
9611 std::string fieldName,dtunit;
9612 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fileName,i,false,fieldName,typcha,infos,dtunit));
9617 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms);
9622 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms);
9627 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] !";
9628 throw INTERP_KERNEL::Exception(oss.str().c_str());
9632 loadAllGlobals(fid);
9634 catch(INTERP_KERNEL::Exception& e)
9639 void MEDFileFields::writeLL(med_idt fid) const
9642 writeGlobals(fid,*this);
9643 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9645 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
9648 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
9649 throw INTERP_KERNEL::Exception(oss.str().c_str());
9651 elt->writeLL(fid,*this);
9655 void MEDFileFields::write(const std::string& fileName, int mode) const
9657 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
9658 MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),medmod));
9663 * This method alloc the arrays and load potentially huge arrays contained in this field.
9664 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
9665 * This method can be also called to refresh or reinit values from a file.
9667 * \throw If the fileName is not set or points to a non readable MED file.
9669 void MEDFileFields::loadArrays()
9671 if(getFileName().empty())
9672 throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
9673 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
9674 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9676 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9678 elt->loadBigArraysRecursively(fid,*elt);
9683 * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
9684 * But once data loaded once, this method does nothing.
9686 * \throw If the fileName is not set or points to a non readable MED file.
9687 * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
9689 void MEDFileFields::loadArraysIfNecessary()
9691 if(!getFileName().empty())
9693 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
9694 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9696 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9698 elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
9704 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
9705 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
9706 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
9708 * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
9710 void MEDFileFields::unloadArrays()
9712 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9714 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9716 elt->unloadArrays();
9721 * 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.
9722 * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
9723 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
9725 * \sa MEDFileFields::loadArraysIfNecessary
9727 void MEDFileFields::unloadArraysWithoutDataLoss()
9729 if(!getFileName().empty())
9733 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
9735 std::vector<std::string> ret;
9736 std::set<std::string> ret2;
9737 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9739 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
9740 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
9741 if(ret2.find(*it2)==ret2.end())
9743 ret.push_back(*it2);
9750 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
9752 std::vector<std::string> ret;
9753 std::set<std::string> ret2;
9754 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9756 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
9757 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
9758 if(ret2.find(*it2)==ret2.end())
9760 ret.push_back(*it2);
9767 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
9769 std::vector<std::string> ret;
9770 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9772 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
9773 ret.insert(ret.end(),tmp.begin(),tmp.end());
9778 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
9780 std::vector<std::string> ret;
9781 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9783 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
9784 ret.insert(ret.end(),tmp.begin(),tmp.end());
9789 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
9791 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
9792 (*it)->changePflsRefsNamesGen2(mapOfModif);
9795 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
9797 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
9798 (*it)->changeLocsRefsNamesGen2(mapOfModif);
9801 void MEDFileFields::resize(int newSize)
9803 _fields.resize(newSize);
9806 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
9808 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
9812 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
9815 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
9816 _fields.push_back(field->getContent());
9817 appendGlobs(*field,1e-12);
9820 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
9823 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
9824 if(i>=(int)_fields.size())
9825 _fields.resize(i+1);
9826 _fields[i]=field->getContent();
9827 appendGlobs(*field,1e-12);
9830 void MEDFileFields::destroyFieldAtPos(int i)
9832 destroyFieldsAtPos(&i,&i+1);
9835 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
9837 std::vector<bool> b(_fields.size(),true);
9838 for(const int *i=startIds;i!=endIds;i++)
9840 if(*i<0 || *i>=(int)_fields.size())
9842 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
9843 throw INTERP_KERNEL::Exception(oss.str().c_str());
9847 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
9849 for(std::size_t i=0;i<_fields.size();i++)
9851 fields[j++]=_fields[i];
9855 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
9857 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
9858 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
9859 std::vector<bool> b(_fields.size(),true);
9861 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
9863 if(k<0 || k>=(int)_fields.size())
9865 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
9866 throw INTERP_KERNEL::Exception(oss.str().c_str());
9870 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
9872 for(std::size_t i=0;i<_fields.size();i++)
9874 fields[j++]=_fields[i];
9878 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
9881 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9883 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9885 ret=cur->changeMeshNames(modifTab) || ret;
9891 * \param [in] meshName the name of the mesh that will be renumbered.
9892 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
9893 * This code corresponds to the distribution of types in the corresponding mesh.
9894 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
9895 * \param [in] renumO2N the old to new renumber array.
9896 * \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
9899 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
9902 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9904 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
9907 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
9913 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
9915 if(i<0 || i>=(int)_fields.size())
9917 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
9918 throw INTERP_KERNEL::Exception(oss.str().c_str());
9920 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
9923 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret;
9924 const MEDFileFieldMultiTSWithoutSDA *fmtsC=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts);
9925 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts);
9927 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
9929 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
9932 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
9933 throw INTERP_KERNEL::Exception(oss.str().c_str());
9935 ret->shallowCpyGlobs(*this);
9940 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
9941 * This method is accessible in python using __getitem__ with a list in input.
9942 * \return a new object that the caller should deal with.
9944 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
9946 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
9947 std::size_t sz=std::distance(startIds,endIds);
9948 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
9950 for(const int *i=startIds;i!=endIds;i++,j++)
9952 if(*i<0 || *i>=(int)_fields.size())
9954 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
9955 throw INTERP_KERNEL::Exception(oss.str().c_str());
9957 fields[j]=_fields[*i];
9959 ret->_fields=fields;
9963 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
9965 return getFieldAtPos(getPosFromFieldName(fieldName));
9969 * This method removes, if any, fields in \a this having no time steps.
9970 * 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.
9972 * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
9974 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
9976 std::vector<MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
9977 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9979 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9982 if(elt->getNumberOfTS()>0)
9983 newFields.push_back(*it);
9986 if(_fields.size()==newFields.size())
9993 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
9994 * This method can be seen as a filter applied on \a this, that returns an object containing
9995 * 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
9996 * shallow copied from \a this.
9998 * \param [in] meshName - the name of the mesh on w
9999 * \return a new object that the caller should deal with.
10001 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
10003 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
10004 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10006 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10009 if(cur->getMeshName()==meshName)
10012 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
10013 ret->_fields.push_back(cur2);
10016 ret->shallowCpyOnlyUsedGlobs(*this);
10021 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
10022 * Input time steps are specified using a pair of integer (iteration, order).
10023 * 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,
10024 * but for each multitimestep only the time steps in \a timeSteps are kept.
10025 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
10027 * The returned object points to shallow copy of elements in \a this.
10029 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
10030 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
10031 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10033 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10035 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
10036 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10038 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10041 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
10042 ret->_fields.push_back(elt);
10044 ret->shallowCpyOnlyUsedGlobs(*this);
10049 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
10051 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10053 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
10054 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10056 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10059 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
10060 if(elt->getNumberOfTS()!=0)
10061 ret->_fields.push_back(elt);
10063 ret->shallowCpyOnlyUsedGlobs(*this);
10067 MEDFileFieldsIterator *MEDFileFields::iterator()
10069 return new MEDFileFieldsIterator(this);
10072 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
10074 std::string tmp(fieldName);
10075 std::vector<std::string> poss;
10076 for(std::size_t i=0;i<_fields.size();i++)
10078 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=_fields[i];
10081 std::string fname(f->getName());
10085 poss.push_back(fname);
10088 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
10089 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
10091 throw INTERP_KERNEL::Exception(oss.str().c_str());
10094 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
10099 _nb_iter=fs->getNumberOfFields();
10103 MEDFileFieldsIterator::~MEDFileFieldsIterator()
10107 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
10109 if(_iter_id<_nb_iter)
10111 MEDFileFields *fs(_fs);
10113 return fs->getFieldAtPos(_iter_id++);