1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (CEA/DEN)
21 #include "MEDFileField.hxx"
22 #include "MEDFileMesh.hxx"
23 #include "MEDLoaderBase.hxx"
24 #include "MEDFileUtilities.hxx"
25 #include "MEDFileFieldOverView.hxx"
27 #include "MEDCouplingFieldDouble.hxx"
28 #include "MEDCouplingFieldDiscretization.hxx"
30 #include "InterpKernelAutoPtr.hxx"
31 #include "CellModel.hxx"
36 extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
37 extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
38 extern med_geometry_type typmainoeud[1];
39 extern med_geometry_type typmai3[34];
41 using namespace ParaMEDMEM;
43 const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64";
44 const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32";
46 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const std::string& locName)
48 return new MEDFileFieldLoc(fid,locName);
51 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, int id)
53 return new MEDFileFieldLoc(fid,id);
56 MEDFileFieldLoc *MEDFileFieldLoc::New(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
58 return new MEDFileFieldLoc(locName,geoType,refCoo,gsCoo,w);
61 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, const std::string& locName):_name(locName)
63 med_geometry_type geotype;
64 med_geometry_type sectiongeotype;
66 INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
67 INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
68 MEDlocalizationInfoByName(fid,locName.c_str(),&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
69 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
70 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
71 _nb_node_per_cell=cm.getNumberOfNodes();
72 _ref_coo.resize(_dim*_nb_node_per_cell);
73 _gs_coo.resize(_dim*_nb_gauss_pt);
74 _w.resize(_nb_gauss_pt);
75 MEDlocalizationRd(fid,locName.c_str(),MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
78 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id)
80 med_geometry_type geotype;
81 med_geometry_type sectiongeotype;
83 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
84 INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
85 INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
86 MEDlocalizationInfo(fid,id+1,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
88 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
89 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
90 _nb_node_per_cell=cm.getNumberOfNodes();
91 _ref_coo.resize(_dim*_nb_node_per_cell);
92 _gs_coo.resize(_dim*_nb_gauss_pt);
93 _w.resize(_nb_gauss_pt);
94 MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
97 MEDFileFieldLoc::MEDFileFieldLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType,
98 const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w):_name(locName),_geo_type(geoType),_ref_coo(refCoo),_gs_coo(gsCoo),
101 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
102 _dim=cm.getDimension();
103 _nb_node_per_cell=cm.getNumberOfNodes();
104 _nb_gauss_pt=_w.size();
107 MEDFileFieldLoc *MEDFileFieldLoc::deepCpy() const
109 return new MEDFileFieldLoc(*this);
112 std::size_t MEDFileFieldLoc::getHeapMemorySizeWithoutChildren() const
114 return (_ref_coo.capacity()+_gs_coo.capacity()+_w.capacity())*sizeof(double)+_name.capacity();
117 std::vector<const BigMemoryObject *> MEDFileFieldLoc::getDirectChildrenWithNull() const
119 return std::vector<const BigMemoryObject *>();
122 void MEDFileFieldLoc::simpleRepr(std::ostream& oss) const
124 static const char OFF7[]="\n ";
125 oss << "\"" << _name << "\"" << OFF7;
126 oss << "GeoType=" << INTERP_KERNEL::CellModel::GetCellModel(_geo_type).getRepr() << OFF7;
127 oss << "Dimension=" << _dim << OFF7;
128 oss << "Number of Gauss points=" << _nb_gauss_pt << OFF7;
129 oss << "Number of nodes per cell=" << _nb_node_per_cell << OFF7;
130 oss << "RefCoords="; std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
131 oss << "Weights="; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
132 oss << "GaussPtsCoords="; std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," ")); oss << std::endl;
135 void MEDFileFieldLoc::setName(const std::string& name)
140 bool MEDFileFieldLoc::isEqual(const MEDFileFieldLoc& other, double eps) const
142 if(_name!=other._name)
146 if(_nb_gauss_pt!=other._nb_gauss_pt)
148 if(_nb_node_per_cell!=other._nb_node_per_cell)
150 if(_geo_type!=other._geo_type)
152 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_ref_coo,other._ref_coo,eps))
154 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_gs_coo,other._gs_coo,eps))
156 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_w,other._w,eps))
162 void MEDFileFieldLoc::writeLL(med_idt fid) const
164 MEDlocalizationWr(fid,_name.c_str(),typmai3[(int)_geo_type],_dim,&_ref_coo[0],MED_FULL_INTERLACE,_nb_gauss_pt,&_gs_coo[0],&_w[0],MED_NO_INTERPOLATION,MED_NO_MESH_SUPPORT);
167 std::string MEDFileFieldLoc::repr() const
169 std::ostringstream oss; oss.precision(15);
170 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
171 oss << "Localization \"" << _name << "\" :\n" << " - Geometric Type : " << cm.getRepr();
172 oss << "\n - Dimension : " << _dim << "\n - Number of gauss points : ";
173 oss << _nb_gauss_pt << "\n - Number of nodes in cell : " << _nb_node_per_cell;
174 oss << "\n - Ref coords are : ";
175 int sz=_ref_coo.size();
178 int nbOfTuples=sz/_dim;
179 for(int i=0;i<nbOfTuples;i++)
182 for(int j=0;j<_dim;j++)
183 { oss << _ref_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
188 std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," "));
189 oss << "\n - Gauss coords in reference element : ";
193 int nbOfTuples=sz/_dim;
194 for(int i=0;i<nbOfTuples;i++)
197 for(int j=0;j<_dim;j++)
198 { oss << _gs_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
203 std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," "));
204 oss << "\n - Weights of Gauss coords are : "; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," "));
208 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
210 _type=field->getTypeOfField();
216 getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,offset,offset+nbOfCells,1);
217 _end=_start+nbOfCells;
223 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
224 const int *arrPtr=arr->getConstPointer();
225 getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,arrPtr[offset],arrPtr[offset+nbOfCells],1);
226 _end=_start+(arrPtr[offset+nbOfCells]-arrPtr[offset]);
232 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
233 const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
234 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
236 throw INTERP_KERNEL::Exception("assignFieldNoProfile : invalid call to this method ! Internal Error !");
237 const DataArrayInt *dai=disc2->getArrayOfDiscIds();
238 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> dai2=disc2->getOffsetArr(field->getMesh());
239 const int *dai2Ptr=dai2->getConstPointer();
240 int nbi=gsLoc.getWeights().size();
241 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=dai->selectByTupleId2(offset,offset+nbOfCells,1);
242 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da2->getIdsEqual(_loc_id);
243 const int *da3Ptr=da3->getConstPointer();
244 if(da3->getNumberOfTuples()!=nbOfCells)
245 {//profile : for gauss even in NoProfile !!!
246 std::ostringstream oss; oss << "Pfl_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
248 da3->setName(_profile.c_str());
249 glob.appendProfile(da3);
251 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da4=DataArrayInt::New();
252 _nval=da3->getNbOfElems();
253 da4->alloc(_nval*nbi,1);
254 int *da4Ptr=da4->getPointer();
255 for(int i=0;i<_nval;i++)
257 int ref=dai2Ptr[offset+da3Ptr[i]];
258 for(int j=0;j<nbi;j++)
261 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
262 _localization=oss2.str();
263 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,da4);
264 _end=_start+_nval*nbi;
265 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
269 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile : not implemented yet for such discretization type of field !");
275 * Leaf method of field with profile assignement. This method is the most general one. No optimization is done here.
276 * \param [in] pflName input containing name of profile if any. 0 if no profile (except for GAUSS_PT where a no profile can hide a profile when splitted by loc_id).
277 * \param [in] multiTypePfl is the end user profile specified in high level API
278 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
279 * \param [in] locIds is the profile needed to be created for MED file format. It can be null if all cells of current geometric type are fetched in \a multiTypePfl.
280 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
281 * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
283 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arrr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
286 _type=field->getTypeOfField();
287 std::string pflName(multiTypePfl->getName());
288 std::ostringstream oss; oss << pflName;
292 { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType()); oss << "_" << cm.getRepr(); }
299 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : existing profile with empty name !");
300 if(_type!=ON_GAUSS_PT)
302 locIds->setName(oss.str().c_str());
303 glob.appendProfile(locIds);
312 _nval=idsInPfl->getNumberOfTuples();
313 getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,0,arrr->getNumberOfTuples(),1);
319 _nval=idsInPfl->getNumberOfTuples();
320 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,idsInPfl);
326 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
327 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr->deltaShiftIndex();
328 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->begin(),multiTypePfl->end());
329 arr3->computeOffsets2();
330 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
331 int trueNval=tmp->getNumberOfTuples();
332 _nval=idsInPfl->getNumberOfTuples();
333 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
334 _end=_start+trueNval;
339 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(field->getDiscretization());
341 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
342 const DataArrayInt *da1=disc2->getArrayOfDiscIds();
343 const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
344 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da1->selectByTupleId(idsInPfl->begin(),idsInPfl->end());
345 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da2->getIdsEqual(_loc_id);
346 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da4=idsInPfl->selectByTupleId(da3->begin(),da3->end());
348 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPart(multiTypePfl->begin(),multiTypePfl->end());
349 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=disc2->getOffsetArr(mesh2);
351 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=DataArrayInt::New();
353 for(const int *pt=da4->begin();pt!=da4->end();pt++)
354 trueNval+=arr->getIJ(*pt+1,0)-arr->getIJ(*pt,0);
355 tmp->alloc(trueNval,1);
356 int *tmpPtr=tmp->getPointer();
357 for(const int *pt=da4->begin();pt!=da4->end();pt++)
358 for(int j=arr->getIJ(*pt,0);j<arr->getIJ(*pt+1,0);j++)
361 _nval=da4->getNumberOfTuples();
362 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
363 _end=_start+trueNval;
364 oss << "_loc_" << _loc_id;
367 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da5=locIds->selectByTupleId(da3->begin(),da3->end());
368 da5->setName(oss.str().c_str());
369 glob.appendProfile(da5);
374 if(da3->getNumberOfTuples()!=nbOfEltsInWholeMesh || !da3->isIdentity())
376 da3->setName(oss.str().c_str());
377 glob.appendProfile(da3);
381 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
382 _localization=oss2.str();
383 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
387 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for such discretization type of field !");
392 void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob)
395 _nval=arrr->getNumberOfTuples();
396 getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,0,_nval,1);
401 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt, const PartDefinition *pd)
403 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt,pd);
406 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId)
408 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string());
411 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(const MEDFileFieldPerMeshPerTypePerDisc& other)
413 return new MEDFileFieldPerMeshPerTypePerDisc(other);
416 std::size_t MEDFileFieldPerMeshPerTypePerDisc::getHeapMemorySizeWithoutChildren() const
418 return _profile.capacity()+_localization.capacity()+sizeof(MEDFileFieldPerMeshPerTypePerDisc);
421 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypePerDisc::getDirectChildrenWithNull() const
423 std::vector<const BigMemoryObject *> ret(1);
424 ret[0]=(const PartDefinition*)_pd;
428 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCpy(MEDFileFieldPerMeshPerType *father) const
430 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> ret=new MEDFileFieldPerMeshPerTypePerDisc(*this);
435 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField atype, int profileIt, const PartDefinition *pd)
436 try:_type(atype),_father(fath),_profile_it(profileIt),_pd(const_cast<PartDefinition *>(pd))
441 catch(INTERP_KERNEL::Exception& e)
446 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
450 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(const MEDFileFieldPerMeshPerTypePerDisc& other):RefCountObject(other),_type(other._type),_father(0),_start(other._start),_end(other._end),_nval(other._nval),_profile(other._profile),_localization(other._localization),_loc_id(other._loc_id),_profile_it(other._profile_it),_pd(other._pd),_tmp_work1(other._tmp_work1)
454 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(0),_start(-std::numeric_limits<int>::max()),_end(-std::numeric_limits<int>::max()),
455 _nval(-std::numeric_limits<int>::max()),_loc_id(-std::numeric_limits<int>::max())
459 void MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile(med_idt fid, const std::string& fieldName, int nbOfCompo, int iteration, int order, med_entity_type menti, med_geometry_type mgeoti, unsigned char *startFeedingPtr)
461 const PartDefinition *pd(_pd);
464 INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
466 med_int nbValsInFile=MEDfieldnValueWithProfileByName(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile.c_str(),MED_COMPACT_PFLMODE,&tmp1,locname,&nbi);
467 if(_end-_start!=nbValsInFile*nbi)
469 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : The number of tuples to read is " << nbValsInFile << "*" << nbi << " (nb integration points) ! But in data structure it values " << _end-_start << " is expected !";
470 throw INTERP_KERNEL::Exception(oss.str().c_str());
472 MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,_profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,startFeedingPtr);
476 if(!_profile.empty())
477 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : not implemented !");
478 INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)),locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
480 int overallNval(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
481 const SlicePartDefinition *spd(dynamic_cast<const SlicePartDefinition *>(pd));
485 spd->getSlice(start,stop,step);
486 int nbOfEltsToLoad(DataArray::GetNumberOfItemGivenBES(start,stop,step,"MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile"));
487 med_filter filter=MED_FILTER_INIT;
488 MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
489 MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
490 /*start*/start+1,/*stride*/step,/*count*/1,/*blocksize*/nbOfEltsToLoad,
491 /*lastblocksize=useless because count=1*/0,&filter);
492 MEDfieldValueAdvancedRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,startFeedingPtr);
493 MEDfilterClose(&filter);
496 const DataArrayPartDefinition *dpd(dynamic_cast<const DataArrayPartDefinition *>(pd));
499 dpd->checkCoherency();
500 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> myIds(dpd->toDAI());
501 int a(myIds->getMinValueInArray()),b(myIds->getMaxValueInArray());
502 myIds->applyLin(1,-a);
503 int nbOfEltsToLoad(b-a+1);
504 med_filter filter=MED_FILTER_INIT;
505 {//TODO : manage int32 !
506 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> tmp(DataArrayDouble::New());
507 tmp->alloc(nbOfEltsToLoad,nbOfCompo);
508 MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
509 MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
510 /*start*/a+1,/*stride*/1,/*count*/1,/*blocksize*/nbOfEltsToLoad,
511 /*lastblocksize=useless because count=1*/0,&filter);
512 MEDfieldValueAdvancedRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,reinterpret_cast<unsigned char *>(tmp->getPointer()));
513 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> feeder(DataArrayDouble::New());
514 feeder->useExternalArrayWithRWAccess(reinterpret_cast<double *>(startFeedingPtr),_nval,nbOfCompo);
515 feeder->setContigPartOfSelectedValues(0,tmp,myIds);
517 MEDfilterClose(&filter);
520 throw INTERP_KERNEL::Exception("Not implemented yet for not slices!");
524 const MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
529 void MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
531 INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
532 INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
533 std::string fieldName(nasc.getName()),meshName(getMeshName());
534 int iteration(getIteration()),order(getOrder());
535 TypeOfField type(getType());
536 INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
538 med_geometry_type mgeoti;
539 med_entity_type menti(MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti));
540 int zeNVal(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
541 _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
542 _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
543 const PartDefinition *pd(_pd);
550 if(!_profile.empty())
551 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively : profiles are not managed yet with part of def !");
552 _nval=pd->getNumberOfElems();
555 _end=start+_nval*nbi;
557 if(type==ON_CELLS && !_localization.empty())
559 if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
560 setType(ON_GAUSS_PT);
563 setType(ON_GAUSS_NE);
564 _localization.clear();
569 void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, const MEDFileFieldNameScope& nasc)
571 std::string fieldName(nasc.getName()),meshName(getMeshName());
572 int iteration(getIteration()),order(getOrder());
573 TypeOfField type(getType());
574 INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
575 med_geometry_type mgeoti;
576 med_entity_type menti(MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti));
578 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !");
581 DataArray *arr(getOrCreateAndGetArray());//arr is not null due to the spec of getOrCreateAndGetArray
582 if(_start<0 || _start>=arr->getNumberOfTuples())
584 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << ") !";
585 throw INTERP_KERNEL::Exception(oss.str().c_str());
587 if(_end<0 || _end>arr->getNumberOfTuples())
589 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !";
590 throw INTERP_KERNEL::Exception(oss.str().c_str());
592 int nbOfCompo(arr->getNumberOfComponents());
593 DataArrayDouble *arrD(dynamic_cast<DataArrayDouble *>(arr));
596 double *startFeeding(arrD->getPointer()+_start*nbOfCompo);
597 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
600 DataArrayInt *arrI(dynamic_cast<DataArrayInt *>(arr));
603 int *startFeeding(arrI->getPointer()+_start*nbOfCompo);
604 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
607 throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
611 * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
613 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart)
615 int delta=_end-_start;
616 _start=newValueOfStart;
620 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
622 return _father->getIteration();
625 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
627 return _father->getOrder();
630 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
632 return _father->getTime();
635 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
637 return _father->getMeshName();
640 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
642 const char startLine[]=" ## ";
643 std::string startLine2(bkOffset,' ');
644 startLine2+=startLine;
645 MEDCouplingFieldDiscretization *tmp=MEDCouplingFieldDiscretization::New(_type);
646 oss << startLine2 << "Localization #" << id << "." << std::endl;
647 oss << startLine2 << " Type=" << tmp->getRepr() << "." << std::endl;
649 oss << startLine2 << " This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
650 oss << startLine2 << " This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
651 oss << startLine2 << " This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
654 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
659 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
664 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
669 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
671 return _father->getGeoType();
674 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
676 return _father->getNumberOfComponents();
679 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
684 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray()
686 return _father->getOrCreateAndGetArray();
689 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const
691 const MEDFileFieldPerMeshPerType *fath=_father;
692 return fath->getOrCreateAndGetArray();
695 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
697 return _father->getInfo();
700 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
705 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const std::string& newPflName)
710 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
712 return _localization;
715 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const std::string& newLocName)
717 _localization=newLocName;
720 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
722 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
724 if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
726 _profile=(*it2).second;
732 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
734 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
736 if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
738 _localization=(*it2).second;
744 void MEDFileFieldPerMeshPerTypePerDisc::getFieldAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
748 dads.push_back(std::pair<int,int>(_start,_end));
749 geoTypes.push_back(getGeoType());
754 pfls.push_back(glob->getProfile(_profile.c_str()));
756 if(_localization.empty())
760 locs.push_back(glob->getLocalizationId(_localization.c_str()));
764 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
766 entries[startEntryId]=std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int> ,std::pair<int,int> >(std::pair<INTERP_KERNEL::NormalizedCellType,int>(getGeoType(),discId),std::pair<int,int>(_start,_end));
770 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
772 TypeOfField type=getType();
773 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
774 med_geometry_type mgeoti;
775 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
776 const DataArray *arr=getOrCreateAndGetArray();
778 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
779 const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
780 const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
781 const unsigned char *locToWrite=0;
783 locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
785 locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
787 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
788 MEDfieldValueWithProfileWr(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
789 MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
793 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const
798 dad.first=_start; dad.second=_end;
802 * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
803 * This code corresponds to the distribution of types in the corresponding mesh.
804 * \param [out] ptToFill memory zone where the output will be stored.
805 * \return the size of data pushed into output param \a ptToFill
807 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const
810 std::ostringstream oss;
811 std::size_t nbOfType=codeOfMesh.size()/3;
813 for(std::size_t i=0;i<nbOfType && found==-1;i++)
814 if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
818 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
819 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
820 throw INTERP_KERNEL::Exception(oss.str().c_str());
825 if(_nval!=codeOfMesh[3*found+1])
827 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
828 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
829 oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
830 throw INTERP_KERNEL::Exception(oss.str().c_str());
832 for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
837 const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
838 if(pfl->getNumberOfTuples()!=_nval)
840 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
841 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
843 oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
844 throw INTERP_KERNEL::Exception(oss.str().c_str());
846 int offset2=codeOfMesh[3*found+2];
847 for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
849 if(*pflId<codeOfMesh[3*found+1])
850 *work++=offset2+*pflId;
856 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const
858 for(int i=_start;i<_end;i++)
863 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId)
874 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
878 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
881 std::map<std::pair<std::string,TypeOfField>,int> m;
882 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
883 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
884 if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
885 m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
887 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
888 ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
893 * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
895 * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
896 * \param [in] entriesOnSameDisc some entries **on same localization** if not the result can be invalid. The _start and _end on them are relative to \a arr parameter.
897 * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
898 * \param [in] newCode one of the input parameter to explicit the new geo type dispatch (in classical format same than those asked by MEDFileFields::renumberEntitiesLyingOnMesh)
899 * \param [in,out] glob if necessary by the method, new profiles can be added to it
900 * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
901 * \param [out] result All new entries will be appended on it.
902 * \return false if the configuration of renumbering leads to an unnecessary resplit of input \a entriesOnSameDisc. If not true is returned (the most general case !)
904 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
905 const DataArrayInt *explicitIdsInMesh,
906 const std::vector<int>& newCode,
907 MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
908 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >& result)
910 if(entriesOnSameDisc.empty())
912 TypeOfField type=entriesOnSameDisc[0]->getType();
913 int szEntities=0,szTuples=0;
914 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
915 { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
916 int nbi=szTuples/szEntities;
917 if(szTuples%szEntities!=0)
918 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
919 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
920 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
921 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
922 std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
923 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
924 std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
925 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
927 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
929 int startOfEltIdOfChunk=(*it)->_start;
930 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newEltIds=explicitIdsInMesh->substr(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
931 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
932 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
934 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
935 newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
937 newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
938 newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
940 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
941 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
942 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
943 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
945 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
947 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arrPart=arr->substr(offset,offset+szTuples);
948 arrPart->renumberInPlace(renumTupleIds->begin());
949 arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
951 const int *idIt=diffVals->begin();
952 std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
954 for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
956 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=newGeoTypesEltIdsAllGather->getIdsEqual(*idIt);
957 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
958 int nbEntityElts=subIds->getNumberOfTuples();
960 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
961 NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIdentity() || nbEntityElts!=newCode[3*(*idIt)+1],nbi,
965 result.push_back(eltToAdd);
966 offset2+=nbEntityElts*nbi;
968 ret=ret || li.empty();
973 * \param [in] typeF type of field of new chunk
974 * \param [in] geoType the geometric type of the chunk
975 * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
976 * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
977 * \param [in] nbi number of integration points
978 * \param [in] offset The offset in the **global array of data**.
979 * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
980 * to the new chunk to create.
981 * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
982 * \param [out] notInExisting If false the return newly allocated entry is not coming from \a entriesOnSameDisc. If true the output comes from copy of \a entriesOnSameDisc
983 * and corresponding entry erased from \a entriesOnSameDisc.
984 * \return a newly allocated chunk
986 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
987 bool isPfl, int nbi, int offset,
988 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
989 MEDFileFieldGlobsReal& glob,
992 int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
993 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
994 for(;it!=entriesOnSameDisc.end();it++)
996 if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
1000 if((*it)->_profile.empty())
1003 if(!(*it)->_profile.empty())
1005 const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
1006 if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
1012 if(it==entriesOnSameDisc.end())
1015 MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
1017 ret->_loc_id=(int)geoType;
1018 ret->_nval=nbMeshEntities;
1020 ret->_end=ret->_start+ret->_nval*nbi;
1023 idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
1024 glob.appendProfile(idsOfMeshElt);
1025 ret->_profile=idsOfMeshElt->getName();
1027 //tony treatment of localization
1032 notInExisting=false;
1033 MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1034 ret->_loc_id=(int)geoType;
1035 ret->setNewStart(offset);
1036 entriesOnSameDisc.erase(it);
1042 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd)
1044 return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc,pd);
1047 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType)
1049 return new MEDFileFieldPerMeshPerType(fath,geoType);
1052 std::size_t MEDFileFieldPerMeshPerType::getHeapMemorySizeWithoutChildren() const
1054 return _field_pm_pt_pd.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc>);
1057 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerType::getDirectChildrenWithNull() const
1059 std::vector<const BigMemoryObject *> ret;
1060 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1061 ret.push_back((const MEDFileFieldPerMeshPerTypePerDisc *)*it);
1065 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCpy(MEDFileFieldPerMesh *father) const
1067 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
1068 ret->_father=father;
1070 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1072 if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
1073 ret->_field_pm_pt_pd[i]=(*it)->deepCpy((MEDFileFieldPerMeshPerType *)ret);
1078 void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1080 std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
1081 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1082 _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1086 * This method is the most general one. No optimization is done here.
1087 * \param [in] multiTypePfl is the end user profile specified in high level API
1088 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1089 * \param [in] locIds is the profile needed to be created for MED file format. It can be null if all cells of current geometric type are fetched in \a multiTypePfl.
1090 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1091 * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1092 * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
1094 void MEDFileFieldPerMeshPerType::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1096 std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1097 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1098 _field_pm_pt_pd[*it]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1101 void MEDFileFieldPerMeshPerType::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1103 _field_pm_pt_pd.resize(1);
1104 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1105 _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1108 void MEDFileFieldPerMeshPerType::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1110 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2=pfl->deepCpy();
1111 if(!arr || !arr->isAllocated())
1112 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::assignNodeFieldProfile : input array is null, or not allocated !");
1113 _field_pm_pt_pd.resize(1);
1114 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1115 _field_pm_pt_pd[0]->assignFieldProfile(true,start,pfl,pfl2,pfl2,-1,field,arr,0,glob,nasc);//mesh is not requested so 0 is send.
1118 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1120 TypeOfField type=field->getTypeOfField();
1121 if(type!=ON_GAUSS_PT)
1123 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1124 int sz=_field_pm_pt_pd.size();
1126 for(int j=0;j<sz && !found;j++)
1128 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1130 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1136 _field_pm_pt_pd.resize(sz+1);
1137 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1139 std::vector<int> ret(1,(int)sz);
1144 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1145 int sz2=ret2.size();
1146 std::vector<int> ret3(sz2);
1148 for(int i=0;i<sz2;i++)
1150 int sz=_field_pm_pt_pd.size();
1151 int locIdToFind=ret2[i];
1153 for(int j=0;j<sz && !found;j++)
1155 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1157 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1164 _field_pm_pt_pd.resize(sz+1);
1165 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1173 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1175 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1176 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1178 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1179 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1181 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1182 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleId2(offset,offset+nbOfCells,1);
1183 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1184 if(retTmp->presenceOfValue(-1))
1185 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1186 std::vector<int> ret(retTmp->begin(),retTmp->end());
1190 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1192 TypeOfField type=field->getTypeOfField();
1193 if(type!=ON_GAUSS_PT)
1195 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1196 int sz=_field_pm_pt_pd.size();
1198 for(int j=0;j<sz && !found;j++)
1200 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1202 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1208 _field_pm_pt_pd.resize(sz+1);
1209 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1211 std::vector<int> ret(1,0);
1216 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1217 int sz2=ret2.size();
1218 std::vector<int> ret3(sz2);
1220 for(int i=0;i<sz2;i++)
1222 int sz=_field_pm_pt_pd.size();
1223 int locIdToFind=ret2[i];
1225 for(int j=0;j<sz && !found;j++)
1227 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1229 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1236 _field_pm_pt_pd.resize(sz+1);
1237 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1245 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1247 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1248 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1250 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1251 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1253 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1254 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1255 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1256 if(retTmp->presenceOfValue(-1))
1257 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1258 std::vector<int> ret(retTmp->begin(),retTmp->end());
1262 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerType::getFather() const
1267 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1269 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1270 int curDim=(int)cm.getDimension();
1271 dim=std::max(dim,curDim);
1274 void MEDFileFieldPerMeshPerType::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1276 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1278 (*it)->fillTypesOfFieldAvailable(types);
1282 void MEDFileFieldPerMeshPerType::fillFieldSplitedByType(std::vector< std::pair<int,int> >& dads, std::vector<TypeOfField>& types, std::vector<std::string>& pfls, std::vector<std::string>& locs) const
1284 int sz=_field_pm_pt_pd.size();
1285 dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1286 for(int i=0;i<sz;i++)
1288 _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1292 int MEDFileFieldPerMeshPerType::getIteration() const
1294 return _father->getIteration();
1297 int MEDFileFieldPerMeshPerType::getOrder() const
1299 return _father->getOrder();
1302 double MEDFileFieldPerMeshPerType::getTime() const
1304 return _father->getTime();
1307 std::string MEDFileFieldPerMeshPerType::getMeshName() const
1309 return _father->getMeshName();
1312 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1314 const char startLine[]=" ## ";
1315 std::string startLine2(bkOffset,' ');
1316 std::string startLine3(startLine2);
1317 startLine3+=startLine;
1318 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1320 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1321 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1324 oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1325 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1327 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1329 const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1331 cur->simpleRepr(bkOffset,oss,i);
1334 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1339 void MEDFileFieldPerMeshPerType::getSizes(int& globalSz, int& nbOfEntries) const
1341 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1343 globalSz+=(*it)->getNumberOfTuples();
1345 nbOfEntries+=(int)_field_pm_pt_pd.size();
1348 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1354 int MEDFileFieldPerMeshPerType::getNumberOfComponents() const
1356 return _father->getNumberOfComponents();
1359 bool MEDFileFieldPerMeshPerType::presenceOfMultiDiscPerGeoType() const
1362 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1364 const MEDFileFieldPerMeshPerTypePerDisc *fmtd(*it);
1371 DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray()
1373 return _father->getOrCreateAndGetArray();
1376 const DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray() const
1378 const MEDFileFieldPerMesh *fath=_father;
1379 return fath->getOrCreateAndGetArray();
1382 const std::vector<std::string>& MEDFileFieldPerMeshPerType::getInfo() const
1384 return _father->getInfo();
1387 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsed() const
1389 std::vector<std::string> ret;
1390 std::set<std::string> ret2;
1391 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1393 std::string tmp=(*it1)->getProfile();
1395 if(ret2.find(tmp)==ret2.end())
1404 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsed() const
1406 std::vector<std::string> ret;
1407 std::set<std::string> ret2;
1408 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1410 std::string tmp=(*it1)->getLocalization();
1411 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1412 if(ret2.find(tmp)==ret2.end())
1421 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsedMulti() const
1423 std::vector<std::string> ret;
1424 std::set<std::string> ret2;
1425 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1427 std::string tmp=(*it1)->getProfile();
1434 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsedMulti() const
1436 std::vector<std::string> ret;
1437 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1439 std::string tmp=(*it1)->getLocalization();
1440 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1446 void MEDFileFieldPerMeshPerType::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1448 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1449 (*it1)->changePflsRefsNamesGen(mapOfModif);
1452 void MEDFileFieldPerMeshPerType::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1454 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1455 (*it1)->changeLocsRefsNamesGen(mapOfModif);
1458 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId)
1460 if(_field_pm_pt_pd.empty())
1462 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1463 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1464 throw INTERP_KERNEL::Exception(oss.str().c_str());
1466 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1467 return _field_pm_pt_pd[locId];
1468 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1469 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1470 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1471 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1472 return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1475 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) const
1477 if(_field_pm_pt_pd.empty())
1479 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1480 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1481 throw INTERP_KERNEL::Exception(oss.str().c_str());
1483 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1484 return _field_pm_pt_pd[locId];
1485 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1486 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1487 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1488 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1489 return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1492 void MEDFileFieldPerMeshPerType::getFieldAtLevel(int meshDim, TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
1494 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1496 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1497 if(meshDim!=(int)cm.getDimension())
1500 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1501 (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1504 void MEDFileFieldPerMeshPerType::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1507 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1509 (*it)->fillValues(i,startEntryId,entries);
1513 void MEDFileFieldPerMeshPerType::setLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
1515 _field_pm_pt_pd=leaves;
1516 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1517 (*it)->setFather(this);
1521 * \param [in,out] globalNum a global numbering counter for the renumbering.
1522 * \param [out] its - list of pair (start,stop) kept
1523 * \return bool - false if the type of field \a tof is not contained in \a this.
1525 bool MEDFileFieldPerMeshPerType::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
1528 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1529 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1530 if((*it)->getType()==tof)
1532 newPmPtPd.push_back(*it);
1533 std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1534 (*it)->setNewStart(globalNum);
1535 globalNum=(*it)->getEnd();
1536 its.push_back(bgEnd);
1540 _field_pm_pt_pd=newPmPtPd;
1545 * \param [in,out] globalNum a global numbering counter for the renumbering.
1546 * \param [out] its - list of pair (start,stop) kept
1547 * \return bool - false if the type of field \a tof is not contained in \a this.
1549 bool MEDFileFieldPerMeshPerType::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
1551 if(_field_pm_pt_pd.size()<=idOfDisc)
1553 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> elt(_field_pm_pt_pd[idOfDisc]);
1554 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd(1,elt);
1555 std::pair<int,int> bgEnd; bgEnd.first=_field_pm_pt_pd[idOfDisc]->getStart(); bgEnd.second=_field_pm_pt_pd[idOfDisc]->getEnd();
1556 elt->setNewStart(globalNum);
1557 globalNum=elt->getEnd();
1558 its.push_back(bgEnd);
1559 _field_pm_pt_pd=newPmPtPd;
1563 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType):_father(fath),_geo_type(geoType)
1567 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):_father(fath),_geo_type(geoType)
1569 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1570 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1571 med_geometry_type mgeoti;
1572 med_entity_type menti(ConvertIntoMEDFileType(type,geoType,mgeoti));
1573 int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName));
1574 _field_pm_pt_pd.resize(nbProfiles);
1575 for(int i=0;i<nbProfiles;i++)
1577 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i,pd);
1581 int nbProfiles2=MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName);
1582 for(int i=0;i<nbProfiles2;i++)
1583 _field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i,pd));
1587 void MEDFileFieldPerMeshPerType::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
1589 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1590 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1593 void MEDFileFieldPerMeshPerType::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1595 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1596 (*it)->loadBigArray(fid,nasc);
1599 void MEDFileFieldPerMeshPerType::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1601 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1603 (*it)->copyOptionsFrom(*this);
1604 (*it)->writeLL(fid,nasc);
1608 med_entity_type MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1613 medfGeoType=typmai3[(int)ikGeoType];
1616 medfGeoType=MED_NONE;
1619 medfGeoType=typmai3[(int)ikGeoType];
1620 return MED_NODE_ELEMENT;
1622 medfGeoType=typmai3[(int)ikGeoType];
1625 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1627 return MED_UNDEF_ENTITY_TYPE;
1630 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
1632 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm,entities);
1635 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1637 return new MEDFileFieldPerMesh(fath,mesh);
1640 std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
1642 return _mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType >);
1645 std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildrenWithNull() const
1647 std::vector<const BigMemoryObject *> ret;
1648 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1649 ret.push_back((const MEDFileFieldPerMeshPerType *)*it);
1653 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCpy(MEDFileAnyTypeField1TSWithoutSDA *father) const
1655 MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1656 ret->_father=father;
1658 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1660 if((const MEDFileFieldPerMeshPerType *)*it)
1661 ret->_field_pm_pt[i]=(*it)->deepCpy((MEDFileFieldPerMesh *)(ret));
1666 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1668 std::string startLine(bkOffset,' ');
1669 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1670 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1672 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1674 const MEDFileFieldPerMeshPerType *cur=*it;
1676 cur->simpleRepr(bkOffset,oss,i);
1679 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1684 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh)
1686 _mesh_name=mesh->getName();
1687 mesh->getTime(_mesh_iteration,_mesh_order);
1690 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1692 int nbOfTypes=code.size()/3;
1694 for(int i=0;i<nbOfTypes;i++)
1696 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1697 int nbOfCells=code[3*i+1];
1698 int pos=addNewEntryIfNecessary(type);
1699 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1705 * This method is the most general one. No optimization is done here.
1706 * \param [in] multiTypePfl is the end user profile specified in high level API
1707 * \param [in] code is the code of \a mesh[multiTypePfl] mesh. It is of size of number of different geometric types into \a mesh[multiTypePfl].
1708 * \param [in] code2 is the code of the \b WHOLE mesh on the same level. So all types in \a code are in \a code2.
1709 * \param [in] idsInPflPerType is the selection into the \a multiTypePfl whole profile that corresponds to the given geometric type. This vector is always 3 times smaller than \a code.
1710 * \param [in] idsPerType is a vector containing the profiles needed to be created for MED file format. \b WARNING these processed MED file profiles can be subdivided again in case of Gauss points.
1711 * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
1713 void MEDFileFieldPerMesh::assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const std::vector<int>& code, const std::vector<int>& code2, const std::vector<DataArrayInt *>& idsInPflPerType, const std::vector<DataArrayInt *>& idsPerType, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1715 int nbOfTypes(code.size()/3);
1716 for(int i=0;i<nbOfTypes;i++)
1718 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1719 int pos=addNewEntryIfNecessary(type);
1720 DataArrayInt *pfl=0;
1722 pfl=idsPerType[code[3*i+2]];
1723 int nbOfTupes2=code2.size()/3;
1725 for(;found<nbOfTupes2;found++)
1726 if(code[3*i]==code2[3*found])
1728 if(found==nbOfTupes2)
1729 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1730 _field_pm_pt[pos]->assignFieldProfile(nbOfTypes==1,start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1734 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1736 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1737 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1740 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1742 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1743 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1746 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
1748 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1749 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1752 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1754 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1755 (*it)->loadBigArraysRecursively(fid,nasc);
1758 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1760 int nbOfTypes=_field_pm_pt.size();
1761 for(int i=0;i<nbOfTypes;i++)
1763 _field_pm_pt[i]->copyOptionsFrom(*this);
1764 _field_pm_pt[i]->writeLL(fid,nasc);
1768 void MEDFileFieldPerMesh::getDimension(int& dim) const
1770 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1771 (*it)->getDimension(dim);
1774 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1776 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1777 (*it)->fillTypesOfFieldAvailable(types);
1780 std::vector< std::vector< std::pair<int,int> > > MEDFileFieldPerMesh::getFieldSplitedByType(std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> > & locs) const
1782 int sz=_field_pm_pt.size();
1783 std::vector< std::vector<std::pair<int,int> > > ret(sz);
1784 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1785 for(int i=0;i<sz;i++)
1787 types[i]=_field_pm_pt[i]->getGeoType();
1788 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1793 double MEDFileFieldPerMesh::getTime() const
1796 return _father->getTime(tmp1,tmp2);
1799 int MEDFileFieldPerMesh::getIteration() const
1801 return _father->getIteration();
1804 int MEDFileFieldPerMesh::getOrder() const
1806 return _father->getOrder();
1809 int MEDFileFieldPerMesh::getNumberOfComponents() const
1811 return _father->getNumberOfComponents();
1814 bool MEDFileFieldPerMesh::presenceOfMultiDiscPerGeoType() const
1816 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1818 const MEDFileFieldPerMeshPerType *fpmt(*it);
1821 if(fpmt->presenceOfMultiDiscPerGeoType())
1827 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
1830 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1831 return _father->getOrCreateAndGetArray();
1834 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
1837 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1838 return _father->getOrCreateAndGetArray();
1841 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1843 return _father->getInfo();
1847 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
1848 * Before the call of this method 'geoTypes','dads','pfls','locs' must be reorganized so that types in geoTypes are contiguous and ordered following typmai2 array.
1849 * It returns 2 output vectors :
1850 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
1851 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
1852 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
1854 void MEDFileFieldPerMesh::SortArraysPerType(const MEDFileFieldGlobsReal *glob, TypeOfField type, const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes, const std::vector< std::pair<int,int> >& dads, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& locs, std::vector<int>& code, std::vector<DataArrayInt *>& notNullPfls)
1856 int notNullPflsSz=0;
1857 int nbOfArrs=geoTypes.size();
1858 for(int i=0;i<nbOfArrs;i++)
1861 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
1862 int nbOfDiffGeoTypes=geoTypes3.size();
1863 code.resize(3*nbOfDiffGeoTypes);
1864 notNullPfls.resize(notNullPflsSz);
1867 for(int i=0;i<nbOfDiffGeoTypes;i++)
1870 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
1871 std::vector<const DataArrayInt *> notNullTmp;
1873 notNullTmp.push_back(pfls[j]);
1875 for(;j<nbOfArrs;j++)
1876 if(geoTypes[j]==refType)
1879 notNullTmp.push_back(pfls[j]);
1883 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
1884 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
1885 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
1886 code[3*i]=(int)refType;
1887 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
1888 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
1889 if(notNullTmp.empty())
1893 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
1894 code[3*i+2]=notNullPflsSz++;
1900 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
1902 int MEDFileFieldPerMesh::ComputeNbOfElems(const MEDFileFieldGlobsReal *glob, TypeOfField type, const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes, const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs)
1906 for(int i=0;i<sz;i++)
1910 if(type!=ON_GAUSS_NE)
1911 ret+=dads[i].second-dads[i].first;
1914 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
1915 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
1920 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
1921 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
1927 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
1929 std::vector<std::string> ret;
1930 std::set<std::string> ret2;
1931 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1933 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
1934 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1935 if(ret2.find(*it2)==ret2.end())
1937 ret.push_back(*it2);
1944 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
1946 std::vector<std::string> ret;
1947 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1949 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
1950 ret.insert(ret.end(),tmp.begin(),tmp.end());
1955 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
1957 std::vector<std::string> ret;
1958 std::set<std::string> ret2;
1959 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1961 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
1962 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1963 if(ret2.find(*it2)==ret2.end())
1965 ret.push_back(*it2);
1972 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
1974 std::vector<std::string> ret;
1975 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1977 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
1978 ret.insert(ret.end(),tmp.begin(),tmp.end());
1983 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
1985 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
1987 if((*it).first==_mesh_name)
1989 _mesh_name=(*it).second;
1996 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
1997 MEDFileFieldGlobsReal& glob)
1999 if(_mesh_name!=meshName)
2001 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
2002 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
2003 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
2004 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
2005 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
2006 getUndergroundDataArrayExt(entries);
2007 DataArray *arr0=getOrCreateAndGetArray();//tony
2009 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
2010 DataArrayDouble *arr=dynamic_cast<DataArrayDouble *>(arr0);//tony
2012 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
2015 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
2016 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
2018 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
2020 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2021 sz+=(*it).second.second-(*it).second.first;
2024 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2026 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
2027 ////////////////////
2028 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
2029 int *workI2=explicitIdsOldInMesh->getPointer();
2030 int sz1=0,sz2=0,sid=1;
2031 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
2032 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
2033 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
2035 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
2036 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
2037 int *workI=explicitIdsOldInArr->getPointer();
2038 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
2040 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
2041 (*itL2)->setLocId(sz2);
2042 (*itL2)->_tmp_work1=(*itL2)->getStart();
2043 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
2045 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
2047 explicitIdsOldInMesh->reAlloc(sz2);
2048 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
2049 ////////////////////
2050 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
2051 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
2052 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
2053 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
2055 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
2056 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
2057 otherEntriesNew.back()->setLocId((*it)->getGeoType());
2059 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
2060 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
2061 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
2063 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
2064 int newStart=elt->getLocId();
2065 elt->setLocId((*it)->getGeoType());
2066 elt->setNewStart(newStart);
2067 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
2068 entriesKeptNew.push_back(elt);
2069 entriesKeptNew2.push_back(elt);
2071 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
2072 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
2073 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
2074 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
2076 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
2079 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
2081 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
2082 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
2084 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
2085 glob,arr2,otherEntriesNew) || ret;
2089 // Assign new dispatching
2090 assignNewLeaves(otherEntriesNew);
2091 arr->cpyFrom(*arr2);
2096 * \param [in,out] globalNum a global numbering counter for the renumbering.
2097 * \param [out] its - list of pair (start,stop) kept
2099 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
2101 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > ret;
2102 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2104 std::vector< std::pair<int,int> > its2;
2105 if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
2108 its.insert(its.end(),its2.begin(),its2.end());
2115 * \param [in,out] globalNum a global numbering counter for the renumbering.
2116 * \param [out] its - list of pair (start,stop) kept
2118 void MEDFileFieldPerMesh::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
2120 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > ret;
2121 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2123 std::vector< std::pair<int,int> > its2;
2124 if((*it)->keepOnlyGaussDiscretization(idOfDisc,globalNum,its2))
2127 its.insert(its.end(),its2.begin(),its2.end());
2133 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
2135 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > > types;
2136 for( std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
2137 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
2139 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > fieldPmPt(types.size());
2140 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
2141 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=fieldPmPt.begin();
2142 for(;it1!=types.end();it1++,it2++)
2144 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
2145 elt->setLeaves((*it1).second);
2148 _field_pm_pt=fieldPmPt;
2151 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2153 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2154 (*it)->changePflsRefsNamesGen(mapOfModif);
2157 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2159 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2160 (*it)->changeLocsRefsNamesGen(mapOfModif);
2164 * \param [in] mesh is the whole mesh
2166 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2168 if(_field_pm_pt.empty())
2169 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2171 std::vector< std::pair<int,int> > dads;
2172 std::vector<const DataArrayInt *> pfls;
2173 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2174 std::vector<int> locs,code;
2175 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2176 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2177 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2179 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2182 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2183 throw INTERP_KERNEL::Exception(oss.str().c_str());
2186 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2187 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2190 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2192 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2195 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr);
2196 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2202 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2206 if(nb!=mesh->getNumberOfNodes())
2208 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2209 oss << " nodes in mesh !";
2210 throw INTERP_KERNEL::Exception(oss.str().c_str());
2212 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2215 return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2219 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
2221 if(_field_pm_pt.empty())
2222 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2224 std::vector<std::pair<int,int> > dads;
2225 std::vector<const DataArrayInt *> pfls;
2226 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2227 std::vector<int> locs,code;
2228 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2229 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2230 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2232 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2235 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2236 throw INTERP_KERNEL::Exception(oss.str().c_str());
2238 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2239 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2242 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2243 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2248 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2252 if(nb!=mesh->getNumberOfNodes())
2254 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2255 oss << " nodes in mesh !";
2256 throw INTERP_KERNEL::Exception(oss.str().c_str());
2259 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2265 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
2269 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2271 (*it)->getSizes(globalSz,nbOfEntries);
2273 entries.resize(nbOfEntries);
2275 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2277 (*it)->fillValues(nbOfEntries,entries);
2281 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
2283 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2285 if((*it)->getGeoType()==typ)
2286 return (*it)->getLeafGivenLocId(locId);
2288 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2289 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2290 oss << "Possiblities are : ";
2291 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2293 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2294 oss << "\"" << cm2.getRepr() << "\", ";
2296 throw INTERP_KERNEL::Exception(oss.str().c_str());
2299 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
2301 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2303 if((*it)->getGeoType()==typ)
2304 return (*it)->getLeafGivenLocId(locId);
2306 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2307 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2308 oss << "Possiblities are : ";
2309 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2311 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2312 oss << "\"" << cm2.getRepr() << "\", ";
2314 throw INTERP_KERNEL::Exception(oss.str().c_str());
2317 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2320 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2321 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=_field_pm_pt.begin();
2322 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2324 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2329 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2334 int ret=std::distance(_field_pm_pt.begin(),it2);
2335 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2340 * 'dads' and 'locs' input parameters have the same number of elements
2341 * \param [in] mesh is \b NOT the global mesh, but the possibly reduced mesh. \a mesh parameter will be directly aggregated in the returned field
2343 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2344 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2345 const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2348 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2349 ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2350 MEDCouplingAutoRefCountObjectPtr<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2351 const std::vector<std::string>& infos=getInfo();
2352 da->setInfoOnComponents(infos);
2354 if(type==ON_GAUSS_PT)
2357 int nbOfArrs=dads.size();
2358 for(int i=0;i<nbOfArrs;i++)
2360 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2361 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2362 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2363 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> di=DataArrayInt::New();
2364 di->alloc(nbOfElems,1);
2366 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2367 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2376 * This method is an extension of MEDFileFieldPerMesh::finishField method. It deals with profiles. This method should be called when type is different from ON_NODES.
2377 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2378 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2379 * The order of cells in the returned field is those imposed by the profile.
2380 * \param [in] mesh is the global mesh.
2382 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2383 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2384 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2385 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2387 if(da->isIdentity())
2389 int nbOfTuples=da->getNumberOfTuples();
2390 if(nbOfTuples==mesh->getNumberOfCells())
2391 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2393 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2394 m2->setName(mesh->getName().c_str());
2395 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2401 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2403 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2404 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2405 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2407 if(da->isIdentity())
2409 int nbOfTuples=da->getNumberOfTuples();
2410 if(nbOfTuples==mesh->getNumberOfNodes())//No problem for NORM_ERROR because it is in context of node
2411 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2413 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2414 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2417 if(meshu->getNodalConnectivity()==0)
2419 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2420 int nb=da->getNbOfElems();
2421 const int *ptr=da->getConstPointer();
2422 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2423 meshuc->allocateCells(nb);
2424 for(int i=0;i<nb;i++)
2425 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2426 meshuc->finishInsertingCells();
2427 ret->setMesh(meshuc);
2428 const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2429 if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2430 disc->checkCoherencyBetween(meshuc,arrOut);
2435 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2437 DataArrayInt *arr2=0;
2438 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2439 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2440 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3(arr2);
2441 int nnodes=mesh2->getNumberOfNodes();
2442 if(nnodes==(int)da->getNbOfElems())
2444 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2445 arrOut->renumberInPlace(da3->getConstPointer());
2446 mesh2->setName(mesh->getName().c_str());
2447 ret->setMesh(mesh2);
2452 std::ostringstream oss; oss << "MEDFileFieldPerMesh::finishFieldNode2 : The field on nodes lies on a node profile so that it is impossible to find a submesh having exactly the same nodes of that profile !!!";
2453 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2454 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2455 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2456 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2457 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2458 throw INTERP_KERNEL::Exception(oss.str().c_str());
2464 * This method is the most light method of field retrieving.
2466 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
2470 pflOut=DataArrayInt::New();
2471 pflOut->alloc(nbOfElems,1);
2476 pflOut=const_cast<DataArrayInt*>(pflIn);
2479 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> safePfl(pflOut);
2480 MEDCouplingAutoRefCountObjectPtr<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2481 const std::vector<std::string>& infos=getInfo();
2482 int nbOfComp=infos.size();
2483 for(int i=0;i<nbOfComp;i++)
2484 da->setInfoOnComponent(i,infos[i].c_str());
2495 static MFFPMIter *NewCell(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities);
2496 static bool IsPresenceOfNode(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities);
2497 virtual ~MFFPMIter() { }
2498 virtual void begin() = 0;
2499 virtual bool finished() const = 0;
2500 virtual void next() = 0;
2501 virtual int current() const = 0;
2504 class MFFPMIterSimple : public MFFPMIter
2507 MFFPMIterSimple():_pos(0) { }
2508 void begin() { _pos=0; }
2509 bool finished() const { return _pos>=MED_N_CELL_FIXED_GEO; }
2510 void next() { _pos++; }
2511 int current() const { return _pos; }
2516 class MFFPMIter2 : public MFFPMIter
2519 MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts);
2520 void begin() { _it=_ids.begin(); }
2521 bool finished() const { return _it==_ids.end(); }
2522 void next() { _it++; }
2523 int current() const { return *_it; }
2525 std::vector<int> _ids;
2526 std::vector<int>::const_iterator _it;
2529 MFFPMIter *MFFPMIter::NewCell(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
2532 return new MFFPMIterSimple;
2535 std::vector<INTERP_KERNEL::NormalizedCellType> tmp;
2536 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=(*entities).begin();it!=(*entities).end();it++)
2538 if((*it).first==ON_CELLS || (*it).first==ON_GAUSS_NE || (*it).first==ON_GAUSS_PT)
2539 tmp.push_back((*it).second);
2541 return new MFFPMIter2(tmp);
2545 bool MFFPMIter::IsPresenceOfNode(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
2551 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=(*entities).begin();it!=(*entities).end();it++)
2552 if((*it).first==ON_NODES)
2558 MFFPMIter2::MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts)
2560 std::size_t sz(cts.size());
2562 for(std::size_t i=0;i<sz;i++)
2564 INTERP_KERNEL::NormalizedCellType *loc(std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,cts[i]));
2565 if(loc!=typmai2+MED_N_CELL_FIXED_GEO)
2566 _ids[i]=(int)std::distance(typmai2,loc);
2568 throw INTERP_KERNEL::Exception("MFFPMIter2 : The specified geo type does not exists !");
2574 MEDFileFieldPerMesh::MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities):_mesh_iteration(meshIteration),_mesh_order(meshOrder),
2577 INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2578 INTERP_KERNEL::AutoPtr<char> pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2579 INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2580 const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
2581 INTERP_KERNEL::AutoCppPtr<MFFPMIter> iter0(MFFPMIter::NewCell(entities));
2582 for(iter0->begin();!iter0->finished();iter0->next())
2584 int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL ,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2585 std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2586 int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2587 std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2588 if(nbProfile>0 || nbProfile2>0)
2590 const PartDefinition *pd(0);
2592 pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[iter0->current()]),typmai2[iter0->current()]);
2593 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nasc,pd));
2600 if(MFFPMIter::IsPresenceOfNode(entities))
2602 int nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName);
2605 const PartDefinition *pd(0);
2607 pd=mmu->getPartDefAtLevel(1,INTERP_KERNEL::NORM_ERROR);
2608 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd));
2609 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2614 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2616 copyTinyInfoFrom(mesh);
2619 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
2621 if(id>=(int)_pfls.size())
2623 _pfls[id]=DataArrayInt::New();
2624 int lgth=MEDprofileSizeByName(fid,pflName.c_str());
2625 _pfls[id]->setName(pflName);
2626 _pfls[id]->alloc(lgth,1);
2627 MEDprofileRd(fid,pflName.c_str(),_pfls[id]->getPointer());
2628 _pfls[id]->applyLin(1,-1,0);//Converting into C format
2631 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2633 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2635 MEDprofileInfo(fid,i+1,pflName,&sz);
2636 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2637 if(i>=(int)_pfls.size())
2639 _pfls[i]=DataArrayInt::New();
2640 _pfls[i]->alloc(sz,1);
2641 _pfls[i]->setName(pflCpp.c_str());
2642 MEDprofileRd(fid,pflName,_pfls[i]->getPointer());
2643 _pfls[i]->applyLin(1,-1,0);//Converting into C format
2646 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
2648 int nbOfPfls=_pfls.size();
2649 for(int i=0;i<nbOfPfls;i++)
2651 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cpy=_pfls[i]->deepCpy();
2652 cpy->applyLin(1,1,0);
2653 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2654 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2655 MEDprofileWr(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer());
2658 int nbOfLocs=_locs.size();
2659 for(int i=0;i<nbOfLocs;i++)
2660 _locs[i]->writeLL(fid);
2663 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
2665 std::vector<std::string> pfls=getPfls();
2666 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2668 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2671 _pfls.push_back(*it);
2675 int id=std::distance(pfls.begin(),it2);
2676 if(!(*it)->isEqual(*_pfls[id]))
2678 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2679 throw INTERP_KERNEL::Exception(oss.str().c_str());
2683 std::vector<std::string> locs=getLocs();
2684 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
2686 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2689 _locs.push_back(*it);
2693 int id=std::distance(locs.begin(),it2);
2694 if(!(*it)->isEqual(*_locs[id],eps))
2696 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2697 throw INTERP_KERNEL::Exception(oss.str().c_str());
2703 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
2705 for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
2706 getProfile((*it).c_str());
2709 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
2711 for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
2712 getLocalization((*it).c_str());
2715 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
2717 std::vector<std::string> profiles=real.getPflsReallyUsed();
2718 int sz=profiles.size();
2720 for(int i=0;i<sz;i++)
2721 loadProfileInFile(fid,i,profiles[i].c_str());
2723 std::vector<std::string> locs=real.getLocsReallyUsed();
2726 for(int i=0;i<sz;i++)
2727 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2730 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid)
2732 int nProfil=MEDnProfile(fid);
2733 for(int i=0;i<nProfil;i++)
2734 loadProfileInFile(fid,i);
2735 int sz=MEDnLocalization(fid);
2737 for(int i=0;i<sz;i++)
2739 _locs[i]=MEDFileFieldLoc::New(fid,i);
2743 MEDFileFieldGlobs *MEDFileFieldGlobs::New(const std::string& fname)
2745 return new MEDFileFieldGlobs(fname);
2748 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2750 return new MEDFileFieldGlobs;
2753 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
2755 return _file_name.capacity()+_pfls.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<DataArrayInt>)+_locs.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>);
2758 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildrenWithNull() const
2760 std::vector<const BigMemoryObject *> ret;
2761 for(std::vector< MEDCouplingAutoRefCountObjectPtr< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2762 ret.push_back((const DataArrayInt *)*it);
2763 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2764 ret.push_back((const MEDFileFieldLoc *)*it);
2768 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpy() const
2770 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
2772 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2774 if((const DataArrayInt *)*it)
2775 ret->_pfls[i]=(*it)->deepCpy();
2778 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2780 if((const MEDFileFieldLoc*)*it)
2781 ret->_locs[i]=(*it)->deepCpy();
2787 * \throw if a profile in \a pfls in not in \a this.
2788 * \throw if a localization in \a locs in not in \a this.
2789 * \sa MEDFileFieldGlobs::deepCpyPart
2791 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2793 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2794 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2796 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2798 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
2800 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2(pfl);
2801 ret->_pfls.push_back(pfl2);
2803 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2805 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2807 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
2809 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> loc2(loc);
2810 ret->_locs.push_back(loc2);
2812 ret->setFileName(getFileName());
2817 * \throw if a profile in \a pfls in not in \a this.
2818 * \throw if a localization in \a locs in not in \a this.
2819 * \sa MEDFileFieldGlobs::shallowCpyPart
2821 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2823 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2824 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2826 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2828 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
2829 ret->_pfls.push_back(pfl->deepCpy());
2831 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2833 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2835 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
2836 ret->_locs.push_back(loc->deepCpy());
2838 ret->setFileName(getFileName());
2842 MEDFileFieldGlobs::MEDFileFieldGlobs(const std::string& fname):_file_name(fname)
2846 MEDFileFieldGlobs::MEDFileFieldGlobs()
2850 MEDFileFieldGlobs::~MEDFileFieldGlobs()
2854 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
2856 oss << "Profiles :\n";
2857 std::size_t n=_pfls.size();
2858 for(std::size_t i=0;i<n;i++)
2860 oss << " - #" << i << " ";
2861 const DataArrayInt *pfl=_pfls[i];
2863 oss << "\"" << pfl->getName() << "\"\n";
2868 oss << "Localizations :\n";
2869 for(std::size_t i=0;i<n;i++)
2871 oss << " - #" << i << " ";
2872 const MEDFileFieldLoc *loc=_locs[i];
2874 loc->simpleRepr(oss);
2880 void MEDFileFieldGlobs::setFileName(const std::string& fileName)
2882 _file_name=fileName;
2885 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2887 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
2889 DataArrayInt *elt(*it);
2892 std::string name(elt->getName());
2893 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2895 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2897 elt->setName((*it2).second.c_str());
2905 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2907 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
2909 MEDFileFieldLoc *elt(*it);
2912 std::string name(elt->getName());
2913 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2915 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2917 elt->setName((*it2).second.c_str());
2925 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
2927 if(locId<0 || locId>=(int)_locs.size())
2928 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
2929 return _locs[locId]->getNbOfGaussPtPerCell();
2932 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
2934 return getLocalizationFromId(getLocalizationId(locName));
2937 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
2939 if(locId<0 || locId>=(int)_locs.size())
2940 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2941 return *_locs[locId];
2944 namespace ParaMEDMEMImpl
2949 LocFinder(const std::string& loc):_loc(loc) { }
2950 bool operator() (const MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
2952 const std::string &_loc;
2958 PflFinder(const std::string& pfl):_pfl(pfl) { }
2959 bool operator() (const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
2961 const std::string& _pfl;
2965 int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
2967 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),ParaMEDMEMImpl::LocFinder(loc));
2970 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
2971 for(it=_locs.begin();it!=_locs.end();it++)
2972 oss << "\"" << (*it)->getName() << "\", ";
2973 throw INTERP_KERNEL::Exception(oss.str().c_str());
2975 return std::distance(_locs.begin(),it);
2979 * The returned value is never null.
2981 const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
2983 std::string pflNameCpp(pflName);
2984 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2987 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2988 for(it=_pfls.begin();it!=_pfls.end();it++)
2989 oss << "\"" << (*it)->getName() << "\", ";
2990 throw INTERP_KERNEL::Exception(oss.str().c_str());
2995 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
2997 if(pflId<0 || pflId>=(int)_pfls.size())
2998 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2999 return _pfls[pflId];
3002 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
3004 if(locId<0 || locId>=(int)_locs.size())
3005 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3006 return *_locs[locId];
3009 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
3011 return getLocalizationFromId(getLocalizationId(locName));
3015 * The returned value is never null.
3017 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
3019 std::string pflNameCpp(pflName);
3020 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
3023 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3024 for(it=_pfls.begin();it!=_pfls.end();it++)
3025 oss << "\"" << (*it)->getName() << "\", ";
3026 throw INTERP_KERNEL::Exception(oss.str().c_str());
3031 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
3033 if(pflId<0 || pflId>=(int)_pfls.size())
3034 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3035 return _pfls[pflId];
3038 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
3040 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newPfls;
3042 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3044 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
3045 newPfls.push_back(*it);
3050 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
3052 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> > newLocs;
3054 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3056 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
3057 newLocs.push_back(*it);
3062 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
3064 int sz=_pfls.size();
3065 std::vector<std::string> ret(sz);
3066 for(int i=0;i<sz;i++)
3067 ret[i]=_pfls[i]->getName();
3071 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
3073 int sz=_locs.size();
3074 std::vector<std::string> ret(sz);
3075 for(int i=0;i<sz;i++)
3076 ret[i]=_locs[i]->getName();
3080 bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
3082 std::vector<std::string> v=getPfls();
3083 std::string s(pflName);
3084 return std::find(v.begin(),v.end(),s)!=v.end();
3087 bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
3089 std::vector<std::string> v=getLocs();
3090 std::string s(locName);
3091 return std::find(v.begin(),v.end(),s)!=v.end();
3094 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
3096 std::map<int,std::vector<int> > m;
3098 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3100 const DataArrayInt *tmp=(*it);
3103 m[tmp->getHashCode()].push_back(i);
3106 std::vector< std::vector<int> > ret;
3107 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
3109 if((*it2).second.size()>1)
3111 std::vector<int> ret0;
3112 bool equalityOrNot=false;
3113 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
3115 std::vector<int>::const_iterator it4=it3; it4++;
3116 for(;it4!=(*it2).second.end();it4++)
3118 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
3121 ret0.push_back(*it3);
3122 ret0.push_back(*it4);
3128 ret.push_back(ret0);
3134 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
3136 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
3139 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
3141 std::string name(pfl->getName());
3143 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
3144 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3145 if(name==(*it)->getName())
3147 if(!pfl->isEqual(*(*it)))
3149 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
3150 throw INTERP_KERNEL::Exception(oss.str().c_str());
3154 _pfls.push_back(pfl);
3157 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)
3159 std::string name(locName);
3161 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
3162 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
3163 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3164 if((*it)->isName(locName))
3166 if(!(*it)->isEqual(*obj,1e-12))
3168 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
3169 throw INTERP_KERNEL::Exception(oss.str().c_str());
3172 _locs.push_back(obj);
3175 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
3177 std::vector<std::string> names=getPfls();
3178 return CreateNewNameNotIn("NewPfl_",names);
3181 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
3183 std::vector<std::string> names=getLocs();
3184 return CreateNewNameNotIn("NewLoc_",names);
3187 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
3189 for(std::size_t sz=0;sz<100000;sz++)
3191 std::ostringstream tryName;
3192 tryName << prefix << sz;
3193 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
3194 return tryName.str();
3196 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
3200 * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
3201 * \param [in] fname - the file name.
3203 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(const std::string& fname):_globals(MEDFileFieldGlobs::New(fname))
3208 * Creates an empty MEDFileFieldGlobsReal.
3210 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
3214 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
3219 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildrenWithNull() const
3221 std::vector<const BigMemoryObject *> ret;
3222 ret.push_back((const MEDFileFieldGlobs *)_globals);
3227 * Returns a string describing profiles and Gauss points held in \a this.
3228 * \return std::string - the description string.
3230 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
3232 const MEDFileFieldGlobs *glob=_globals;
3233 std::ostringstream oss2; oss2 << glob;
3234 std::string stars(oss2.str().length(),'*');
3235 oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n";
3237 glob->simpleRepr(oss);
3239 oss << "NO GLOBAL INFORMATION !\n";
3242 void MEDFileFieldGlobsReal::resetContent()
3244 _globals=MEDFileFieldGlobs::New();
3247 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
3252 * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
3253 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3255 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3257 _globals=other._globals;
3261 * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3262 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3264 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3266 const MEDFileFieldGlobs *otherg(other._globals);
3269 _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3273 * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3274 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3276 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3278 const MEDFileFieldGlobs *otherg(other._globals);
3281 _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3284 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3286 _globals=other._globals;
3287 if((const MEDFileFieldGlobs *)_globals)
3288 _globals=other._globals->deepCpy();
3292 * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3293 * \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3294 * \param [in] eps - a precision used to compare Gauss points with same name held by
3295 * \a this and \a other MEDFileFieldGlobsReal.
3296 * \throw If \a this and \a other hold profiles with equal names but different ids.
3297 * \throw If \a this and \a other hold different Gauss points with equal names.
3299 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
3301 const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3302 if(thisGlobals==otherGlobals)
3306 _globals=other._globals;
3309 _globals->appendGlobs(*other._globals,eps);
3312 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
3314 checkGlobsPflsPartCoherency();
3315 checkGlobsLocsPartCoherency();
3318 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
3320 contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3323 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
3325 contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3328 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3330 contentNotNull()->loadProfileInFile(fid,id,pflName);
3333 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3335 contentNotNull()->loadProfileInFile(fid,id);
3338 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
3340 contentNotNull()->loadGlobals(fid,*this);
3343 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid)
3345 contentNotNull()->loadAllGlobals(fid);
3348 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3350 contentNotNull()->writeGlobals(fid,opt);
3354 * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3355 * or getPflsReallyUsedMulti().
3356 * \return std::vector<std::string> - a sequence of names of all profiles.
3358 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3360 return contentNotNull()->getPfls();
3364 * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3365 * or getLocsReallyUsedMulti().
3366 * \return std::vector<std::string> - a sequence of names of all localizations.
3368 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3370 return contentNotNull()->getLocs();
3374 * Checks if the profile with a given name exists.
3375 * \param [in] pflName - the profile name of interest.
3376 * \return bool - \c true if the profile named \a pflName exists.
3378 bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
3380 return contentNotNull()->existsPfl(pflName);
3384 * Checks if the localization with a given name exists.
3385 * \param [in] locName - the localization name of interest.
3386 * \return bool - \c true if the localization named \a locName exists.
3388 bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
3390 return contentNotNull()->existsLoc(locName);
3393 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
3395 return contentNotNull()->createNewNameOfPfl();
3398 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
3400 return contentNotNull()->createNewNameOfLoc();
3404 * Sets the name of a MED file.
3405 * \param [inout] fileName - the file name.
3407 void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
3409 contentNotNull()->setFileName(fileName);
3413 * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3414 * in the same order.
3415 * \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3416 * Each item of this sequence is a vector containing ids of equal profiles.
3418 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3420 return contentNotNull()->whichAreEqualProfiles();
3424 * Finds equal localizations.
3425 * \param [in] eps - a precision used to compare real values of the localizations.
3426 * \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3427 * Each item of this sequence is a vector containing ids of equal localizations.
3429 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3431 return contentNotNull()->whichAreEqualLocs(eps);
3435 * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3436 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3437 * this sequence is a pair whose
3438 * - the first item is a vector of profile names to replace by the second item,
3439 * - the second item is a profile name to replace every profile name of the first item.
3441 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3443 contentNotNull()->changePflsNamesInStruct(mapOfModif);
3447 * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3448 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3449 * this sequence is a pair whose
3450 * - the first item is a vector of localization names to replace by the second item,
3451 * - the second item is a localization name to replace every localization name of the first item.
3453 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3455 contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3459 * Replaces references to some profiles (a reference is a profile name) by references
3460 * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3461 * them-selves accordingly. <br>
3462 * This method is a generalization of changePflName().
3463 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3464 * this sequence is a pair whose
3465 * - the first item is a vector of profile names to replace by the second item,
3466 * - the second item is a profile name to replace every profile of the first item.
3467 * \sa changePflsRefsNamesGen()
3468 * \sa changePflName()
3470 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3472 changePflsRefsNamesGen(mapOfModif);
3473 changePflsNamesInStruct(mapOfModif);
3477 * Replaces references to some localizations (a reference is a localization name) by references
3478 * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3479 * them-selves accordingly. <br>
3480 * This method is a generalization of changeLocName().
3481 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3482 * this sequence is a pair whose
3483 * - the first item is a vector of localization names to replace by the second item,
3484 * - the second item is a localization name to replace every localization of the first item.
3485 * \sa changeLocsRefsNamesGen()
3486 * \sa changeLocName()
3488 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3490 changeLocsRefsNamesGen(mapOfModif);
3491 changeLocsNamesInStruct(mapOfModif);
3495 * Renames the profile having a given name and updates references to this profile.
3496 * \param [in] oldName - the name of the profile to rename.
3497 * \param [in] newName - a new name of the profile.
3498 * \sa changePflsNames().
3500 void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
3502 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3503 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3505 changePflsNames(mapOfModif);
3509 * Renames the localization having a given name and updates references to this localization.
3510 * \param [in] oldName - the name of the localization to rename.
3511 * \param [in] newName - a new name of the localization.
3512 * \sa changeLocsNames().
3514 void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
3516 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3517 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3519 changeLocsNames(mapOfModif);
3523 * Removes duplicated profiles. Returns a map used to update references to removed
3524 * profiles via changePflsRefsNamesGen().
3525 * Equal profiles are found using whichAreEqualProfiles().
3526 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3527 * a sequence describing the performed replacements of profiles. Each element of
3528 * this sequence is a pair whose
3529 * - the first item is a vector of profile names replaced by the second item,
3530 * - the second item is a profile name replacing every profile of the first item.
3532 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
3534 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3535 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3537 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3539 std::vector< std::string > tmp((*it).size());
3541 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3542 tmp[j]=std::string(getProfileFromId(*it2)->getName());
3543 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3545 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3546 killProfileIds(tmp2);
3548 changePflsRefsNamesGen(ret);
3553 * Removes duplicated localizations. Returns a map used to update references to removed
3554 * localizations via changeLocsRefsNamesGen().
3555 * Equal localizations are found using whichAreEqualLocs().
3556 * \param [in] eps - a precision used to compare real values of the localizations.
3557 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3558 * a sequence describing the performed replacements of localizations. Each element of
3559 * this sequence is a pair whose
3560 * - the first item is a vector of localization names replaced by the second item,
3561 * - the second item is a localization name replacing every localization of the first item.
3563 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
3565 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3566 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3568 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3570 std::vector< std::string > tmp((*it).size());
3572 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3573 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3574 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3576 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3577 killLocalizationIds(tmp2);
3579 changeLocsRefsNamesGen(ret);
3584 * Returns number of Gauss points per cell in a given localization.
3585 * \param [in] locId - an id of the localization of interest.
3586 * \return int - the number of the Gauss points per cell.
3588 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
3590 return contentNotNull()->getNbOfGaussPtPerCell(locId);
3594 * Returns an id of a localization by its name.
3595 * \param [in] loc - the localization name of interest.
3596 * \return int - the id of the localization.
3597 * \throw If there is no a localization named \a loc.
3599 int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
3601 return contentNotNull()->getLocalizationId(loc);
3605 * Returns the name of the MED file.
3606 * \return const std::string& - the MED file name.
3608 std::string MEDFileFieldGlobsReal::getFileName() const
3610 return contentNotNull()->getFileName();
3614 * Returns a localization object by its name.
3615 * \param [in] locName - the name of the localization of interest.
3616 * \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3617 * \throw If there is no a localization named \a locName.
3619 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
3621 return contentNotNull()->getLocalization(locName);
3625 * Returns a localization object by its id.
3626 * \param [in] locId - the id of the localization of interest.
3627 * \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3628 * \throw If there is no a localization with id \a locId.
3630 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
3632 return contentNotNull()->getLocalizationFromId(locId);
3636 * Returns a profile array by its name.
3637 * \param [in] pflName - the name of the profile of interest.
3638 * \return const DataArrayInt * - the profile array having the name \a pflName.
3639 * \throw If there is no a profile named \a pflName.
3641 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
3643 return contentNotNull()->getProfile(pflName);
3647 * Returns a profile array by its id.
3648 * \param [in] pflId - the id of the profile of interest.
3649 * \return const DataArrayInt * - the profile array having the id \a pflId.
3650 * \throw If there is no a profile with id \a pflId.
3652 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
3654 return contentNotNull()->getProfileFromId(pflId);
3658 * Returns a localization object, apt for modification, by its id.
3659 * \param [in] locId - the id of the localization of interest.
3660 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3661 * having the id \a locId.
3662 * \throw If there is no a localization with id \a locId.
3664 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
3666 return contentNotNull()->getLocalizationFromId(locId);
3670 * Returns a localization object, apt for modification, by its name.
3671 * \param [in] locName - the name of the localization of interest.
3672 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3673 * having the name \a locName.
3674 * \throw If there is no a localization named \a locName.
3676 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
3678 return contentNotNull()->getLocalization(locName);
3682 * Returns a profile array, apt for modification, by its name.
3683 * \param [in] pflName - the name of the profile of interest.
3684 * \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3685 * \throw If there is no a profile named \a pflName.
3687 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
3689 return contentNotNull()->getProfile(pflName);
3693 * Returns a profile array, apt for modification, by its id.
3694 * \param [in] pflId - the id of the profile of interest.
3695 * \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3696 * \throw If there is no a profile with id \a pflId.
3698 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
3700 return contentNotNull()->getProfileFromId(pflId);
3704 * Removes profiles given by their ids. No data is updated to track this removal.
3705 * \param [in] pflIds - a sequence of ids of the profiles to remove.
3707 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
3709 contentNotNull()->killProfileIds(pflIds);
3713 * Removes localizations given by their ids. No data is updated to track this removal.
3714 * \param [in] locIds - a sequence of ids of the localizations to remove.
3716 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
3718 contentNotNull()->killLocalizationIds(locIds);
3722 * Stores a profile array.
3723 * \param [in] pfl - the profile array to store.
3724 * \throw If the name of \a pfl is empty.
3725 * \throw If a profile with the same name as that of \a pfl already exists but contains
3728 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
3730 contentNotNull()->appendProfile(pfl);
3734 * Adds a new localization of Gauss points.
3735 * \param [in] locName - the name of the new localization.
3736 * \param [in] geoType - a geometrical type of the reference cell.
3737 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
3738 * must be \c nbOfNodesPerCell * \c dimOfType.
3739 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
3740 * must be _wg_.size() * \c dimOfType.
3741 * \param [in] w - the weights of Gauss points.
3742 * \throw If \a locName is empty.
3743 * \throw If a localization with the name \a locName already exists but is
3744 * different form the new one.
3746 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)
3748 contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
3751 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
3753 MEDFileFieldGlobs *g(_globals);
3755 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
3759 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
3761 const MEDFileFieldGlobs *g(_globals);
3763 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
3767 //= MEDFileFieldNameScope
3769 MEDFileFieldNameScope::MEDFileFieldNameScope()
3773 MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName):_name(fieldName)
3778 * Returns the name of \a this field.
3779 * \return std::string - a string containing the field name.
3781 std::string MEDFileFieldNameScope::getName() const
3787 * Sets name of \a this field
3788 * \param [in] name - the new field name.
3790 void MEDFileFieldNameScope::setName(const std::string& fieldName)
3795 std::string MEDFileFieldNameScope::getDtUnit() const
3800 void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
3805 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
3808 _dt_unit=other._dt_unit;
3811 //= MEDFileAnyTypeField1TSWithoutSDA
3813 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
3815 _field_per_mesh.resize(other._field_per_mesh.size());
3817 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
3819 if((const MEDFileFieldPerMesh *)*it)
3820 _field_per_mesh[i]=(*it)->deepCpy(this);
3825 * Prints a string describing \a this field into a stream. This string is outputted
3826 * by \c print Python command.
3827 * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
3828 * \param [in,out] oss - the out stream.
3829 * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
3830 * info id printed, else, not.
3832 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
3834 std::string startOfLine(bkOffset,' ');
3835 oss << startOfLine << "Field ";
3837 oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
3838 oss << "on one time Step ";
3840 oss << "(" << f1tsId << ") ";
3841 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
3842 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
3843 const DataArray *arr=getUndergroundDataArray();
3846 const std::vector<std::string> &comps=arr->getInfoOnComponents();
3849 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
3850 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
3851 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
3853 if(arr->isAllocated())
3855 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
3858 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
3862 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
3864 oss << startOfLine << "----------------------" << std::endl;
3865 if(!_field_per_mesh.empty())
3868 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
3870 const MEDFileFieldPerMesh *cur=(*it2);
3872 cur->simpleRepr(bkOffset,oss,i);
3874 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
3879 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
3881 oss << startOfLine << "----------------------" << std::endl;
3884 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
3886 const DataArray *arr(getUndergroundDataArray());
3888 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
3889 int nbOfCompo=arr->getNumberOfComponents();
3890 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
3891 for(int i=0;i<nbOfCompo;i++)
3894 std::vector<int> v(1,i);
3895 MEDCouplingAutoRefCountObjectPtr<DataArray> arr2=arr->keepSelectedComponents(v);
3896 ret[i]->setArray(arr2);
3901 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)
3905 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
3910 * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
3911 * empty. Returns -1 if this in on nodes.
3912 * \return int - the dimension of \a this.
3914 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
3917 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3918 (*it)->getDimension(ret);
3923 * Returns the mesh name.
3924 * \return std::string - a string holding the mesh name.
3925 * \throw If \c _field_per_mesh.empty()
3927 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const
3929 if(_field_per_mesh.empty())
3930 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
3931 return _field_per_mesh[0]->getMeshName();
3934 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const std::string& newMeshName)
3936 std::string oldName(getMeshName());
3937 std::vector< std::pair<std::string,std::string> > v(1);
3938 v[0].first=oldName; v[0].second=newMeshName;
3942 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
3945 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3947 MEDFileFieldPerMesh *cur(*it);
3949 ret=cur->changeMeshNames(modifTab) || ret;
3955 * Returns the number of iteration of the state of underlying mesh.
3956 * \return int - the iteration number.
3957 * \throw If \c _field_per_mesh.empty()
3959 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
3961 if(_field_per_mesh.empty())
3962 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
3963 return _field_per_mesh[0]->getMeshIteration();
3967 * Returns the order number of iteration of the state of underlying mesh.
3968 * \return int - the order number.
3969 * \throw If \c _field_per_mesh.empty()
3971 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
3973 if(_field_per_mesh.empty())
3974 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
3975 return _field_per_mesh[0]->getMeshOrder();
3979 * Checks if \a this field is tagged by a given iteration number and a given
3980 * iteration order number.
3981 * \param [in] iteration - the iteration number of interest.
3982 * \param [in] order - the iteration order number of interest.
3983 * \return bool - \c true if \a this->getIteration() == \a iteration &&
3984 * \a this->getOrder() == \a order.
3986 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
3988 return iteration==_iteration && order==_order;
3992 * Returns number of iteration and order number of iteration when
3993 * \a this field has been calculated.
3994 * \return std::pair<int,int> - a pair of the iteration number and the iteration
3997 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
3999 std::pair<int,int> p;
4005 * Returns number of iteration and order number of iteration when
4006 * \a this field has been calculated.
4007 * \param [in,out] p - a pair returning the iteration number and the iteration
4010 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
4017 * Returns all types of spatial discretization of \a this field.
4018 * \param [in,out] types - a sequence of types of \a this field.
4020 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
4022 std::set<TypeOfField> types2;
4023 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4025 (*it)->fillTypesOfFieldAvailable(types2);
4027 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
4028 std::copy(types2.begin(),types2.end(),bi);
4032 * Returns all types of spatial discretization of \a this field.
4033 * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
4036 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
4038 std::vector<TypeOfField> ret;
4039 fillTypesOfFieldAvailable(ret);
4043 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
4045 std::vector<std::string> ret;
4046 std::set<std::string> ret2;
4047 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4049 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
4050 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4051 if(ret2.find(*it2)==ret2.end())
4053 ret.push_back(*it2);
4060 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
4062 std::vector<std::string> ret;
4063 std::set<std::string> ret2;
4064 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4066 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
4067 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4068 if(ret2.find(*it2)==ret2.end())
4070 ret.push_back(*it2);
4077 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
4079 std::vector<std::string> ret;
4080 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4082 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
4083 ret.insert(ret.end(),tmp.begin(),tmp.end());
4088 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
4090 std::vector<std::string> ret;
4091 std::set<std::string> ret2;
4092 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4094 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
4095 ret.insert(ret.end(),tmp.begin(),tmp.end());
4100 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4102 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4103 (*it)->changePflsRefsNamesGen(mapOfModif);
4106 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4108 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4109 (*it)->changeLocsRefsNamesGen(mapOfModif);
4113 * Returns all attributes of parts of \a this field lying on a given mesh.
4114 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4115 * item of every of returned sequences refers to the _i_-th part of \a this field.
4116 * Thus all sequences returned by this method are of the same length equal to number
4117 * of different types of supporting entities.<br>
4118 * A field part can include sub-parts with several different spatial discretizations,
4119 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
4120 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4121 * of a nested sequence corresponds to a type of spatial discretization.<br>
4122 * This method allows for iteration over MEDFile DataStructure without any overhead.
4123 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4124 * for the case with only one underlying mesh. (Actually, the number of meshes is
4125 * not checked if \a mname == \c NULL).
4126 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4127 * a field part is returned.
4128 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4129 * This sequence is of the same length as \a types.
4130 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4131 * discretization. A profile name can be empty.
4132 * Length of this and of nested sequences is the same as that of \a typesF.
4133 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4134 * discretization. A localization name can be empty.
4135 * Length of this and of nested sequences is the same as that of \a typesF.
4136 * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
4137 * of ids of tuples within the data array, per each type of spatial
4138 * discretization within one mesh entity type.
4139 * Length of this and of nested sequences is the same as that of \a typesF.
4140 * \throw If no field is lying on \a mname.
4142 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
4146 meshId=getMeshIdFromMeshName(mname);
4148 if(_field_per_mesh.empty())
4149 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4150 return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4154 * Returns dimensions of mesh elements \a this field lies on. The returned value is a
4155 * maximal absolute dimension and values returned via the out parameter \a levs are
4156 * dimensions relative to the maximal absolute dimension. <br>
4157 * This method is designed for MEDFileField1TS instances that have a discretization
4158 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS",
4159 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT",
4160 * \ref ParaMEDMEM::ON_GAUSS_NE "ON_GAUSS_NE".
4161 * Only these 3 discretizations will be taken into account here. If \a this is
4162 * \ref ParaMEDMEM::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
4163 * This method is useful to make the link between the dimension of the underlying mesh
4164 * and the levels of \a this, because it is possible that the highest dimension of \a this
4165 * field is not equal to the dimension of the underlying mesh.
4167 * Let's consider the following case:
4168 * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
4169 * TETRA4, HEXA8, TRI3 and SEG2.
4170 * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
4171 * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
4173 * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
4174 * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
4175 * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
4176 * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
4177 * parameter of getFieldAtLevel() is computed basing on the returned values as this:
4178 * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
4180 * to retrieve the highest level of
4181 * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br>
4182 * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
4183 * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
4184 * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
4185 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4186 * for the case with only one underlying mesh. (Actually, the number of meshes is
4187 * not checked if \a mname == \c NULL).
4188 * \param [in,out] levs - a sequence returning the dimensions relative to the maximal
4189 * absolute one. They are in decreasing order. This sequence is cleared before
4191 * \return int - the maximal absolute dimension of elements \a this fields lies on.
4192 * \throw If no field is lying on \a mname.
4194 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
4197 int meshId=getMeshIdFromMeshName(mname);
4198 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4199 std::vector< std::vector<TypeOfField> > typesF;
4200 std::vector< std::vector<std::string> > pfls, locs;
4201 _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4203 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
4204 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
4205 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
4207 st.erase(INTERP_KERNEL::NORM_ERROR);
4209 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
4211 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
4212 ret1.insert((int)cm.getDimension());
4214 int ret=*std::max_element(ret1.begin(),ret1.end());
4215 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
4216 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
4221 * \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.
4222 * \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.
4223 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4224 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4226 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
4228 int mid=getMeshIdFromMeshName(mName);
4229 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4233 * \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.
4234 * \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.
4235 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4236 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4238 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
4240 int mid=getMeshIdFromMeshName(mName);
4241 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4245 * \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.
4247 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
4249 if(_field_per_mesh.empty())
4250 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4253 std::string mName2(mName);
4255 std::vector<std::string> msg;
4256 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4257 if(mName2==(*it)->getMeshName())
4260 msg.push_back((*it)->getMeshName());
4261 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4262 oss << "Possible meshes are : ";
4263 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4264 oss << "\"" << (*it2) << "\" ";
4265 throw INTERP_KERNEL::Exception(oss.str().c_str());
4268 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
4271 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4272 std::string tmp(mesh->getName());
4274 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4275 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4277 for(;it!=_field_per_mesh.end();it++,i++)
4279 if((*it)->getMeshName()==tmp)
4282 int sz=_field_per_mesh.size();
4283 _field_per_mesh.resize(sz+1);
4284 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4288 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4289 MEDFileFieldGlobsReal& glob)
4292 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4294 MEDFileFieldPerMesh *fpm(*it);
4296 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4302 * This method splits \a this into several sub-parts so that each sub parts have exactly one spatial discretization. This method implements the minimal
4303 * splitting that leads to single spatial discretization of this.
4305 * \sa splitMultiDiscrPerGeoTypes
4307 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
4309 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4310 std::vector< std::vector<TypeOfField> > typesF;
4311 std::vector< std::vector<std::string> > pfls,locs;
4312 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4313 std::set<TypeOfField> allEnt;
4314 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4315 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4316 allEnt.insert(*it2);
4317 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4318 std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4319 for(std::size_t i=0;i<allEnt.size();i++,it3++)
4321 std::vector< std::pair<int,int> > its;
4322 ret[i]=shallowCpy();
4323 int newLgth(ret[i]->keepOnlySpatialDiscretization(*it3,its));
4324 ret[i]->updateData(newLgth,its);
4330 * This method performs a sub splitting as splitDiscretizations does but finer. This is the finest spliting level that can be done.
4331 * This method implements the minimal splitting so that each returned elements are mono Gauss discretization per geometric type.
4333 * \sa splitDiscretizations
4335 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes() const
4337 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4338 std::vector< std::vector<TypeOfField> > typesF;
4339 std::vector< std::vector<std::string> > pfls,locs;
4340 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4341 std::set<TypeOfField> allEnt;
4342 std::size_t nbOfMDPGT(0),ii(0);
4343 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++,ii++)
4345 nbOfMDPGT=std::max(nbOfMDPGT,locs[ii].size());
4346 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4347 allEnt.insert(*it2);
4349 if(allEnt.size()!=1)
4350 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : this field is expected to be defined only on one spatial discretization !");
4352 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
4355 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret0(1);
4356 ret0[0]=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(this); this->incrRef();
4359 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfMDPGT);
4360 for(std::size_t i=0;i<nbOfMDPGT;i++)
4362 std::vector< std::pair<int,int> > its;
4363 ret[i]=shallowCpy();
4364 int newLgth(ret[i]->keepOnlyGaussDiscretization(i,its));
4365 ret[i]->updateData(newLgth,its);
4370 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
4372 int globalCounter(0);
4373 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4374 (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4375 return globalCounter;
4378 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlyGaussDiscretization(std::size_t idOfDisc, std::vector< std::pair<int,int> >& its)
4380 int globalCounter(0);
4381 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4382 (*it)->keepOnlyGaussDiscretization(idOfDisc,globalCounter,its);
4383 return globalCounter;
4386 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
4388 if(_nb_of_tuples_to_be_allocated>=0)
4390 _nb_of_tuples_to_be_allocated=newLgth;
4391 const DataArray *oldArr(getUndergroundDataArray());
4394 MEDCouplingAutoRefCountObjectPtr<DataArray> newArr(createNewEmptyDataArrayInstance());
4395 newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
4397 _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
4401 if(_nb_of_tuples_to_be_allocated==-1)
4403 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4405 const DataArray *oldArr(getUndergroundDataArray());
4406 if(!oldArr || !oldArr->isAllocated())
4407 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4408 MEDCouplingAutoRefCountObjectPtr<DataArray> newArr(createNewEmptyDataArrayInstance());
4409 newArr->alloc(newLgth,getNumberOfComponents());
4411 newArr->copyStringInfoFrom(*oldArr);
4413 for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4415 if((*it).second<(*it).first)
4416 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4417 newArr->setContigPartOfSelectedValues2(pos,oldArr,(*it).first,(*it).second,1);
4418 pos+=(*it).second-(*it).first;
4423 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4426 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
4428 if(_field_per_mesh.empty())
4429 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4430 if(_field_per_mesh.size()>1)
4431 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4432 _field_per_mesh[0]->copyOptionsFrom(opts);
4433 _field_per_mesh[0]->writeLL(fid,nasc);
4437 * 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.
4438 * If false is returned the memory allocation is not required.
4440 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
4442 if(_nb_of_tuples_to_be_allocated>=0)
4444 getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4445 _nb_of_tuples_to_be_allocated=-2;
4448 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4450 if(_nb_of_tuples_to_be_allocated==-1)
4451 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4452 if(_nb_of_tuples_to_be_allocated<-3)
4453 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4454 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4457 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
4459 med_int numdt,numit;
4463 med_int meshnumdt,meshnumit;
4464 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4465 MEDfieldComputingStepInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt);
4466 MEDfield23ComputingStepMeshInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit);
4467 if(_iteration!=numdt || _order!=numit)
4468 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4469 _field_per_mesh.resize(nmesh);
4474 std::string meshNameCpp(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
4475 mm=ms->getMeshWithName(meshNameCpp);
4478 for(int i=0;i<nmesh;i++)
4479 _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i,meshnumdt,meshnumit,nasc,mm,entities);
4480 _nb_of_tuples_to_be_allocated=0;
4481 for(int i=0;i<nmesh;i++)
4482 _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4485 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
4487 allocIfNecessaryTheArrayToReceiveDataFromFile();
4488 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4489 (*it)->loadBigArraysRecursively(fid,nasc);
4492 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
4494 if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4495 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4496 (*it)->loadBigArraysRecursively(fid,nasc);
4499 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
4501 loadOnlyStructureOfDataRecursively(fid,nasc,ms,entities);
4502 loadBigArraysRecursively(fid,nasc);
4505 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
4507 DataArray *thisArr(getUndergroundDataArray());
4508 if(thisArr && thisArr->isAllocated())
4510 _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
4511 thisArr->desallocate();
4515 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
4517 return _dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh >);
4520 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
4522 std::vector<const BigMemoryObject *> ret;
4523 if(getUndergroundDataArray())
4524 ret.push_back(getUndergroundDataArray());
4525 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4526 ret.push_back((const MEDFileFieldPerMesh *)*it);
4531 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4532 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4533 * "Sort By Type"), if not, an exception is thrown.
4534 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
4535 * \param [in] arr - the array of values.
4536 * \param [in,out] glob - the global data where profiles and localization present in
4537 * \a field, if any, are added.
4538 * \throw If the name of \a field is empty.
4539 * \throw If the data array of \a field is not set.
4540 * \throw If \a this->_arr is already allocated but has different number of components
4542 * \throw If the underlying mesh of \a field has no name.
4543 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4545 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4547 const MEDCouplingMesh *mesh=field->getMesh();
4549 TypeOfField type=field->getTypeOfField();
4550 std::vector<DataArrayInt *> dummy;
4551 int start=copyTinyInfoFrom(field,arr);
4552 int pos=addNewEntryIfNecessary(mesh);
4555 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4556 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4559 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4563 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4564 * of a given mesh are used as the support of the given field (a real support is not used).
4565 * Elements of the given mesh must be sorted suitable for writing to MED file.
4566 * Order of underlying mesh entities of the given field specified by \a profile parameter
4567 * is not prescribed; this method permutes field values to have them sorted by element
4568 * type as required for writing to MED file. A new profile is added only if no equal
4569 * profile is missing.
4570 * \param [in] field - the field to add to \a this. The field double values are ignored.
4571 * \param [in] arrOfVals - the values of the field \a field used.
4572 * \param [in] mesh - the supporting mesh of \a field.
4573 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4574 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
4575 * \param [in,out] glob - the global data where profiles and localization present in
4576 * \a field, if any, are added.
4577 * \throw If either \a field or \a mesh or \a profile has an empty name.
4578 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4579 * \throw If the data array of \a field is not set.
4580 * \throw If \a this->_arr is already allocated but has different number of components
4582 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4583 * \sa setFieldNoProfileSBT()
4585 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4588 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
4589 if(!arrOfVals || !arrOfVals->isAllocated())
4590 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
4591 TypeOfField type=field->getTypeOfField();
4592 std::vector<DataArrayInt *> idsInPflPerType;
4593 std::vector<DataArrayInt *> idsPerType;
4594 std::vector<int> code,code2;
4595 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4598 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4599 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
4600 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin());
4601 std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
4603 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> field2=field->clone(false);
4604 int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
4605 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4607 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4608 throw INTERP_KERNEL::Exception(oss.str().c_str());
4611 int start=copyTinyInfoFrom(field,arrOfVals);
4612 code2=m->getDistributionOfTypes();
4614 int pos=addNewEntryIfNecessary(m);
4615 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4619 if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
4620 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
4621 std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
4622 std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
4623 int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
4624 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4626 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4627 throw INTERP_KERNEL::Exception(oss.str().c_str());
4629 int start=copyTinyInfoFrom(field,arrOfVals);
4630 int pos=addNewEntryIfNecessary(m);
4631 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4636 * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
4638 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
4640 if(_nb_of_tuples_to_be_allocated>=0)
4641 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 !");
4642 DataArray *arr(getOrCreateAndGetArray());
4643 arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
4644 _nb_of_tuples_to_be_allocated=-3;
4648 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4649 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4650 * larger by the size of \a field. Returns an id of the first not filled
4651 * tuple of \a this->_arr.
4652 * \param [in] field - the field to copy the info on components and the name from.
4653 * \return int - the id of first not initialized tuple of \a this->_arr.
4654 * \throw If the name of \a field is empty.
4655 * \throw If the data array of \a field is not set.
4656 * \throw If \a this->_arr is already allocated but has different number of components
4659 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
4662 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4663 std::string name(field->getName());
4664 setName(name.c_str());
4665 setDtUnit(field->getTimeUnit());
4667 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4669 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4670 if(!arr->isAllocated())
4671 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
4672 _dt=field->getTime(_iteration,_order);
4673 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4674 if(!getOrCreateAndGetArray()->isAllocated())
4676 allocNotFromFile(arr->getNumberOfTuples());
4681 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4682 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4683 getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
4684 _nb_of_tuples_to_be_allocated=-3;
4685 return oldNbOfTuples;
4690 * Returns number of components in \a this field
4691 * \return int - the number of components.
4693 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4695 return getOrCreateAndGetArray()->getNumberOfComponents();
4699 * Change info on components in \a this.
4700 * \throw If size of \a infos is not equal to the number of components already in \a this.
4702 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
4704 DataArray *arr=getOrCreateAndGetArray();
4705 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
4709 * Returns info on components of \a this field.
4710 * \return const std::vector<std::string>& - a sequence of strings each being an
4711 * information on _i_-th component.
4713 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
4715 const DataArray *arr=getOrCreateAndGetArray();
4716 return arr->getInfoOnComponents();
4720 * Returns a mutable info on components of \a this field.
4721 * \return std::vector<std::string>& - a sequence of strings each being an
4722 * information on _i_-th component.
4724 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
4726 DataArray *arr=getOrCreateAndGetArray();
4727 return arr->getInfoOnComponents();
4730 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const
4732 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4734 const MEDFileFieldPerMesh *fpm(*it);
4737 if(fpm->presenceOfMultiDiscPerGeoType())
4744 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4745 * \param [in] type - a spatial discretization of the new field.
4746 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4747 * \param [in] mName - a name of the supporting mesh.
4748 * \param [in] renumPol - specifies how to permute values of the result field according to
4749 * the optional numbers of cells and nodes, if any. The valid values are
4750 * - 0 - do not permute.
4751 * - 1 - permute cells.
4752 * - 2 - permute nodes.
4753 * - 3 - permute cells and nodes.
4755 * \param [in] glob - the global data storing profiles and localization.
4756 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4757 * caller is to delete this field using decrRef() as it is no more needed.
4758 * \throw If the MED file is not readable.
4759 * \throw If there is no mesh named \a mName in the MED file.
4760 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4761 * \throw If no field of \a this is lying on the mesh \a mName.
4762 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4764 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4766 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4768 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4770 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4771 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4775 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4776 * \param [in] type - a spatial discretization of the new field.
4777 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4778 * \param [in] renumPol - specifies how to permute values of the result field according to
4779 * the optional numbers of cells and nodes, if any. The valid values are
4780 * - 0 - do not permute.
4781 * - 1 - permute cells.
4782 * - 2 - permute nodes.
4783 * - 3 - permute cells and nodes.
4785 * \param [in] glob - the global data storing profiles and localization.
4786 * \param [in] mesh - the supporting mesh.
4787 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4788 * caller is to delete this field using decrRef() as it is no more needed.
4789 * \throw If the MED file is not readable.
4790 * \throw If no field of \a this is lying on \a mesh.
4791 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4792 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4794 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4796 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax,false);
4797 const DataArrayInt *d=mesh->getNumberFieldAtLevel(meshDimRelToMax);
4798 const DataArrayInt *e=mesh->getNumberFieldAtLevel(1);
4799 if(meshDimRelToMax==1)
4800 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
4801 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
4805 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
4807 * \param [in] type - a spatial discretization of the new field.
4808 * \param [in] mName - a name of the supporting mesh.
4809 * \param [in] renumPol - specifies how to permute values of the result field according to
4810 * the optional numbers of cells and nodes, if any. The valid values are
4811 * - 0 - do not permute.
4812 * - 1 - permute cells.
4813 * - 2 - permute nodes.
4814 * - 3 - permute cells and nodes.
4816 * \param [in] glob - the global data storing profiles and localization.
4817 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4818 * caller is to delete this field using decrRef() as it is no more needed.
4819 * \throw If the MED file is not readable.
4820 * \throw If there is no mesh named \a mName in the MED file.
4821 * \throw If there are no mesh entities in the mesh.
4822 * \throw If no field values of the given \a type are available.
4824 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4826 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4828 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4830 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4831 int absDim=getDimension();
4832 int meshDimRelToMax=absDim-mm->getMeshDimension();
4833 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4837 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4838 * \param [in] type - a spatial discretization of the new field.
4839 * \param [in] renumPol - specifies how to permute values of the result field according to
4840 * the optional numbers of cells and nodes, if any. The valid values are
4841 * - 0 - do not permute.
4842 * - 1 - permute cells.
4843 * - 2 - permute nodes.
4844 * - 3 - permute cells and nodes.
4846 * \param [in] glob - the global data storing profiles and localization.
4847 * \param [in] mesh - the supporting mesh.
4848 * \param [in] cellRenum - the cell numbers array used for permutation of the result
4849 * field according to \a renumPol.
4850 * \param [in] nodeRenum - the node numbers array used for permutation of the result
4851 * field according to \a renumPol.
4852 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4853 * caller is to delete this field using decrRef() as it is no more needed.
4854 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4855 * \throw If no field of \a this is lying on \a mesh.
4856 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4858 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
4860 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
4861 int meshId=getMeshIdFromMeshName(mesh->getName());
4863 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
4868 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4875 throw INTERP_KERNEL::Exception(msg1);
4876 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4879 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
4881 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4882 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
4883 throw INTERP_KERNEL::Exception(oss.str().c_str());
4885 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
4886 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
4887 std::vector<DataArray *> arrOut2(1,arrOut);
4888 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
4889 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
4890 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
4897 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4899 throw INTERP_KERNEL::Exception(msg1);
4902 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
4904 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4905 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
4906 throw INTERP_KERNEL::Exception(oss.str().c_str());
4908 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
4909 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
4910 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
4911 ret->renumberNodes(nodeRenumSafe->getConstPointer());
4916 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
4921 * Returns values and a profile of the field of a given type lying on a given support.
4922 * \param [in] type - a spatial discretization of the field.
4923 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4924 * \param [in] mesh - the supporting mesh.
4925 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
4926 * field of interest lies on. If the field lies on all entities of the given
4927 * dimension, all ids in \a pfl are zero. The caller is to delete this array
4928 * using decrRef() as it is no more needed.
4929 * \param [in] glob - the global data storing profiles and localization.
4930 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
4931 * field. The caller is to delete this array using decrRef() as it is no more needed.
4932 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4933 * \throw If no field of \a this is lying on \a mesh.
4934 * \throw If no field values of the given \a type are available.
4936 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
4938 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4939 int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
4940 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
4941 ret->setName(nasc.getName().c_str());
4945 //= MEDFileField1TSWithoutSDA
4948 * Throws if a given value is not a valid (non-extended) relative dimension.
4949 * \param [in] meshDimRelToMax - the relative dimension value.
4950 * \throw If \a meshDimRelToMax > 0.
4952 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
4954 if(meshDimRelToMax>0)
4955 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
4959 * Checks if elements of a given mesh are in the order suitable for writing
4960 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
4961 * vector describing types of elements and their number.
4962 * \param [in] mesh - the mesh to check.
4963 * \return std::vector<int> - a vector holding for each element type (1) item of
4964 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
4965 * These values are in full-interlace mode.
4966 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4968 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
4971 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
4972 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
4973 int nbOfTypes=geoTypes.size();
4974 std::vector<int> code(3*nbOfTypes);
4975 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr1=DataArrayInt::New();
4976 arr1->alloc(nbOfTypes,1);
4977 int *arrPtr=arr1->getPointer();
4978 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
4979 for(int i=0;i<nbOfTypes;i++,it++)
4980 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
4981 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
4982 const int *arrPtr2=arr2->getConstPointer();
4984 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
4987 int nbCells=mesh->getNumberOfCellsWithType(*it);
4988 code[3*pos]=(int)(*it);
4989 code[3*pos+1]=nbCells;
4990 code[3*pos+2]=-1;//no profiles
4992 std::vector<const DataArrayInt *> idsPerType;//no profiles
4993 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
4997 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
5002 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5004 return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5008 * Returns all attributes and values of parts of \a this field lying on a given mesh.
5009 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
5010 * item of every of returned sequences refers to the _i_-th part of \a this field.
5011 * Thus all sequences returned by this method are of the same length equal to number
5012 * of different types of supporting entities.<br>
5013 * A field part can include sub-parts with several different spatial discretizations,
5014 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
5015 * for example. Hence, some of the returned sequences contains nested sequences, and an item
5016 * of a nested sequence corresponds to a type of spatial discretization.<br>
5017 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
5018 * The overhead is due to selecting values into new instances of DataArrayDouble.
5019 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
5020 * for the case with only one underlying mesh. (Actually, the number of meshes is
5021 * not checked if \a mname == \c NULL).
5022 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
5023 * a field part is returned.
5024 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
5025 * A field part can include sub-parts with several different spatial discretizations,
5026 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and
5027 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT" for example.
5028 * This sequence is of the same length as \a types.
5029 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
5030 * discretization. A profile name can be empty.
5031 * Length of this and of nested sequences is the same as that of \a typesF.
5032 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
5033 * discretization. A localization name can be empty.
5034 * Length of this and of nested sequences is the same as that of \a typesF.
5035 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
5036 * per each type of spatial discretization within one mesh entity type.
5037 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
5038 * Length of this and of nested sequences is the same as that of \a typesF.
5039 * \throw If no field is lying on \a mname.
5041 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
5045 meshId=getMeshIdFromMeshName(mname);
5047 if(_field_per_mesh.empty())
5048 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
5049 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
5050 int nbOfRet=ret0.size();
5051 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
5052 for(int i=0;i<nbOfRet;i++)
5054 const std::vector< std::pair<int,int> >& p=ret0[i];
5055 int nbOfRet1=p.size();
5056 ret[i].resize(nbOfRet1);
5057 for(int j=0;j<nbOfRet1;j++)
5059 DataArrayDouble *tmp=_arr->selectByTupleId2(p[j].first,p[j].second,1);
5067 * Returns a pointer to the underground DataArrayDouble instance. So the
5068 * caller should not decrRef() it. This method allows for a direct access to the field
5069 * values. This method is quite unusable if there is more than a nodal field or a cell
5070 * field on single geometric cell type.
5071 * \return DataArrayDouble * - the pointer to the field values array.
5073 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDouble() const
5075 const DataArrayDouble *ret=_arr;
5077 return const_cast<DataArrayDouble *>(ret);
5082 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
5087 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
5089 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
5090 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5091 ret->deepCpyLeavesFrom(*this);
5092 const DataArrayDouble *arr(_arr);
5095 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr->convertToIntArr());
5096 ret->setArray(arr2);
5102 * Returns a pointer to the underground DataArrayDouble instance. So the
5103 * caller should not decrRef() it. This method allows for a direct access to the field
5104 * values. This method is quite unusable if there is more than a nodal field or a cell
5105 * field on single geometric cell type.
5106 * \return DataArrayDouble * - the pointer to the field values array.
5108 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArray() const
5110 return getUndergroundDataArrayDouble();
5114 * Returns a pointer to the underground DataArrayDouble instance and a
5115 * sequence describing parameters of a support of each part of \a this field. The
5116 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5117 * direct access to the field values. This method is intended for the field lying on one
5119 * \param [in,out] entries - the sequence describing parameters of a support of each
5120 * part of \a this field. Each item of this sequence consists of two parts. The
5121 * first part describes a type of mesh entity and an id of discretization of a
5122 * current field part. The second part describes a range of values [begin,end)
5123 * within the returned array relating to the current field part.
5124 * \return DataArrayDouble * - the pointer to the field values array.
5125 * \throw If the number of underlying meshes is not equal to 1.
5126 * \throw If no field values are available.
5127 * \sa getUndergroundDataArray()
5129 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5131 if(_field_per_mesh.size()!=1)
5132 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5133 if(_field_per_mesh[0]==0)
5134 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5135 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5136 return getUndergroundDataArrayDouble();
5140 * Returns a pointer to the underground DataArrayDouble instance and a
5141 * sequence describing parameters of a support of each part of \a this field. The
5142 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5143 * direct access to the field values. This method is intended for the field lying on one
5145 * \param [in,out] entries - the sequence describing parameters of a support of each
5146 * part of \a this field. Each item of this sequence consists of two parts. The
5147 * first part describes a type of mesh entity and an id of discretization of a
5148 * current field part. The second part describes a range of values [begin,end)
5149 * within the returned array relating to the current field part.
5150 * \return DataArrayDouble * - the pointer to the field values array.
5151 * \throw If the number of underlying meshes is not equal to 1.
5152 * \throw If no field values are available.
5153 * \sa getUndergroundDataArray()
5155 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5157 return getUndergroundDataArrayDoubleExt(entries);
5160 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
5162 DataArrayDouble *arr(getOrCreateAndGetArrayDouble());
5163 arr->setInfoAndChangeNbOfCompo(infos);
5166 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
5170 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
5172 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
5173 ret->deepCpyLeavesFrom(*this);
5177 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCpy() const
5179 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret=static_cast<MEDFileField1TSWithoutSDA *>(shallowCpy());
5180 if((const DataArrayDouble *)_arr)
5181 ret->_arr=_arr->deepCpy();
5185 void MEDFileField1TSWithoutSDA::setArray(DataArray *arr)
5189 _nb_of_tuples_to_be_allocated=-1;
5193 DataArrayDouble *arrC=dynamic_cast<DataArrayDouble *>(arr);
5195 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayDouble !");
5197 _nb_of_tuples_to_be_allocated=-3;
5202 DataArray *MEDFileField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
5204 return DataArrayDouble::New();
5207 DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble()
5209 DataArrayDouble *ret=_arr;
5212 _arr=DataArrayDouble::New();
5216 DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray()
5218 return getOrCreateAndGetArrayDouble();
5221 const DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble() const
5223 const DataArrayDouble *ret=_arr;
5226 DataArrayDouble *ret2=DataArrayDouble::New();
5227 const_cast<MEDFileField1TSWithoutSDA *>(this)->_arr=DataArrayDouble::New();
5231 const DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray() const
5233 return getOrCreateAndGetArrayDouble();
5236 //= MEDFileIntField1TSWithoutSDA
5238 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5240 return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5243 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
5247 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order,
5248 const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
5250 DataArrayInt *arr(getOrCreateAndGetArrayInt());
5251 arr->setInfoAndChangeNbOfCompo(infos);
5254 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
5259 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const
5261 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
5262 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5263 ret->deepCpyLeavesFrom(*this);
5264 const DataArrayInt *arr(_arr);
5267 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2(arr->convertToDblArr());
5268 ret->setArray(arr2);
5274 * Returns a pointer to the underground DataArrayInt instance. So the
5275 * caller should not decrRef() it. This method allows for a direct access to the field
5276 * values. This method is quite unusable if there is more than a nodal field or a cell
5277 * field on single geometric cell type.
5278 * \return DataArrayInt * - the pointer to the field values array.
5280 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArray() const
5282 return getUndergroundDataArrayInt();
5286 * Returns a pointer to the underground DataArrayInt instance. So the
5287 * caller should not decrRef() it. This method allows for a direct access to the field
5288 * values. This method is quite unusable if there is more than a nodal field or a cell
5289 * field on single geometric cell type.
5290 * \return DataArrayInt * - the pointer to the field values array.
5292 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayInt() const
5294 const DataArrayInt *ret=_arr;
5296 return const_cast<DataArrayInt *>(ret);
5302 * Returns a pointer to the underground DataArrayInt instance and a
5303 * sequence describing parameters of a support of each part of \a this field. The
5304 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5305 * direct access to the field values. This method is intended for the field lying on one
5307 * \param [in,out] entries - the sequence describing parameters of a support of each
5308 * part of \a this field. Each item of this sequence consists of two parts. The
5309 * first part describes a type of mesh entity and an id of discretization of a
5310 * current field part. The second part describes a range of values [begin,end)
5311 * within the returned array relating to the current field part.
5312 * \return DataArrayInt * - the pointer to the field values array.
5313 * \throw If the number of underlying meshes is not equal to 1.
5314 * \throw If no field values are available.
5315 * \sa getUndergroundDataArray()
5317 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5319 return getUndergroundDataArrayIntExt(entries);
5323 * Returns a pointer to the underground DataArrayInt instance and a
5324 * sequence describing parameters of a support of each part of \a this field. The
5325 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5326 * direct access to the field values. This method is intended for the field lying on one
5328 * \param [in,out] entries - the sequence describing parameters of a support of each
5329 * part of \a this field. Each item of this sequence consists of two parts. The
5330 * first part describes a type of mesh entity and an id of discretization of a
5331 * current field part. The second part describes a range of values [begin,end)
5332 * within the returned array relating to the current field part.
5333 * \return DataArrayInt * - the pointer to the field values array.
5334 * \throw If the number of underlying meshes is not equal to 1.
5335 * \throw If no field values are available.
5336 * \sa getUndergroundDataArray()
5338 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5340 if(_field_per_mesh.size()!=1)
5341 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5342 if(_field_per_mesh[0]==0)
5343 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5344 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5345 return getUndergroundDataArrayInt();
5348 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5350 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5351 ret->deepCpyLeavesFrom(*this);
5355 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCpy() const
5357 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret=static_cast<MEDFileIntField1TSWithoutSDA *>(shallowCpy());
5358 if((const DataArrayInt *)_arr)
5359 ret->_arr=_arr->deepCpy();
5363 void MEDFileIntField1TSWithoutSDA::setArray(DataArray *arr)
5367 _nb_of_tuples_to_be_allocated=-1;
5371 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>(arr);
5373 throw INTERP_KERNEL::Exception("MEDFileIntField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayInt !");
5375 _nb_of_tuples_to_be_allocated=-3;
5380 DataArray *MEDFileIntField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
5382 return DataArrayInt::New();
5385 DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt()
5387 DataArrayInt *ret=_arr;
5390 _arr=DataArrayInt::New();
5394 DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray()
5396 return getOrCreateAndGetArrayInt();
5399 const DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt() const
5401 const DataArrayInt *ret=_arr;
5404 DataArrayInt *ret2=DataArrayInt::New();
5405 const_cast<MEDFileIntField1TSWithoutSDA *>(this)->_arr=DataArrayInt::New();
5409 const DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray() const
5411 return getOrCreateAndGetArrayInt();
5414 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5418 //= MEDFileAnyTypeField1TS
5420 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
5422 med_field_type typcha;
5424 std::vector<std::string> infos;
5425 std::string dtunit,fieldName;
5426 LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
5427 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5432 ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5437 ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5442 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] !";
5443 throw INTERP_KERNEL::Exception(oss.str().c_str());
5446 ret->setDtUnit(dtunit.c_str());
5447 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5449 med_int numdt,numit;
5451 MEDfieldComputingStepInfo(fid,fieldName.c_str(),1,&numdt,&numit,&dt);
5452 ret->setTime(numdt,numit,dt);
5455 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5457 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5461 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
5462 try:MEDFileFieldGlobsReal(fileName)
5464 MEDFileUtilities::CheckFileForRead(fileName);
5465 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5466 _content=BuildContentFrom(fid,fileName,loadAll,ms);
5469 catch(INTERP_KERNEL::Exception& e)
5474 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5476 med_field_type typcha;
5477 std::vector<std::string> infos;
5480 int nbSteps=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5481 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5486 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5491 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5496 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] !";
5497 throw INTERP_KERNEL::Exception(oss.str().c_str());
5500 ret->setDtUnit(dtunit.c_str());
5501 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5505 std::ostringstream oss; oss << "MEDFileField1TS(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5506 throw INTERP_KERNEL::Exception(oss.str().c_str());
5509 med_int numdt,numit;
5511 MEDfieldComputingStepInfo(fid,fieldName.c_str(),1,&numdt,&numit,&dt);
5512 ret->setTime(numdt,numit,dt);
5515 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5517 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5521 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5522 try:MEDFileFieldGlobsReal(fileName)
5524 MEDFileUtilities::CheckFileForRead(fileName);
5525 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5526 _content=BuildContentFrom(fid,fileName,fieldName,loadAll,ms);
5529 catch(INTERP_KERNEL::Exception& e)
5534 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, const std::string& fileName)
5537 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5538 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5540 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New();
5541 ret->setFileName(fileName);
5542 ret->_content=c; c->incrRef();
5545 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5547 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New();
5548 ret->setFileName(fileName);
5549 ret->_content=c; c->incrRef();
5552 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5555 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
5557 MEDFileUtilities::CheckFileForRead(fileName);
5558 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5559 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll,0);
5560 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5561 ret->loadGlobals(fid);
5565 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
5567 MEDFileUtilities::CheckFileForRead(fileName);
5568 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5569 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll,0);
5570 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5571 ret->loadGlobals(fid);
5575 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
5577 MEDFileUtilities::CheckFileForRead(fileName);
5578 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5579 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,iteration,order,loadAll,0);
5580 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5581 ret->loadGlobals(fid);
5585 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5587 med_field_type typcha;
5588 std::vector<std::string> infos;
5591 int nbOfStep2=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5592 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5597 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5602 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5607 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] !";
5608 throw INTERP_KERNEL::Exception(oss.str().c_str());
5611 ret->setDtUnit(dtunit.c_str());
5612 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5615 std::vector< std::pair<int,int> > dtits(nbOfStep2);
5616 for(int i=0;i<nbOfStep2 && !found;i++)
5618 med_int numdt,numit;
5620 MEDfieldComputingStepInfo(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt);
5621 if(numdt==iteration && numit==order)
5627 dtits[i]=std::pair<int,int>(numdt,numit);
5631 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << fileName << "' ! Available iterations are : ";
5632 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5633 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5634 throw INTERP_KERNEL::Exception(oss.str().c_str());
5637 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5639 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5643 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5644 try:MEDFileFieldGlobsReal(fileName)
5646 MEDFileUtilities::CheckFileForRead(fileName);
5647 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5648 _content=BuildContentFrom(fid,fileName.c_str(),fieldName.c_str(),iteration,order,loadAll,ms);
5651 catch(INTERP_KERNEL::Exception& e)
5657 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5658 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5660 * \warning this is a shallow copy constructor
5662 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5664 if(!shallowCopyOfContent)
5666 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5667 otherPtr->incrRef();
5668 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5672 _content=other.shallowCpy();
5676 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)
5680 int nbFields=MEDnField(fid);
5681 if(fieldIdCFormat>=nbFields)
5683 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << fileName << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5684 throw INTERP_KERNEL::Exception(oss.str().c_str());
5687 int ncomp=MEDfieldnComponent(fid,fieldIdCFormat+1);
5688 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5689 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5690 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5691 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5692 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5695 MEDfieldInfo(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
5696 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5697 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5698 infos.clear(); infos.resize(ncomp);
5699 for(int j=0;j<ncomp;j++)
5700 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5705 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5708 * \return in case of success the number of time steps available for the field with name \a fieldName.
5710 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)
5712 int nbFields=MEDnField(fid);
5714 std::vector<std::string> fns(nbFields);
5716 for(int i=0;i<nbFields && !found;i++)
5719 nbOfStep2=LocateField2(fid,fileName,i,false,tmp,typcha,infos,dtunitOut);
5721 found=(tmp==fieldName);
5727 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
5728 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5729 oss << "\"" << *it << "\" ";
5730 throw INTERP_KERNEL::Exception(oss.str().c_str());
5736 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5737 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5738 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5739 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5740 * to keep a valid instance.
5741 * 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.
5742 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5743 * 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.
5745 * \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.
5746 * \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.
5747 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5748 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5749 * \param [in] newLocName is the new localization name.
5750 * \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.
5751 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5753 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
5755 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5756 std::string oldPflName=disc->getProfile();
5757 std::vector<std::string> vv=getPflsReallyUsedMulti();
5758 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5759 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5761 disc->setProfile(newPflName);
5762 DataArrayInt *pfl=getProfile(oldPflName.c_str());
5763 pfl->setName(newPflName);
5767 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5768 throw INTERP_KERNEL::Exception(oss.str().c_str());
5773 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5774 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5775 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5776 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5777 * to keep a valid instance.
5778 * 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.
5779 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5780 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5781 * 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.
5783 * \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.
5784 * \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.
5785 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5786 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5787 * \param [in] newLocName is the new localization name.
5788 * \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.
5789 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
5791 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
5793 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5794 std::string oldLocName=disc->getLocalization();
5795 std::vector<std::string> vv=getLocsReallyUsedMulti();
5796 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
5797 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
5799 disc->setLocalization(newLocName);
5800 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
5801 loc.setName(newLocName);
5805 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
5806 throw INTERP_KERNEL::Exception(oss.str().c_str());
5810 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
5812 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5814 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
5818 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
5820 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5822 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
5827 * Writes \a this field into a MED file specified by its name.
5828 * \param [in] fileName - the MED file name.
5829 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
5830 * - 2 - erase; an existing file is removed.
5831 * - 1 - append; same data should not be present in an existing file.
5832 * - 0 - overwrite; same data present in an existing file is overwritten.
5833 * \throw If the field name is not set.
5834 * \throw If no field data is set.
5835 * \throw If \a mode == 1 and the same data is present in an existing file.
5837 void MEDFileAnyTypeField1TS::write(const std::string& fileName, int mode) const
5839 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
5840 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
5845 * This method alloc the arrays and load potentially huge arrays contained in this field.
5846 * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
5847 * This method can be also called to refresh or reinit values from a file.
5849 * \throw If the fileName is not set or points to a non readable MED file.
5850 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5852 void MEDFileAnyTypeField1TS::loadArrays()
5854 if(getFileName().empty())
5855 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
5856 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
5857 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
5861 * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
5862 * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
5863 * this method does not throw if \a this does not come from file read.
5865 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
5867 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
5869 if(!getFileName().empty())
5871 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
5872 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
5877 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
5878 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
5879 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
5881 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
5883 void MEDFileAnyTypeField1TS::unloadArrays()
5885 contentNotNullBase()->unloadArrays();
5889 * 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.
5890 * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
5891 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
5893 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5895 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
5897 if(!getFileName().empty())
5898 contentNotNullBase()->unloadArrays();
5901 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
5903 int nbComp=getNumberOfComponents();
5904 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5905 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5906 for(int i=0;i<nbComp;i++)
5908 std::string info=getInfo()[i];
5910 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
5911 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
5912 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
5914 if(getName().empty())
5915 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
5916 MEDfieldCr(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
5917 writeGlobals(fid,*this);
5918 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
5921 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
5923 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
5926 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
5928 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
5929 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
5934 * Returns a string describing \a this field. This string is outputted
5935 * by \c print Python command.
5937 std::string MEDFileAnyTypeField1TS::simpleRepr() const
5939 std::ostringstream oss;
5940 contentNotNullBase()->simpleRepr(0,oss,-1);
5941 simpleReprGlobs(oss);
5946 * This method returns all profiles whose name is non empty used.
5947 * \b WARNING If profile is used several times it will be reported \b only \b once.
5948 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
5950 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
5952 return contentNotNullBase()->getPflsReallyUsed2();
5956 * This method returns all localizations whose name is non empty used.
5957 * \b WARNING If localization is used several times it will be reported \b only \b once.
5959 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
5961 return contentNotNullBase()->getLocsReallyUsed2();
5965 * This method returns all profiles whose name is non empty used.
5966 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
5968 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
5970 return contentNotNullBase()->getPflsReallyUsedMulti2();
5974 * This method returns all localizations whose name is non empty used.
5975 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
5977 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
5979 return contentNotNullBase()->getLocsReallyUsedMulti2();
5982 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5984 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
5987 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5989 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
5992 int MEDFileAnyTypeField1TS::getDimension() const
5994 return contentNotNullBase()->getDimension();
5997 int MEDFileAnyTypeField1TS::getIteration() const
5999 return contentNotNullBase()->getIteration();
6002 int MEDFileAnyTypeField1TS::getOrder() const
6004 return contentNotNullBase()->getOrder();
6007 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
6009 return contentNotNullBase()->getTime(iteration,order);
6012 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
6014 contentNotNullBase()->setTime(iteration,order,val);
6017 std::string MEDFileAnyTypeField1TS::getName() const
6019 return contentNotNullBase()->getName();
6022 void MEDFileAnyTypeField1TS::setName(const std::string& name)
6024 contentNotNullBase()->setName(name);
6027 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
6029 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
6032 std::string MEDFileAnyTypeField1TS::getDtUnit() const
6034 return contentNotNullBase()->getDtUnit();
6037 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
6039 contentNotNullBase()->setDtUnit(dtUnit);
6042 std::string MEDFileAnyTypeField1TS::getMeshName() const
6044 return contentNotNullBase()->getMeshName();
6047 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
6049 contentNotNullBase()->setMeshName(newMeshName);
6052 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
6054 return contentNotNullBase()->changeMeshNames(modifTab);
6057 int MEDFileAnyTypeField1TS::getMeshIteration() const
6059 return contentNotNullBase()->getMeshIteration();
6062 int MEDFileAnyTypeField1TS::getMeshOrder() const
6064 return contentNotNullBase()->getMeshOrder();
6067 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
6069 return contentNotNullBase()->getNumberOfComponents();
6072 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
6074 return contentNotNullBase()->isDealingTS(iteration,order);
6077 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
6079 return contentNotNullBase()->getDtIt();
6082 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
6084 contentNotNullBase()->fillIteration(p);
6087 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
6089 contentNotNullBase()->fillTypesOfFieldAvailable(types);
6092 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
6094 contentNotNullBase()->setInfo(infos);
6097 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
6099 return contentNotNullBase()->getInfo();
6101 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
6103 return contentNotNullBase()->getInfo();
6106 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
6108 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
6111 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
6113 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6116 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
6118 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6121 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
6123 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
6126 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
6128 return contentNotNullBase()->getTypesOfFieldAvailable();
6131 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,
6132 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6134 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
6138 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
6139 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
6140 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
6142 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
6144 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6146 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
6147 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
6148 std::size_t sz(contentsSplit.size());
6149 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
6150 for(std::size_t i=0;i<sz;i++)
6152 ret[i]=shallowCpy();
6153 ret[i]->_content=contentsSplit[i];
6159 * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
6160 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6162 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
6164 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6166 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
6167 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
6168 std::size_t sz(contentsSplit.size());
6169 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
6170 for(std::size_t i=0;i<sz;i++)
6172 ret[i]=shallowCpy();
6173 ret[i]->_content=contentsSplit[i];
6179 * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this.
6180 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6182 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const
6184 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6186 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !");
6187 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
6188 std::size_t sz(contentsSplit.size());
6189 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
6190 for(std::size_t i=0;i<sz;i++)
6192 ret[i]=shallowCpy();
6193 ret[i]->_content=contentsSplit[i];
6198 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCpy() const
6200 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=shallowCpy();
6201 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
6202 ret->_content=_content->deepCpy();
6203 ret->deepCpyGlobs(*this);
6207 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
6209 return contentNotNullBase()->copyTinyInfoFrom(field,arr);
6215 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6216 * the first field that has been read from a specified MED file.
6217 * \param [in] fileName - the name of the MED file to read.
6218 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6219 * is to delete this field using decrRef() as it is no more needed.
6220 * \throw If reading the file fails.
6222 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll)
6224 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret(new MEDFileField1TS(fileName,loadAll,0));
6225 ret->contentNotNull();
6230 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6231 * a given field that has been read from a specified MED file.
6232 * \param [in] fileName - the name of the MED file to read.
6233 * \param [in] fieldName - the name of the field to read.
6234 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6235 * is to delete this field using decrRef() as it is no more needed.
6236 * \throw If reading the file fails.
6237 * \throw If there is no field named \a fieldName in the file.
6239 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6241 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret(new MEDFileField1TS(fileName,fieldName,loadAll,0));
6242 ret->contentNotNull();
6247 * Returns a new instance of MEDFileField1TS holding data of a given time step of
6248 * a given field that has been read from a specified MED file.
6249 * \param [in] fileName - the name of the MED file to read.
6250 * \param [in] fieldName - the name of the field to read.
6251 * \param [in] iteration - the iteration number of a required time step.
6252 * \param [in] order - the iteration order number of required time step.
6253 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6254 * is to delete this field using decrRef() as it is no more needed.
6255 * \throw If reading the file fails.
6256 * \throw If there is no field named \a fieldName in the file.
6257 * \throw If the required time step is missing from the file.
6259 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6261 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret(new MEDFileField1TS(fileName,fieldName,iteration,order,loadAll,0));
6262 ret->contentNotNull();
6267 * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6268 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6270 * Returns a new instance of MEDFileField1TS holding either a shallow copy
6271 * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
6272 * \warning this is a shallow copy constructor
6273 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
6274 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
6275 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6276 * is to delete this field using decrRef() as it is no more needed.
6278 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6280 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(other,shallowCopyOfContent);
6281 ret->contentNotNull();
6286 * Returns a new empty instance of MEDFileField1TS.
6287 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6288 * is to delete this field using decrRef() as it is no more needed.
6290 MEDFileField1TS *MEDFileField1TS::New()
6292 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS;
6293 ret->contentNotNull();
6298 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
6299 * following the given input policy.
6301 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6302 * By default (true) the globals are deeply copied.
6303 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
6305 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
6307 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret;
6308 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6311 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
6313 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
6314 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
6315 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc,getFileName()));
6318 ret=MEDFileIntField1TS::New();
6320 ret->deepCpyGlobs(*this);
6322 ret->shallowCpyGlobs(*this);
6326 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const
6328 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6330 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
6331 const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
6333 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 !");
6337 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull()
6339 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6341 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
6342 MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
6344 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 !");
6348 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MEDCouplingAutoRefCountObjectPtr<DataArray>& arr)
6351 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
6352 if(!((DataArray*)arr))
6353 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
6354 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
6356 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6357 f->setArray(arrOutC);
6360 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr)
6362 if(!((DataArray*)arr))
6363 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
6364 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
6366 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6371 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
6372 try:MEDFileAnyTypeField1TS(fileName,loadAll,ms)
6375 catch(INTERP_KERNEL::Exception& e)
6378 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6379 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll,ms)
6382 catch(INTERP_KERNEL::Exception& e)
6385 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6386 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll,ms)
6389 catch(INTERP_KERNEL::Exception& e)
6393 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6394 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6396 * \warning this is a shallow copy constructor
6398 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6399 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6402 catch(INTERP_KERNEL::Exception& e)
6405 MEDFileField1TS::MEDFileField1TS()
6407 _content=new MEDFileField1TSWithoutSDA;
6411 * Returns a new MEDCouplingFieldDouble of a given type lying on
6412 * mesh entities of a given dimension of the first mesh in MED file. If \a this field
6413 * has not been constructed via file reading, an exception is thrown.
6414 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6415 * \param [in] type - a spatial discretization of interest.
6416 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6417 * \param [in] renumPol - specifies how to permute values of the result field according to
6418 * the optional numbers of cells and nodes, if any. The valid values are
6419 * - 0 - do not permute.
6420 * - 1 - permute cells.
6421 * - 2 - permute nodes.
6422 * - 3 - permute cells and nodes.
6424 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6425 * caller is to delete this field using decrRef() as it is no more needed.
6426 * \throw If \a this field has not been constructed via file reading.
6427 * \throw If the MED file is not readable.
6428 * \throw If there is no mesh in the MED file.
6429 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6430 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6431 * \sa getFieldOnMeshAtLevel()
6433 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6435 if(getFileName().empty())
6436 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6437 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6438 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull());
6439 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6444 * Returns a new MEDCouplingFieldDouble of a given type lying on
6445 * the top level cells of the first mesh in MED file. If \a this field
6446 * has not been constructed via file reading, an exception is thrown.
6447 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6448 * \param [in] type - a spatial discretization of interest.
6449 * \param [in] renumPol - specifies how to permute values of the result field according to
6450 * the optional numbers of cells and nodes, if any. The valid values are
6451 * - 0 - do not permute.
6452 * - 1 - permute cells.
6453 * - 2 - permute nodes.
6454 * - 3 - permute cells and nodes.
6456 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6457 * caller is to delete this field using decrRef() as it is no more needed.
6458 * \throw If \a this field has not been constructed via file reading.
6459 * \throw If the MED file is not readable.
6460 * \throw If there is no mesh in the MED file.
6461 * \throw If no field values of the given \a type.
6462 * \throw If no field values lying on the top level support.
6463 * \sa getFieldAtLevel()
6465 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
6467 if(getFileName().empty())
6468 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6469 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6470 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull());
6471 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6476 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6477 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6478 * \param [in] type - a spatial discretization of the new field.
6479 * \param [in] mesh - the supporting mesh.
6480 * \param [in] renumPol - specifies how to permute values of the result field according to
6481 * the optional numbers of cells and nodes, if any. The valid values are
6482 * - 0 - do not permute.
6483 * - 1 - permute cells.
6484 * - 2 - permute nodes.
6485 * - 3 - permute cells and nodes.
6487 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6488 * caller is to delete this field using decrRef() as it is no more needed.
6489 * \throw If no field of \a this is lying on \a mesh.
6490 * \throw If the mesh is empty.
6491 * \throw If no field values of the given \a type are available.
6492 * \sa getFieldAtLevel()
6493 * \sa getFieldOnMeshAtLevel()
6495 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
6497 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6498 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull());
6499 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6504 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6505 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6506 * \param [in] type - a spatial discretization of interest.
6507 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6508 * \param [in] mesh - the supporting mesh.
6509 * \param [in] renumPol - specifies how to permute values of the result field according to
6510 * the optional numbers of cells and nodes, if any. The valid values are
6511 * - 0 - do not permute.
6512 * - 1 - permute cells.
6513 * - 2 - permute nodes.
6514 * - 3 - permute cells and nodes.
6516 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6517 * caller is to delete this field using decrRef() as it is no more needed.
6518 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6519 * \throw If no field of \a this is lying on \a mesh.
6520 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6521 * \sa getFieldAtLevel()
6522 * \sa getFieldOnMeshAtLevel()
6524 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
6526 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6527 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull());
6528 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6533 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6534 * This method is called "Old" because in MED3 norm a field has only one meshName
6535 * attached, so this method is for readers of MED2 files. If \a this field
6536 * has not been constructed via file reading, an exception is thrown.
6537 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6538 * \param [in] type - a spatial discretization of interest.
6539 * \param [in] mName - a name of the supporting mesh.
6540 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6541 * \param [in] renumPol - specifies how to permute values of the result field according to
6542 * the optional numbers of cells and nodes, if any. The valid values are
6543 * - 0 - do not permute.
6544 * - 1 - permute cells.
6545 * - 2 - permute nodes.
6546 * - 3 - permute cells and nodes.
6548 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6549 * caller is to delete this field using decrRef() as it is no more needed.
6550 * \throw If the MED file is not readable.
6551 * \throw If there is no mesh named \a mName in the MED file.
6552 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6553 * \throw If \a this field has not been constructed via file reading.
6554 * \throw If no field of \a this is lying on the mesh named \a mName.
6555 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6556 * \sa getFieldAtLevel()
6558 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
6560 if(getFileName().empty())
6561 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6562 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6563 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
6564 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6569 * Returns values and a profile of the field of a given type lying on a given support.
6570 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6571 * \param [in] type - a spatial discretization of the field.
6572 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6573 * \param [in] mesh - the supporting mesh.
6574 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6575 * field of interest lies on. If the field lies on all entities of the given
6576 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6577 * using decrRef() as it is no more needed.
6578 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6579 * field. The caller is to delete this array using decrRef() as it is no more needed.
6580 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6581 * \throw If no field of \a this is lying on \a mesh.
6582 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6584 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6586 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6587 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
6591 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6592 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6593 * "Sort By Type"), if not, an exception is thrown.
6594 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6595 * \param [in] field - the field to add to \a this.
6596 * \throw If the name of \a field is empty.
6597 * \throw If the data array of \a field is not set.
6598 * \throw If the data array is already allocated but has different number of components
6600 * \throw If the underlying mesh of \a field has no name.
6601 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6603 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
6606 contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
6610 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6611 * can be an aggregation of several MEDCouplingFieldDouble instances.
6612 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6613 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6616 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6617 * A new profile is added only if no equal profile is missing.
6618 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6619 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
6620 * \param [in] mesh - the supporting mesh of \a field.
6621 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6622 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6623 * \throw If either \a field or \a mesh or \a profile has an empty name.
6624 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6625 * \throw If the data array of \a field is not set.
6626 * \throw If the data array of \a this is already allocated but has different number of
6627 * components than \a field.
6628 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6629 * \sa setFieldNoProfileSBT()
6631 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6634 contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6637 MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const
6639 return new MEDFileField1TS(*this);
6642 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const
6644 return contentNotNull()->getUndergroundDataArrayDouble();
6647 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
6649 return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
6652 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6653 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6655 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6658 //= MEDFileIntField1TS
6660 MEDFileIntField1TS *MEDFileIntField1TS::New()
6662 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS;
6663 ret->contentNotNull();
6667 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll)
6669 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,loadAll,0));
6670 ret->contentNotNull();
6674 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6676 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,fieldName,loadAll,0));
6677 ret->contentNotNull();
6681 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6683 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,fieldName,iteration,order,loadAll,0));
6684 ret->contentNotNull();
6688 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6690 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6691 ret->contentNotNull();
6695 MEDFileIntField1TS::MEDFileIntField1TS()
6697 _content=new MEDFileIntField1TSWithoutSDA;
6700 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
6701 try:MEDFileAnyTypeField1TS(fileName,loadAll,ms)
6704 catch(INTERP_KERNEL::Exception& e)
6707 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6708 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll,ms)
6711 catch(INTERP_KERNEL::Exception& e)
6714 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6715 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll,ms)
6718 catch(INTERP_KERNEL::Exception& e)
6722 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6723 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6725 * \warning this is a shallow copy constructor
6727 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6731 MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const
6733 return new MEDFileIntField1TS(*this);
6737 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
6738 * following the given input policy.
6740 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6741 * By default (true) the globals are deeply copied.
6742 * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
6744 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const
6746 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret;
6747 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6750 const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
6752 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
6753 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
6754 ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc,getFileName()));
6757 ret=MEDFileField1TS::New();
6759 ret->deepCpyGlobs(*this);
6761 ret->shallowCpyGlobs(*this);
6766 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6767 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6768 * "Sort By Type"), if not, an exception is thrown.
6769 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6770 * \param [in] field - the field to add to \a this. The field double values are ignored.
6771 * \param [in] arrOfVals - the values of the field \a field used.
6772 * \throw If the name of \a field is empty.
6773 * \throw If the data array of \a field is not set.
6774 * \throw If the data array is already allocated but has different number of components
6776 * \throw If the underlying mesh of \a field has no name.
6777 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6779 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals)
6782 contentNotNull()->setFieldNoProfileSBT(field,arrOfVals,*this,*contentNotNull());
6786 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6787 * can be an aggregation of several MEDCouplingFieldDouble instances.
6788 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6789 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6792 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6793 * A new profile is added only if no equal profile is missing.
6794 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6795 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
6796 * \param [in] arrOfVals - the values of the field \a field used.
6797 * \param [in] mesh - the supporting mesh of \a field.
6798 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6799 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6800 * \throw If either \a field or \a mesh or \a profile has an empty name.
6801 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6802 * \throw If the data array of \a field is not set.
6803 * \throw If the data array of \a this is already allocated but has different number of
6804 * components than \a field.
6805 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6806 * \sa setFieldNoProfileSBT()
6808 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6811 contentNotNull()->setFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6814 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const
6816 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6818 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
6819 const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
6821 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 !");
6825 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
6827 if(getFileName().empty())
6828 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6829 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut2;
6830 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut2,*contentNotNull());
6831 DataArrayInt *arrOutC=dynamic_cast<DataArrayInt *>((DataArray *)arrOut2);
6833 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : mismatch between dataArrays type and MEDFileIntField1TS ! Expected int32 !");
6835 arrOut->incrRef(); // arrOut2 dies at the end of the func
6839 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr)
6841 if(!((DataArray *)arr))
6842 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
6843 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>((DataArray *)arr);
6845 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
6851 * Returns a new MEDCouplingFieldDouble of a given type lying on
6852 * the top level cells of the first mesh in MED file. If \a this field
6853 * has not been constructed via file reading, an exception is thrown.
6854 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6855 * \param [in] type - a spatial discretization of interest.
6856 * \param [out] arrOut - the DataArrayInt containing values of field.
6857 * \param [in] renumPol - specifies how to permute values of the result field according to
6858 * the optional numbers of cells and nodes, if any. The valid values are
6859 * - 0 - do not permute.
6860 * - 1 - permute cells.
6861 * - 2 - permute nodes.
6862 * - 3 - permute cells and nodes.
6864 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6865 * caller is to delete this field using decrRef() as it is no more needed.
6866 * \throw If \a this field has not been constructed via file reading.
6867 * \throw If the MED file is not readable.
6868 * \throw If there is no mesh in the MED file.
6869 * \throw If no field values of the given \a type.
6870 * \throw If no field values lying on the top level support.
6871 * \sa getFieldAtLevel()
6873 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, DataArrayInt* &arrOut, int renumPol) const
6875 if(getFileName().empty())
6876 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6877 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6878 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNull());
6879 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6884 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6885 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6886 * \param [in] type - a spatial discretization of the new field.
6887 * \param [in] mesh - the supporting mesh.
6888 * \param [out] arrOut - the DataArrayInt containing values of field.
6889 * \param [in] renumPol - specifies how to permute values of the result field according to
6890 * the optional numbers of cells and nodes, if any. The valid values are
6891 * - 0 - do not permute.
6892 * - 1 - permute cells.
6893 * - 2 - permute nodes.
6894 * - 3 - permute cells and nodes.
6896 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6897 * caller is to delete this field using decrRef() as it is no more needed.
6898 * \throw If no field of \a this is lying on \a mesh.
6899 * \throw If the mesh is empty.
6900 * \throw If no field values of the given \a type are available.
6901 * \sa getFieldAtLevel()
6902 * \sa getFieldOnMeshAtLevel()
6904 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
6906 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6907 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNull());
6908 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6913 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6914 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6915 * \param [in] type - a spatial discretization of interest.
6916 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6917 * \param [out] arrOut - the DataArrayInt containing values of field.
6918 * \param [in] mesh - the supporting mesh.
6919 * \param [in] renumPol - specifies how to permute values of the result field according to
6920 * the optional numbers of cells and nodes, if any. The valid values are
6921 * - 0 - do not permute.
6922 * - 1 - permute cells.
6923 * - 2 - permute nodes.
6924 * - 3 - permute cells and nodes.
6926 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6927 * caller is to delete this field using decrRef() as it is no more needed.
6928 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6929 * \throw If no field of \a this is lying on \a mesh.
6930 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6931 * \sa getFieldAtLevel()
6932 * \sa getFieldOnMeshAtLevel()
6934 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
6936 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6937 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNull());
6938 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6943 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6944 * This method is called "Old" because in MED3 norm a field has only one meshName
6945 * attached, so this method is for readers of MED2 files. If \a this field
6946 * has not been constructed via file reading, an exception is thrown.
6947 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6948 * \param [in] type - a spatial discretization of interest.
6949 * \param [in] mName - a name of the supporting mesh.
6950 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6951 * \param [out] arrOut - the DataArrayInt containing values of field.
6952 * \param [in] renumPol - specifies how to permute values of the result field according to
6953 * the optional numbers of cells and nodes, if any. The valid values are
6954 * - 0 - do not permute.
6955 * - 1 - permute cells.
6956 * - 2 - permute nodes.
6957 * - 3 - permute cells and nodes.
6959 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6960 * caller is to delete this field using decrRef() as it is no more needed.
6961 * \throw If the MED file is not readable.
6962 * \throw If there is no mesh named \a mName in the MED file.
6963 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6964 * \throw If \a this field has not been constructed via file reading.
6965 * \throw If no field of \a this is lying on the mesh named \a mName.
6966 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6967 * \sa getFieldAtLevel()
6969 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
6971 if(getFileName().empty())
6972 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6973 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6974 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNull());
6975 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6980 * Returns values and a profile of the field of a given type lying on a given support.
6981 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6982 * \param [in] type - a spatial discretization of the field.
6983 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6984 * \param [in] mesh - the supporting mesh.
6985 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6986 * field of interest lies on. If the field lies on all entities of the given
6987 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6988 * using decrRef() as it is no more needed.
6989 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
6990 * field. The caller is to delete this array using decrRef() as it is no more needed.
6991 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6992 * \throw If no field of \a this is lying on \a mesh.
6993 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6995 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6997 MEDCouplingAutoRefCountObjectPtr<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6998 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
7001 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull()
7003 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7005 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
7006 MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
7008 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 !");
7012 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const
7014 return contentNotNull()->getUndergroundDataArrayInt();
7017 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
7019 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
7023 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileFieldNameScope(fieldName)
7028 * \param [in] fieldId field id in C mode
7030 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
7032 med_field_type typcha;
7033 std::string dtunitOut;
7034 int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,"",fieldId,false,_name,typcha,_infos,dtunitOut);
7035 setDtUnit(dtunitOut.c_str());
7036 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities);
7039 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, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
7040 try:MEDFileFieldNameScope(fieldName),_infos(infos)
7042 setDtUnit(dtunit.c_str());
7043 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities);
7045 catch(INTERP_KERNEL::Exception& e)
7050 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
7052 std::size_t ret(_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA>));
7053 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7054 ret+=(*it).capacity();
7058 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
7060 std::vector<const BigMemoryObject *> ret;
7061 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7062 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
7067 * 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
7070 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
7072 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7073 ret->setInfo(_infos);
7074 int sz=(int)_time_steps.size();
7075 for(const int *id=startIds;id!=endIds;id++)
7077 if(*id>=0 && *id<sz)
7079 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
7080 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7084 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7086 ret->pushBackTimeStep(tse2);
7090 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
7091 oss << " ! Should be in [0," << sz << ") !";
7092 throw INTERP_KERNEL::Exception(oss.str().c_str());
7095 if(ret->getNumberOfTS()>0)
7096 ret->synchronizeNameScope();
7097 ret->copyNameScope(*this);
7102 * 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
7105 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
7107 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
7108 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7109 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7110 ret->setInfo(_infos);
7111 int sz=(int)_time_steps.size();
7113 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
7117 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
7118 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7122 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7124 ret->pushBackTimeStep(tse2);
7128 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
7129 oss << " ! Should be in [0," << sz << ") !";
7130 throw INTERP_KERNEL::Exception(oss.str().c_str());
7133 if(ret->getNumberOfTS()>0)
7134 ret->synchronizeNameScope();
7135 ret->copyNameScope(*this);
7139 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7142 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7143 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7145 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7148 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7149 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
7150 ids->pushBackSilent(id);
7152 return buildFromTimeStepIds(ids->begin(),ids->end());
7155 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7158 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7159 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7161 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7164 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7165 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
7166 ids->pushBackSilent(id);
7168 return buildFromTimeStepIds(ids->begin(),ids->end());
7171 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
7173 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7175 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7178 if(cur->presenceOfMultiDiscPerGeoType())
7184 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
7189 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
7194 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
7197 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7199 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
7200 if(pt->isDealingTS(iteration,order))
7203 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
7204 std::vector< std::pair<int,int> > vp=getIterations();
7205 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
7206 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
7207 throw INTERP_KERNEL::Exception(oss.str().c_str());
7210 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
7212 return *_time_steps[getTimeStepPos(iteration,order)];
7215 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
7217 return *_time_steps[getTimeStepPos(iteration,order)];
7220 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const
7222 if(_time_steps.empty())
7223 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
7224 return _time_steps[0]->getMeshName();
7227 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const std::string& newMeshName)
7229 std::string oldName(getMeshName());
7230 std::vector< std::pair<std::string,std::string> > v(1);
7231 v[0].first=oldName; v[0].second=newMeshName;
7235 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
7238 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7240 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7242 ret=cur->changeMeshNames(modifTab) || ret;
7248 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
7250 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
7252 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
7256 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
7258 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7260 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
7263 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
7264 MEDFileFieldGlobsReal& glob)
7267 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7269 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
7271 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
7276 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7278 std::string startLine(bkOffset,' ');
7279 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
7281 oss << " (" << fmtsId << ")";
7282 oss << " has the following name: \"" << _name << "\"." << std::endl;
7283 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
7284 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7286 oss << startLine << " - \"" << *it << "\"" << std::endl;
7289 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7291 std::string chapter(17,'0'+i);
7292 oss << startLine << chapter << std::endl;
7293 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7295 cur->simpleRepr(bkOffset+2,oss,i);
7297 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
7298 oss << startLine << chapter << std::endl;
7302 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
7304 std::size_t sz=_time_steps.size();
7305 std::vector< std::pair<int,int> > ret(sz);
7307 for(std::size_t i=0;i<sz;i++)
7309 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
7312 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
7316 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
7317 throw INTERP_KERNEL::Exception(oss.str().c_str());
7323 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>& tse)
7325 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
7327 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
7328 checkCoherencyOfType(tse2);
7329 if(_time_steps.empty())
7331 setName(tse2->getName().c_str());
7332 setInfo(tse2->getInfo());
7334 checkThatComponentsMatch(tse2->getInfo());
7335 _time_steps.push_back(tse);
7338 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
7340 std::size_t nbOfCompo=_infos.size();
7341 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7343 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7346 if((cur->getInfo()).size()!=nbOfCompo)
7348 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
7349 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
7350 throw INTERP_KERNEL::Exception(oss.str().c_str());
7352 cur->copyNameScope(*this);
7357 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
7359 _time_steps.resize(nbPdt);
7360 for(int i=0;i<nbPdt;i++)
7362 std::vector< std::pair<int,int> > ts;
7363 med_int numdt=0,numo=0;
7364 med_int meshIt=0,meshOrder=0;
7366 MEDfieldComputingStepMeshInfo(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder);
7371 _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7376 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7380 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
7383 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities);
7385 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entities);
7389 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
7391 if(_time_steps.empty())
7392 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
7393 checkThatNbOfCompoOfTSMatchThis();
7394 std::vector<std::string> infos(getInfo());
7395 int nbComp=infos.size();
7396 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7397 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7398 for(int i=0;i<nbComp;i++)
7400 std::string info=infos[i];
7402 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7403 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7404 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7407 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7408 MEDfieldCr(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
7409 int nbOfTS=_time_steps.size();
7410 for(int i=0;i<nbOfTS;i++)
7411 _time_steps[i]->writeLL(fid,opts,*this);
7414 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
7416 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7418 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7420 elt->loadBigArraysRecursively(fid,nasc);
7424 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
7426 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7428 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7430 elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7434 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
7436 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7438 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7440 elt->unloadArrays();
7444 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7446 return _time_steps.size();
7449 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
7451 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7452 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7454 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7456 newTS.push_back(*it);
7461 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
7463 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7464 int maxId=(int)_time_steps.size();
7466 std::set<int> idsToDel;
7467 for(const int *id=startIds;id!=endIds;id++,ii++)
7469 if(*id>=0 && *id<maxId)
7471 idsToDel.insert(*id);
7475 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7476 throw INTERP_KERNEL::Exception(oss.str().c_str());
7479 for(int iii=0;iii<maxId;iii++)
7480 if(idsToDel.find(iii)==idsToDel.end())
7481 newTS.push_back(_time_steps[iii]);
7485 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
7487 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7488 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7489 if(nbOfEntriesToKill==0)
7491 std::size_t sz=_time_steps.size();
7492 std::vector<bool> b(sz,true);
7494 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7496 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7497 for(std::size_t i=0;i<sz;i++)
7499 newTS.push_back(_time_steps[i]);
7503 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
7506 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
7507 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7509 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7513 tmp->getTime(it2,ord);
7514 if(it2==iteration && order==ord)
7517 oss << "(" << it2 << "," << ord << "), ";
7520 throw INTERP_KERNEL::Exception(oss.str().c_str());
7523 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
7526 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
7528 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7530 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7534 double ti=tmp->getTime(it2,ord);
7535 if(fabs(time-ti)<eps)
7541 throw INTERP_KERNEL::Exception(oss.str().c_str());
7544 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
7546 int lgth=_time_steps.size();
7547 std::vector< std::pair<int,int> > ret(lgth);
7548 for(int i=0;i<lgth;i++)
7549 _time_steps[i]->fillIteration(ret[i]);
7554 * 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'
7555 * This method returns two things.
7556 * - The absolute dimension of 'this' in first parameter.
7557 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7558 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
7560 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7561 * Only these 3 discretizations will be taken into account here.
7563 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7564 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7565 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7567 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7568 * 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'.
7570 * Let's consider the typical following case :
7571 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7572 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7573 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7575 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7577 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7579 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7580 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7581 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7582 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7584 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
7586 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7589 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
7591 if(pos<0 || pos>=(int)_time_steps.size())
7593 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7594 throw INTERP_KERNEL::Exception(oss.str().c_str());
7596 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7599 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7600 oss << "\nTry to use following method eraseEmptyTS !";
7601 throw INTERP_KERNEL::Exception(oss.str().c_str());
7606 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
7608 if(pos<0 || pos>=(int)_time_steps.size())
7610 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7611 throw INTERP_KERNEL::Exception(oss.str().c_str());
7613 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7616 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7617 oss << "\nTry to use following method eraseEmptyTS !";
7618 throw INTERP_KERNEL::Exception(oss.str().c_str());
7623 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
7625 std::vector<std::string> ret;
7626 std::set<std::string> ret2;
7627 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7629 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
7630 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7631 if(ret2.find(*it2)==ret2.end())
7633 ret.push_back(*it2);
7640 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
7642 std::vector<std::string> ret;
7643 std::set<std::string> ret2;
7644 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7646 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
7647 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7648 if(ret2.find(*it2)==ret2.end())
7650 ret.push_back(*it2);
7657 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
7659 std::vector<std::string> ret;
7660 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7662 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
7663 ret.insert(ret.end(),tmp.begin(),tmp.end());
7668 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
7670 std::vector<std::string> ret;
7671 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7673 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
7674 ret.insert(ret.end(),tmp.begin(),tmp.end());
7679 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7681 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7682 (*it)->changePflsRefsNamesGen2(mapOfModif);
7685 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7687 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7688 (*it)->changeLocsRefsNamesGen2(mapOfModif);
7691 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
7693 int lgth=_time_steps.size();
7694 std::vector< std::vector<TypeOfField> > ret(lgth);
7695 for(int i=0;i<lgth;i++)
7696 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
7701 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
7703 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
7705 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
7708 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCpy() const
7710 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
7712 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7714 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
7715 ret->_time_steps[i]=(*it)->deepCpy();
7720 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
7722 std::size_t sz(_infos.size()),sz2(_time_steps.size());
7723 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7724 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7725 for(std::size_t i=0;i<sz;i++)
7727 ret[i]=shallowCpy();
7728 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7730 for(std::size_t i=0;i<sz2;i++)
7732 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7735 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7736 throw INTERP_KERNEL::Exception(oss.str().c_str());
7740 for(std::size_t i=0;i<sz;i++)
7741 for(std::size_t j=0;j<sz2;j++)
7742 ret[i]->_time_steps[j]=ts[j][i];
7747 * This method splits into discretization each time steps in \a this.
7748 * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
7750 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
7752 std::size_t sz(_time_steps.size());
7753 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7754 for(std::size_t i=0;i<sz;i++)
7756 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7759 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
7760 throw INTERP_KERNEL::Exception(oss.str().c_str());
7762 items[i]=timeStep->splitDiscretizations();
7765 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
7766 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
7767 std::vector< TypeOfField > types;
7768 for(std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7769 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7771 std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
7773 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
7774 std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
7775 if(it2==types.end())
7776 types.push_back(ts[0]);
7778 ret.resize(types.size()); ret2.resize(types.size());
7779 for(std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7780 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7782 TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
7783 std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
7784 ret2[pos].push_back(*it1);
7786 for(std::size_t i=0;i<types.size();i++)
7788 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7789 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
7790 elt->pushBackTimeStep(*it1);//also updates infos in elt
7792 elt->MEDFileFieldNameScope::operator=(*this);
7798 * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
7800 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
7802 std::size_t sz(_time_steps.size());
7803 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7804 std::size_t szOut(std::numeric_limits<std::size_t>::max());
7805 for(std::size_t i=0;i<sz;i++)
7807 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7810 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
7811 throw INTERP_KERNEL::Exception(oss.str().c_str());
7813 items[i]=timeStep->splitMultiDiscrPerGeoTypes();
7814 if(szOut==std::numeric_limits<std::size_t>::max())
7815 szOut=items[i].size();
7817 if(items[i].size()!=szOut)
7818 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
7820 if(szOut==std::numeric_limits<std::size_t>::max())
7821 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
7822 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
7823 for(std::size_t i=0;i<szOut;i++)
7825 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7826 for(std::size_t j=0;j<sz;j++)
7827 elt->pushBackTimeStep(items[j][i]);
7829 elt->MEDFileFieldNameScope::operator=(*this);
7834 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
7836 _name=field->getName();
7838 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
7840 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
7841 _infos=arr->getInfoOnComponents();
7844 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
7846 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
7847 if(_name!=field->getName())
7849 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
7850 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
7851 throw INTERP_KERNEL::Exception(oss.str().c_str());
7854 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
7855 checkThatComponentsMatch(arr->getInfoOnComponents());
7858 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
7860 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
7861 if(getInfo().size()!=compos.size())
7863 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
7864 oss << " number of components of element to append (" << compos.size() << ") !";
7865 throw INTERP_KERNEL::Exception(oss.str().c_str());
7869 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
7870 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
7871 oss << " But compo in input fields are : ";
7872 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
7874 throw INTERP_KERNEL::Exception(oss.str().c_str());
7878 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
7880 std::size_t sz=_infos.size();
7882 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
7884 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7886 if(elt->getInfo().size()!=sz)
7888 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
7889 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
7890 throw INTERP_KERNEL::Exception(oss.str().c_str());
7895 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
7898 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7899 if(!_time_steps.empty())
7900 checkCoherencyOfTinyInfo(field,arr);
7901 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
7902 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7903 objC->setFieldNoProfileSBT(field,arr,glob,*this);
7904 copyTinyInfoFrom(field,arr);
7905 _time_steps.push_back(obj);
7908 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
7911 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7912 if(!_time_steps.empty())
7913 checkCoherencyOfTinyInfo(field,arr);
7914 MEDFileField1TSWithoutSDA *objC=new MEDFileField1TSWithoutSDA;
7915 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7916 objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
7917 copyTinyInfoFrom(field,arr);
7918 _time_steps.push_back(obj);
7921 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ts)
7923 int sz=(int)_time_steps.size();
7926 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
7927 throw INTERP_KERNEL::Exception(oss.str().c_str());
7929 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
7932 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
7934 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
7935 throw INTERP_KERNEL::Exception(oss.str().c_str());
7941 //= MEDFileFieldMultiTSWithoutSDA
7943 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, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
7945 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
7948 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
7952 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7957 * \param [in] fieldId field id in C mode
7959 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
7960 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
7963 catch(INTERP_KERNEL::Exception& e)
7966 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, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
7967 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
7970 catch(INTERP_KERNEL::Exception& e)
7973 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
7975 return new MEDFileField1TSWithoutSDA;
7978 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
7981 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7982 const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
7984 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
7987 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const
7989 return MEDFileField1TSWithoutSDA::TYPE_STR;
7992 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const
7994 return new MEDFileFieldMultiTSWithoutSDA(*this);
7997 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const
7999 return new MEDFileFieldMultiTSWithoutSDA;
8003 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
8004 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
8006 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
8008 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
8009 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8011 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
8012 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
8015 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
8017 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
8018 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8020 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8022 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8025 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
8027 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
8028 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
8029 ret->setIteration(i,elt);
8035 //= MEDFileAnyTypeFieldMultiTS
8037 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
8041 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
8042 try:MEDFileFieldGlobsReal(fileName)
8044 MEDFileUtilities::CheckFileForRead(fileName);
8045 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8046 _content=BuildContentFrom(fid,fileName,loadAll,ms);
8049 catch(INTERP_KERNEL::Exception& e)
8054 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8056 med_field_type typcha;
8057 std::vector<std::string> infos;
8060 MEDFileAnyTypeField1TS::LocateField(fid,fileName,fieldName,i,typcha,infos,dtunit);
8061 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8066 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8071 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8076 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] !";
8077 throw INTERP_KERNEL::Exception(oss.str().c_str());
8080 ret->setDtUnit(dtunit.c_str());
8084 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
8086 med_field_type typcha;
8088 std::vector<std::string> infos;
8089 std::string dtunit,fieldName;
8090 MEDFileAnyTypeField1TS::LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
8091 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8096 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8101 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8106 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] !";
8107 throw INTERP_KERNEL::Exception(oss.str().c_str());
8110 ret->setDtUnit(dtunit.c_str());
8114 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, const std::string& fileName)
8117 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
8118 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
8120 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=MEDFileFieldMultiTS::New();
8121 ret->setFileName(fileName);
8122 ret->_content=c; c->incrRef();
8125 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
8127 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=MEDFileIntFieldMultiTS::New();
8128 ret->setFileName(fileName);
8129 ret->_content=c; c->incrRef();
8132 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
8135 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8136 try:MEDFileFieldGlobsReal(fileName)
8138 MEDFileUtilities::CheckFileForRead(fileName);
8139 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8140 _content=BuildContentFrom(fid,fileName,fieldName,loadAll,ms,entities);
8143 catch(INTERP_KERNEL::Exception& e)
8148 //= MEDFileIntFieldMultiTSWithoutSDA
8150 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, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8152 return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8155 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
8159 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8163 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, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8164 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8167 catch(INTERP_KERNEL::Exception& e)
8171 * \param [in] fieldId field id in C mode
8173 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8174 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8177 catch(INTERP_KERNEL::Exception& e)
8180 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8182 return new MEDFileIntField1TSWithoutSDA;
8185 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8188 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8189 const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
8191 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8194 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const
8196 return MEDFileIntField1TSWithoutSDA::TYPE_STR;
8199 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const
8201 return new MEDFileIntFieldMultiTSWithoutSDA(*this);
8204 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const
8206 return new MEDFileIntFieldMultiTSWithoutSDA;
8209 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const
8211 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
8212 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8214 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8216 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8219 const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
8221 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
8222 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
8223 ret->setIteration(i,elt);
8229 //= MEDFileAnyTypeFieldMultiTS
8232 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
8233 * that has been read from a specified MED file.
8234 * \param [in] fileName - the name of the MED file to read.
8235 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8236 * is to delete this field using decrRef() as it is no more needed.
8237 * \throw If reading the file fails.
8239 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
8241 MEDFileUtilities::CheckFileForRead(fileName);
8242 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8243 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll,0);
8244 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
8245 ret->loadGlobals(fid);
8250 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
8251 * that has been read from a specified MED file.
8252 * \param [in] fileName - the name of the MED file to read.
8253 * \param [in] fieldName - the name of the field to read.
8254 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8255 * is to delete this field using decrRef() as it is no more needed.
8256 * \throw If reading the file fails.
8257 * \throw If there is no field named \a fieldName in the file.
8259 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8261 MEDFileUtilities::CheckFileForRead(fileName);
8262 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8263 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fileName,fieldName,loadAll,0,0));
8264 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
8265 ret->loadGlobals(fid);
8270 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8271 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8273 * \warning this is a shallow copy constructor
8275 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8277 if(!shallowCopyOfContent)
8279 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
8280 otherPtr->incrRef();
8281 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
8285 _content=other.shallowCpy();
8289 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
8291 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8293 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
8297 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
8299 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8301 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
8305 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
8307 return contentNotNullBase()->getPflsReallyUsed2();
8310 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
8312 return contentNotNullBase()->getLocsReallyUsed2();
8315 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
8317 return contentNotNullBase()->getPflsReallyUsedMulti2();
8320 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
8322 return contentNotNullBase()->getLocsReallyUsedMulti2();
8325 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8327 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
8330 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8332 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
8335 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
8337 return contentNotNullBase()->getNumberOfTS();
8340 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
8342 contentNotNullBase()->eraseEmptyTS();
8345 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
8347 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
8350 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
8352 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
8355 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
8357 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
8358 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8363 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
8365 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
8366 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8371 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
8373 return contentNotNullBase()->getIterations();
8376 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
8378 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
8379 pushBackTimeStep(*it);
8382 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
8385 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
8386 int nbOfTS(fmts->getNumberOfTS());
8387 for(int i=0;i<nbOfTS;i++)
8389 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
8390 pushBackTimeStep(elt);
8394 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
8397 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
8398 checkCoherencyOfType(f1ts);
8400 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
8401 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
8403 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
8404 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
8405 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
8406 _content->pushBackTimeStep(cSafe);
8407 appendGlobs(*f1ts,1e-12);
8410 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
8412 contentNotNullBase()->synchronizeNameScope();
8415 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
8417 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
8420 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
8422 return contentNotNullBase()->getPosGivenTime(time,eps);
8425 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8427 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
8430 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
8432 return contentNotNullBase()->getTypesOfFieldAvailable();
8435 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
8437 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
8440 std::string MEDFileAnyTypeFieldMultiTS::getName() const
8442 return contentNotNullBase()->getName();
8445 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
8447 contentNotNullBase()->setName(name);
8450 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
8452 return contentNotNullBase()->getDtUnit();
8455 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
8457 contentNotNullBase()->setDtUnit(dtUnit);
8460 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8462 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
8465 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
8467 return contentNotNullBase()->getTimeSteps(ret1);
8470 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
8472 return contentNotNullBase()->getMeshName();
8475 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
8477 contentNotNullBase()->setMeshName(newMeshName);
8480 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
8482 return contentNotNullBase()->changeMeshNames(modifTab);
8485 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
8487 return contentNotNullBase()->getInfo();
8490 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
8492 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
8495 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
8497 return contentNotNullBase()->setInfo(info);
8500 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
8502 const std::vector<std::string> ret=getInfo();
8503 return (int)ret.size();
8506 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
8508 writeGlobals(fid,*this);
8509 contentNotNullBase()->writeLL(fid,*this);
8513 * Writes \a this field into a MED file specified by its name.
8514 * \param [in] fileName - the MED file name.
8515 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
8516 * - 2 - erase; an existing file is removed.
8517 * - 1 - append; same data should not be present in an existing file.
8518 * - 0 - overwrite; same data present in an existing file is overwritten.
8519 * \throw If the field name is not set.
8520 * \throw If no field data is set.
8521 * \throw If \a mode == 1 and the same data is present in an existing file.
8523 void MEDFileAnyTypeFieldMultiTS::write(const std::string& fileName, int mode) const
8525 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
8526 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
8531 * This method alloc the arrays and load potentially huge arrays contained in this field.
8532 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
8533 * This method can be also called to refresh or reinit values from a file.
8535 * \throw If the fileName is not set or points to a non readable MED file.
8537 void MEDFileAnyTypeFieldMultiTS::loadArrays()
8539 if(getFileName().empty())
8540 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
8541 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
8542 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
8546 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
8547 * But once data loaded once, this method does nothing.
8549 * \throw If the fileName is not set or points to a non readable MED file.
8550 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
8552 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
8554 if(!getFileName().empty())
8556 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
8557 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
8562 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
8563 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
8564 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
8566 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
8568 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
8570 contentNotNullBase()->unloadArrays();
8574 * 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.
8575 * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
8576 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
8578 * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
8580 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
8582 if(!getFileName().empty())
8583 contentNotNullBase()->unloadArrays();
8586 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
8588 std::ostringstream oss;
8589 contentNotNullBase()->simpleRepr(0,oss,-1);
8590 simpleReprGlobs(oss);
8594 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
8596 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
8599 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
8601 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
8602 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
8607 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
8608 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8609 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
8611 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
8613 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8615 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
8616 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
8617 std::size_t sz(contentsSplit.size());
8618 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8619 for(std::size_t i=0;i<sz;i++)
8621 ret[i]=shallowCpy();
8622 ret[i]->_content=contentsSplit[i];
8628 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
8629 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8631 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
8633 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8635 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
8636 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
8637 std::size_t sz(contentsSplit.size());
8638 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8639 for(std::size_t i=0;i<sz;i++)
8641 ret[i]=shallowCpy();
8642 ret[i]->_content=contentsSplit[i];
8648 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
8649 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8651 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
8653 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8655 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
8656 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
8657 std::size_t sz(contentsSplit.size());
8658 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8659 for(std::size_t i=0;i<sz;i++)
8661 ret[i]=shallowCpy();
8662 ret[i]->_content=contentsSplit[i];
8667 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCpy() const
8669 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8670 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
8671 ret->_content=_content->deepCpy();
8672 ret->deepCpyGlobs(*this);
8676 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
8682 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8683 * \param [in] iteration - the iteration number of a required time step.
8684 * \param [in] order - the iteration order number of required time step.
8685 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
8686 * delete this field using decrRef() as it is no more needed.
8687 * \throw If there is no required time step in \a this field.
8689 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
8691 int pos=getPosOfTimeStep(iteration,order);
8692 return getTimeStepAtPos(pos);
8696 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8697 * \param [in] time - the time of the time step of interest.
8698 * \param [in] eps - a precision used to compare time values.
8699 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8700 * delete this field using decrRef() as it is no more needed.
8701 * \throw If there is no required time step in \a this field.
8703 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
8705 int pos=getPosGivenTime(time,eps);
8706 return getTimeStepAtPos(pos);
8710 * 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.
8711 * The float64 value of time attached to the pair of integers are not considered here.
8712 * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
8714 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
8715 * \throw If there is a null pointer in \a vectFMTS.
8717 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
8719 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
8720 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8721 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8722 while(!lstFMTS.empty())
8724 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8725 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8727 throw INTERP_KERNEL::Exception(msg);
8728 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
8729 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8730 elt.push_back(curIt); it=lstFMTS.erase(it);
8731 while(it!=lstFMTS.end())
8735 throw INTERP_KERNEL::Exception(msg);
8736 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
8738 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8748 * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
8749 * All returned instances in a subvector can be safely loaded, rendered along time
8750 * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
8751 * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
8752 * 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).
8753 * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
8754 * 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.
8756 * \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().
8757 * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
8758 * \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.
8759 * \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.
8761 * \throw If an element in \a vectFMTS has not only one spatial discretization set.
8762 * \throw If an element in \a vectFMTS change of spatial discretization along time.
8763 * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
8764 * \thorw If some elements in \a vectFMTS do not have the same times steps.
8765 * \throw If mesh is null.
8766 * \throw If an element in \a vectFMTS is null.
8767 * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
8769 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> >& fsc)
8771 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
8773 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
8774 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8775 if(vectFMTS.empty())
8777 std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
8778 MEDFileAnyTypeFieldMultiTS *frstElt(*it);
8780 throw INTERP_KERNEL::Exception(msg);
8782 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
8783 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
8784 for(;it!=vectFMTS.end();it++,i++)
8787 throw INTERP_KERNEL::Exception(msg);
8788 TypeOfField tof0,tof1;
8789 if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
8792 vectFMTSNotNodes.push_back(*it);
8794 vectFMTSNodes.push_back(*it);
8797 vectFMTSNotNodes.push_back(*it);
8799 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> > cmps;
8800 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
8802 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
8805 bool isFetched(false);
8806 for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
8809 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
8810 if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
8811 { ret[i].push_back(*it2); isFetched=true; }
8815 std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
8816 MEDCouplingAutoRefCountObjectPtr<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
8817 ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
8825 * 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.
8826 * \param [out] cmps - same size than the returned vector.
8828 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> >& cmps)
8830 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8831 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8832 while(!lstFMTS.empty())
8834 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8835 MEDFileAnyTypeFieldMultiTS *ref(*it);
8836 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8837 elt.push_back(ref); it=lstFMTS.erase(it);
8838 MEDCouplingAutoRefCountObjectPtr<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
8839 MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
8840 while(it!=lstFMTS.end())
8842 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8843 if(cmp->isEqual(curIt))
8844 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8848 ret.push_back(elt); cmps.push_back(cmp);
8854 * 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.
8855 * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
8857 * \throw If \a f0 or \a f1 has not only one spatial discretization set.
8858 * \throw If \a f0 or \a f1 change of spatial discretization along time.
8859 * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
8860 * \thorw If \a f0 and \a f1 do not have the same times steps.
8861 * \throw If mesh is null.
8862 * \throw If \a f0 or \a f1 is null.
8863 * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
8865 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
8868 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
8870 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
8871 if(f0->getMeshName()!=mesh->getName())
8873 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8874 throw INTERP_KERNEL::Exception(oss.str().c_str());
8876 if(f1->getMeshName()!=mesh->getName())
8878 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8879 throw INTERP_KERNEL::Exception(oss.str().c_str());
8881 int nts=f0->getNumberOfTS();
8882 if(nts!=f1->getNumberOfTS())
8883 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
8886 for(int i=0;i<nts;i++)
8888 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
8889 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
8890 std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
8891 if(tofs0.size()!=1 || tofs1.size()!=1)
8892 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
8895 if(tof0!=tofs0[0] || tof1!=tofs1[0])
8896 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
8899 { tof0=tofs0[0]; tof1=tofs1[0]; }
8900 if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
8902 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() << ") !";
8903 throw INTERP_KERNEL::Exception(oss.str().c_str());
8905 if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
8907 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() << ") !";
8908 throw INTERP_KERNEL::Exception(oss.str().c_str());
8910 if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
8912 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() << ") !";
8913 throw INTERP_KERNEL::Exception(oss.str().c_str());
8919 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
8921 return new MEDFileAnyTypeFieldMultiTSIterator(this);
8924 //= MEDFileFieldMultiTS
8927 * Returns a new empty instance of MEDFileFieldMultiTS.
8928 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8929 * is to delete this field using decrRef() as it is no more needed.
8931 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
8933 return new MEDFileFieldMultiTS;
8937 * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
8938 * that has been read from a specified MED file.
8939 * \param [in] fileName - the name of the MED file to read.
8940 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8941 * is to delete this field using decrRef() as it is no more needed.
8942 * \throw If reading the file fails.
8944 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll)
8946 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,loadAll,0);
8947 ret->contentNotNull();//to check that content type matches with \a this type.
8952 * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
8953 * that has been read from a specified MED file.
8954 * \param [in] fileName - the name of the MED file to read.
8955 * \param [in] fieldName - the name of the field to read.
8956 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8957 * is to delete this field using decrRef() as it is no more needed.
8958 * \throw If reading the file fails.
8959 * \throw If there is no field named \a fieldName in the file.
8961 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8963 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,fieldName,loadAll,0);
8964 ret->contentNotNull();//to check that content type matches with \a this type.
8969 * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8970 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8972 * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
8973 * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
8974 * \warning this is a shallow copy constructor
8975 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
8976 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
8977 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8978 * is to delete this field using decrRef() as it is no more needed.
8980 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8982 return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
8985 MEDFileFieldMultiTS *MEDFileFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
8987 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fileName,fieldName,loadAll,0,&entities));
8988 ret->contentNotNull();//to check that content type matches with \a this type.
8992 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
8994 return new MEDFileFieldMultiTS(*this);
8997 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9000 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9001 const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
9003 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
9007 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
9008 * following the given input policy.
9010 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9011 * By default (true) the globals are deeply copied.
9012 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
9014 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
9016 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret;
9017 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9020 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
9022 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
9023 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
9024 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc,getFileName()));
9027 ret=MEDFileIntFieldMultiTS::New();
9029 ret->deepCpyGlobs(*this);
9031 ret->shallowCpyGlobs(*this);
9036 * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
9037 * \param [in] pos - a time step id.
9038 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9039 * delete this field using decrRef() as it is no more needed.
9040 * \throw If \a pos is not a valid time step id.
9042 MEDFileAnyTypeField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const
9044 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9047 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9048 throw INTERP_KERNEL::Exception(oss.str().c_str());
9050 const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
9053 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
9054 ret->shallowCpyGlobs(*this);
9057 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
9058 throw INTERP_KERNEL::Exception(oss.str().c_str());
9062 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9063 * mesh entities of a given dimension of the first mesh in MED file.
9064 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9065 * \param [in] type - a spatial discretization of interest.
9066 * \param [in] iteration - the iteration number of a required time step.
9067 * \param [in] order - the iteration order number of required time step.
9068 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9069 * \param [in] renumPol - specifies how to permute values of the result field according to
9070 * the optional numbers of cells and nodes, if any. The valid values are
9071 * - 0 - do not permute.
9072 * - 1 - permute cells.
9073 * - 2 - permute nodes.
9074 * - 3 - permute cells and nodes.
9076 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9077 * caller is to delete this field using decrRef() as it is no more needed.
9078 * \throw If the MED file is not readable.
9079 * \throw If there is no mesh in the MED file.
9080 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9081 * \throw If no field values of the required parameters are available.
9083 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9085 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9086 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9088 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
9089 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
9090 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9091 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9096 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9097 * the top level cells of the first mesh in MED file.
9098 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9099 * \param [in] type - a spatial discretization of interest.
9100 * \param [in] iteration - the iteration number of a required time step.
9101 * \param [in] order - the iteration order number of required time step.
9102 * \param [in] renumPol - specifies how to permute values of the result field according to
9103 * the optional numbers of cells and nodes, if any. The valid values are
9104 * - 0 - do not permute.
9105 * - 1 - permute cells.
9106 * - 2 - permute nodes.
9107 * - 3 - permute cells and nodes.
9109 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9110 * caller is to delete this field using decrRef() as it is no more needed.
9111 * \throw If the MED file is not readable.
9112 * \throw If there is no mesh in the MED file.
9113 * \throw If no field values of the required parameters are available.
9115 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9117 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9118 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9120 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
9121 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
9122 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9123 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9128 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9130 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9131 * \param [in] type - a spatial discretization of interest.
9132 * \param [in] iteration - the iteration number of a required time step.
9133 * \param [in] order - the iteration order number of required time step.
9134 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9135 * \param [in] mesh - the supporting mesh.
9136 * \param [in] renumPol - specifies how to permute values of the result field according to
9137 * the optional numbers of cells and nodes, if any. The valid values are
9138 * - 0 - do not permute.
9139 * - 1 - permute cells.
9140 * - 2 - permute nodes.
9141 * - 3 - permute cells and nodes.
9143 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9144 * caller is to delete this field using decrRef() as it is no more needed.
9145 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9146 * \throw If no field of \a this is lying on \a mesh.
9147 * \throw If no field values of the required parameters are available.
9149 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9151 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9152 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9154 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9155 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
9156 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
9157 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9162 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9164 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9165 * \param [in] type - a spatial discretization of the new field.
9166 * \param [in] iteration - the iteration number of a required time step.
9167 * \param [in] order - the iteration order number of required time step.
9168 * \param [in] mesh - the supporting mesh.
9169 * \param [in] renumPol - specifies how to permute values of the result field according to
9170 * the optional numbers of cells and nodes, if any. The valid values are
9171 * - 0 - do not permute.
9172 * - 1 - permute cells.
9173 * - 2 - permute nodes.
9174 * - 3 - permute cells and nodes.
9176 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9177 * caller is to delete this field using decrRef() as it is no more needed.
9178 * \throw If no field of \a this is lying on \a mesh.
9179 * \throw If no field values of the required parameters are available.
9181 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
9183 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9184 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9186 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9187 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
9188 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
9189 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9194 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
9195 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9196 * This method is useful for MED2 file format when field on different mesh was autorized.
9198 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
9200 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9201 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9203 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
9204 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
9205 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
9206 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9211 * Returns values and a profile of the field of a given type, of a given time step,
9212 * lying on a given support.
9213 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9214 * \param [in] type - a spatial discretization of the field.
9215 * \param [in] iteration - the iteration number of a required time step.
9216 * \param [in] order - the iteration order number of required time step.
9217 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9218 * \param [in] mesh - the supporting mesh.
9219 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9220 * field of interest lies on. If the field lies on all entities of the given
9221 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9222 * using decrRef() as it is no more needed.
9223 * \param [in] glob - the global data storing profiles and localization.
9224 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
9225 * field. The caller is to delete this array using decrRef() as it is no more needed.
9226 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9227 * \throw If no field of \a this is lying on \a mesh.
9228 * \throw If no field values of the required parameters are available.
9230 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9232 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9233 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9235 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
9236 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9237 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
9240 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const
9242 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9244 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
9245 const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
9247 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 !");
9251 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull()
9253 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9255 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
9256 MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
9258 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 !");
9263 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9264 * the given field is checked if its elements are sorted suitable for writing to MED file
9265 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9266 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9267 * \param [in] field - the field to add to \a this.
9268 * \throw If the name of \a field is empty.
9269 * \throw If the data array of \a field is not set.
9270 * \throw If existing time steps have different name or number of components than \a field.
9271 * \throw If the underlying mesh of \a field has no name.
9272 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9274 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
9276 const DataArrayDouble *arr=0;
9278 arr=field->getArray();
9279 contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
9283 * Adds a MEDCouplingFieldDouble to \a this as another time step.
9284 * The mesh support of input parameter \a field is ignored here, it can be NULL.
9285 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9288 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9289 * A new profile is added only if no equal profile is missing.
9290 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9291 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
9292 * \param [in] mesh - the supporting mesh of \a field.
9293 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9294 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
9295 * \throw If either \a field or \a mesh or \a profile has an empty name.
9296 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9297 * \throw If the data array of \a field is not set.
9298 * \throw If the data array of \a this is already allocated but has different number of
9299 * components than \a field.
9300 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9301 * \sa setFieldNoProfileSBT()
9303 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9305 const DataArrayDouble *arr=0;
9307 arr=field->getArray();
9308 contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
9311 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
9313 _content=new MEDFileFieldMultiTSWithoutSDA;
9316 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9317 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll,ms)
9320 catch(INTERP_KERNEL::Exception& e)
9323 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
9324 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll,ms,entities)
9327 catch(INTERP_KERNEL::Exception& e)
9330 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9334 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
9336 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
9339 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9341 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9344 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
9346 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
9349 //= MEDFileAnyTypeFieldMultiTSIterator
9351 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
9356 _nb_iter=fmts->getNumberOfTS();
9360 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
9364 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
9366 if(_iter_id<_nb_iter)
9368 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
9370 return fmts->getTimeStepAtPos(_iter_id++);
9378 //= MEDFileIntFieldMultiTS
9381 * Returns a new empty instance of MEDFileFieldMultiTS.
9382 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9383 * is to delete this field using decrRef() as it is no more needed.
9385 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
9387 return new MEDFileIntFieldMultiTS;
9391 * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
9392 * that has been read from a specified MED file.
9393 * \param [in] fileName - the name of the MED file to read.
9394 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9395 * is to delete this field using decrRef() as it is no more needed.
9396 * \throw If reading the file fails.
9398 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll)
9400 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,loadAll,0);
9401 ret->contentNotNull();//to check that content type matches with \a this type.
9406 * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
9407 * that has been read from a specified MED file.
9408 * \param [in] fileName - the name of the MED file to read.
9409 * \param [in] fieldName - the name of the field to read.
9410 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9411 * is to delete this field using decrRef() as it is no more needed.
9412 * \throw If reading the file fails.
9413 * \throw If there is no field named \a fieldName in the file.
9415 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9417 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll,0);
9418 ret->contentNotNull();//to check that content type matches with \a this type.
9423 * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9424 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9426 * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
9427 * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9428 * \warning this is a shallow copy constructor
9429 * \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
9430 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9431 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9432 * is to delete this field using decrRef() as it is no more needed.
9434 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9436 return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
9439 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9441 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll,0,&entities);
9442 ret->contentNotNull();//to check that content type matches with \a this type.
9447 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
9448 * following the given input policy.
9450 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9451 * By default (true) the globals are deeply copied.
9452 * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
9454 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const
9456 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret;
9457 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9460 const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
9462 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
9463 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
9464 ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc,getFileName()));
9467 ret=MEDFileFieldMultiTS::New();
9469 ret->deepCpyGlobs(*this);
9471 ret->shallowCpyGlobs(*this);
9475 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const
9477 return new MEDFileIntFieldMultiTS(*this);
9480 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9483 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9484 const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
9486 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
9490 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9491 * mesh entities of a given dimension of the first mesh in MED file.
9492 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9493 * \param [in] type - a spatial discretization of interest.
9494 * \param [in] iteration - the iteration number of a required time step.
9495 * \param [in] order - the iteration order number of required time step.
9496 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9497 * \param [out] arrOut - the DataArrayInt containing values of field.
9498 * \param [in] renumPol - specifies how to permute values of the result field according to
9499 * the optional numbers of cells and nodes, if any. The valid values are
9500 * - 0 - do not permute.
9501 * - 1 - permute cells.
9502 * - 2 - permute nodes.
9503 * - 3 - permute cells and nodes.
9505 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9506 * caller is to delete this field using decrRef() as it is no more needed.
9507 * \throw If the MED file is not readable.
9508 * \throw If there is no mesh in the MED file.
9509 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9510 * \throw If no field values of the required parameters are available.
9512 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
9514 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9515 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9517 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
9518 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9519 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase());
9520 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9525 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9526 * the top level cells of the first mesh in MED file.
9527 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9528 * \param [in] type - a spatial discretization of interest.
9529 * \param [in] iteration - the iteration number of a required time step.
9530 * \param [in] order - the iteration order number of required time step.
9531 * \param [out] arrOut - the DataArrayInt containing values of field.
9532 * \param [in] renumPol - specifies how to permute values of the result field according to
9533 * the optional numbers of cells and nodes, if any. The valid values are
9534 * - 0 - do not permute.
9535 * - 1 - permute cells.
9536 * - 2 - permute nodes.
9537 * - 3 - permute cells and nodes.
9539 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9540 * caller is to delete this field using decrRef() as it is no more needed.
9541 * \throw If the MED file is not readable.
9542 * \throw If there is no mesh in the MED file.
9543 * \throw If no field values of the required parameters are available.
9545 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, DataArrayInt* &arrOut, int renumPol) const
9547 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9548 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9550 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
9551 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9552 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase());
9553 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9558 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9560 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9561 * \param [in] type - a spatial discretization of interest.
9562 * \param [in] iteration - the iteration number of a required time step.
9563 * \param [in] order - the iteration order number of required time step.
9564 * \param [out] arrOut - the DataArrayInt containing values of field.
9565 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9566 * \param [in] mesh - the supporting mesh.
9567 * \param [in] renumPol - specifies how to permute values of the result field according to
9568 * the optional numbers of cells and nodes, if any. The valid values are
9569 * - 0 - do not permute.
9570 * - 1 - permute cells.
9571 * - 2 - permute nodes.
9572 * - 3 - permute cells and nodes.
9574 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9575 * caller is to delete this field using decrRef() as it is no more needed.
9576 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9577 * \throw If no field of \a this is lying on \a mesh.
9578 * \throw If no field values of the required parameters are available.
9580 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
9582 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9583 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9585 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9586 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9587 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase());
9588 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9593 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9595 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9596 * \param [in] type - a spatial discretization of the new field.
9597 * \param [in] iteration - the iteration number of a required time step.
9598 * \param [in] order - the iteration order number of required time step.
9599 * \param [in] mesh - the supporting mesh.
9600 * \param [out] arrOut - the DataArrayInt containing values of field.
9601 * \param [in] renumPol - specifies how to permute values of the result field according to
9602 * the optional numbers of cells and nodes, if any. The valid values are
9603 * - 0 - do not permute.
9604 * - 1 - permute cells.
9605 * - 2 - permute nodes.
9606 * - 3 - permute cells and nodes.
9608 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9609 * caller is to delete this field using decrRef() as it is no more needed.
9610 * \throw If no field of \a this is lying on \a mesh.
9611 * \throw If no field values of the required parameters are available.
9613 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
9615 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9616 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9618 throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9619 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9620 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase());
9621 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9626 * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
9627 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9628 * This method is useful for MED2 file format when field on different mesh was autorized.
9630 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
9632 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9633 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9635 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9636 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9637 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase());
9638 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9643 * Returns values and a profile of the field of a given type, of a given time step,
9644 * lying on a given support.
9645 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9646 * \param [in] type - a spatial discretization of the field.
9647 * \param [in] iteration - the iteration number of a required time step.
9648 * \param [in] order - the iteration order number of required time step.
9649 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9650 * \param [in] mesh - the supporting mesh.
9651 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9652 * field of interest lies on. If the field lies on all entities of the given
9653 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9654 * using decrRef() as it is no more needed.
9655 * \param [in] glob - the global data storing profiles and localization.
9656 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
9657 * field. The caller is to delete this array using decrRef() as it is no more needed.
9658 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9659 * \throw If no field of \a this is lying on \a mesh.
9660 * \throw If no field values of the required parameters are available.
9662 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9664 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9665 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9667 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
9668 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9669 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
9673 * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
9674 * \param [in] pos - a time step id.
9675 * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
9676 * delete this field using decrRef() as it is no more needed.
9677 * \throw If \a pos is not a valid time step id.
9679 MEDFileAnyTypeField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
9681 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9684 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9685 throw INTERP_KERNEL::Exception(oss.str().c_str());
9687 const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
9690 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
9691 ret->shallowCpyGlobs(*this);
9694 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
9695 throw INTERP_KERNEL::Exception(oss.str().c_str());
9699 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9700 * the given field is checked if its elements are sorted suitable for writing to MED file
9701 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9702 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9703 * \param [in] field - the field to add to \a this.
9704 * \throw If the name of \a field is empty.
9705 * \throw If the data array of \a field is not set.
9706 * \throw If existing time steps have different name or number of components than \a field.
9707 * \throw If the underlying mesh of \a field has no name.
9708 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9710 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals)
9712 contentNotNull()->appendFieldNoProfileSBT(field,arrOfVals,*this);
9716 * Adds a MEDCouplingFieldDouble to \a this as another time step.
9717 * The mesh support of input parameter \a field is ignored here, it can be NULL.
9718 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9721 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9722 * A new profile is added only if no equal profile is missing.
9723 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9724 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
9725 * \param [in] arrOfVals - the values of the field \a field used.
9726 * \param [in] mesh - the supporting mesh of \a field.
9727 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9728 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
9729 * \throw If either \a field or \a mesh or \a profile has an empty name.
9730 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9731 * \throw If the data array of \a field is not set.
9732 * \throw If the data array of \a this is already allocated but has different number of
9733 * components than \a field.
9734 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9735 * \sa setFieldNoProfileSBT()
9737 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9739 contentNotNull()->appendFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this);
9742 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const
9744 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9746 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
9747 const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9749 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 !");
9753 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull()
9755 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9757 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
9758 MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9760 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 !");
9764 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
9766 _content=new MEDFileIntFieldMultiTSWithoutSDA;
9769 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9773 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9774 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll,ms)
9777 catch(INTERP_KERNEL::Exception& e)
9780 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
9781 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll,ms,entities)
9784 catch(INTERP_KERNEL::Exception& e)
9787 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9789 return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9794 MEDFileFields *MEDFileFields::New()
9796 return new MEDFileFields;
9799 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
9801 return new MEDFileFields(fileName,loadAll,0,0);
9804 MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9806 return new MEDFileFields(fileName,loadAll,ms,0);
9809 MEDFileFields *MEDFileFields::LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9811 return new MEDFileFields(fileName,loadAll,0,&entities);
9814 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
9816 std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
9817 ret+=_fields.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
9821 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
9823 std::vector<const BigMemoryObject *> ret;
9824 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9825 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
9829 MEDFileFields *MEDFileFields::deepCpy() const
9831 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
9833 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9835 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9836 ret->_fields[i]=(*it)->deepCpy();
9838 ret->deepCpyGlobs(*this);
9842 MEDFileFields *MEDFileFields::shallowCpy() const
9844 return new MEDFileFields(*this);
9848 * 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
9849 * 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.
9850 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
9852 * \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.
9853 * \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.
9855 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9857 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
9859 std::set< std::pair<int,int> > s;
9860 bool firstShot=true;
9861 areThereSomeForgottenTS=false;
9862 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9864 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9866 std::vector< std::pair<int,int> > v=(*it)->getIterations();
9867 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
9869 { s=s1; firstShot=false; }
9872 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
9874 areThereSomeForgottenTS=true;
9878 std::vector< std::pair<int,int> > ret;
9879 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
9883 int MEDFileFields::getNumberOfFields() const
9885 return _fields.size();
9888 std::vector<std::string> MEDFileFields::getFieldsNames() const
9890 std::vector<std::string> ret(_fields.size());
9892 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9894 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
9897 ret[i]=f->getName();
9901 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
9902 throw INTERP_KERNEL::Exception(oss.str().c_str());
9908 std::vector<std::string> MEDFileFields::getMeshesNames() const
9910 std::vector<std::string> ret;
9911 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9913 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9915 ret.push_back(cur->getMeshName());
9920 std::string MEDFileFields::simpleRepr() const
9922 std::ostringstream oss;
9923 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
9928 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
9930 int nbOfFields=getNumberOfFields();
9931 std::string startLine(bkOffset,' ');
9932 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
9934 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9936 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9939 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
9943 oss << startLine << " - not defined !" << std::endl;
9947 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9949 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9950 std::string chapter(17,'0'+i);
9951 oss << startLine << chapter << std::endl;
9954 cur->simpleRepr(bkOffset+2,oss,i);
9958 oss << startLine << " - not defined !" << std::endl;
9960 oss << startLine << chapter << std::endl;
9962 simpleReprGlobs(oss);
9965 MEDFileFields::MEDFileFields()
9969 MEDFileFields::MEDFileFields(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
9970 try:MEDFileFieldGlobsReal(fileName)
9972 MEDFileUtilities::CheckFileForRead(fileName);
9973 MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY));
9974 int nbFields(MEDnField(fid));
9975 _fields.resize(nbFields);
9976 med_field_type typcha;
9977 for(int i=0;i<nbFields;i++)
9979 std::vector<std::string> infos;
9980 std::string fieldName,dtunit;
9981 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fileName,i,false,fieldName,typcha,infos,dtunit));
9986 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
9991 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
9996 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] !";
9997 throw INTERP_KERNEL::Exception(oss.str().c_str());
10001 loadAllGlobals(fid);
10003 catch(INTERP_KERNEL::Exception& e)
10008 void MEDFileFields::writeLL(med_idt fid) const
10011 writeGlobals(fid,*this);
10012 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10014 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
10017 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
10018 throw INTERP_KERNEL::Exception(oss.str().c_str());
10020 elt->writeLL(fid,*this);
10024 void MEDFileFields::write(const std::string& fileName, int mode) const
10026 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
10027 MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),medmod));
10032 * This method alloc the arrays and load potentially huge arrays contained in this field.
10033 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
10034 * This method can be also called to refresh or reinit values from a file.
10036 * \throw If the fileName is not set or points to a non readable MED file.
10038 void MEDFileFields::loadArrays()
10040 if(getFileName().empty())
10041 throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
10042 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
10043 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10045 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10047 elt->loadBigArraysRecursively(fid,*elt);
10052 * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
10053 * But once data loaded once, this method does nothing.
10055 * \throw If the fileName is not set or points to a non readable MED file.
10056 * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
10058 void MEDFileFields::loadArraysIfNecessary()
10060 if(!getFileName().empty())
10062 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
10063 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10065 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10067 elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
10073 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
10074 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
10075 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
10077 * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
10079 void MEDFileFields::unloadArrays()
10081 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10083 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10085 elt->unloadArrays();
10090 * 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.
10091 * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
10092 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
10094 * \sa MEDFileFields::loadArraysIfNecessary
10096 void MEDFileFields::unloadArraysWithoutDataLoss()
10098 if(!getFileName().empty())
10102 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
10104 std::vector<std::string> ret;
10105 std::set<std::string> ret2;
10106 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10108 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
10109 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10110 if(ret2.find(*it2)==ret2.end())
10112 ret.push_back(*it2);
10119 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
10121 std::vector<std::string> ret;
10122 std::set<std::string> ret2;
10123 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10125 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
10126 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10127 if(ret2.find(*it2)==ret2.end())
10129 ret.push_back(*it2);
10136 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
10138 std::vector<std::string> ret;
10139 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10141 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
10142 ret.insert(ret.end(),tmp.begin(),tmp.end());
10147 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
10149 std::vector<std::string> ret;
10150 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10152 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
10153 ret.insert(ret.end(),tmp.begin(),tmp.end());
10158 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10160 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10161 (*it)->changePflsRefsNamesGen2(mapOfModif);
10164 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10166 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10167 (*it)->changeLocsRefsNamesGen2(mapOfModif);
10170 void MEDFileFields::resize(int newSize)
10172 _fields.resize(newSize);
10175 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
10177 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
10181 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
10184 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
10185 _fields.push_back(field->getContent());
10186 appendGlobs(*field,1e-12);
10189 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
10192 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
10193 if(i>=(int)_fields.size())
10194 _fields.resize(i+1);
10195 _fields[i]=field->getContent();
10196 appendGlobs(*field,1e-12);
10199 void MEDFileFields::destroyFieldAtPos(int i)
10201 destroyFieldsAtPos(&i,&i+1);
10204 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
10206 std::vector<bool> b(_fields.size(),true);
10207 for(const int *i=startIds;i!=endIds;i++)
10209 if(*i<0 || *i>=(int)_fields.size())
10211 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10212 throw INTERP_KERNEL::Exception(oss.str().c_str());
10216 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10218 for(std::size_t i=0;i<_fields.size();i++)
10220 fields[j++]=_fields[i];
10224 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
10226 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
10227 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
10228 std::vector<bool> b(_fields.size(),true);
10230 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
10232 if(k<0 || k>=(int)_fields.size())
10234 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
10235 throw INTERP_KERNEL::Exception(oss.str().c_str());
10239 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10241 for(std::size_t i=0;i<_fields.size();i++)
10243 fields[j++]=_fields[i];
10247 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
10250 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10252 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10254 ret=cur->changeMeshNames(modifTab) || ret;
10260 * \param [in] meshName the name of the mesh that will be renumbered.
10261 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
10262 * This code corresponds to the distribution of types in the corresponding mesh.
10263 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
10264 * \param [in] renumO2N the old to new renumber array.
10265 * \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
10266 * field in \a this.
10268 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
10271 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10273 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
10276 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
10282 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
10284 if(i<0 || i>=(int)_fields.size())
10286 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
10287 throw INTERP_KERNEL::Exception(oss.str().c_str());
10289 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
10292 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret;
10293 const MEDFileFieldMultiTSWithoutSDA *fmtsC=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts);
10294 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts);
10296 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
10298 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
10301 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
10302 throw INTERP_KERNEL::Exception(oss.str().c_str());
10304 ret->shallowCpyGlobs(*this);
10309 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
10310 * This method is accessible in python using __getitem__ with a list in input.
10311 * \return a new object that the caller should deal with.
10313 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
10315 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
10316 std::size_t sz=std::distance(startIds,endIds);
10317 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
10319 for(const int *i=startIds;i!=endIds;i++,j++)
10321 if(*i<0 || *i>=(int)_fields.size())
10323 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10324 throw INTERP_KERNEL::Exception(oss.str().c_str());
10326 fields[j]=_fields[*i];
10328 ret->_fields=fields;
10332 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
10334 return getFieldAtPos(getPosFromFieldName(fieldName));
10338 * This method removes, if any, fields in \a this having no time steps.
10339 * 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.
10341 * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
10343 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
10345 std::vector<MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
10346 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10348 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10351 if(elt->getNumberOfTS()>0)
10352 newFields.push_back(*it);
10355 if(_fields.size()==newFields.size())
10362 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
10363 * This method can be seen as a filter applied on \a this, that returns an object containing
10364 * 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
10365 * shallow copied from \a this.
10367 * \param [in] meshName - the name of the mesh on w
10368 * \return a new object that the caller should deal with.
10370 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
10372 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
10373 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10375 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10378 if(cur->getMeshName()==meshName)
10381 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
10382 ret->_fields.push_back(cur2);
10385 ret->shallowCpyOnlyUsedGlobs(*this);
10390 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
10391 * Input time steps are specified using a pair of integer (iteration, order).
10392 * 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,
10393 * but for each multitimestep only the time steps in \a timeSteps are kept.
10394 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
10396 * The returned object points to shallow copy of elements in \a this.
10398 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
10399 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
10400 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10402 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10404 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
10405 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10407 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10410 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
10411 ret->_fields.push_back(elt);
10413 ret->shallowCpyOnlyUsedGlobs(*this);
10418 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
10420 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10422 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
10423 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10425 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10428 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
10429 if(elt->getNumberOfTS()!=0)
10430 ret->_fields.push_back(elt);
10432 ret->shallowCpyOnlyUsedGlobs(*this);
10436 MEDFileFieldsIterator *MEDFileFields::iterator()
10438 return new MEDFileFieldsIterator(this);
10441 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
10443 std::string tmp(fieldName);
10444 std::vector<std::string> poss;
10445 for(std::size_t i=0;i<_fields.size();i++)
10447 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=_fields[i];
10450 std::string fname(f->getName());
10454 poss.push_back(fname);
10457 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
10458 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
10460 throw INTERP_KERNEL::Exception(oss.str().c_str());
10463 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
10468 _nb_iter=fs->getNumberOfFields();
10472 MEDFileFieldsIterator::~MEDFileFieldsIterator()
10476 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
10478 if(_iter_id<_nb_iter)
10480 MEDFileFields *fs(_fs);
10482 return fs->getFieldAtPos(_iter_id++);