1 // Copyright (C) 2007-2016 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.txx"
22 #include "MEDFileMesh.hxx"
23 #include "MEDLoaderBase.hxx"
24 #include "MEDLoaderTraits.hxx"
25 #include "MEDFileSafeCaller.txx"
26 #include "MEDFileFieldOverView.hxx"
28 #include "MEDCouplingFieldDouble.hxx"
29 #include "MEDCouplingFieldTemplate.hxx"
30 #include "MEDCouplingFieldDiscretization.hxx"
32 #include "InterpKernelAutoPtr.hxx"
33 #include "CellModel.hxx"
38 extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
39 extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
40 extern med_geometry_type typmainoeud[1];
41 extern med_geometry_type typmai3[34];
43 using namespace MEDCoupling;
45 template class MEDFileField1TSTemplateWithoutSDA<int>;
46 template class MEDFileField1TSTemplateWithoutSDA<double>;
48 const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64";
49 const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32";
51 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const std::string& locName)
53 return new MEDFileFieldLoc(fid,locName);
56 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, int id)
58 return new MEDFileFieldLoc(fid,id);
61 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)
63 return new MEDFileFieldLoc(locName,geoType,refCoo,gsCoo,w);
66 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, const std::string& locName):_name(locName)
68 med_geometry_type geotype;
69 med_geometry_type sectiongeotype;
71 INTERP_KERNEL::AutoPtr<char> geointerpname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
72 INTERP_KERNEL::AutoPtr<char> sectionmeshname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
73 MEDlocalizationInfoByName(fid,locName.c_str(),&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
74 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
75 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
76 _nb_node_per_cell=cm.getNumberOfNodes();
77 _ref_coo.resize(_dim*_nb_node_per_cell);
78 _gs_coo.resize(_dim*_nb_gauss_pt);
79 _w.resize(_nb_gauss_pt);
80 MEDlocalizationRd(fid,locName.c_str(),MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
83 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id)
85 med_geometry_type geotype;
86 med_geometry_type sectiongeotype;
88 INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
89 INTERP_KERNEL::AutoPtr<char> geointerpname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
90 INTERP_KERNEL::AutoPtr<char> sectionmeshname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
91 MEDlocalizationInfo(fid,id+1,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
93 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
94 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
95 _nb_node_per_cell=cm.getNumberOfNodes();
96 _ref_coo.resize(_dim*_nb_node_per_cell);
97 _gs_coo.resize(_dim*_nb_gauss_pt);
98 _w.resize(_nb_gauss_pt);
99 MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
102 MEDFileFieldLoc::MEDFileFieldLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType,
103 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),
106 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
107 _dim=cm.getDimension();
108 _nb_node_per_cell=cm.getNumberOfNodes();
109 _nb_gauss_pt=_w.size();
112 MEDFileFieldLoc *MEDFileFieldLoc::deepCopy() const
114 return new MEDFileFieldLoc(*this);
117 std::size_t MEDFileFieldLoc::getHeapMemorySizeWithoutChildren() const
119 return (_ref_coo.capacity()+_gs_coo.capacity()+_w.capacity())*sizeof(double)+_name.capacity();
122 std::vector<const BigMemoryObject *> MEDFileFieldLoc::getDirectChildrenWithNull() const
124 return std::vector<const BigMemoryObject *>();
127 void MEDFileFieldLoc::simpleRepr(std::ostream& oss) const
129 static const char OFF7[]="\n ";
130 oss << "\"" << _name << "\"" << OFF7;
131 oss << "GeoType=" << INTERP_KERNEL::CellModel::GetCellModel(_geo_type).getRepr() << OFF7;
132 oss << "Dimension=" << _dim << OFF7;
133 oss << "Number of Gauss points=" << _nb_gauss_pt << OFF7;
134 oss << "Number of nodes per cell=" << _nb_node_per_cell << OFF7;
135 oss << "RefCoords="; std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
136 oss << "Weights="; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
137 oss << "GaussPtsCoords="; std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," ")); oss << std::endl;
140 void MEDFileFieldLoc::setName(const std::string& name)
145 bool MEDFileFieldLoc::isEqual(const MEDFileFieldLoc& other, double eps) const
147 if(_name!=other._name)
151 if(_nb_gauss_pt!=other._nb_gauss_pt)
153 if(_nb_node_per_cell!=other._nb_node_per_cell)
155 if(_geo_type!=other._geo_type)
157 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_ref_coo,other._ref_coo,eps))
159 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_gs_coo,other._gs_coo,eps))
161 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_w,other._w,eps))
167 void MEDFileFieldLoc::writeLL(med_idt fid) const
169 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);
172 std::string MEDFileFieldLoc::repr() const
174 std::ostringstream oss; oss.precision(15);
175 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
176 oss << "Localization \"" << _name << "\" :\n" << " - Geometric Type : " << cm.getRepr();
177 oss << "\n - Dimension : " << _dim << "\n - Number of gauss points : ";
178 oss << _nb_gauss_pt << "\n - Number of nodes in cell : " << _nb_node_per_cell;
179 oss << "\n - Ref coords are : ";
180 int sz=_ref_coo.size();
183 int nbOfTuples=sz/_dim;
184 for(int i=0;i<nbOfTuples;i++)
187 for(int j=0;j<_dim;j++)
188 { oss << _ref_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
193 std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," "));
194 oss << "\n - Gauss coords in reference element : ";
198 int nbOfTuples=sz/_dim;
199 for(int i=0;i<nbOfTuples;i++)
202 for(int j=0;j<_dim;j++)
203 { oss << _gs_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
208 std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," "));
209 oss << "\n - Weights of Gauss coords are : "; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," "));
213 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
215 _type=field->getTypeOfField();
221 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,offset,offset+nbOfCells,1);
222 _end=_start+nbOfCells;
228 MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
229 const int *arrPtr=arr->getConstPointer();
230 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,arrPtr[offset],arrPtr[offset+nbOfCells],1);
231 _end=_start+(arrPtr[offset+nbOfCells]-arrPtr[offset]);
237 const MEDCouplingFieldDiscretization *disc(field->getDiscretization());
238 const MEDCouplingGaussLocalization& gsLoc(field->getGaussLocalization(_loc_id));
239 const MEDCouplingFieldDiscretizationGauss *disc2(dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc));
241 throw INTERP_KERNEL::Exception("assignFieldNoProfile : invalid call to this method ! Internal Error !");
242 const DataArrayInt *dai(disc2->getArrayOfDiscIds());
243 MCAuto<DataArrayInt> dai2(disc2->getOffsetArr(field->getMesh()));
244 const int *dai2Ptr(dai2->getConstPointer());
245 int nbi(gsLoc.getWeights().size());
246 MCAuto<DataArrayInt> da2(dai->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1));
247 MCAuto<DataArrayInt> da3(da2->findIdsEqual(_loc_id));
248 const int *da3Ptr(da3->getConstPointer());
249 if(da3->getNumberOfTuples()!=nbOfCells)
250 {//profile : for gauss even in NoProfile !!!
251 std::ostringstream oss; oss << "Pfl_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
253 da3->setName(_profile.c_str());
254 glob.appendProfile(da3);
256 MCAuto<DataArrayInt> da4(DataArrayInt::New());
257 _nval=da3->getNbOfElems();
258 da4->alloc(_nval*nbi,1);
259 int *da4Ptr(da4->getPointer());
260 for(int i=0;i<_nval;i++)
262 int ref=dai2Ptr[offset+da3Ptr[i]];
263 for(int j=0;j<nbi;j++)
266 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
267 _localization=oss2.str();
268 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,da4);
269 _end=_start+_nval*nbi;
270 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
274 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile : not implemented yet for such discretization type of field !");
280 * Leaf method of field with profile assignement. This method is the most general one. No optimization is done here.
281 * \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).
282 * \param [in] multiTypePfl is the end user profile specified in high level API
283 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
284 * \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.
285 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
286 * \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.
288 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)
291 _type=field->getTypeOfField();
292 std::string pflName(multiTypePfl->getName());
293 std::ostringstream oss; oss << pflName;
297 { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType()); oss << "_" << cm.getRepr(); }
304 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : existing profile with empty name !");
305 if(_type!=ON_GAUSS_PT)
307 locIds->setName(oss.str());
308 glob.appendProfile(locIds);
317 _nval=idsInPfl->getNumberOfTuples();
318 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,0,arrr->getNumberOfTuples(),1);
324 _nval=idsInPfl->getNumberOfTuples();
325 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,idsInPfl);
331 MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
332 MCAuto<DataArrayInt> arr2=arr->deltaShiftIndex();
333 MCAuto<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->begin(),multiTypePfl->end());
334 arr3->computeOffsetsFull();
335 MCAuto<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
336 int trueNval=tmp->getNumberOfTuples();
337 _nval=idsInPfl->getNumberOfTuples();
338 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
339 _end=_start+trueNval;
344 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(field->getDiscretization());
346 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
347 const DataArrayInt *da1=disc2->getArrayOfDiscIds();
348 const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
349 MCAuto<DataArrayInt> da2=da1->selectByTupleId(idsInPfl->begin(),idsInPfl->end());
350 MCAuto<DataArrayInt> da3=da2->findIdsEqual(_loc_id);
351 MCAuto<DataArrayInt> da4=idsInPfl->selectByTupleId(da3->begin(),da3->end());
353 MCAuto<MEDCouplingMesh> mesh2=mesh->buildPart(multiTypePfl->begin(),multiTypePfl->end());
354 MCAuto<DataArrayInt> arr=disc2->getOffsetArr(mesh2);
356 MCAuto<DataArrayInt> tmp=DataArrayInt::New();
358 for(const int *pt=da4->begin();pt!=da4->end();pt++)
359 trueNval+=arr->getIJ(*pt+1,0)-arr->getIJ(*pt,0);
360 tmp->alloc(trueNval,1);
361 int *tmpPtr=tmp->getPointer();
362 for(const int *pt=da4->begin();pt!=da4->end();pt++)
363 for(int j=arr->getIJ(*pt,0);j<arr->getIJ(*pt+1,0);j++)
366 _nval=da4->getNumberOfTuples();
367 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
368 _end=_start+trueNval;
369 oss << "_loc_" << _loc_id;
372 MCAuto<DataArrayInt> da5=locIds->selectByTupleId(da3->begin(),da3->end());
373 da5->setName(oss.str());
374 glob.appendProfile(da5);
379 if(!da3->isIota(nbOfEltsInWholeMesh))
381 da3->setName(oss.str());
382 glob.appendProfile(da3);
386 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
387 _localization=oss2.str();
388 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
392 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for such discretization type of field !");
397 void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob)
400 _nval=arrr->getNumberOfTuples();
401 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,0,_nval,1);
406 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt, const PartDefinition *pd)
408 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt,pd);
411 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId)
413 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string());
416 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(const MEDFileFieldPerMeshPerTypePerDisc& other)
418 return new MEDFileFieldPerMeshPerTypePerDisc(other);
421 std::size_t MEDFileFieldPerMeshPerTypePerDisc::getHeapMemorySizeWithoutChildren() const
423 return _profile.capacity()+_localization.capacity()+sizeof(MEDFileFieldPerMeshPerTypePerDisc);
426 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypePerDisc::getDirectChildrenWithNull() const
428 std::vector<const BigMemoryObject *> ret(1);
429 ret[0]=(const PartDefinition*)_pd;
433 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCopy(MEDFileFieldPerMeshPerType *father) const
435 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret=new MEDFileFieldPerMeshPerTypePerDisc(*this);
440 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField atype, int profileIt, const PartDefinition *pd)
441 try:_type(atype),_father(fath),_profile_it(profileIt),_pd(const_cast<PartDefinition *>(pd))
446 catch(INTERP_KERNEL::Exception& e)
451 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
455 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)
459 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(0),_start(-std::numeric_limits<int>::max()),_end(-std::numeric_limits<int>::max()),
460 _nval(-std::numeric_limits<int>::max()),_loc_id(-std::numeric_limits<int>::max())
464 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)
466 const PartDefinition *pd(_pd);
469 INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
471 med_int nbValsInFile(MEDfieldnValueWithProfileByName(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile.c_str(),MED_COMPACT_PFLMODE,&tmp1,locname,&nbi));
472 if(_end-_start!=nbValsInFile*nbi)
474 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 !";
475 throw INTERP_KERNEL::Exception(oss.str());
477 MEDFILESAFECALLERRD0(MEDfieldValueWithProfileRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,_profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,startFeedingPtr));
481 if(!_profile.empty())
482 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : not implemented !");
483 INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)),locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
485 int overallNval(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
486 const SlicePartDefinition *spd(dynamic_cast<const SlicePartDefinition *>(pd));
490 spd->getSlice(start,stop,step);
491 int nbOfEltsToLoad(DataArray::GetNumberOfItemGivenBES(start,stop,step,"MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile"));
492 med_filter filter=MED_FILTER_INIT;
493 MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
494 MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
495 /*start*/start+1,/*stride*/step,/*count*/1,/*blocksize*/nbOfEltsToLoad,
496 /*lastblocksize=useless because count=1*/0,&filter);
497 MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,startFeedingPtr));
498 MEDfilterClose(&filter);
501 const DataArrayPartDefinition *dpd(dynamic_cast<const DataArrayPartDefinition *>(pd));
504 dpd->checkConsistencyLight();
505 MCAuto<DataArrayInt> myIds(dpd->toDAI());
506 int a(myIds->getMinValueInArray()),b(myIds->getMaxValueInArray());
507 myIds=myIds->deepCopy();// WARNING deep copy here because _pd is modified by applyLin !!!
508 myIds->applyLin(1,-a);
509 int nbOfEltsToLoad(b-a+1);
510 med_filter filter=MED_FILTER_INIT;
511 {//TODO : manage int32 !
512 MCAuto<DataArrayDouble> tmp(DataArrayDouble::New());
513 tmp->alloc(nbOfEltsToLoad,nbOfCompo);
514 MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
515 MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
516 /*start*/a+1,/*stride*/1,/*count*/1,/*blocksize*/nbOfEltsToLoad,
517 /*lastblocksize=useless because count=1*/0,&filter);
518 MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,reinterpret_cast<unsigned char *>(tmp->getPointer())));
519 MCAuto<DataArrayDouble> feeder(DataArrayDouble::New());
520 feeder->useExternalArrayWithRWAccess(reinterpret_cast<double *>(startFeedingPtr),_nval,nbOfCompo);
521 feeder->setContigPartOfSelectedValues(0,tmp,myIds);
523 MEDfilterClose(&filter);
526 throw INTERP_KERNEL::Exception("Not implemented yet for not slices!");
530 const MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
535 void MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
537 INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
538 INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
539 std::string fieldName(nasc.getName()),meshName(getMeshName());
540 int iteration(getIteration()),order(getOrder());
541 TypeOfField type(getType());
542 INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
544 med_geometry_type mgeoti;
545 med_entity_type menti(MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti));
546 int zeNVal(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
547 _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
548 _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
549 const PartDefinition *pd(_pd);
556 if(!_profile.empty())
557 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively : profiles are not managed yet with part of def !");
558 _nval=pd->getNumberOfElems();
561 _end=start+_nval*nbi;
563 if(type==ON_CELLS && !_localization.empty())
565 if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
566 setType(ON_GAUSS_PT);
569 setType(ON_GAUSS_NE);
570 _localization.clear();
575 void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, const MEDFileFieldNameScope& nasc)
577 std::string fieldName(nasc.getName()),meshName(getMeshName());
578 int iteration(getIteration()),order(getOrder());
579 TypeOfField type(getType());
580 INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
581 med_geometry_type mgeoti;
582 med_entity_type menti(MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti));
584 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !");
587 DataArray *arr(getOrCreateAndGetArray());//arr is not null due to the spec of getOrCreateAndGetArray
588 if(_start<0 || _start>=arr->getNumberOfTuples())
590 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << ") !";
591 throw INTERP_KERNEL::Exception(oss.str());
593 if(_end<0 || _end>arr->getNumberOfTuples())
595 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !";
596 throw INTERP_KERNEL::Exception(oss.str());
598 int nbOfCompo(arr->getNumberOfComponents());
599 DataArrayDouble *arrD(dynamic_cast<DataArrayDouble *>(arr));
602 double *startFeeding(arrD->getPointer()+_start*nbOfCompo);
603 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
606 DataArrayInt *arrI(dynamic_cast<DataArrayInt *>(arr));
609 int *startFeeding(arrI->getPointer()+_start*nbOfCompo);
610 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
613 throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
617 * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
619 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart)
621 int delta=_end-_start;
622 _start=newValueOfStart;
626 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
628 return _father->getIteration();
631 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
633 return _father->getOrder();
636 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
638 return _father->getTime();
641 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
643 return _father->getMeshName();
646 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
648 const char startLine[]=" ## ";
649 std::string startLine2(bkOffset,' ');
650 startLine2+=startLine;
651 MEDCouplingFieldDiscretization *tmp=MEDCouplingFieldDiscretization::New(_type);
652 oss << startLine2 << "Localization #" << id << "." << std::endl;
653 oss << startLine2 << " Type=" << tmp->getRepr() << "." << std::endl;
655 oss << startLine2 << " This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
656 oss << startLine2 << " This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
657 oss << startLine2 << " This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
660 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
665 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
670 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
675 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
677 return _father->getGeoType();
680 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
682 return _father->getNumberOfComponents();
685 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
690 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray()
692 return _father->getOrCreateAndGetArray();
695 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const
697 const MEDFileFieldPerMeshPerType *fath=_father;
698 return fath->getOrCreateAndGetArray();
701 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
703 return _father->getInfo();
706 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
711 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const std::string& newPflName)
716 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
718 return _localization;
721 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const std::string& newLocName)
723 _localization=newLocName;
726 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
728 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
730 if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
732 _profile=(*it2).second;
738 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
740 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
742 if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
744 _localization=(*it2).second;
750 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
754 dads.push_back(std::pair<int,int>(_start,_end));
755 geoTypes.push_back(getGeoType());
760 pfls.push_back(glob->getProfile(_profile.c_str()));
762 if(_localization.empty())
766 locs.push_back(glob->getLocalizationId(_localization.c_str()));
770 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
772 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));
776 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
778 TypeOfField type=getType();
779 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
780 med_geometry_type mgeoti;
781 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
782 const DataArray *arr=getOrCreateAndGetArray();
784 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
785 if(!arr->isAllocated())
786 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : the array to be written is not allocated !");
787 const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
788 const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
789 const unsigned char *locToWrite=0;
791 locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
793 locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
795 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
796 MEDFILESAFECALLERWR0(MEDfieldValueWithProfileWr,(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
797 MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
801 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const
806 dad.first=_start; dad.second=_end;
810 * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
811 * This code corresponds to the distribution of types in the corresponding mesh.
812 * \param [out] ptToFill memory zone where the output will be stored.
813 * \return the size of data pushed into output param \a ptToFill
815 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const
818 std::ostringstream oss;
819 std::size_t nbOfType=codeOfMesh.size()/3;
821 for(std::size_t i=0;i<nbOfType && found==-1;i++)
822 if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
826 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
827 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
828 throw INTERP_KERNEL::Exception(oss.str());
833 if(_nval!=codeOfMesh[3*found+1])
835 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
836 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
837 oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
838 throw INTERP_KERNEL::Exception(oss.str());
840 for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
845 const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
846 if(pfl->getNumberOfTuples()!=_nval)
848 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
849 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
851 oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
852 throw INTERP_KERNEL::Exception(oss.str());
854 int offset2=codeOfMesh[3*found+2];
855 for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
857 if(*pflId<codeOfMesh[3*found+1])
858 *work++=offset2+*pflId;
864 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const
866 for(int i=_start;i<_end;i++)
871 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId)
882 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
886 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
889 std::map<std::pair<std::string,TypeOfField>,int> m;
890 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
891 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
892 if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
893 m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
895 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
896 ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
901 * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
903 * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
904 * \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.
905 * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
906 * \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)
907 * \param [in,out] glob if necessary by the method, new profiles can be added to it
908 * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
909 * \param [out] result All new entries will be appended on it.
910 * \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 !)
912 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
913 const DataArrayInt *explicitIdsInMesh,
914 const std::vector<int>& newCode,
915 MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
916 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >& result)
918 if(entriesOnSameDisc.empty())
920 TypeOfField type=entriesOnSameDisc[0]->getType();
921 int szEntities=0,szTuples=0;
922 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
923 { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
924 int nbi=szTuples/szEntities;
925 if(szTuples%szEntities!=0)
926 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
927 MCAuto<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
928 MCAuto<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
929 std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
930 std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
931 std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
932 std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
933 MCAuto<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
935 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
937 int startOfEltIdOfChunk=(*it)->_start;
938 MCAuto<DataArrayInt> newEltIds=explicitIdsInMesh->subArray(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
939 MCAuto<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
940 MCAuto<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
942 MCAuto<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
943 newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
945 newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
946 newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
948 MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
949 MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
950 MCAuto<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
951 MCAuto<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
953 MCAuto<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
955 MCAuto<DataArrayDouble> arrPart=arr->subArray(offset,offset+szTuples);
956 arrPart->renumberInPlace(renumTupleIds->begin());
957 arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
959 const int *idIt=diffVals->begin();
960 std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
962 for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
964 MCAuto<DataArrayInt> ids=newGeoTypesEltIdsAllGather->findIdsEqual(*idIt);
965 MCAuto<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
966 int nbEntityElts=subIds->getNumberOfTuples();
968 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
969 NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIota(newCode[3*(*idIt)+1]),nbi,
973 result.push_back(eltToAdd);
974 offset2+=nbEntityElts*nbi;
976 ret=ret || li.empty();
981 * \param [in] typeF type of field of new chunk
982 * \param [in] geoType the geometric type of the chunk
983 * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
984 * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
985 * \param [in] nbi number of integration points
986 * \param [in] offset The offset in the **global array of data**.
987 * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
988 * to the new chunk to create.
989 * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
990 * \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
991 * and corresponding entry erased from \a entriesOnSameDisc.
992 * \return a newly allocated chunk
994 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
995 bool isPfl, int nbi, int offset,
996 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
997 MEDFileFieldGlobsReal& glob,
1000 int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
1001 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
1002 for(;it!=entriesOnSameDisc.end();it++)
1004 if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
1008 if((*it)->_profile.empty())
1011 if(!(*it)->_profile.empty())
1013 const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
1014 if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
1020 if(it==entriesOnSameDisc.end())
1023 MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
1025 ret->_loc_id=(int)geoType;
1026 ret->_nval=nbMeshEntities;
1028 ret->_end=ret->_start+ret->_nval*nbi;
1031 idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
1032 glob.appendProfile(idsOfMeshElt);
1033 ret->_profile=idsOfMeshElt->getName();
1035 //tony treatment of localization
1040 notInExisting=false;
1041 MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1042 ret->_loc_id=(int)geoType;
1043 ret->setNewStart(offset);
1044 entriesOnSameDisc.erase(it);
1050 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd)
1052 return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc,pd);
1055 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType)
1057 return new MEDFileFieldPerMeshPerType(fath,geoType);
1060 std::size_t MEDFileFieldPerMeshPerType::getHeapMemorySizeWithoutChildren() const
1062 return _field_pm_pt_pd.capacity()*sizeof(MCAuto<MEDFileFieldPerMeshPerTypePerDisc>);
1065 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerType::getDirectChildrenWithNull() const
1067 std::vector<const BigMemoryObject *> ret;
1068 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1069 ret.push_back((const MEDFileFieldPerMeshPerTypePerDisc *)*it);
1073 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCopy(MEDFileFieldPerMesh *father) const
1075 MCAuto<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
1076 ret->_father=father;
1078 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1080 if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
1081 ret->_field_pm_pt_pd[i]=(*it)->deepCopy((MEDFileFieldPerMeshPerType *)ret);
1086 void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1088 std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
1089 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1090 _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1094 * This method is the most general one. No optimization is done here.
1095 * \param [in] multiTypePfl is the end user profile specified in high level API
1096 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1097 * \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.
1098 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1099 * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1100 * \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.
1102 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)
1104 std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1105 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1106 _field_pm_pt_pd[*it]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1109 void MEDFileFieldPerMeshPerType::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1111 _field_pm_pt_pd.resize(1);
1112 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1113 _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1116 void MEDFileFieldPerMeshPerType::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1118 MCAuto<DataArrayInt> pfl2=pfl->deepCopy();
1119 if(!arr || !arr->isAllocated())
1120 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::assignNodeFieldProfile : input array is null, or not allocated !");
1121 _field_pm_pt_pd.resize(1);
1122 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1123 _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.
1126 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1128 TypeOfField type=field->getTypeOfField();
1129 if(type!=ON_GAUSS_PT)
1131 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1132 int sz=_field_pm_pt_pd.size();
1134 for(int j=0;j<sz && !found;j++)
1136 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1138 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1144 _field_pm_pt_pd.resize(sz+1);
1145 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1147 std::vector<int> ret(1,(int)sz);
1152 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1153 int sz2=ret2.size();
1154 std::vector<int> ret3(sz2);
1156 for(int i=0;i<sz2;i++)
1158 int sz=_field_pm_pt_pd.size();
1159 int locIdToFind=ret2[i];
1161 for(int j=0;j<sz && !found;j++)
1163 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1165 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1172 _field_pm_pt_pd.resize(sz+1);
1173 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1181 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1183 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1184 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1186 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1187 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1189 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1190 MCAuto<DataArrayInt> da2=da->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1);
1191 MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1192 if(retTmp->presenceOfValue(-1))
1193 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1194 std::vector<int> ret(retTmp->begin(),retTmp->end());
1198 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1200 TypeOfField type=field->getTypeOfField();
1201 if(type!=ON_GAUSS_PT)
1203 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1204 int sz=_field_pm_pt_pd.size();
1206 for(int j=0;j<sz && !found;j++)
1208 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1210 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1216 _field_pm_pt_pd.resize(sz+1);
1217 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1219 std::vector<int> ret(1,0);
1224 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1225 int sz2=ret2.size();
1226 std::vector<int> ret3(sz2);
1228 for(int i=0;i<sz2;i++)
1230 int sz=_field_pm_pt_pd.size();
1231 int locIdToFind=ret2[i];
1233 for(int j=0;j<sz && !found;j++)
1235 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1237 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1244 _field_pm_pt_pd.resize(sz+1);
1245 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1253 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1255 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1256 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1258 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1259 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1261 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1262 MCAuto<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1263 MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1264 if(retTmp->presenceOfValue(-1))
1265 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1266 std::vector<int> ret(retTmp->begin(),retTmp->end());
1270 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerType::getFather() const
1275 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1277 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1278 int curDim((int)cm.getDimension());
1279 dim=std::max(dim,curDim);
1282 bool MEDFileFieldPerMeshPerType::isUniqueLevel(int& dim) const
1284 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1285 int curDim((int)cm.getDimension());
1286 if(dim!=std::numeric_limits<int>::max())
1296 void MEDFileFieldPerMeshPerType::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1298 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1300 (*it)->fillTypesOfFieldAvailable(types);
1304 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
1306 int sz=_field_pm_pt_pd.size();
1307 dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1308 for(int i=0;i<sz;i++)
1310 _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1314 int MEDFileFieldPerMeshPerType::getIteration() const
1316 return _father->getIteration();
1319 int MEDFileFieldPerMeshPerType::getOrder() const
1321 return _father->getOrder();
1324 double MEDFileFieldPerMeshPerType::getTime() const
1326 return _father->getTime();
1329 std::string MEDFileFieldPerMeshPerType::getMeshName() const
1331 return _father->getMeshName();
1334 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1336 const char startLine[]=" ## ";
1337 std::string startLine2(bkOffset,' ');
1338 std::string startLine3(startLine2);
1339 startLine3+=startLine;
1340 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1342 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1343 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1346 oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1347 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1349 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1351 const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1353 cur->simpleRepr(bkOffset,oss,i);
1356 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1361 void MEDFileFieldPerMeshPerType::getSizes(int& globalSz, int& nbOfEntries) const
1363 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1365 globalSz+=(*it)->getNumberOfTuples();
1367 nbOfEntries+=(int)_field_pm_pt_pd.size();
1370 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1376 int MEDFileFieldPerMeshPerType::getNumberOfComponents() const
1378 return _father->getNumberOfComponents();
1381 bool MEDFileFieldPerMeshPerType::presenceOfMultiDiscPerGeoType() const
1384 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1386 const MEDFileFieldPerMeshPerTypePerDisc *fmtd(*it);
1393 DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray()
1395 return _father->getOrCreateAndGetArray();
1398 const DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray() const
1400 const MEDFileFieldPerMesh *fath=_father;
1401 return fath->getOrCreateAndGetArray();
1404 const std::vector<std::string>& MEDFileFieldPerMeshPerType::getInfo() const
1406 return _father->getInfo();
1409 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsed() const
1411 std::vector<std::string> ret;
1412 std::set<std::string> ret2;
1413 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1415 std::string tmp=(*it1)->getProfile();
1417 if(ret2.find(tmp)==ret2.end())
1426 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsed() const
1428 std::vector<std::string> ret;
1429 std::set<std::string> ret2;
1430 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1432 std::string tmp=(*it1)->getLocalization();
1433 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1434 if(ret2.find(tmp)==ret2.end())
1443 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsedMulti() const
1445 std::vector<std::string> ret;
1446 std::set<std::string> ret2;
1447 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1449 std::string tmp=(*it1)->getProfile();
1456 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsedMulti() const
1458 std::vector<std::string> ret;
1459 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1461 std::string tmp=(*it1)->getLocalization();
1462 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1468 void MEDFileFieldPerMeshPerType::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1470 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1471 (*it1)->changePflsRefsNamesGen(mapOfModif);
1474 void MEDFileFieldPerMeshPerType::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1476 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1477 (*it1)->changeLocsRefsNamesGen(mapOfModif);
1480 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId)
1482 if(_field_pm_pt_pd.empty())
1484 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1485 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1486 throw INTERP_KERNEL::Exception(oss.str());
1488 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1489 return _field_pm_pt_pd[locId];
1490 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1491 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1492 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1493 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1494 return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1497 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) const
1499 if(_field_pm_pt_pd.empty())
1501 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1502 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1503 throw INTERP_KERNEL::Exception(oss.str());
1505 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1506 return _field_pm_pt_pd[locId];
1507 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1508 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1509 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1510 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1511 return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1514 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
1516 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1518 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1519 if(meshDim!=(int)cm.getDimension())
1522 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1523 (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1526 void MEDFileFieldPerMeshPerType::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1529 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1531 (*it)->fillValues(i,startEntryId,entries);
1535 void MEDFileFieldPerMeshPerType::setLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
1537 _field_pm_pt_pd=leaves;
1538 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1539 (*it)->setFather(this);
1543 * \param [in,out] globalNum a global numbering counter for the renumbering.
1544 * \param [out] its - list of pair (start,stop) kept
1545 * \return bool - false if the type of field \a tof is not contained in \a this.
1547 bool MEDFileFieldPerMeshPerType::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
1550 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1551 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1552 if((*it)->getType()==tof)
1554 newPmPtPd.push_back(*it);
1555 std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1556 (*it)->setNewStart(globalNum);
1557 globalNum=(*it)->getEnd();
1558 its.push_back(bgEnd);
1562 _field_pm_pt_pd=newPmPtPd;
1567 * \param [in,out] globalNum a global numbering counter for the renumbering.
1568 * \param [out] its - list of pair (start,stop) kept
1569 * \return bool - false if the type of field \a tof is not contained in \a this.
1571 bool MEDFileFieldPerMeshPerType::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
1573 if(_field_pm_pt_pd.size()<=idOfDisc)
1575 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt(_field_pm_pt_pd[idOfDisc]);
1576 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd(1,elt);
1577 std::pair<int,int> bgEnd; bgEnd.first=_field_pm_pt_pd[idOfDisc]->getStart(); bgEnd.second=_field_pm_pt_pd[idOfDisc]->getEnd();
1578 elt->setNewStart(globalNum);
1579 globalNum=elt->getEnd();
1580 its.push_back(bgEnd);
1581 _field_pm_pt_pd=newPmPtPd;
1585 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):_father(fath),_geo_type(geoType)
1587 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1588 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1589 med_geometry_type mgeoti;
1590 med_entity_type menti(ConvertIntoMEDFileType(type,geoType,mgeoti));
1591 int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName));
1592 _field_pm_pt_pd.resize(nbProfiles);
1593 for(int i=0;i<nbProfiles;i++)
1595 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i,pd);
1599 int nbProfiles2(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName));
1600 for(int i=0;i<nbProfiles2;i++)
1601 _field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i,pd));
1605 void MEDFileFieldPerMeshPerType::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
1607 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1608 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1611 void MEDFileFieldPerMeshPerType::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1613 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1614 (*it)->loadBigArray(fid,nasc);
1617 void MEDFileFieldPerMeshPerType::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1619 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1621 (*it)->copyOptionsFrom(*this);
1622 (*it)->writeLL(fid,nasc);
1626 med_entity_type MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1631 medfGeoType=typmai3[(int)ikGeoType];
1634 medfGeoType=MED_NONE;
1637 medfGeoType=typmai3[(int)ikGeoType];
1638 return MED_NODE_ELEMENT;
1640 medfGeoType=typmai3[(int)ikGeoType];
1643 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1645 return MED_UNDEF_ENTITY_TYPE;
1648 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)
1650 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm,entities);
1653 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1655 return new MEDFileFieldPerMesh(fath,mesh);
1658 std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
1660 return _mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MCAuto< MEDFileFieldPerMeshPerType >);
1663 std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildrenWithNull() const
1665 std::vector<const BigMemoryObject *> ret;
1666 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1667 ret.push_back((const MEDFileFieldPerMeshPerType *)*it);
1671 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCopy(MEDFileAnyTypeField1TSWithoutSDA *father) const
1673 MCAuto< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1674 ret->_father=father;
1676 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1678 if((const MEDFileFieldPerMeshPerType *)*it)
1679 ret->_field_pm_pt[i]=(*it)->deepCopy((MEDFileFieldPerMesh *)(ret));
1684 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1686 std::string startLine(bkOffset,' ');
1687 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1688 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1690 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1692 const MEDFileFieldPerMeshPerType *cur=*it;
1694 cur->simpleRepr(bkOffset,oss,i);
1697 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1702 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh)
1704 _mesh_name=mesh->getName();
1705 mesh->getTime(_mesh_iteration,_mesh_order);
1708 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1710 int nbOfTypes=code.size()/3;
1712 for(int i=0;i<nbOfTypes;i++)
1714 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1715 int nbOfCells=code[3*i+1];
1716 int pos=addNewEntryIfNecessary(type);
1717 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1723 * This method is the most general one. No optimization is done here.
1724 * \param [in] multiTypePfl is the end user profile specified in high level API
1725 * \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].
1726 * \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.
1727 * \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.
1728 * \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.
1729 * \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.
1731 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)
1733 int nbOfTypes(code.size()/3);
1734 for(int i=0;i<nbOfTypes;i++)
1736 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1737 int pos=addNewEntryIfNecessary(type);
1738 DataArrayInt *pfl=0;
1740 pfl=idsPerType[code[3*i+2]];
1741 int nbOfTupes2=code2.size()/3;
1743 for(;found<nbOfTupes2;found++)
1744 if(code[3*i]==code2[3*found])
1746 if(found==nbOfTupes2)
1747 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1748 _field_pm_pt[pos]->assignFieldProfile(nbOfTypes==1,start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1752 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1754 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1755 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1758 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1760 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1761 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1764 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
1766 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1767 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1770 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1772 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1773 (*it)->loadBigArraysRecursively(fid,nasc);
1776 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1778 int nbOfTypes=_field_pm_pt.size();
1779 for(int i=0;i<nbOfTypes;i++)
1781 _field_pm_pt[i]->copyOptionsFrom(*this);
1782 _field_pm_pt[i]->writeLL(fid,nasc);
1786 void MEDFileFieldPerMesh::getDimension(int& dim) const
1788 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1789 (*it)->getDimension(dim);
1792 bool MEDFileFieldPerMesh::isUniqueLevel(int& dim) const
1794 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1795 if(!(*it)->isUniqueLevel(dim))
1800 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1802 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1803 (*it)->fillTypesOfFieldAvailable(types);
1806 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
1808 int sz=_field_pm_pt.size();
1809 std::vector< std::vector<std::pair<int,int> > > ret(sz);
1810 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1811 for(int i=0;i<sz;i++)
1813 types[i]=_field_pm_pt[i]->getGeoType();
1814 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1819 double MEDFileFieldPerMesh::getTime() const
1822 return _father->getTime(tmp1,tmp2);
1825 int MEDFileFieldPerMesh::getIteration() const
1827 return _father->getIteration();
1830 int MEDFileFieldPerMesh::getOrder() const
1832 return _father->getOrder();
1835 int MEDFileFieldPerMesh::getNumberOfComponents() const
1837 return _father->getNumberOfComponents();
1840 bool MEDFileFieldPerMesh::presenceOfMultiDiscPerGeoType() const
1842 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1844 const MEDFileFieldPerMeshPerType *fpmt(*it);
1847 if(fpmt->presenceOfMultiDiscPerGeoType())
1853 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
1856 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1857 return _father->getOrCreateAndGetArray();
1860 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
1863 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1864 return _father->getOrCreateAndGetArray();
1867 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1869 return _father->getInfo();
1873 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
1874 * 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.
1875 * It returns 2 output vectors :
1876 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
1877 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
1878 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
1880 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)
1882 int notNullPflsSz=0;
1883 int nbOfArrs=geoTypes.size();
1884 for(int i=0;i<nbOfArrs;i++)
1887 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
1888 int nbOfDiffGeoTypes=geoTypes3.size();
1889 code.resize(3*nbOfDiffGeoTypes);
1890 notNullPfls.resize(notNullPflsSz);
1893 for(int i=0;i<nbOfDiffGeoTypes;i++)
1896 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
1897 std::vector<const DataArrayInt *> notNullTmp;
1899 notNullTmp.push_back(pfls[j]);
1901 for(;j<nbOfArrs;j++)
1902 if(geoTypes[j]==refType)
1905 notNullTmp.push_back(pfls[j]);
1909 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
1910 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
1911 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
1912 code[3*i]=(int)refType;
1913 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
1914 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
1915 if(notNullTmp.empty())
1919 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
1920 code[3*i+2]=notNullPflsSz++;
1926 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
1928 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)
1932 for(int i=0;i<sz;i++)
1936 if(type!=ON_GAUSS_NE)
1937 ret+=dads[i].second-dads[i].first;
1940 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
1941 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
1946 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
1947 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
1953 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
1955 std::vector<std::string> ret;
1956 std::set<std::string> ret2;
1957 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1959 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
1960 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1961 if(ret2.find(*it2)==ret2.end())
1963 ret.push_back(*it2);
1970 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
1972 std::vector<std::string> ret;
1973 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1975 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
1976 ret.insert(ret.end(),tmp.begin(),tmp.end());
1981 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
1983 std::vector<std::string> ret;
1984 std::set<std::string> ret2;
1985 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1987 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
1988 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1989 if(ret2.find(*it2)==ret2.end())
1991 ret.push_back(*it2);
1998 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
2000 std::vector<std::string> ret;
2001 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2003 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
2004 ret.insert(ret.end(),tmp.begin(),tmp.end());
2009 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
2011 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
2013 if((*it).first==_mesh_name)
2015 _mesh_name=(*it).second;
2022 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
2023 MEDFileFieldGlobsReal& glob)
2025 if(_mesh_name!=meshName)
2027 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
2028 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
2029 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
2030 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
2031 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
2032 getUndergroundDataArrayExt(entries);
2033 DataArray *arr0(getOrCreateAndGetArray());//tony
2035 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
2036 DataArrayDouble *arr(dynamic_cast<DataArrayDouble *>(arr0));//tony
2038 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
2041 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
2042 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
2044 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
2046 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2047 sz+=(*it).second.second-(*it).second.first;
2050 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2052 MCAuto<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
2053 ////////////////////
2054 MCAuto<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
2055 int *workI2=explicitIdsOldInMesh->getPointer();
2056 int sz1=0,sz2=0,sid=1;
2057 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
2058 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
2059 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
2061 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
2062 MCAuto<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
2063 int *workI=explicitIdsOldInArr->getPointer();
2064 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
2066 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
2067 (*itL2)->setLocId(sz2);
2068 (*itL2)->_tmp_work1=(*itL2)->getStart();
2069 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
2071 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
2073 explicitIdsOldInMesh->reAlloc(sz2);
2074 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
2075 ////////////////////
2076 MCAuto<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
2077 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
2078 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
2079 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
2081 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
2082 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
2083 otherEntriesNew.back()->setLocId((*it)->getGeoType());
2085 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
2086 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
2087 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
2089 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
2090 int newStart=elt->getLocId();
2091 elt->setLocId((*it)->getGeoType());
2092 elt->setNewStart(newStart);
2093 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
2094 entriesKeptNew.push_back(elt);
2095 entriesKeptNew2.push_back(elt);
2097 MCAuto<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
2098 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
2099 MCAuto<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
2100 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
2102 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
2105 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
2107 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
2108 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
2110 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
2111 glob,arr2,otherEntriesNew) || ret;
2115 // Assign new dispatching
2116 assignNewLeaves(otherEntriesNew);
2117 arr->deepCopyFrom(*arr2);
2122 * \param [in,out] globalNum a global numbering counter for the renumbering.
2123 * \param [out] its - list of pair (start,stop) kept
2125 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
2127 std::vector< MCAuto< MEDFileFieldPerMeshPerType > > ret;
2128 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2130 std::vector< std::pair<int,int> > its2;
2131 if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
2134 its.insert(its.end(),its2.begin(),its2.end());
2141 * \param [in,out] globalNum a global numbering counter for the renumbering.
2142 * \param [out] its - list of pair (start,stop) kept
2144 void MEDFileFieldPerMesh::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
2146 std::vector< MCAuto< MEDFileFieldPerMeshPerType > > ret;
2147 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2149 std::vector< std::pair<int,int> > its2;
2150 if((*it)->keepOnlyGaussDiscretization(idOfDisc,globalNum,its2))
2153 its.insert(its.end(),its2.begin(),its2.end());
2159 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
2161 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > > types;
2162 for( std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
2163 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
2165 std::vector< MCAuto< MEDFileFieldPerMeshPerType > > fieldPmPt(types.size());
2166 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
2167 std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it2=fieldPmPt.begin();
2168 for(;it1!=types.end();it1++,it2++)
2170 MCAuto<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
2171 elt->setLeaves((*it1).second);
2174 _field_pm_pt=fieldPmPt;
2177 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2179 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2180 (*it)->changePflsRefsNamesGen(mapOfModif);
2183 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2185 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2186 (*it)->changeLocsRefsNamesGen(mapOfModif);
2190 * \param [in] mesh is the whole mesh
2192 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2194 if(_field_pm_pt.empty())
2195 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2197 std::vector< std::pair<int,int> > dads;
2198 std::vector<const DataArrayInt *> pfls;
2199 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2200 std::vector<int> locs,code;
2201 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2202 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2203 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2205 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2208 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2209 throw INTERP_KERNEL::Exception(oss.str());
2212 std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2213 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2216 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2218 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2221 MCAuto<DataArrayInt> arr2(arr);
2222 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2228 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2232 if(nb!=mesh->getNumberOfNodes())
2234 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2235 oss << " nodes in mesh !";
2236 throw INTERP_KERNEL::Exception(oss.str());
2238 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2241 return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2245 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
2247 if(_field_pm_pt.empty())
2248 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2250 std::vector<std::pair<int,int> > dads;
2251 std::vector<const DataArrayInt *> pfls;
2252 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2253 std::vector<int> locs,code;
2254 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2255 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2256 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2258 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2261 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2262 throw INTERP_KERNEL::Exception(oss.str());
2264 std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2265 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2268 MCAuto<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2269 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2274 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2278 if(nb!=mesh->getNumberOfNodes())
2280 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2281 oss << " nodes in mesh !";
2282 throw INTERP_KERNEL::Exception(oss.str());
2285 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2291 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
2295 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2297 (*it)->getSizes(globalSz,nbOfEntries);
2299 entries.resize(nbOfEntries);
2301 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2303 (*it)->fillValues(nbOfEntries,entries);
2307 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
2309 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2311 if((*it)->getGeoType()==typ)
2312 return (*it)->getLeafGivenLocId(locId);
2314 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2315 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2316 oss << "Possiblities are : ";
2317 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2319 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2320 oss << "\"" << cm2.getRepr() << "\", ";
2322 throw INTERP_KERNEL::Exception(oss.str());
2325 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
2327 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2329 if((*it)->getGeoType()==typ)
2330 return (*it)->getLeafGivenLocId(locId);
2332 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2333 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2334 oss << "Possiblities are : ";
2335 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2337 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2338 oss << "\"" << cm2.getRepr() << "\", ";
2340 throw INTERP_KERNEL::Exception(oss.str());
2344 * \param [in,out] start - Integer that gives the current position in the final aggregated array
2345 * \param [in] pms - list of elements to aggregate. integer gives the mesh id
2346 * \param [in] dts - (Distribution of types) = level 1 : meshes to aggregate. Level 2 : all geo type. Level 3 pair specifying geo type and number of elem in geotype.
2347 * \param [out] extractInfo - Gives information about the where the data comes from. It is a vector of triplet. First element in the triplet the mesh pos. The 2nd one the start pos. The 3rd the end pos.
2349 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> MEDFileFieldPerMeshPerTypePerDisc::Aggregate(int &start, const std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >& pms, const std::vector< std::vector< std::pair<int,int> > >& dts, TypeOfField tof, MEDFileFieldPerMeshPerType *father, std::vector<std::pair< int, std::pair<int,int> > >& extractInfo)
2351 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret(new MEDFileFieldPerMeshPerTypePerDisc(father,tof));
2353 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : empty input vector !");
2354 for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it=pms.begin();it!=pms.end();it++)
2357 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : presence of null pointer !");
2358 if(!(*it).second->getProfile().empty())
2359 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for profiles !");
2360 if(!(*it).second->getLocalization().empty())
2361 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for gauss pts !");
2363 INTERP_KERNEL::NormalizedCellType gt(pms[0].second->getGeoType());
2365 std::vector< std::pair<int,int> > filteredDTS;
2366 for(std::vector< std::vector< std::pair<int,int> > >::const_iterator it=dts.begin();it!=dts.end();it++,i++)
2367 for(std::vector< std::pair<int,int> >::const_iterator it2=(*it).begin();it2!=(*it).end();it2++)
2368 if((*it2).first==gt)
2369 filteredDTS.push_back(std::pair<int,int>(i,(*it2).second));
2370 if(pms.size()!=filteredDTS.size())
2371 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles !");
2372 std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it1(pms.begin());
2373 std::vector< std::pair<int,int> >::const_iterator it2(filteredDTS.begin());
2374 int zeStart(start),nval(0);
2375 for(;it1!=pms.end();it1++,it2++)
2377 if((*it1).first!=(*it2).first)
2378 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles 2 !");
2379 int s1((*it1).second->getStart()),e1((*it1).second->getEnd());
2380 extractInfo.push_back(std::pair<int, std::pair<int,int> >((*it1).first,std::pair<int,int>(s1,e1)));
2382 nval+=((*it1).second)->getNumberOfVals();
2384 ret->_start=zeStart; ret->_end=start; ret->_nval=nval;
2388 MCAuto<MEDFileFieldPerMeshPerType> MEDFileFieldPerMeshPerType::Aggregate(int &start, const std::vector<std::pair<int,const MEDFileFieldPerMeshPerType *> >& pms, const std::vector< std::vector< std::pair<int,int> > >& dts, INTERP_KERNEL::NormalizedCellType gt, MEDFileFieldPerMesh *father, std::vector<std::pair< int, std::pair<int,int> > >& extractInfo)
2390 MCAuto<MEDFileFieldPerMeshPerType> ret(new MEDFileFieldPerMeshPerType(father,gt));
2391 std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > > m;
2392 for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerType *> >::const_iterator it=pms.begin();it!=pms.end();it++)
2394 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it2=(*it).second->_field_pm_pt_pd.begin();it2!=(*it).second->_field_pm_pt_pd.end();it2++)
2395 m[(*it2)->getType()].push_back(std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * >((*it).first,*it2));
2397 for(std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > >::const_iterator it=m.begin();it!=m.end();it++)
2399 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> agg(MEDFileFieldPerMeshPerTypePerDisc::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
2400 ret->_field_pm_pt_pd.push_back(agg);
2405 MCAuto<MEDFileFieldPerMesh> MEDFileFieldPerMesh::Aggregate(int &start, const std::vector<const MEDFileFieldPerMesh *>& pms, const std::vector< std::vector< std::pair<int,int> > >& dts, MEDFileAnyTypeField1TSWithoutSDA *father, std::vector<std::pair< int, std::pair<int,int> > >& extractInfo)
2407 MCAuto<MEDFileFieldPerMesh> ret(new MEDFileFieldPerMesh(father,pms[0]->getMeshName(),pms[0]->getMeshIteration(),pms[0]->getMeshOrder()));
2408 std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > > m;
2410 for(std::vector<const MEDFileFieldPerMesh *>::const_iterator it=pms.begin();it!=pms.end();it++,i++)
2412 const std::vector< MCAuto< MEDFileFieldPerMeshPerType > >& v((*it)->_field_pm_pt);
2413 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it2=v.begin();it2!=v.end();it2++)
2415 INTERP_KERNEL::NormalizedCellType gt((*it2)->getGeoType());
2416 m[gt].push_back(std::pair<int,const MEDFileFieldPerMeshPerType *>(i,*it2));
2419 for(std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > >::const_iterator it=m.begin();it!=m.end();it++)
2421 MCAuto<MEDFileFieldPerMeshPerType> agg(MEDFileFieldPerMeshPerType::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
2422 ret->_field_pm_pt.push_back(agg);
2427 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2430 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2431 std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it2=_field_pm_pt.begin();
2432 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2434 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2439 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2444 int ret=std::distance(_field_pm_pt.begin(),it2);
2445 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2450 * 'dads' and 'locs' input parameters have the same number of elements
2451 * \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
2453 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2454 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2455 const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2458 MCAuto<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2459 ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2460 MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2461 const std::vector<std::string>& infos=getInfo();
2462 da->setInfoOnComponents(infos);
2464 if(type==ON_GAUSS_PT)
2467 int nbOfArrs=dads.size();
2468 for(int i=0;i<nbOfArrs;i++)
2470 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2471 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2472 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2473 MCAuto<DataArrayInt> di=DataArrayInt::New();
2474 di->alloc(nbOfElems,1);
2476 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2477 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2486 * 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.
2487 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2488 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2489 * The order of cells in the returned field is those imposed by the profile.
2490 * \param [in] mesh is the global mesh.
2492 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2493 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2494 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2495 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2497 if(da->isIota(mesh->getNumberOfCells()))
2498 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2499 MCAuto<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2500 m2->setName(mesh->getName().c_str());
2501 MCAuto<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2507 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2509 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2510 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2511 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2513 if(da->isIota(mesh->getNumberOfNodes()))
2514 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2515 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2516 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2519 if(meshu->getNodalConnectivity()==0)
2521 MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2522 int nb=da->getNbOfElems();
2523 const int *ptr=da->getConstPointer();
2524 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2525 meshuc->allocateCells(nb);
2526 for(int i=0;i<nb;i++)
2527 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2528 meshuc->finishInsertingCells();
2529 ret->setMesh(meshuc);
2530 const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2531 if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2532 disc->checkCoherencyBetween(meshuc,arrOut);
2537 MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2539 DataArrayInt *arr2=0;
2540 MCAuto<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2541 MCAuto<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2542 MCAuto<DataArrayInt> arr3(arr2);
2543 int nnodes=mesh2->getNumberOfNodes();
2544 if(nnodes==(int)da->getNbOfElems())
2546 MCAuto<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2547 arrOut->renumberInPlace(da3->getConstPointer());
2548 mesh2->setName(mesh->getName().c_str());
2549 ret->setMesh(mesh2);
2554 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 !!!";
2555 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2556 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2557 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2558 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2559 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2560 throw INTERP_KERNEL::Exception(oss.str());
2566 * This method is the most light method of field retrieving.
2568 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
2572 pflOut=DataArrayInt::New();
2573 pflOut->alloc(nbOfElems,1);
2578 pflOut=const_cast<DataArrayInt*>(pflIn);
2581 MCAuto<DataArrayInt> safePfl(pflOut);
2582 MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2583 const std::vector<std::string>& infos=getInfo();
2584 int nbOfComp=infos.size();
2585 for(int i=0;i<nbOfComp;i++)
2586 da->setInfoOnComponent(i,infos[i].c_str());
2597 static MFFPMIter *NewCell(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities);
2598 static bool IsPresenceOfNode(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities);
2599 virtual ~MFFPMIter() { }
2600 virtual void begin() = 0;
2601 virtual bool finished() const = 0;
2602 virtual void next() = 0;
2603 virtual int current() const = 0;
2606 class MFFPMIterSimple : public MFFPMIter
2609 MFFPMIterSimple():_pos(0) { }
2610 void begin() { _pos=0; }
2611 bool finished() const { return _pos>=MED_N_CELL_FIXED_GEO; }
2612 void next() { _pos++; }
2613 int current() const { return _pos; }
2618 class MFFPMIter2 : public MFFPMIter
2621 MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts);
2622 void begin() { _it=_ids.begin(); }
2623 bool finished() const { return _it==_ids.end(); }
2624 void next() { _it++; }
2625 int current() const { return *_it; }
2627 std::vector<int> _ids;
2628 std::vector<int>::const_iterator _it;
2631 MFFPMIter *MFFPMIter::NewCell(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
2634 return new MFFPMIterSimple;
2637 std::vector<INTERP_KERNEL::NormalizedCellType> tmp;
2638 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=(*entities).begin();it!=(*entities).end();it++)
2640 if((*it).first==ON_CELLS || (*it).first==ON_GAUSS_NE || (*it).first==ON_GAUSS_PT)
2641 tmp.push_back((*it).second);
2643 return new MFFPMIter2(tmp);
2647 bool MFFPMIter::IsPresenceOfNode(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
2653 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=(*entities).begin();it!=(*entities).end();it++)
2654 if((*it).first==ON_NODES)
2660 MFFPMIter2::MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts)
2662 std::size_t sz(cts.size());
2664 for(std::size_t i=0;i<sz;i++)
2666 INTERP_KERNEL::NormalizedCellType *loc(std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,cts[i]));
2667 if(loc!=typmai2+MED_N_CELL_FIXED_GEO)
2668 _ids[i]=(int)std::distance(typmai2,loc);
2670 throw INTERP_KERNEL::Exception("MFFPMIter2 : The specified geo type does not exists !");
2676 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),
2679 INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2680 INTERP_KERNEL::AutoPtr<char> pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2681 INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2682 const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
2683 INTERP_KERNEL::AutoCppPtr<MFFPMIter> iter0(MFFPMIter::NewCell(entities));
2684 for(iter0->begin();!iter0->finished();iter0->next())
2686 int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL ,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2687 std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2688 int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2689 std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2690 if(nbProfile>0 || nbProfile2>0)
2692 const PartDefinition *pd(0);
2694 pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[iter0->current()]),typmai2[iter0->current()]);
2695 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nasc,pd));
2702 if(MFFPMIter::IsPresenceOfNode(entities))
2704 int nbProfile(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName));
2707 const PartDefinition *pd(0);
2709 pd=mmu->getPartDefAtLevel(1,INTERP_KERNEL::NORM_ERROR);
2710 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd));
2711 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2716 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2718 copyTinyInfoFrom(mesh);
2721 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
2723 if(id>=(int)_pfls.size())
2725 _pfls[id]=DataArrayInt::New();
2726 int lgth(MEDprofileSizeByName(fid,pflName.c_str()));
2727 _pfls[id]->setName(pflName);
2728 _pfls[id]->alloc(lgth,1);
2729 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName.c_str(),_pfls[id]->getPointer()));
2730 _pfls[id]->applyLin(1,-1,0);//Converting into C format
2733 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2735 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2737 MEDFILESAFECALLERRD0(MEDprofileInfo,(fid,i+1,pflName,&sz));
2738 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2739 if(i>=(int)_pfls.size())
2741 _pfls[i]=DataArrayInt::New();
2742 _pfls[i]->alloc(sz,1);
2743 _pfls[i]->setName(pflCpp.c_str());
2744 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName,_pfls[i]->getPointer()));
2745 _pfls[i]->applyLin(1,-1,0);//Converting into C format
2748 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
2750 int nbOfPfls=_pfls.size();
2751 for(int i=0;i<nbOfPfls;i++)
2753 MCAuto<DataArrayInt> cpy=_pfls[i]->deepCopy();
2754 cpy->applyLin(1,1,0);
2755 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2756 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2757 MEDFILESAFECALLERWR0(MEDprofileWr,(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer()));
2760 int nbOfLocs=_locs.size();
2761 for(int i=0;i<nbOfLocs;i++)
2762 _locs[i]->writeLL(fid);
2765 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
2767 std::vector<std::string> pfls=getPfls();
2768 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2770 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2773 _pfls.push_back(*it);
2777 int id=std::distance(pfls.begin(),it2);
2778 if(!(*it)->isEqual(*_pfls[id]))
2780 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2781 throw INTERP_KERNEL::Exception(oss.str());
2785 std::vector<std::string> locs=getLocs();
2786 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
2788 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2791 _locs.push_back(*it);
2795 int id=std::distance(locs.begin(),it2);
2796 if(!(*it)->isEqual(*_locs[id],eps))
2798 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2799 throw INTERP_KERNEL::Exception(oss.str());
2805 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
2807 for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
2808 getProfile((*it).c_str());
2811 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
2813 for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
2814 getLocalization((*it).c_str());
2817 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
2819 std::vector<std::string> profiles=real.getPflsReallyUsed();
2820 int sz=profiles.size();
2822 for(int i=0;i<sz;i++)
2823 loadProfileInFile(fid,i,profiles[i].c_str());
2825 std::vector<std::string> locs=real.getLocsReallyUsed();
2828 for(int i=0;i<sz;i++)
2829 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2832 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid)
2834 int nProfil=MEDnProfile(fid);
2835 for(int i=0;i<nProfil;i++)
2836 loadProfileInFile(fid,i);
2837 int sz=MEDnLocalization(fid);
2839 for(int i=0;i<sz;i++)
2841 _locs[i]=MEDFileFieldLoc::New(fid,i);
2845 MEDFileFieldGlobs *MEDFileFieldGlobs::New(med_idt fid)
2847 return new MEDFileFieldGlobs(fid);
2850 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2852 return new MEDFileFieldGlobs;
2855 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
2857 return _file_name.capacity()+_pfls.capacity()*sizeof(MCAuto<DataArrayInt>)+_locs.capacity()*sizeof(MCAuto<MEDFileFieldLoc>);
2860 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildrenWithNull() const
2862 std::vector<const BigMemoryObject *> ret;
2863 for(std::vector< MCAuto< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2864 ret.push_back((const DataArrayInt *)*it);
2865 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2866 ret.push_back((const MEDFileFieldLoc *)*it);
2870 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCopy() const
2872 MCAuto<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
2874 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2876 if((const DataArrayInt *)*it)
2877 ret->_pfls[i]=(*it)->deepCopy();
2880 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2882 if((const MEDFileFieldLoc*)*it)
2883 ret->_locs[i]=(*it)->deepCopy();
2889 * \throw if a profile in \a pfls in not in \a this.
2890 * \throw if a localization in \a locs in not in \a this.
2891 * \sa MEDFileFieldGlobs::deepCpyPart
2893 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2895 MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2896 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2898 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2900 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
2902 MCAuto<DataArrayInt> pfl2(pfl);
2903 ret->_pfls.push_back(pfl2);
2905 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2907 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2909 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
2911 MCAuto<MEDFileFieldLoc> loc2(loc);
2912 ret->_locs.push_back(loc2);
2914 ret->setFileName(getFileName());
2919 * \throw if a profile in \a pfls in not in \a this.
2920 * \throw if a localization in \a locs in not in \a this.
2921 * \sa MEDFileFieldGlobs::shallowCpyPart
2923 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2925 MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2926 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2928 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2930 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
2931 ret->_pfls.push_back(pfl->deepCopy());
2933 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2935 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2937 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
2938 ret->_locs.push_back(loc->deepCopy());
2940 ret->setFileName(getFileName());
2944 MEDFileFieldGlobs::MEDFileFieldGlobs(med_idt fid):_file_name(MEDFileWritable::FileNameFromFID(fid))
2948 MEDFileFieldGlobs::MEDFileFieldGlobs()
2952 MEDFileFieldGlobs::~MEDFileFieldGlobs()
2956 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
2958 oss << "Profiles :\n";
2959 std::size_t n=_pfls.size();
2960 for(std::size_t i=0;i<n;i++)
2962 oss << " - #" << i << " ";
2963 const DataArrayInt *pfl=_pfls[i];
2965 oss << "\"" << pfl->getName() << "\"\n";
2970 oss << "Localizations :\n";
2971 for(std::size_t i=0;i<n;i++)
2973 oss << " - #" << i << " ";
2974 const MEDFileFieldLoc *loc=_locs[i];
2976 loc->simpleRepr(oss);
2982 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2984 for(std::vector< MCAuto<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
2986 DataArrayInt *elt(*it);
2989 std::string name(elt->getName());
2990 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2992 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2994 elt->setName((*it2).second.c_str());
3002 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3004 for(std::vector< MCAuto<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
3006 MEDFileFieldLoc *elt(*it);
3009 std::string name(elt->getName());
3010 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3012 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3014 elt->setName((*it2).second.c_str());
3022 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
3024 if(locId<0 || locId>=(int)_locs.size())
3025 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
3026 return _locs[locId]->getNbOfGaussPtPerCell();
3029 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
3031 return getLocalizationFromId(getLocalizationId(locName));
3034 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
3036 if(locId<0 || locId>=(int)_locs.size())
3037 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3038 return *_locs[locId];
3042 namespace MEDCouplingImpl
3047 LocFinder(const std::string& loc):_loc(loc) { }
3048 bool operator() (const MCAuto<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
3050 const std::string &_loc;
3056 PflFinder(const std::string& pfl):_pfl(pfl) { }
3057 bool operator() (const MCAuto<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
3059 const std::string& _pfl;
3064 int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
3066 std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),MEDCouplingImpl::LocFinder(loc));
3069 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
3070 for(it=_locs.begin();it!=_locs.end();it++)
3071 oss << "\"" << (*it)->getName() << "\", ";
3072 throw INTERP_KERNEL::Exception(oss.str());
3074 return std::distance(_locs.begin(),it);
3078 * The returned value is never null.
3080 const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
3082 std::string pflNameCpp(pflName);
3083 std::vector< MCAuto<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3086 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3087 for(it=_pfls.begin();it!=_pfls.end();it++)
3088 oss << "\"" << (*it)->getName() << "\", ";
3089 throw INTERP_KERNEL::Exception(oss.str());
3094 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
3096 if(pflId<0 || pflId>=(int)_pfls.size())
3097 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3098 return _pfls[pflId];
3101 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
3103 if(locId<0 || locId>=(int)_locs.size())
3104 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3105 return *_locs[locId];
3108 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
3110 return getLocalizationFromId(getLocalizationId(locName));
3114 * The returned value is never null.
3116 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
3118 std::string pflNameCpp(pflName);
3119 std::vector< MCAuto<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3122 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3123 for(it=_pfls.begin();it!=_pfls.end();it++)
3124 oss << "\"" << (*it)->getName() << "\", ";
3125 throw INTERP_KERNEL::Exception(oss.str());
3130 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
3132 if(pflId<0 || pflId>=(int)_pfls.size())
3133 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3134 return _pfls[pflId];
3137 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
3139 std::vector< MCAuto<DataArrayInt> > newPfls;
3141 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3143 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
3144 newPfls.push_back(*it);
3149 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
3151 std::vector< MCAuto<MEDFileFieldLoc> > newLocs;
3153 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3155 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
3156 newLocs.push_back(*it);
3161 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
3163 int sz=_pfls.size();
3164 std::vector<std::string> ret(sz);
3165 for(int i=0;i<sz;i++)
3166 ret[i]=_pfls[i]->getName();
3170 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
3172 int sz=_locs.size();
3173 std::vector<std::string> ret(sz);
3174 for(int i=0;i<sz;i++)
3175 ret[i]=_locs[i]->getName();
3179 bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
3181 std::vector<std::string> v=getPfls();
3182 std::string s(pflName);
3183 return std::find(v.begin(),v.end(),s)!=v.end();
3186 bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
3188 std::vector<std::string> v=getLocs();
3189 std::string s(locName);
3190 return std::find(v.begin(),v.end(),s)!=v.end();
3193 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
3195 std::map<int,std::vector<int> > m;
3197 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3199 const DataArrayInt *tmp=(*it);
3202 m[tmp->getHashCode()].push_back(i);
3205 std::vector< std::vector<int> > ret;
3206 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
3208 if((*it2).second.size()>1)
3210 std::vector<int> ret0;
3211 bool equalityOrNot=false;
3212 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
3214 std::vector<int>::const_iterator it4=it3; it4++;
3215 for(;it4!=(*it2).second.end();it4++)
3217 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
3220 ret0.push_back(*it3);
3221 ret0.push_back(*it4);
3227 ret.push_back(ret0);
3233 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
3235 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
3238 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
3240 std::string name(pfl->getName());
3242 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
3243 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3244 if(name==(*it)->getName())
3246 if(!pfl->isEqual(*(*it)))
3248 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
3249 throw INTERP_KERNEL::Exception(oss.str());
3253 _pfls.push_back(pfl);
3256 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)
3258 std::string name(locName);
3260 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
3261 MCAuto<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
3262 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3263 if((*it)->isName(locName))
3265 if(!(*it)->isEqual(*obj,1e-12))
3267 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
3268 throw INTERP_KERNEL::Exception(oss.str());
3271 _locs.push_back(obj);
3274 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
3276 std::vector<std::string> names=getPfls();
3277 return CreateNewNameNotIn("NewPfl_",names);
3280 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
3282 std::vector<std::string> names=getLocs();
3283 return CreateNewNameNotIn("NewLoc_",names);
3286 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
3288 for(std::size_t sz=0;sz<100000;sz++)
3290 std::ostringstream tryName;
3291 tryName << prefix << sz;
3292 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
3293 return tryName.str();
3295 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
3299 * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
3300 * \param [in] fname - the file name.
3302 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(med_idt fid):_globals(MEDFileFieldGlobs::New(fid))
3307 * Creates an empty MEDFileFieldGlobsReal.
3309 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
3313 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
3318 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildrenWithNull() const
3320 std::vector<const BigMemoryObject *> ret;
3321 ret.push_back((const MEDFileFieldGlobs *)_globals);
3326 * Returns a string describing profiles and Gauss points held in \a this.
3327 * \return std::string - the description string.
3329 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
3331 const MEDFileFieldGlobs *glob=_globals;
3332 std::ostringstream oss2; oss2 << glob;
3333 std::string stars(oss2.str().length(),'*');
3334 oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n";
3336 glob->simpleRepr(oss);
3338 oss << "NO GLOBAL INFORMATION !\n";
3341 void MEDFileFieldGlobsReal::resetContent()
3343 _globals=MEDFileFieldGlobs::New();
3346 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
3351 * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
3352 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3354 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3356 _globals=other._globals;
3360 * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3361 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3363 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3365 const MEDFileFieldGlobs *otherg(other._globals);
3368 _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3372 * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3373 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3375 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3377 const MEDFileFieldGlobs *otherg(other._globals);
3380 _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3383 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3385 _globals=other._globals;
3386 if((const MEDFileFieldGlobs *)_globals)
3387 _globals=other._globals->deepCopy();
3391 * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3392 * \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3393 * \param [in] eps - a precision used to compare Gauss points with same name held by
3394 * \a this and \a other MEDFileFieldGlobsReal.
3395 * \throw If \a this and \a other hold profiles with equal names but different ids.
3396 * \throw If \a this and \a other hold different Gauss points with equal names.
3398 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
3400 const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3401 if(thisGlobals==otherGlobals)
3405 _globals=other._globals;
3408 _globals->appendGlobs(*other._globals,eps);
3411 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
3413 checkGlobsPflsPartCoherency();
3414 checkGlobsLocsPartCoherency();
3417 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
3419 contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3422 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
3424 contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3427 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3429 contentNotNull()->loadProfileInFile(fid,id,pflName);
3432 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3434 contentNotNull()->loadProfileInFile(fid,id);
3437 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
3439 contentNotNull()->loadGlobals(fid,*this);
3442 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid)
3444 contentNotNull()->loadAllGlobals(fid);
3447 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3449 contentNotNull()->writeGlobals(fid,opt);
3453 * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3454 * or getPflsReallyUsedMulti().
3455 * \return std::vector<std::string> - a sequence of names of all profiles.
3457 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3459 return contentNotNull()->getPfls();
3463 * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3464 * or getLocsReallyUsedMulti().
3465 * \return std::vector<std::string> - a sequence of names of all localizations.
3467 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3469 return contentNotNull()->getLocs();
3473 * Checks if the profile with a given name exists.
3474 * \param [in] pflName - the profile name of interest.
3475 * \return bool - \c true if the profile named \a pflName exists.
3477 bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
3479 return contentNotNull()->existsPfl(pflName);
3483 * Checks if the localization with a given name exists.
3484 * \param [in] locName - the localization name of interest.
3485 * \return bool - \c true if the localization named \a locName exists.
3487 bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
3489 return contentNotNull()->existsLoc(locName);
3492 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
3494 return contentNotNull()->createNewNameOfPfl();
3497 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
3499 return contentNotNull()->createNewNameOfLoc();
3503 * Sets the name of a MED file.
3504 * \param [inout] fileName - the file name.
3506 void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
3508 contentNotNull()->setFileName(fileName);
3512 * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3513 * in the same order.
3514 * \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3515 * Each item of this sequence is a vector containing ids of equal profiles.
3517 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3519 return contentNotNull()->whichAreEqualProfiles();
3523 * Finds equal localizations.
3524 * \param [in] eps - a precision used to compare real values of the localizations.
3525 * \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3526 * Each item of this sequence is a vector containing ids of equal localizations.
3528 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3530 return contentNotNull()->whichAreEqualLocs(eps);
3534 * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3535 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3536 * this sequence is a pair whose
3537 * - the first item is a vector of profile names to replace by the second item,
3538 * - the second item is a profile name to replace every profile name of the first item.
3540 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3542 contentNotNull()->changePflsNamesInStruct(mapOfModif);
3546 * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3547 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3548 * this sequence is a pair whose
3549 * - the first item is a vector of localization names to replace by the second item,
3550 * - the second item is a localization name to replace every localization name of the first item.
3552 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3554 contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3558 * Replaces references to some profiles (a reference is a profile name) by references
3559 * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3560 * them-selves accordingly. <br>
3561 * This method is a generalization of changePflName().
3562 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3563 * this sequence is a pair whose
3564 * - the first item is a vector of profile names to replace by the second item,
3565 * - the second item is a profile name to replace every profile of the first item.
3566 * \sa changePflsRefsNamesGen()
3567 * \sa changePflName()
3569 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3571 changePflsRefsNamesGen(mapOfModif);
3572 changePflsNamesInStruct(mapOfModif);
3576 * Replaces references to some localizations (a reference is a localization name) by references
3577 * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3578 * them-selves accordingly. <br>
3579 * This method is a generalization of changeLocName().
3580 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3581 * this sequence is a pair whose
3582 * - the first item is a vector of localization names to replace by the second item,
3583 * - the second item is a localization name to replace every localization of the first item.
3584 * \sa changeLocsRefsNamesGen()
3585 * \sa changeLocName()
3587 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3589 changeLocsRefsNamesGen(mapOfModif);
3590 changeLocsNamesInStruct(mapOfModif);
3594 * Renames the profile having a given name and updates references to this profile.
3595 * \param [in] oldName - the name of the profile to rename.
3596 * \param [in] newName - a new name of the profile.
3597 * \sa changePflsNames().
3599 void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
3601 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3602 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3604 changePflsNames(mapOfModif);
3608 * Renames the localization having a given name and updates references to this localization.
3609 * \param [in] oldName - the name of the localization to rename.
3610 * \param [in] newName - a new name of the localization.
3611 * \sa changeLocsNames().
3613 void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
3615 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3616 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3618 changeLocsNames(mapOfModif);
3622 * Removes duplicated profiles. Returns a map used to update references to removed
3623 * profiles via changePflsRefsNamesGen().
3624 * Equal profiles are found using whichAreEqualProfiles().
3625 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3626 * a sequence describing the performed replacements of profiles. Each element of
3627 * this sequence is a pair whose
3628 * - the first item is a vector of profile names replaced by the second item,
3629 * - the second item is a profile name replacing every profile of the first item.
3631 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
3633 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3634 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3636 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3638 std::vector< std::string > tmp((*it).size());
3640 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3641 tmp[j]=std::string(getProfileFromId(*it2)->getName());
3642 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3644 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3645 killProfileIds(tmp2);
3647 changePflsRefsNamesGen(ret);
3652 * Removes duplicated localizations. Returns a map used to update references to removed
3653 * localizations via changeLocsRefsNamesGen().
3654 * Equal localizations are found using whichAreEqualLocs().
3655 * \param [in] eps - a precision used to compare real values of the localizations.
3656 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3657 * a sequence describing the performed replacements of localizations. Each element of
3658 * this sequence is a pair whose
3659 * - the first item is a vector of localization names replaced by the second item,
3660 * - the second item is a localization name replacing every localization of the first item.
3662 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
3664 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3665 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3667 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3669 std::vector< std::string > tmp((*it).size());
3671 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3672 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3673 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3675 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3676 killLocalizationIds(tmp2);
3678 changeLocsRefsNamesGen(ret);
3683 * Returns number of Gauss points per cell in a given localization.
3684 * \param [in] locId - an id of the localization of interest.
3685 * \return int - the number of the Gauss points per cell.
3687 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
3689 return contentNotNull()->getNbOfGaussPtPerCell(locId);
3693 * Returns an id of a localization by its name.
3694 * \param [in] loc - the localization name of interest.
3695 * \return int - the id of the localization.
3696 * \throw If there is no a localization named \a loc.
3698 int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
3700 return contentNotNull()->getLocalizationId(loc);
3704 * Returns the name of the MED file.
3705 * \return const std::string& - the MED file name.
3707 std::string MEDFileFieldGlobsReal::getFileName() const
3709 return contentNotNull()->getFileName();
3713 * Returns a localization object by its name.
3714 * \param [in] locName - the name of the localization of interest.
3715 * \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3716 * \throw If there is no a localization named \a locName.
3718 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
3720 return contentNotNull()->getLocalization(locName);
3724 * Returns a localization object by its id.
3725 * \param [in] locId - the id of the localization of interest.
3726 * \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3727 * \throw If there is no a localization with id \a locId.
3729 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
3731 return contentNotNull()->getLocalizationFromId(locId);
3735 * Returns a profile array by its name.
3736 * \param [in] pflName - the name of the profile of interest.
3737 * \return const DataArrayInt * - the profile array having the name \a pflName.
3738 * \throw If there is no a profile named \a pflName.
3740 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
3742 return contentNotNull()->getProfile(pflName);
3746 * Returns a profile array by its id.
3747 * \param [in] pflId - the id of the profile of interest.
3748 * \return const DataArrayInt * - the profile array having the id \a pflId.
3749 * \throw If there is no a profile with id \a pflId.
3751 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
3753 return contentNotNull()->getProfileFromId(pflId);
3757 * Returns a localization object, apt for modification, by its id.
3758 * \param [in] locId - the id of the localization of interest.
3759 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3760 * having the id \a locId.
3761 * \throw If there is no a localization with id \a locId.
3763 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
3765 return contentNotNull()->getLocalizationFromId(locId);
3769 * Returns a localization object, apt for modification, by its name.
3770 * \param [in] locName - the name of the localization of interest.
3771 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3772 * having the name \a locName.
3773 * \throw If there is no a localization named \a locName.
3775 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
3777 return contentNotNull()->getLocalization(locName);
3781 * Returns a profile array, apt for modification, by its name.
3782 * \param [in] pflName - the name of the profile of interest.
3783 * \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3784 * \throw If there is no a profile named \a pflName.
3786 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
3788 return contentNotNull()->getProfile(pflName);
3792 * Returns a profile array, apt for modification, by its id.
3793 * \param [in] pflId - the id of the profile of interest.
3794 * \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3795 * \throw If there is no a profile with id \a pflId.
3797 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
3799 return contentNotNull()->getProfileFromId(pflId);
3803 * Removes profiles given by their ids. No data is updated to track this removal.
3804 * \param [in] pflIds - a sequence of ids of the profiles to remove.
3806 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
3808 contentNotNull()->killProfileIds(pflIds);
3812 * Removes localizations given by their ids. No data is updated to track this removal.
3813 * \param [in] locIds - a sequence of ids of the localizations to remove.
3815 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
3817 contentNotNull()->killLocalizationIds(locIds);
3821 * Stores a profile array.
3822 * \param [in] pfl - the profile array to store.
3823 * \throw If the name of \a pfl is empty.
3824 * \throw If a profile with the same name as that of \a pfl already exists but contains
3827 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
3829 contentNotNull()->appendProfile(pfl);
3833 * Adds a new localization of Gauss points.
3834 * \param [in] locName - the name of the new localization.
3835 * \param [in] geoType - a geometrical type of the reference cell.
3836 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
3837 * must be \c nbOfNodesPerCell * \c dimOfType.
3838 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
3839 * must be _wg_.size() * \c dimOfType.
3840 * \param [in] w - the weights of Gauss points.
3841 * \throw If \a locName is empty.
3842 * \throw If a localization with the name \a locName already exists but is
3843 * different form the new one.
3845 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)
3847 contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
3850 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
3852 MEDFileFieldGlobs *g(_globals);
3854 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
3858 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
3860 const MEDFileFieldGlobs *g(_globals);
3862 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
3866 //= MEDFileFieldNameScope
3868 MEDFileFieldNameScope::MEDFileFieldNameScope()
3872 MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName):_name(fieldName)
3877 * Returns the name of \a this field.
3878 * \return std::string - a string containing the field name.
3880 std::string MEDFileFieldNameScope::getName() const
3886 * Sets name of \a this field
3887 * \param [in] name - the new field name.
3889 void MEDFileFieldNameScope::setName(const std::string& fieldName)
3894 std::string MEDFileFieldNameScope::getDtUnit() const
3899 void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
3904 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
3907 _dt_unit=other._dt_unit;
3910 //= MEDFileAnyTypeField1TSWithoutSDA
3912 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
3914 _field_per_mesh.resize(other._field_per_mesh.size());
3916 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
3918 if((const MEDFileFieldPerMesh *)*it)
3919 _field_per_mesh[i]=(*it)->deepCopy(this);
3924 * Prints a string describing \a this field into a stream. This string is outputted
3925 * by \c print Python command.
3926 * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
3927 * \param [in,out] oss - the out stream.
3928 * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
3929 * info id printed, else, not.
3931 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
3933 std::string startOfLine(bkOffset,' ');
3934 oss << startOfLine << "Field ";
3936 oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
3937 oss << "on one time Step ";
3939 oss << "(" << f1tsId << ") ";
3940 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
3941 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
3942 const DataArray *arr=getUndergroundDataArray();
3945 const std::vector<std::string> &comps=arr->getInfoOnComponents();
3948 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
3949 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
3950 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
3952 if(arr->isAllocated())
3954 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
3957 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
3961 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
3963 oss << startOfLine << "----------------------" << std::endl;
3964 if(!_field_per_mesh.empty())
3967 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
3969 const MEDFileFieldPerMesh *cur=(*it2);
3971 cur->simpleRepr(bkOffset,oss,i);
3973 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
3978 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
3980 oss << startOfLine << "----------------------" << std::endl;
3983 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
3985 const DataArray *arr(getUndergroundDataArray());
3987 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
3988 int nbOfCompo=arr->getNumberOfComponents();
3989 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
3990 for(int i=0;i<nbOfCompo;i++)
3993 std::vector<int> v(1,i);
3994 MCAuto<DataArray> arr2=arr->keepSelectedComponents(v);
3995 ret[i]->setArray(arr2);
4000 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)
4004 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
4009 * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
4010 * empty. Returns -1 if this in on nodes.
4011 * \return int - the dimension of \a this.
4013 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
4016 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4017 (*it)->getDimension(ret);
4022 * Returns the mesh name.
4023 * \return std::string - a string holding the mesh name.
4024 * \throw If \c _field_per_mesh.empty()
4026 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const
4028 if(_field_per_mesh.empty())
4029 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
4030 return _field_per_mesh[0]->getMeshName();
4033 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const std::string& newMeshName)
4035 std::string oldName(getMeshName());
4036 std::vector< std::pair<std::string,std::string> > v(1);
4037 v[0].first=oldName; v[0].second=newMeshName;
4041 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
4044 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4046 MEDFileFieldPerMesh *cur(*it);
4048 ret=cur->changeMeshNames(modifTab) || ret;
4054 * Returns the number of iteration of the state of underlying mesh.
4055 * \return int - the iteration number.
4056 * \throw If \c _field_per_mesh.empty()
4058 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
4060 if(_field_per_mesh.empty())
4061 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
4062 return _field_per_mesh[0]->getMeshIteration();
4066 * Returns the order number of iteration of the state of underlying mesh.
4067 * \return int - the order number.
4068 * \throw If \c _field_per_mesh.empty()
4070 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
4072 if(_field_per_mesh.empty())
4073 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
4074 return _field_per_mesh[0]->getMeshOrder();
4078 * Checks if \a this field is tagged by a given iteration number and a given
4079 * iteration order number.
4080 * \param [in] iteration - the iteration number of interest.
4081 * \param [in] order - the iteration order number of interest.
4082 * \return bool - \c true if \a this->getIteration() == \a iteration &&
4083 * \a this->getOrder() == \a order.
4085 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
4087 return iteration==_iteration && order==_order;
4091 * Returns number of iteration and order number of iteration when
4092 * \a this field has been calculated.
4093 * \return std::pair<int,int> - a pair of the iteration number and the iteration
4096 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
4098 std::pair<int,int> p;
4104 * Returns number of iteration and order number of iteration when
4105 * \a this field has been calculated.
4106 * \param [in,out] p - a pair returning the iteration number and the iteration
4109 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
4116 * Returns all types of spatial discretization of \a this field.
4117 * \param [in,out] types - a sequence of types of \a this field.
4119 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
4121 std::set<TypeOfField> types2;
4122 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4124 (*it)->fillTypesOfFieldAvailable(types2);
4126 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
4127 std::copy(types2.begin(),types2.end(),bi);
4131 * Returns all types of spatial discretization of \a this field.
4132 * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
4135 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
4137 std::vector<TypeOfField> ret;
4138 fillTypesOfFieldAvailable(ret);
4142 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
4144 std::vector<std::string> ret;
4145 std::set<std::string> ret2;
4146 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4148 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
4149 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4150 if(ret2.find(*it2)==ret2.end())
4152 ret.push_back(*it2);
4159 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
4161 std::vector<std::string> ret;
4162 std::set<std::string> ret2;
4163 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4165 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
4166 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4167 if(ret2.find(*it2)==ret2.end())
4169 ret.push_back(*it2);
4176 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
4178 std::vector<std::string> ret;
4179 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4181 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
4182 ret.insert(ret.end(),tmp.begin(),tmp.end());
4187 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
4189 std::vector<std::string> ret;
4190 std::set<std::string> ret2;
4191 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4193 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
4194 ret.insert(ret.end(),tmp.begin(),tmp.end());
4199 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4201 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4202 (*it)->changePflsRefsNamesGen(mapOfModif);
4205 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4207 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4208 (*it)->changeLocsRefsNamesGen(mapOfModif);
4212 * Returns all attributes of parts of \a this field lying on a given mesh.
4213 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4214 * item of every of returned sequences refers to the _i_-th part of \a this field.
4215 * Thus all sequences returned by this method are of the same length equal to number
4216 * of different types of supporting entities.<br>
4217 * A field part can include sub-parts with several different spatial discretizations,
4218 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
4219 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4220 * of a nested sequence corresponds to a type of spatial discretization.<br>
4221 * This method allows for iteration over MEDFile DataStructure without any overhead.
4222 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4223 * for the case with only one underlying mesh. (Actually, the number of meshes is
4224 * not checked if \a mname == \c NULL).
4225 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4226 * a field part is returned.
4227 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4228 * This sequence is of the same length as \a types.
4229 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4230 * discretization. A profile name can be empty.
4231 * Length of this and of nested sequences is the same as that of \a typesF.
4232 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4233 * discretization. A localization name can be empty.
4234 * Length of this and of nested sequences is the same as that of \a typesF.
4235 * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
4236 * of ids of tuples within the data array, per each type of spatial
4237 * discretization within one mesh entity type.
4238 * Length of this and of nested sequences is the same as that of \a typesF.
4239 * \throw If no field is lying on \a mname.
4241 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
4245 meshId=getMeshIdFromMeshName(mname);
4247 if(_field_per_mesh.empty())
4248 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4249 return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4253 * Returns dimensions of mesh elements \a this field lies on. The returned value is a
4254 * maximal absolute dimension and values returned via the out parameter \a levs are
4255 * dimensions relative to the maximal absolute dimension. <br>
4256 * This method is designed for MEDFileField1TS instances that have a discretization
4257 * \ref MEDCoupling::ON_CELLS "ON_CELLS",
4258 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT",
4259 * \ref MEDCoupling::ON_GAUSS_NE "ON_GAUSS_NE".
4260 * Only these 3 discretizations will be taken into account here. If \a this is
4261 * \ref MEDCoupling::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
4262 * This method is useful to make the link between the dimension of the underlying mesh
4263 * and the levels of \a this, because it is possible that the highest dimension of \a this
4264 * field is not equal to the dimension of the underlying mesh.
4266 * Let's consider the following case:
4267 * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
4268 * TETRA4, HEXA8, TRI3 and SEG2.
4269 * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
4270 * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
4272 * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
4273 * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
4274 * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
4275 * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
4276 * parameter of getFieldAtLevel() is computed basing on the returned values as this:
4277 * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
4279 * to retrieve the highest level of
4280 * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br>
4281 * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
4282 * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
4283 * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
4284 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4285 * for the case with only one underlying mesh. (Actually, the number of meshes is
4286 * not checked if \a mname == \c NULL).
4287 * \param [in,out] levs - a sequence returning the dimensions relative to the maximal
4288 * absolute one. They are in decreasing order. This sequence is cleared before
4290 * \return int - the maximal absolute dimension of elements \a this fields lies on.
4291 * \throw If no field is lying on \a mname.
4293 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
4296 int meshId=getMeshIdFromMeshName(mname);
4297 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4298 std::vector< std::vector<TypeOfField> > typesF;
4299 std::vector< std::vector<std::string> > pfls, locs;
4300 _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4302 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
4303 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
4304 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
4306 st.erase(INTERP_KERNEL::NORM_ERROR);
4308 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
4310 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
4311 ret1.insert((int)cm.getDimension());
4313 int ret=*std::max_element(ret1.begin(),ret1.end());
4314 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
4315 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
4320 * \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.
4321 * \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.
4322 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4323 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4325 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
4327 int mid=getMeshIdFromMeshName(mName);
4328 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4332 * \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.
4333 * \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.
4334 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4335 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4337 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
4339 int mid=getMeshIdFromMeshName(mName);
4340 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4344 * \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.
4346 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
4348 if(_field_per_mesh.empty())
4349 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4352 std::string mName2(mName);
4354 std::vector<std::string> msg;
4355 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4356 if(mName2==(*it)->getMeshName())
4359 msg.push_back((*it)->getMeshName());
4360 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4361 oss << "Possible meshes are : ";
4362 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4363 oss << "\"" << (*it2) << "\" ";
4364 throw INTERP_KERNEL::Exception(oss.str());
4367 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
4370 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4371 std::string tmp(mesh->getName());
4373 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4374 std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4376 for(;it!=_field_per_mesh.end();it++,i++)
4378 if((*it)->getMeshName()==tmp)
4381 int sz=_field_per_mesh.size();
4382 _field_per_mesh.resize(sz+1);
4383 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4387 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4388 MEDFileFieldGlobsReal& glob)
4391 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4393 MEDFileFieldPerMesh *fpm(*it);
4395 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4401 * This method splits \a this into several sub-parts so that each sub parts have exactly one spatial discretization. This method implements the minimal
4402 * splitting that leads to single spatial discretization of this.
4404 * \sa splitMultiDiscrPerGeoTypes
4406 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
4408 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4409 std::vector< std::vector<TypeOfField> > typesF;
4410 std::vector< std::vector<std::string> > pfls,locs;
4411 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4412 std::set<TypeOfField> allEnt;
4413 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4414 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4415 allEnt.insert(*it2);
4416 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4417 std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4418 for(std::size_t i=0;i<allEnt.size();i++,it3++)
4420 std::vector< std::pair<int,int> > its;
4421 ret[i]=shallowCpy();
4422 int newLgth(ret[i]->keepOnlySpatialDiscretization(*it3,its));
4423 ret[i]->updateData(newLgth,its);
4429 * This method performs a sub splitting as splitDiscretizations does but finer. This is the finest spliting level that can be done.
4430 * This method implements the minimal splitting so that each returned elements are mono Gauss discretization per geometric type.
4432 * \sa splitDiscretizations
4434 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes() const
4436 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4437 std::vector< std::vector<TypeOfField> > typesF;
4438 std::vector< std::vector<std::string> > pfls,locs;
4439 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4440 std::set<TypeOfField> allEnt;
4441 std::size_t nbOfMDPGT(0),ii(0);
4442 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++,ii++)
4444 nbOfMDPGT=std::max(nbOfMDPGT,locs[ii].size());
4445 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4446 allEnt.insert(*it2);
4448 if(allEnt.size()!=1)
4449 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : this field is expected to be defined only on one spatial discretization !");
4451 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
4454 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret0(1);
4455 ret0[0]=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(this); this->incrRef();
4458 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfMDPGT);
4459 for(std::size_t i=0;i<nbOfMDPGT;i++)
4461 std::vector< std::pair<int,int> > its;
4462 ret[i]=shallowCpy();
4463 int newLgth(ret[i]->keepOnlyGaussDiscretization(i,its));
4464 ret[i]->updateData(newLgth,its);
4469 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
4471 int globalCounter(0);
4472 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4473 (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4474 return globalCounter;
4477 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlyGaussDiscretization(std::size_t idOfDisc, std::vector< std::pair<int,int> >& its)
4479 int globalCounter(0);
4480 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4481 (*it)->keepOnlyGaussDiscretization(idOfDisc,globalCounter,its);
4482 return globalCounter;
4485 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
4487 if(_nb_of_tuples_to_be_allocated>=0)
4489 _nb_of_tuples_to_be_allocated=newLgth;
4490 const DataArray *oldArr(getUndergroundDataArray());
4493 MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4494 newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
4496 _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
4500 if(_nb_of_tuples_to_be_allocated==-1)
4502 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4504 const DataArray *oldArr(getUndergroundDataArray());
4505 if(!oldArr || !oldArr->isAllocated())
4506 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4507 MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4508 newArr->alloc(newLgth,getNumberOfComponents());
4510 newArr->copyStringInfoFrom(*oldArr);
4512 for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4514 if((*it).second<(*it).first)
4515 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4516 newArr->setContigPartOfSelectedValuesSlice(pos,oldArr,(*it).first,(*it).second,1);
4517 pos+=(*it).second-(*it).first;
4522 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4525 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
4527 if(_field_per_mesh.empty())
4528 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4529 if(_field_per_mesh.size()>1)
4530 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4531 _field_per_mesh[0]->copyOptionsFrom(opts);
4532 _field_per_mesh[0]->writeLL(fid,nasc);
4536 * 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.
4537 * If false is returned the memory allocation is not required.
4539 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
4541 if(_nb_of_tuples_to_be_allocated>=0)
4543 getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4544 _nb_of_tuples_to_be_allocated=-2;
4547 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4549 if(_nb_of_tuples_to_be_allocated==-1)
4550 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4551 if(_nb_of_tuples_to_be_allocated<-3)
4552 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4553 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4556 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
4558 med_int numdt,numit;
4562 med_int meshnumdt,meshnumit;
4563 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4564 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt));
4565 MEDFILESAFECALLERRD0(MEDfield23ComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit));
4566 if(_iteration!=numdt || _order!=numit)
4567 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4568 _field_per_mesh.resize(nmesh);
4573 std::string meshNameCpp(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
4574 mm=ms->getMeshWithName(meshNameCpp);
4577 for(int i=0;i<nmesh;i++)
4578 _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i,meshnumdt,meshnumit,nasc,mm,entities);
4579 _nb_of_tuples_to_be_allocated=0;
4580 for(int i=0;i<nmesh;i++)
4581 _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4584 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
4586 allocIfNecessaryTheArrayToReceiveDataFromFile();
4587 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4588 (*it)->loadBigArraysRecursively(fid,nasc);
4591 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
4593 if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4594 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4595 (*it)->loadBigArraysRecursively(fid,nasc);
4598 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
4600 loadOnlyStructureOfDataRecursively(fid,nasc,ms,entities);
4601 loadBigArraysRecursively(fid,nasc);
4604 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
4606 DataArray *thisArr(getUndergroundDataArray());
4607 if(thisArr && thisArr->isAllocated())
4609 _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
4610 thisArr->desallocate();
4614 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
4616 return _dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MCAuto< MEDFileFieldPerMesh >);
4619 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
4621 std::vector<const BigMemoryObject *> ret;
4622 if(getUndergroundDataArray())
4623 ret.push_back(getUndergroundDataArray());
4624 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4625 ret.push_back((const MEDFileFieldPerMesh *)*it);
4630 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4631 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4632 * "Sort By Type"), if not, an exception is thrown.
4633 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
4634 * \param [in] arr - the array of values.
4635 * \param [in,out] glob - the global data where profiles and localization present in
4636 * \a field, if any, are added.
4637 * \throw If the name of \a field is empty.
4638 * \throw If the data array of \a field is not set.
4639 * \throw If \a this->_arr is already allocated but has different number of components
4641 * \throw If the underlying mesh of \a field has no name.
4642 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4644 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4646 const MEDCouplingMesh *mesh=field->getMesh();
4648 TypeOfField type=field->getTypeOfField();
4649 std::vector<DataArrayInt *> dummy;
4650 int start=copyTinyInfoFrom(field,arr);
4651 int pos=addNewEntryIfNecessary(mesh);
4654 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4655 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4658 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4662 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4663 * of a given mesh are used as the support of the given field (a real support is not used).
4664 * Elements of the given mesh must be sorted suitable for writing to MED file.
4665 * Order of underlying mesh entities of the given field specified by \a profile parameter
4666 * is not prescribed; this method permutes field values to have them sorted by element
4667 * type as required for writing to MED file. A new profile is added only if no equal
4668 * profile is missing.
4669 * \param [in] field - the field to add to \a this. The field double values are ignored.
4670 * \param [in] arrOfVals - the values of the field \a field used.
4671 * \param [in] mesh - the supporting mesh of \a field.
4672 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4673 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
4674 * \param [in,out] glob - the global data where profiles and localization present in
4675 * \a field, if any, are added.
4676 * \throw If either \a field or \a mesh or \a profile has an empty name.
4677 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4678 * \throw If the data array of \a field is not set.
4679 * \throw If \a this->_arr is already allocated but has different number of components
4681 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4682 * \sa setFieldNoProfileSBT()
4684 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4687 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
4688 if(!arrOfVals || !arrOfVals->isAllocated())
4689 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
4690 TypeOfField type=field->getTypeOfField();
4691 std::vector<DataArrayInt *> idsInPflPerType;
4692 std::vector<DataArrayInt *> idsPerType;
4693 std::vector<int> code,code2;
4694 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
4697 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4698 std::vector< MCAuto<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
4699 std::vector< MCAuto<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin());
4700 std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
4702 MCAuto<MEDCouplingFieldDouble> field2=field->clone(false);
4703 int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
4704 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4706 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4707 throw INTERP_KERNEL::Exception(oss.str());
4710 int start=copyTinyInfoFrom(field,arrOfVals);
4711 code2=m->getDistributionOfTypes();
4713 int pos=addNewEntryIfNecessary(m);
4714 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4718 if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
4719 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
4720 std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
4721 std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
4722 int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
4723 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4725 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4726 throw INTERP_KERNEL::Exception(oss.str());
4728 int start=copyTinyInfoFrom(field,arrOfVals);
4729 int pos=addNewEntryIfNecessary(m);
4730 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4735 * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
4737 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
4739 if(_nb_of_tuples_to_be_allocated>=0)
4740 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 !");
4741 DataArray *arr(getOrCreateAndGetArray());
4742 arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
4743 _nb_of_tuples_to_be_allocated=-3;
4747 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4748 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4749 * larger by the size of \a field. Returns an id of the first not filled
4750 * tuple of \a this->_arr.
4751 * \param [in] field - the field to copy the info on components and the name from.
4752 * \return int - the id of first not initialized tuple of \a this->_arr.
4753 * \throw If the name of \a field is empty.
4754 * \throw If the data array of \a field is not set.
4755 * \throw If \a this->_arr is already allocated but has different number of components
4758 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
4761 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4762 std::string name(field->getName());
4763 setName(name.c_str());
4764 setDtUnit(field->getTimeUnit());
4766 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4768 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4769 if(!arr->isAllocated())
4770 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
4771 _dt=field->getTime(_iteration,_order);
4772 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4773 if(!getOrCreateAndGetArray()->isAllocated())
4775 allocNotFromFile(arr->getNumberOfTuples());
4780 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4781 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4782 getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
4783 _nb_of_tuples_to_be_allocated=-3;
4784 return oldNbOfTuples;
4789 * Returns number of components in \a this field
4790 * \return int - the number of components.
4792 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4794 return getOrCreateAndGetArray()->getNumberOfComponents();
4798 * Change info on components in \a this.
4799 * \throw If size of \a infos is not equal to the number of components already in \a this.
4801 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
4803 DataArray *arr=getOrCreateAndGetArray();
4804 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
4808 * Returns info on components of \a this field.
4809 * \return const std::vector<std::string>& - a sequence of strings each being an
4810 * information on _i_-th component.
4812 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
4814 const DataArray *arr=getOrCreateAndGetArray();
4815 return arr->getInfoOnComponents();
4819 * Returns a mutable info on components of \a this field.
4820 * \return std::vector<std::string>& - a sequence of strings each being an
4821 * information on _i_-th component.
4823 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
4825 DataArray *arr=getOrCreateAndGetArray();
4826 return arr->getInfoOnComponents();
4829 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const
4831 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4833 const MEDFileFieldPerMesh *fpm(*it);
4836 if(fpm->presenceOfMultiDiscPerGeoType())
4842 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh(const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4844 static const char MSG0[]="MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is too complex to be able to be extracted with \"field\" method ! Call getFieldOnMeshAtLevel method instead to deal with complexity !";
4845 if(_field_per_mesh.empty())
4846 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is empty ! Nothing to extract !");
4847 if(_field_per_mesh.size()>1)
4848 throw INTERP_KERNEL::Exception(MSG0);
4849 if(_field_per_mesh[0].isNull())
4850 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is inconsistent !");
4851 const MEDFileFieldPerMesh *pm(_field_per_mesh[0]);
4852 std::set<TypeOfField> types;
4853 pm->fillTypesOfFieldAvailable(types);
4855 throw INTERP_KERNEL::Exception(MSG0);
4856 TypeOfField type(*types.begin());
4857 int meshDimRelToMax(0);
4862 int myDim(std::numeric_limits<int>::max());
4863 bool isUnique(pm->isUniqueLevel(myDim));
4865 throw INTERP_KERNEL::Exception(MSG0);
4866 meshDimRelToMax=myDim-mesh->getMeshDimension();
4867 if(meshDimRelToMax>0)
4868 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the mesh attached to field is not compatible with the field !");
4870 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,0/*renumPol*/,glob,mesh,arrOut,nasc);
4874 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4875 * \param [in] type - a spatial discretization of the new field.
4876 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4877 * \param [in] mName - a name of the supporting mesh.
4878 * \param [in] renumPol - specifies how to permute values of the result field according to
4879 * the optional numbers of cells and nodes, if any. The valid values are
4880 * - 0 - do not permute.
4881 * - 1 - permute cells.
4882 * - 2 - permute nodes.
4883 * - 3 - permute cells and nodes.
4885 * \param [in] glob - the global data storing profiles and localization.
4886 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4887 * caller is to delete this field using decrRef() as it is no more needed.
4888 * \throw If the MED file is not readable.
4889 * \throw If there is no mesh named \a mName in the MED file.
4890 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4891 * \throw If no field of \a this is lying on the mesh \a mName.
4892 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4894 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4896 MCAuto<MEDFileMesh> mm;
4898 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4900 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4901 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4905 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4906 * \param [in] type - a spatial discretization of the new field.
4907 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4908 * \param [in] renumPol - specifies how to permute values of the result field according to
4909 * the optional numbers of cells and nodes, if any. The valid values are
4910 * - 0 - do not permute.
4911 * - 1 - permute cells.
4912 * - 2 - permute nodes.
4913 * - 3 - permute cells and nodes.
4915 * \param [in] glob - the global data storing profiles and localization.
4916 * \param [in] mesh - the supporting mesh.
4917 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4918 * caller is to delete this field using decrRef() as it is no more needed.
4919 * \throw If the MED file is not readable.
4920 * \throw If no field of \a this is lying on \a mesh.
4921 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4922 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4924 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4926 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax,false));
4927 const DataArrayInt *d(mesh->getNumberFieldAtLevel(meshDimRelToMax)),*e(mesh->getNumberFieldAtLevel(1));
4928 if(meshDimRelToMax==1)
4929 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
4930 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
4934 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
4936 * \param [in] type - a spatial discretization of the new field.
4937 * \param [in] mName - a name of the supporting mesh.
4938 * \param [in] renumPol - specifies how to permute values of the result field according to
4939 * the optional numbers of cells and nodes, if any. The valid values are
4940 * - 0 - do not permute.
4941 * - 1 - permute cells.
4942 * - 2 - permute nodes.
4943 * - 3 - permute cells and nodes.
4945 * \param [in] glob - the global data storing profiles and localization.
4946 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4947 * caller is to delete this field using decrRef() as it is no more needed.
4948 * \throw If the MED file is not readable.
4949 * \throw If there is no mesh named \a mName in the MED file.
4950 * \throw If there are no mesh entities in the mesh.
4951 * \throw If no field values of the given \a type are available.
4953 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4955 MCAuto<MEDFileMesh> mm;
4957 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4959 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4960 int absDim=getDimension();
4961 int meshDimRelToMax=absDim-mm->getMeshDimension();
4962 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4966 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4967 * \param [in] type - a spatial discretization of the new field.
4968 * \param [in] renumPol - specifies how to permute values of the result field according to
4969 * the optional numbers of cells and nodes, if any. The valid values are
4970 * - 0 - do not permute.
4971 * - 1 - permute cells.
4972 * - 2 - permute nodes.
4973 * - 3 - permute cells and nodes.
4975 * \param [in] glob - the global data storing profiles and localization.
4976 * \param [in] mesh - the supporting mesh.
4977 * \param [in] cellRenum - the cell numbers array used for permutation of the result
4978 * field according to \a renumPol.
4979 * \param [in] nodeRenum - the node numbers array used for permutation of the result
4980 * field according to \a renumPol.
4981 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4982 * caller is to delete this field using decrRef() as it is no more needed.
4983 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4984 * \throw If no field of \a this is lying on \a mesh.
4985 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4987 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, const DataArrayInt *cellRenum, const DataArrayInt *nodeRenum, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4989 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
4990 int meshId=getMeshIdFromMeshName(mesh->getName());
4992 MCAuto<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
4997 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5004 throw INTERP_KERNEL::Exception(msg1);
5005 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5008 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
5010 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5011 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
5012 throw INTERP_KERNEL::Exception(oss.str());
5014 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
5015 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
5016 std::vector<DataArray *> arrOut2(1,arrOut);
5017 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
5018 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
5019 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
5026 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5028 throw INTERP_KERNEL::Exception(msg1);
5031 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
5033 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5034 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
5035 throw INTERP_KERNEL::Exception(oss.str());
5037 MCAuto<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
5038 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
5039 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
5040 ret->renumberNodes(nodeRenumSafe->getConstPointer());
5045 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
5050 * Returns values and a profile of the field of a given type lying on a given support.
5051 * \param [in] type - a spatial discretization of the field.
5052 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5053 * \param [in] mesh - the supporting mesh.
5054 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
5055 * field of interest lies on. If the field lies on all entities of the given
5056 * dimension, all ids in \a pfl are zero. The caller is to delete this array
5057 * using decrRef() as it is no more needed.
5058 * \param [in] glob - the global data storing profiles and localization.
5059 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
5060 * field. The caller is to delete this array using decrRef() as it is no more needed.
5061 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
5062 * \throw If no field of \a this is lying on \a mesh.
5063 * \throw If no field values of the given \a type are available.
5065 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
5067 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
5068 int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
5069 MCAuto<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
5070 ret->setName(nasc.getName().c_str());
5074 //= MEDFileField1TSWithoutSDA
5077 * Throws if a given value is not a valid (non-extended) relative dimension.
5078 * \param [in] meshDimRelToMax - the relative dimension value.
5079 * \throw If \a meshDimRelToMax > 0.
5081 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
5083 if(meshDimRelToMax>0)
5084 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
5088 * Checks if elements of a given mesh are in the order suitable for writing
5089 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
5090 * vector describing types of elements and their number.
5091 * \param [in] mesh - the mesh to check.
5092 * \return std::vector<int> - a vector holding for each element type (1) item of
5093 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
5094 * These values are in full-interlace mode.
5095 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
5097 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
5100 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
5101 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
5102 int nbOfTypes=geoTypes.size();
5103 std::vector<int> code(3*nbOfTypes);
5104 MCAuto<DataArrayInt> arr1=DataArrayInt::New();
5105 arr1->alloc(nbOfTypes,1);
5106 int *arrPtr=arr1->getPointer();
5107 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
5108 for(int i=0;i<nbOfTypes;i++,it++)
5109 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
5110 MCAuto<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
5111 const int *arrPtr2=arr2->getConstPointer();
5113 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
5116 int nbCells=mesh->getNumberOfCellsWithType(*it);
5117 code[3*pos]=(int)(*it);
5118 code[3*pos+1]=nbCells;
5119 code[3*pos+2]=-1;//no profiles
5121 std::vector<const DataArrayInt *> idsPerType;//no profiles
5122 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
5126 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
5131 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5133 return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5137 * Returns all attributes and values of parts of \a this field lying on a given mesh.
5138 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
5139 * item of every of returned sequences refers to the _i_-th part of \a this field.
5140 * Thus all sequences returned by this method are of the same length equal to number
5141 * of different types of supporting entities.<br>
5142 * A field part can include sub-parts with several different spatial discretizations,
5143 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
5144 * for example. Hence, some of the returned sequences contains nested sequences, and an item
5145 * of a nested sequence corresponds to a type of spatial discretization.<br>
5146 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
5147 * The overhead is due to selecting values into new instances of DataArrayDouble.
5148 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
5149 * for the case with only one underlying mesh. (Actually, the number of meshes is
5150 * not checked if \a mname == \c NULL).
5151 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
5152 * a field part is returned.
5153 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
5154 * A field part can include sub-parts with several different spatial discretizations,
5155 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and
5156 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT" for example.
5157 * This sequence is of the same length as \a types.
5158 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
5159 * discretization. A profile name can be empty.
5160 * Length of this and of nested sequences is the same as that of \a typesF.
5161 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
5162 * discretization. A localization name can be empty.
5163 * Length of this and of nested sequences is the same as that of \a typesF.
5164 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
5165 * per each type of spatial discretization within one mesh entity type.
5166 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
5167 * Length of this and of nested sequences is the same as that of \a typesF.
5168 * \throw If no field is lying on \a mname.
5170 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
5174 meshId=getMeshIdFromMeshName(mname);
5176 if(_field_per_mesh.empty())
5177 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
5178 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
5179 int nbOfRet=ret0.size();
5180 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
5181 for(int i=0;i<nbOfRet;i++)
5183 const std::vector< std::pair<int,int> >& p=ret0[i];
5184 int nbOfRet1=p.size();
5185 ret[i].resize(nbOfRet1);
5186 for(int j=0;j<nbOfRet1;j++)
5188 DataArrayDouble *tmp=_arr->selectByTupleIdSafeSlice(p[j].first,p[j].second,1);
5195 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
5200 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
5202 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
5203 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5204 ret->deepCpyLeavesFrom(*this);
5205 const DataArrayDouble *arr(_arr);
5208 MCAuto<DataArrayInt> arr2(arr->convertToIntArr());
5209 ret->setArray(arr2);
5215 * Returns a pointer to the underground DataArrayDouble instance and a
5216 * sequence describing parameters of a support of each part of \a this field. The
5217 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5218 * direct access to the field values. This method is intended for the field lying on one
5220 * \param [in,out] entries - the sequence describing parameters of a support of each
5221 * part of \a this field. Each item of this sequence consists of two parts. The
5222 * first part describes a type of mesh entity and an id of discretization of a
5223 * current field part. The second part describes a range of values [begin,end)
5224 * within the returned array relating to the current field part.
5225 * \return DataArrayDouble * - the pointer to the field values array.
5226 * \throw If the number of underlying meshes is not equal to 1.
5227 * \throw If no field values are available.
5228 * \sa getUndergroundDataArray()
5230 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5232 if(_field_per_mesh.size()!=1)
5233 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5234 if(_field_per_mesh[0]==0)
5235 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5236 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5237 return getUndergroundDataArrayTemplate();
5241 * Returns a pointer to the underground DataArrayDouble instance and a
5242 * sequence describing parameters of a support of each part of \a this field. The
5243 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5244 * direct access to the field values. This method is intended for the field lying on one
5246 * \param [in,out] entries - the sequence describing parameters of a support of each
5247 * part of \a this field. Each item of this sequence consists of two parts. The
5248 * first part describes a type of mesh entity and an id of discretization of a
5249 * current field part. The second part describes a range of values [begin,end)
5250 * within the returned array relating to the current field part.
5251 * \return DataArrayDouble * - the pointer to the field values array.
5252 * \throw If the number of underlying meshes is not equal to 1.
5253 * \throw If no field values are available.
5254 * \sa getUndergroundDataArray()
5256 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5258 return getUndergroundDataArrayDoubleExt(entries);
5261 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<double>(fieldName,csit,iteration,order)
5263 DataArrayDouble *arr(getOrCreateAndGetArrayTemplate());
5264 arr->setInfoAndChangeNbOfCompo(infos);
5267 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<double>()
5271 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
5273 MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
5274 ret->deepCpyLeavesFrom(*this);
5278 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCopy() const
5280 MCAuto<MEDFileField1TSWithoutSDA> ret=static_cast<MEDFileField1TSWithoutSDA *>(shallowCpy());
5281 if((const DataArrayDouble *)_arr)
5282 ret->_arr=_arr->deepCopy();
5286 //= MEDFileIntField1TSWithoutSDA
5288 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5290 return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5293 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<int>()
5297 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order,
5298 const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<int>(fieldName,csit,iteration,order)
5300 DataArrayInt *arr(getOrCreateAndGetArrayTemplate());
5301 arr->setInfoAndChangeNbOfCompo(infos);
5304 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
5309 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const
5311 MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
5312 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5313 ret->deepCpyLeavesFrom(*this);
5314 const DataArrayInt *arr(_arr);
5317 MCAuto<DataArrayDouble> arr2(arr->convertToDblArr());
5318 ret->setArray(arr2);
5324 * Returns a pointer to the underground DataArrayInt instance and a
5325 * sequence describing parameters of a support of each part of \a this field. The
5326 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5327 * direct access to the field values. This method is intended for the field lying on one
5329 * \param [in,out] entries - the sequence describing parameters of a support of each
5330 * part of \a this field. Each item of this sequence consists of two parts. The
5331 * first part describes a type of mesh entity and an id of discretization of a
5332 * current field part. The second part describes a range of values [begin,end)
5333 * within the returned array relating to the current field part.
5334 * \return DataArrayInt * - the pointer to the field values array.
5335 * \throw If the number of underlying meshes is not equal to 1.
5336 * \throw If no field values are available.
5337 * \sa getUndergroundDataArray()
5339 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5341 return getUndergroundDataArrayIntExt(entries);
5345 * Returns a pointer to the underground DataArrayInt instance and a
5346 * sequence describing parameters of a support of each part of \a this field. The
5347 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5348 * direct access to the field values. This method is intended for the field lying on one
5350 * \param [in,out] entries - the sequence describing parameters of a support of each
5351 * part of \a this field. Each item of this sequence consists of two parts. The
5352 * first part describes a type of mesh entity and an id of discretization of a
5353 * current field part. The second part describes a range of values [begin,end)
5354 * within the returned array relating to the current field part.
5355 * \return DataArrayInt * - the pointer to the field values array.
5356 * \throw If the number of underlying meshes is not equal to 1.
5357 * \throw If no field values are available.
5358 * \sa getUndergroundDataArray()
5360 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5362 if(_field_per_mesh.size()!=1)
5363 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5364 if(_field_per_mesh[0]==0)
5365 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5366 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5367 return getUndergroundDataArrayTemplate();
5370 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5372 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5373 ret->deepCpyLeavesFrom(*this);
5377 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCopy() const
5379 MCAuto<MEDFileIntField1TSWithoutSDA> ret=static_cast<MEDFileIntField1TSWithoutSDA *>(shallowCpy());
5380 if((const DataArrayInt *)_arr)
5381 ret->_arr=_arr->deepCopy();
5385 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5389 //= MEDFileAnyTypeField1TS
5391 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
5393 med_field_type typcha;
5395 std::vector<std::string> infos;
5396 std::string dtunit,fieldName;
5397 LocateField2(fid,0,true,fieldName,typcha,infos,dtunit);
5398 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5403 ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5408 ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5413 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fid) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of the first field is not in [MED_FLOAT64, MED_INT32] !";
5414 throw INTERP_KERNEL::Exception(oss.str());
5417 ret->setDtUnit(dtunit.c_str());
5418 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5420 med_int numdt,numit;
5422 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5423 ret->setTime(numdt,numit,dt);
5426 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5428 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5432 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
5433 try:MEDFileFieldGlobsReal(fid)
5435 _content=BuildContentFrom(fid,loadAll,ms);
5438 catch(INTERP_KERNEL::Exception& e)
5443 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5445 med_field_type typcha;
5446 std::vector<std::string> infos;
5449 int nbSteps=LocateField(fid,fieldName,iii,typcha,infos,dtunit);
5450 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5455 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5460 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5465 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
5466 throw INTERP_KERNEL::Exception(oss.str());
5469 ret->setDtUnit(dtunit.c_str());
5470 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5474 std::ostringstream oss; oss << "MEDFileField1TS(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5475 throw INTERP_KERNEL::Exception(oss.str());
5478 med_int numdt,numit;
5480 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5481 ret->setTime(numdt,numit,dt);
5484 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5486 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5490 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5491 try:MEDFileFieldGlobsReal(fid)
5493 _content=BuildContentFrom(fid,fieldName,loadAll,ms);
5496 catch(INTERP_KERNEL::Exception& e)
5501 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c)
5504 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5505 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5507 MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
5508 ret->_content=c; c->incrRef();
5511 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5513 MCAuto<MEDFileIntField1TS> ret(MEDFileIntField1TS::New());
5514 ret->_content=c; c->incrRef();
5517 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5520 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, med_idt fid)
5522 MEDFileAnyTypeField1TS *ret(BuildNewInstanceFromContent(c));
5523 ret->setFileName(FileNameFromFID(fid));
5527 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
5529 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5530 return New(fid,loadAll);
5533 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, bool loadAll)
5535 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
5536 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5537 ret->loadGlobals(fid);
5541 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
5543 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5544 return New(fid,fieldName,loadAll);
5547 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
5549 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0));
5550 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5551 ret->loadGlobals(fid);
5555 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
5557 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5558 return New(fid,fieldName,iteration,order,loadAll);
5561 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
5563 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0));
5564 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5565 ret->loadGlobals(fid);
5569 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5571 med_field_type typcha;
5572 std::vector<std::string> infos;
5575 int nbOfStep2(LocateField(fid,fieldName,iii,typcha,infos,dtunit));
5576 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5581 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5586 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5591 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fid,fieldName,iteration,order) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
5592 throw INTERP_KERNEL::Exception(oss.str());
5595 ret->setDtUnit(dtunit.c_str());
5596 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5599 std::vector< std::pair<int,int> > dtits(nbOfStep2);
5600 for(int i=0;i<nbOfStep2 && !found;i++)
5602 med_int numdt,numit;
5604 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt));
5605 if(numdt==iteration && numit==order)
5611 dtits[i]=std::pair<int,int>(numdt,numit);
5615 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available iterations are : ";
5616 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5617 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5618 throw INTERP_KERNEL::Exception(oss.str());
5621 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5623 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5627 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5628 try:MEDFileFieldGlobsReal(fid)
5630 _content=BuildContentFrom(fid,fieldName,iteration,order,loadAll,ms);
5633 catch(INTERP_KERNEL::Exception& e)
5639 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5640 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5642 * \warning this is a shallow copy constructor
5644 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5646 if(!shallowCopyOfContent)
5648 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5649 otherPtr->incrRef();
5650 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5654 _content=other.shallowCpy();
5658 int MEDFileAnyTypeField1TS::LocateField2(med_idt fid, int fieldIdCFormat, bool checkFieldId, std::string& fieldName, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
5662 int nbFields=MEDnField(fid);
5663 if(fieldIdCFormat>=nbFields)
5665 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << FileNameFromFID(fid) << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5666 throw INTERP_KERNEL::Exception(oss.str());
5669 int ncomp(MEDfieldnComponent(fid,fieldIdCFormat+1));
5670 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5671 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5672 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5673 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5674 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5677 MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep));
5678 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5679 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5680 infos.clear(); infos.resize(ncomp);
5681 for(int j=0;j<ncomp;j++)
5682 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5687 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5690 * \return in case of success the number of time steps available for the field with name \a fieldName.
5692 int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const std::string& fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
5694 int nbFields=MEDnField(fid);
5696 std::vector<std::string> fns(nbFields);
5698 for(int i=0;i<nbFields && !found;i++)
5701 nbOfStep2=LocateField2(fid,i,false,tmp,typcha,infos,dtunitOut);
5703 found=(tmp==fieldName);
5709 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available fields are : ";
5710 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5711 oss << "\"" << *it << "\" ";
5712 throw INTERP_KERNEL::Exception(oss.str());
5718 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5719 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5720 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5721 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5722 * to keep a valid instance.
5723 * 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.
5724 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5725 * 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.
5727 * \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.
5728 * \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.
5729 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5730 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5731 * \param [in] newLocName is the new localization name.
5732 * \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.
5733 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5735 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
5737 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5738 std::string oldPflName=disc->getProfile();
5739 std::vector<std::string> vv=getPflsReallyUsedMulti();
5740 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5741 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5743 disc->setProfile(newPflName);
5744 DataArrayInt *pfl=getProfile(oldPflName.c_str());
5745 pfl->setName(newPflName);
5749 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5750 throw INTERP_KERNEL::Exception(oss.str());
5755 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5756 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5757 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5758 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5759 * to keep a valid instance.
5760 * 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.
5761 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5762 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5763 * 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.
5765 * \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.
5766 * \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.
5767 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5768 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5769 * \param [in] newLocName is the new localization name.
5770 * \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.
5771 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
5773 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
5775 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5776 std::string oldLocName=disc->getLocalization();
5777 std::vector<std::string> vv=getLocsReallyUsedMulti();
5778 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
5779 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
5781 disc->setLocalization(newLocName);
5782 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
5783 loc.setName(newLocName);
5787 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
5788 throw INTERP_KERNEL::Exception(oss.str());
5792 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
5794 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5796 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
5800 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
5802 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5804 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
5809 * This method alloc the arrays and load potentially huge arrays contained in this field.
5810 * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
5811 * This method can be also called to refresh or reinit values from a file.
5813 * \throw If the fileName is not set or points to a non readable MED file.
5814 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5816 void MEDFileAnyTypeField1TS::loadArrays()
5818 if(getFileName().empty())
5819 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
5820 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
5821 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
5825 * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
5826 * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
5827 * this method does not throw if \a this does not come from file read.
5829 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
5831 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
5833 if(!getFileName().empty())
5835 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
5836 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
5841 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
5842 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
5843 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
5845 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
5847 void MEDFileAnyTypeField1TS::unloadArrays()
5849 contentNotNullBase()->unloadArrays();
5853 * 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.
5854 * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
5855 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
5857 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5859 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
5861 if(!getFileName().empty())
5862 contentNotNullBase()->unloadArrays();
5865 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
5867 int nbComp(getNumberOfComponents());
5868 INTERP_KERNEL::AutoPtr<char> comp(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
5869 INTERP_KERNEL::AutoPtr<char> unit(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
5870 for(int i=0;i<nbComp;i++)
5872 std::string info=getInfo()[i];
5874 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
5875 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
5876 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
5878 if(getName().empty())
5879 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
5880 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
5881 writeGlobals(fid,*this);
5882 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
5885 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
5887 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
5890 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
5892 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
5893 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
5898 * Returns a string describing \a this field. This string is outputted
5899 * by \c print Python command.
5901 std::string MEDFileAnyTypeField1TS::simpleRepr() const
5903 std::ostringstream oss;
5904 contentNotNullBase()->simpleRepr(0,oss,-1);
5905 simpleReprGlobs(oss);
5910 * This method returns all profiles whose name is non empty used.
5911 * \b WARNING If profile is used several times it will be reported \b only \b once.
5912 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
5914 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
5916 return contentNotNullBase()->getPflsReallyUsed2();
5920 * This method returns all localizations whose name is non empty used.
5921 * \b WARNING If localization is used several times it will be reported \b only \b once.
5923 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
5925 return contentNotNullBase()->getLocsReallyUsed2();
5929 * This method returns all profiles whose name is non empty used.
5930 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
5932 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
5934 return contentNotNullBase()->getPflsReallyUsedMulti2();
5938 * This method returns all localizations whose name is non empty used.
5939 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
5941 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
5943 return contentNotNullBase()->getLocsReallyUsedMulti2();
5946 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5948 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
5951 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5953 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
5956 int MEDFileAnyTypeField1TS::getDimension() const
5958 return contentNotNullBase()->getDimension();
5961 int MEDFileAnyTypeField1TS::getIteration() const
5963 return contentNotNullBase()->getIteration();
5966 int MEDFileAnyTypeField1TS::getOrder() const
5968 return contentNotNullBase()->getOrder();
5971 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
5973 return contentNotNullBase()->getTime(iteration,order);
5976 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
5978 contentNotNullBase()->setTime(iteration,order,val);
5981 std::string MEDFileAnyTypeField1TS::getName() const
5983 return contentNotNullBase()->getName();
5986 void MEDFileAnyTypeField1TS::setName(const std::string& name)
5988 contentNotNullBase()->setName(name);
5991 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
5993 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
5996 std::string MEDFileAnyTypeField1TS::getDtUnit() const
5998 return contentNotNullBase()->getDtUnit();
6001 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
6003 contentNotNullBase()->setDtUnit(dtUnit);
6006 std::string MEDFileAnyTypeField1TS::getMeshName() const
6008 return contentNotNullBase()->getMeshName();
6011 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
6013 contentNotNullBase()->setMeshName(newMeshName);
6016 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
6018 return contentNotNullBase()->changeMeshNames(modifTab);
6021 int MEDFileAnyTypeField1TS::getMeshIteration() const
6023 return contentNotNullBase()->getMeshIteration();
6026 int MEDFileAnyTypeField1TS::getMeshOrder() const
6028 return contentNotNullBase()->getMeshOrder();
6031 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
6033 return contentNotNullBase()->getNumberOfComponents();
6036 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
6038 return contentNotNullBase()->isDealingTS(iteration,order);
6041 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
6043 return contentNotNullBase()->getDtIt();
6046 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
6048 contentNotNullBase()->fillIteration(p);
6051 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
6053 contentNotNullBase()->fillTypesOfFieldAvailable(types);
6056 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
6058 contentNotNullBase()->setInfo(infos);
6061 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
6063 return contentNotNullBase()->getInfo();
6065 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
6067 return contentNotNullBase()->getInfo();
6070 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
6072 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
6075 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
6077 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6080 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
6082 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6085 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
6087 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
6090 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
6092 return contentNotNullBase()->getTypesOfFieldAvailable();
6095 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,
6096 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6098 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
6102 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
6103 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
6104 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
6106 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
6108 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6110 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
6111 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
6112 std::size_t sz(contentsSplit.size());
6113 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6114 for(std::size_t i=0;i<sz;i++)
6116 ret[i]=shallowCpy();
6117 ret[i]->_content=contentsSplit[i];
6123 * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
6124 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6126 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
6128 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6130 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
6131 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
6132 std::size_t sz(contentsSplit.size());
6133 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6134 for(std::size_t i=0;i<sz;i++)
6136 ret[i]=shallowCpy();
6137 ret[i]->_content=contentsSplit[i];
6143 * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this.
6144 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6146 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const
6148 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6150 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !");
6151 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
6152 std::size_t sz(contentsSplit.size());
6153 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6154 for(std::size_t i=0;i<sz;i++)
6156 ret[i]=shallowCpy();
6157 ret[i]->_content=contentsSplit[i];
6162 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCopy() const
6164 MCAuto<MEDFileAnyTypeField1TS> ret=shallowCpy();
6165 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
6166 ret->_content=_content->deepCopy();
6167 ret->deepCpyGlobs(*this);
6171 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
6173 return contentNotNullBase()->copyTinyInfoFrom(field,arr);
6179 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6180 * the first field that has been read from a specified MED file.
6181 * \param [in] fileName - the name of the MED file to read.
6182 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6183 * is to delete this field using decrRef() as it is no more needed.
6184 * \throw If reading the file fails.
6186 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll)
6188 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6189 return New(fid,loadAll);
6192 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, bool loadAll)
6194 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,loadAll,0));
6195 ret->contentNotNull();
6200 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6201 * a given field that has been read from a specified MED file.
6202 * \param [in] fileName - the name of the MED file to read.
6203 * \param [in] fieldName - the name of the field to read.
6204 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6205 * is to delete this field using decrRef() as it is no more needed.
6206 * \throw If reading the file fails.
6207 * \throw If there is no field named \a fieldName in the file.
6209 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6211 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6212 return New(fid,fieldName,loadAll);
6215 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
6217 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,fieldName,loadAll,0));
6218 ret->contentNotNull();
6223 * Returns a new instance of MEDFileField1TS holding data of a given time step of
6224 * a given field that has been read from a specified MED file.
6225 * \param [in] fileName - the name of the MED file to read.
6226 * \param [in] fieldName - the name of the field to read.
6227 * \param [in] iteration - the iteration number of a required time step.
6228 * \param [in] order - the iteration order number of required time step.
6229 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6230 * is to delete this field using decrRef() as it is no more needed.
6231 * \throw If reading the file fails.
6232 * \throw If there is no field named \a fieldName in the file.
6233 * \throw If the required time step is missing from the file.
6235 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6237 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6238 return New(fid,fieldName,iteration,order,loadAll);
6241 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
6243 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,fieldName,iteration,order,loadAll,0));
6244 ret->contentNotNull();
6249 * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6250 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6252 * Returns a new instance of MEDFileField1TS holding either a shallow copy
6253 * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
6254 * \warning this is a shallow copy constructor
6255 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
6256 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
6257 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6258 * is to delete this field using decrRef() as it is no more needed.
6260 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6262 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(other,shallowCopyOfContent));
6263 ret->contentNotNull();
6268 * Returns a new empty instance of MEDFileField1TS.
6269 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6270 * is to delete this field using decrRef() as it is no more needed.
6272 MEDFileField1TS *MEDFileField1TS::New()
6274 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS);
6275 ret->contentNotNull();
6280 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
6281 * following the given input policy.
6283 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6284 * By default (true) the globals are deeply copied.
6285 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
6287 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
6289 MCAuto<MEDFileIntField1TS> ret;
6290 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6293 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
6295 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
6296 MCAuto<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
6297 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc));
6300 ret=MEDFileIntField1TS::New();
6302 ret->deepCpyGlobs(*this);
6304 ret->shallowCpyGlobs(*this);
6308 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const
6310 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6312 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
6313 const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
6315 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 !");
6319 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull()
6321 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6323 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
6324 MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
6326 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 !");
6330 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
6333 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
6335 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
6336 DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6338 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6339 f->setArray(arrOutC);
6342 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MCAuto<DataArray>& arr)
6345 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
6346 DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6348 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6354 * Return an extraction of \a this using \a extractDef map to specify the extraction.
6355 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
6357 * \return A new object that the caller is responsible to deallocate.
6358 * \sa MEDFileUMesh::deduceNodeSubPartFromCellSubPart , MEDFileUMesh::extractPart
6360 MEDFileField1TS *MEDFileField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
6363 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : input mesh is NULL !");
6364 MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
6365 std::vector<TypeOfField> tof(getTypesOfFieldAvailable());
6366 for(std::vector<TypeOfField>::const_iterator it0=tof.begin();it0!=tof.end();it0++)
6368 if((*it0)!=ON_NODES)
6370 std::vector<int> levs;
6371 getNonEmptyLevels(mm->getName(),levs);
6372 for(std::vector<int>::const_iterator lev=levs.begin();lev!=levs.end();lev++)
6374 std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(*lev));
6375 if(it2!=extractDef.end())
6377 MCAuto<DataArrayInt> t((*it2).second);
6379 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6380 MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_CELLS,(*lev),mm));
6381 MCAuto<MEDCouplingFieldDouble> fOut(f->buildSubPart(t));
6382 ret->setFieldNoProfileSBT(fOut);
6388 std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(1));
6389 if(it2==extractDef.end())
6390 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a NODE field and no extract array available for NODE !");
6391 MCAuto<DataArrayInt> t((*it2).second);
6393 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6394 MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_NODES,0,mm));
6395 MCAuto<MEDCouplingFieldDouble> fOut(f->deepCopy());
6396 DataArrayDouble *arr(f->getArray());
6397 MCAuto<DataArrayDouble> newArr(arr->selectByTupleIdSafe(t->begin(),t->end()));
6398 fOut->setArray(newArr);
6399 ret->setFieldNoProfileSBT(fOut);
6405 MEDFileField1TS::MEDFileField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
6406 try:MEDFileAnyTypeField1TS(fid,loadAll,ms)
6409 catch(INTERP_KERNEL::Exception& e)
6412 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6413 try:MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms)
6416 catch(INTERP_KERNEL::Exception& e)
6419 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6420 try:MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms)
6423 catch(INTERP_KERNEL::Exception& e)
6427 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6428 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6430 * \warning this is a shallow copy constructor
6432 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6433 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6436 catch(INTERP_KERNEL::Exception& e)
6439 MEDFileField1TS::MEDFileField1TS()
6441 _content=new MEDFileField1TSWithoutSDA;
6445 * This is the simplest version to fetch a field for MED structure. One drawback : if \a this is a complex field (multi spatial discretization inside a same field) this method will throw exception and more advance
6446 * method should be called (getFieldOnMeshAtLevel for example).
6447 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
6449 * \param [in] mesh - the mesh the field is lying on
6450 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6451 * caller is to delete this field using decrRef() as it is no more needed.
6453 MEDCouplingFieldDouble *MEDFileField1TS::field(const MEDFileMesh *mesh) const
6455 MCAuto<DataArray> arrOut;
6456 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
6457 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6462 * Returns a new MEDCouplingFieldDouble of a given type lying on
6463 * mesh entities of a given dimension of the first mesh in MED file. If \a this field
6464 * has not been constructed via file reading, an exception is thrown.
6465 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6466 * \param [in] type - a spatial discretization of interest.
6467 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6468 * \param [in] renumPol - specifies how to permute values of the result field according to
6469 * the optional numbers of cells and nodes, if any. The valid values are
6470 * - 0 - do not permute.
6471 * - 1 - permute cells.
6472 * - 2 - permute nodes.
6473 * - 3 - permute cells and nodes.
6475 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6476 * caller is to delete this field using decrRef() as it is no more needed.
6477 * \throw If \a this field has not been constructed via file reading.
6478 * \throw If the MED file is not readable.
6479 * \throw If there is no mesh in the MED file.
6480 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6481 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6482 * \sa getFieldOnMeshAtLevel()
6484 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6486 if(getFileName().empty())
6487 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6488 MCAuto<DataArray> arrOut;
6489 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
6490 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6495 * Returns a new MEDCouplingFieldDouble of a given type lying on
6496 * the top level cells of the first mesh in MED file. If \a this field
6497 * has not been constructed via file reading, an exception is thrown.
6498 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6499 * \param [in] type - a spatial discretization of interest.
6500 * \param [in] renumPol - specifies how to permute values of the result field according to
6501 * the optional numbers of cells and nodes, if any. The valid values are
6502 * - 0 - do not permute.
6503 * - 1 - permute cells.
6504 * - 2 - permute nodes.
6505 * - 3 - permute cells and nodes.
6507 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6508 * caller is to delete this field using decrRef() as it is no more needed.
6509 * \throw If \a this field has not been constructed via file reading.
6510 * \throw If the MED file is not readable.
6511 * \throw If there is no mesh in the MED file.
6512 * \throw If no field values of the given \a type.
6513 * \throw If no field values lying on the top level support.
6514 * \sa getFieldAtLevel()
6516 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
6518 if(getFileName().empty())
6519 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6520 MCAuto<DataArray> arrOut;
6521 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
6522 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6527 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6528 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6529 * \param [in] type - a spatial discretization of the new field.
6530 * \param [in] mesh - the supporting mesh.
6531 * \param [in] renumPol - specifies how to permute values of the result field according to
6532 * the optional numbers of cells and nodes, if any. The valid values are
6533 * - 0 - do not permute.
6534 * - 1 - permute cells.
6535 * - 2 - permute nodes.
6536 * - 3 - permute cells and nodes.
6538 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6539 * caller is to delete this field using decrRef() as it is no more needed.
6540 * \throw If no field of \a this is lying on \a mesh.
6541 * \throw If the mesh is empty.
6542 * \throw If no field values of the given \a type are available.
6543 * \sa getFieldAtLevel()
6544 * \sa getFieldOnMeshAtLevel()
6546 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
6548 MCAuto<DataArray> arrOut;
6549 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
6550 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6555 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6556 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6557 * \param [in] type - a spatial discretization of interest.
6558 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6559 * \param [in] mesh - the supporting mesh.
6560 * \param [in] renumPol - specifies how to permute values of the result field according to
6561 * the optional numbers of cells and nodes, if any. The valid values are
6562 * - 0 - do not permute.
6563 * - 1 - permute cells.
6564 * - 2 - permute nodes.
6565 * - 3 - permute cells and nodes.
6567 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6568 * caller is to delete this field using decrRef() as it is no more needed.
6569 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6570 * \throw If no field of \a this is lying on \a mesh.
6571 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6572 * \sa getFieldAtLevel()
6573 * \sa getFieldOnMeshAtLevel()
6575 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
6577 MCAuto<DataArray> arrOut;
6578 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
6579 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6584 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6585 * This method is called "Old" because in MED3 norm a field has only one meshName
6586 * attached, so this method is for readers of MED2 files. If \a this field
6587 * has not been constructed via file reading, an exception is thrown.
6588 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6589 * \param [in] type - a spatial discretization of interest.
6590 * \param [in] mName - a name of the supporting mesh.
6591 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6592 * \param [in] renumPol - specifies how to permute values of the result field according to
6593 * the optional numbers of cells and nodes, if any. The valid values are
6594 * - 0 - do not permute.
6595 * - 1 - permute cells.
6596 * - 2 - permute nodes.
6597 * - 3 - permute cells and nodes.
6599 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6600 * caller is to delete this field using decrRef() as it is no more needed.
6601 * \throw If the MED file is not readable.
6602 * \throw If there is no mesh named \a mName in the MED file.
6603 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6604 * \throw If \a this field has not been constructed via file reading.
6605 * \throw If no field of \a this is lying on the mesh named \a mName.
6606 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6607 * \sa getFieldAtLevel()
6609 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
6611 if(getFileName().empty())
6612 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6613 MCAuto<DataArray> arrOut;
6614 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull()));
6615 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6620 * Returns values and a profile of the field of a given type lying on a given support.
6621 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6622 * \param [in] type - a spatial discretization of the field.
6623 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6624 * \param [in] mesh - the supporting mesh.
6625 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6626 * field of interest lies on. If the field lies on all entities of the given
6627 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6628 * using decrRef() as it is no more needed.
6629 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6630 * field. The caller is to delete this array using decrRef() as it is no more needed.
6631 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6632 * \throw If no field of \a this is lying on \a mesh.
6633 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6635 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6637 MCAuto<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6638 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
6642 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6643 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6644 * "Sort By Type"), if not, an exception is thrown.
6645 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6646 * \param [in] field - the field to add to \a this.
6647 * \throw If the name of \a field is empty.
6648 * \throw If the data array of \a field is not set.
6649 * \throw If the data array is already allocated but has different number of components
6651 * \throw If the underlying mesh of \a field has no name.
6652 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6654 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
6657 contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
6661 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6662 * can be an aggregation of several MEDCouplingFieldDouble instances.
6663 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6664 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6667 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6668 * A new profile is added only if no equal profile is missing.
6669 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6670 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
6671 * \param [in] mesh - the supporting mesh of \a field.
6672 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6673 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6674 * \throw If either \a field or \a mesh or \a profile has an empty name.
6675 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6676 * \throw If the data array of \a field is not set.
6677 * \throw If the data array of \a this is already allocated but has different number of
6678 * components than \a field.
6679 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6680 * \sa setFieldNoProfileSBT()
6682 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6685 contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6688 MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const
6690 return new MEDFileField1TS(*this);
6693 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const
6695 return contentNotNull()->getUndergroundDataArrayTemplate();
6698 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
6700 return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
6703 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6704 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6706 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6709 //= MEDFileIntField1TS
6711 MEDFileIntField1TS *MEDFileIntField1TS::New()
6713 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS);
6714 ret->contentNotNull();
6718 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll)
6720 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6721 return MEDFileIntField1TS::New(fid,loadAll);
6724 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, bool loadAll)
6726 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,loadAll,0));
6727 ret->contentNotNull();
6731 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6733 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6734 return MEDFileIntField1TS::New(fid,fieldName,loadAll);
6737 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
6739 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,loadAll,0));
6740 ret->contentNotNull();
6744 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6746 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6747 return MEDFileIntField1TS::New(fid,fieldName,iteration,order,loadAll);
6750 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
6752 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,iteration,order,loadAll,0));
6753 ret->contentNotNull();
6757 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6759 MCAuto<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6760 ret->contentNotNull();
6764 MEDFileIntField1TS::MEDFileIntField1TS()
6766 _content=new MEDFileIntField1TSWithoutSDA;
6769 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
6770 try:MEDFileAnyTypeField1TS(fid,loadAll,ms)
6773 catch(INTERP_KERNEL::Exception& e)
6776 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6777 try:MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms)
6780 catch(INTERP_KERNEL::Exception& e)
6783 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6784 try:MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms)
6787 catch(INTERP_KERNEL::Exception& e)
6791 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6792 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6794 * \warning this is a shallow copy constructor
6796 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6800 MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const
6802 return new MEDFileIntField1TS(*this);
6806 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
6807 * following the given input policy.
6809 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6810 * By default (true) the globals are deeply copied.
6811 * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
6813 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const
6815 MCAuto<MEDFileField1TS> ret;
6816 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6819 const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
6821 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
6822 MCAuto<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
6823 ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc));
6826 ret=MEDFileField1TS::New();
6828 ret->deepCpyGlobs(*this);
6830 ret->shallowCpyGlobs(*this);
6835 * Adds a MEDCouplingFieldInt to \a this. The underlying mesh of the given field is
6836 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6837 * "Sort By Type"), if not, an exception is thrown.
6838 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6839 * \param [in] field - the field to add to \a this.
6840 * \throw If the name of \a field is empty.
6841 * \throw If the data array of \a field is not set.
6842 * \throw If the data array is already allocated but has different number of components
6844 * \throw If the underlying mesh of \a field has no name.
6845 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6847 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldInt *field)
6849 MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
6851 contentNotNull()->setFieldNoProfileSBT(field2,field->getArray(),*this,*contentNotNull());
6855 * Adds a MEDCouplingFieldInt to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6856 * can be an aggregation of several MEDCouplingFieldDouble instances.
6857 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6858 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6861 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6862 * A new profile is added only if no equal profile is missing.
6863 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6864 * \param [in] field - the field to add to \a this.
6865 * \param [in] mesh - the supporting mesh of \a field.
6866 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6867 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6868 * \throw If either \a field or \a mesh or \a profile has an empty name.
6869 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6870 * \throw If the data array of \a field is not set.
6871 * \throw If the data array of \a this is already allocated but has different number of
6872 * components than \a field.
6873 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6874 * \sa setFieldNoProfileSBT()
6876 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6878 MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
6880 contentNotNull()->setFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6883 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const
6885 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6887 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
6888 const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
6890 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 !");
6894 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6896 if(getFileName().empty())
6897 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6898 MCAuto<DataArray> arrOut;
6899 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
6900 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
6904 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MCAuto<DataArray>& arr)
6907 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
6908 DataArrayInt *arrC(dynamic_cast<DataArrayInt *>((DataArray *)arr));
6910 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
6915 MCAuto<MEDCouplingFieldInt> MEDFileIntField1TS::SetDataArrayDoubleInIntField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
6918 double t0(f->getTime(t1,t2));
6919 MCAuto<DataArrayInt> arr2(DynamicCastSafe<DataArray,DataArrayInt>(arr));
6920 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
6921 MCAuto<MEDCouplingFieldInt> ret(MEDCouplingFieldInt::New(*ft));
6922 ret->setTime(t0,t1,t2); ret->setArray(arr2);
6926 MCAuto<MEDCouplingFieldDouble> MEDFileIntField1TS::ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f)
6929 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ConvertFieldIntToFieldDouble : null input field !");
6931 double t0(f->getTime(t1,t2));
6932 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
6933 MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(*ft));
6934 ret->setTime(t0,t1,t2);
6938 MEDFileIntField1TS *MEDFileIntField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
6940 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::extractPart : not implemented yet !");
6944 * This is the simplest version to fetch a field for MED structure. One drawback : if \a this is a complex field (multi spatial discretization inside a same field) this method will throw exception and more advance
6945 * method should be called (getFieldOnMeshAtLevel for example).
6946 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
6948 * \param [in] mesh - the mesh the field is lying on
6949 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
6950 * caller is to delete this field using decrRef() as it is no more needed.
6952 MEDCouplingFieldInt *MEDFileIntField1TS::field(const MEDFileMesh *mesh) const
6954 MCAuto<DataArray> arrOut;
6955 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
6956 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
6961 * Returns a new MEDCouplingFieldInt of a given type lying on
6962 * the top level cells of the first mesh in MED file. If \a this field
6963 * has not been constructed via file reading, an exception is thrown.
6964 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6965 * \param [in] type - a spatial discretization of interest.
6966 * \param [in] renumPol - specifies how to permute values of the result field according to
6967 * the optional numbers of cells and nodes, if any. The valid values are
6968 * - 0 - do not permute.
6969 * - 1 - permute cells.
6970 * - 2 - permute nodes.
6971 * - 3 - permute cells and nodes.
6973 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
6974 * caller is to delete this field using decrRef() as it is no more needed.
6975 * \throw If \a this field has not been constructed via file reading.
6976 * \throw If the MED file is not readable.
6977 * \throw If there is no mesh in the MED file.
6978 * \throw If no field values of the given \a type.
6979 * \throw If no field values lying on the top level support.
6980 * \sa getFieldAtLevel()
6982 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
6984 if(getFileName().empty())
6985 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6986 MCAuto<DataArray> arrOut;
6987 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
6988 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
6993 * Returns a new MEDCouplingFieldInt of given type lying on a given mesh.
6994 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6995 * \param [in] type - a spatial discretization of the new field.
6996 * \param [in] mesh - the supporting mesh.
6997 * \param [in] renumPol - specifies how to permute values of the result field according to
6998 * the optional numbers of cells and nodes, if any. The valid values are
6999 * - 0 - do not permute.
7000 * - 1 - permute cells.
7001 * - 2 - permute nodes.
7002 * - 3 - permute cells and nodes.
7004 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7005 * caller is to delete this field using decrRef() as it is no more needed.
7006 * \throw If no field of \a this is lying on \a mesh.
7007 * \throw If the mesh is empty.
7008 * \throw If no field values of the given \a type are available.
7009 * \sa getFieldAtLevel()
7010 * \sa getFieldOnMeshAtLevel()
7012 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
7014 MCAuto<DataArray> arrOut;
7015 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
7016 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7021 * Returns a new MEDCouplingFieldInt of a given type lying on a given support.
7022 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7023 * \param [in] type - a spatial discretization of interest.
7024 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7025 * \param [in] mesh - the supporting mesh.
7026 * \param [in] renumPol - specifies how to permute values of the result field according to
7027 * the optional numbers of cells and nodes, if any. The valid values are
7028 * - 0 - do not permute.
7029 * - 1 - permute cells.
7030 * - 2 - permute nodes.
7031 * - 3 - permute cells and nodes.
7033 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7034 * caller is to delete this field using decrRef() as it is no more needed.
7035 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7036 * \throw If no field of \a this is lying on \a mesh.
7037 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7038 * \sa getFieldAtLevel()
7039 * \sa getFieldOnMeshAtLevel()
7041 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
7043 MCAuto<DataArray> arrOut;
7044 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
7045 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7050 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
7051 * This method is called "Old" because in MED3 norm a field has only one meshName
7052 * attached, so this method is for readers of MED2 files. If \a this field
7053 * has not been constructed via file reading, an exception is thrown.
7054 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7055 * \param [in] type - a spatial discretization of interest.
7056 * \param [in] mName - a name of the supporting mesh.
7057 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7058 * \param [in] renumPol - specifies how to permute values of the result field according to
7059 * the optional numbers of cells and nodes, if any. The valid values are
7060 * - 0 - do not permute.
7061 * - 1 - permute cells.
7062 * - 2 - permute nodes.
7063 * - 3 - permute cells and nodes.
7065 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7066 * caller is to delete this field using decrRef() as it is no more needed.
7067 * \throw If the MED file is not readable.
7068 * \throw If there is no mesh named \a mName in the MED file.
7069 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7070 * \throw If \a this field has not been constructed via file reading.
7071 * \throw If no field of \a this is lying on the mesh named \a mName.
7072 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7073 * \sa getFieldAtLevel()
7075 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
7077 if(getFileName().empty())
7078 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7079 MCAuto<DataArray> arrOut;
7080 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
7081 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7086 * Returns values and a profile of the field of a given type lying on a given support.
7087 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7088 * \param [in] type - a spatial discretization of the field.
7089 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7090 * \param [in] mesh - the supporting mesh.
7091 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
7092 * field of interest lies on. If the field lies on all entities of the given
7093 * dimension, all ids in \a pfl are zero. The caller is to delete this array
7094 * using decrRef() as it is no more needed.
7095 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
7096 * field. The caller is to delete this array using decrRef() as it is no more needed.
7097 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7098 * \throw If no field of \a this is lying on \a mesh.
7099 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7101 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
7103 MCAuto<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
7104 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
7107 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull()
7109 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7111 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
7112 MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
7114 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 !");
7118 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const
7120 return contentNotNull()->getUndergroundDataArrayTemplate();
7123 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
7125 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
7129 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileFieldNameScope(fieldName)
7134 * \param [in] fieldId field id in C mode
7136 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
7138 med_field_type typcha;
7139 std::string dtunitOut;
7140 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fieldId,false,_name,typcha,_infos,dtunitOut));
7141 setDtUnit(dtunitOut.c_str());
7142 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities);
7145 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)
7146 try:MEDFileFieldNameScope(fieldName),_infos(infos)
7148 setDtUnit(dtunit.c_str());
7149 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities);
7151 catch(INTERP_KERNEL::Exception& e)
7156 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
7158 std::size_t ret(_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MCAuto<MEDFileField1TSWithoutSDA>));
7159 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7160 ret+=(*it).capacity();
7164 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
7166 std::vector<const BigMemoryObject *> ret;
7167 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7168 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
7173 * 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
7176 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
7178 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7179 ret->setInfo(_infos);
7180 int sz=(int)_time_steps.size();
7181 for(const int *id=startIds;id!=endIds;id++)
7183 if(*id>=0 && *id<sz)
7185 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
7186 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7190 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7192 ret->pushBackTimeStep(tse2);
7196 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
7197 oss << " ! Should be in [0," << sz << ") !";
7198 throw INTERP_KERNEL::Exception(oss.str());
7201 if(ret->getNumberOfTS()>0)
7202 ret->synchronizeNameScope();
7203 ret->copyNameScope(*this);
7208 * 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
7211 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
7213 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
7214 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7215 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7216 ret->setInfo(_infos);
7217 int sz=(int)_time_steps.size();
7219 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
7223 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
7224 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7228 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7230 ret->pushBackTimeStep(tse2);
7234 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
7235 oss << " ! Should be in [0," << sz << ") !";
7236 throw INTERP_KERNEL::Exception(oss.str());
7239 if(ret->getNumberOfTS()>0)
7240 ret->synchronizeNameScope();
7241 ret->copyNameScope(*this);
7245 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7248 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7249 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7251 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7254 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7255 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
7256 ids->pushBackSilent(id);
7258 return buildFromTimeStepIds(ids->begin(),ids->end());
7261 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7264 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7265 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7267 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7270 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7271 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
7272 ids->pushBackSilent(id);
7274 return buildFromTimeStepIds(ids->begin(),ids->end());
7277 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
7279 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7281 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7284 if(cur->presenceOfMultiDiscPerGeoType())
7290 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
7295 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
7300 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
7303 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7305 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
7306 if(pt->isDealingTS(iteration,order))
7309 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
7310 std::vector< std::pair<int,int> > vp=getIterations();
7311 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
7312 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
7313 throw INTERP_KERNEL::Exception(oss.str());
7316 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
7318 return *_time_steps[getTimeStepPos(iteration,order)];
7321 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
7323 return *_time_steps[getTimeStepPos(iteration,order)];
7326 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const
7328 if(_time_steps.empty())
7329 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
7330 return _time_steps[0]->getMeshName();
7333 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const std::string& newMeshName)
7335 std::string oldName(getMeshName());
7336 std::vector< std::pair<std::string,std::string> > v(1);
7337 v[0].first=oldName; v[0].second=newMeshName;
7341 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
7344 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7346 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7348 ret=cur->changeMeshNames(modifTab) || ret;
7354 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
7356 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
7358 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
7362 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
7364 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7366 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
7369 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
7370 MEDFileFieldGlobsReal& glob)
7373 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7375 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
7377 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
7382 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7384 std::string startLine(bkOffset,' ');
7385 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
7387 oss << " (" << fmtsId << ")";
7388 oss << " has the following name: \"" << _name << "\"." << std::endl;
7389 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
7390 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7392 oss << startLine << " - \"" << *it << "\"" << std::endl;
7395 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7397 std::string chapter(17,'0'+i);
7398 oss << startLine << chapter << std::endl;
7399 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7401 cur->simpleRepr(bkOffset+2,oss,i);
7403 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
7404 oss << startLine << chapter << std::endl;
7408 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
7410 std::size_t sz=_time_steps.size();
7411 std::vector< std::pair<int,int> > ret(sz);
7413 for(std::size_t i=0;i<sz;i++)
7415 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
7418 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
7422 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
7423 throw INTERP_KERNEL::Exception(oss.str());
7429 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MCAuto<MEDFileAnyTypeField1TSWithoutSDA>& tse)
7431 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
7433 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
7434 checkCoherencyOfType(tse2);
7435 if(_time_steps.empty())
7437 setName(tse2->getName().c_str());
7438 setInfo(tse2->getInfo());
7440 checkThatComponentsMatch(tse2->getInfo());
7441 if(getDtUnit().empty() && !tse->getDtUnit().empty())
7442 setDtUnit(tse->getDtUnit());
7443 _time_steps.push_back(tse);
7446 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
7448 std::size_t nbOfCompo=_infos.size();
7449 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7451 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7454 if((cur->getInfo()).size()!=nbOfCompo)
7456 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
7457 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
7458 throw INTERP_KERNEL::Exception(oss.str());
7460 cur->copyNameScope(*this);
7465 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)
7467 _time_steps.resize(nbPdt);
7468 for(int i=0;i<nbPdt;i++)
7470 std::vector< std::pair<int,int> > ts;
7471 med_int numdt=0,numo=0;
7472 med_int meshIt=0,meshOrder=0;
7474 MEDFILESAFECALLERRD0(MEDfieldComputingStepMeshInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder));
7479 _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7484 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7488 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
7491 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities);
7493 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entities);
7494 synchronizeNameScope();
7498 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
7500 if(_time_steps.empty())
7501 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
7502 checkThatNbOfCompoOfTSMatchThis();
7503 std::vector<std::string> infos(getInfo());
7504 int nbComp=infos.size();
7505 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7506 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7507 for(int i=0;i<nbComp;i++)
7509 std::string info=infos[i];
7511 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7512 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7513 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7516 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7517 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
7518 int nbOfTS=_time_steps.size();
7519 for(int i=0;i<nbOfTS;i++)
7520 _time_steps[i]->writeLL(fid,opts,*this);
7523 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
7525 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7527 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7529 elt->loadBigArraysRecursively(fid,nasc);
7533 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
7535 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7537 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7539 elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7543 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
7545 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7547 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7549 elt->unloadArrays();
7553 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7555 return _time_steps.size();
7558 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
7560 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7561 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7563 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7565 newTS.push_back(*it);
7570 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
7572 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7573 int maxId=(int)_time_steps.size();
7575 std::set<int> idsToDel;
7576 for(const int *id=startIds;id!=endIds;id++,ii++)
7578 if(*id>=0 && *id<maxId)
7580 idsToDel.insert(*id);
7584 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7585 throw INTERP_KERNEL::Exception(oss.str());
7588 for(int iii=0;iii<maxId;iii++)
7589 if(idsToDel.find(iii)==idsToDel.end())
7590 newTS.push_back(_time_steps[iii]);
7594 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
7596 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7597 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7598 if(nbOfEntriesToKill==0)
7600 std::size_t sz=_time_steps.size();
7601 std::vector<bool> b(sz,true);
7603 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7605 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7606 for(std::size_t i=0;i<sz;i++)
7608 newTS.push_back(_time_steps[i]);
7612 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
7615 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
7616 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7618 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7622 tmp->getTime(it2,ord);
7623 if(it2==iteration && order==ord)
7626 oss << "(" << it2 << "," << ord << "), ";
7629 throw INTERP_KERNEL::Exception(oss.str());
7632 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
7635 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
7637 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7639 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7643 double ti=tmp->getTime(it2,ord);
7644 if(fabs(time-ti)<eps)
7650 throw INTERP_KERNEL::Exception(oss.str());
7653 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
7655 int lgth=_time_steps.size();
7656 std::vector< std::pair<int,int> > ret(lgth);
7657 for(int i=0;i<lgth;i++)
7658 _time_steps[i]->fillIteration(ret[i]);
7663 * 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'
7664 * This method returns two things.
7665 * - The absolute dimension of 'this' in first parameter.
7666 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7667 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
7669 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7670 * Only these 3 discretizations will be taken into account here.
7672 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7673 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7674 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7676 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7677 * 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'.
7679 * Let's consider the typical following case :
7680 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7681 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7682 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7684 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7686 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7688 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7689 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7690 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7691 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7693 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
7695 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7698 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
7700 if(pos<0 || pos>=(int)_time_steps.size())
7702 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7703 throw INTERP_KERNEL::Exception(oss.str());
7705 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7708 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7709 oss << "\nTry to use following method eraseEmptyTS !";
7710 throw INTERP_KERNEL::Exception(oss.str());
7715 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
7717 if(pos<0 || pos>=(int)_time_steps.size())
7719 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7720 throw INTERP_KERNEL::Exception(oss.str());
7722 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7725 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7726 oss << "\nTry to use following method eraseEmptyTS !";
7727 throw INTERP_KERNEL::Exception(oss.str());
7732 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
7734 std::vector<std::string> ret;
7735 std::set<std::string> ret2;
7736 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7738 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
7739 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7740 if(ret2.find(*it2)==ret2.end())
7742 ret.push_back(*it2);
7749 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
7751 std::vector<std::string> ret;
7752 std::set<std::string> ret2;
7753 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7755 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
7756 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7757 if(ret2.find(*it2)==ret2.end())
7759 ret.push_back(*it2);
7766 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
7768 std::vector<std::string> ret;
7769 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7771 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
7772 ret.insert(ret.end(),tmp.begin(),tmp.end());
7777 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
7779 std::vector<std::string> ret;
7780 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7782 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
7783 ret.insert(ret.end(),tmp.begin(),tmp.end());
7788 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7790 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7791 (*it)->changePflsRefsNamesGen2(mapOfModif);
7794 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7796 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7797 (*it)->changeLocsRefsNamesGen2(mapOfModif);
7800 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
7802 int lgth=_time_steps.size();
7803 std::vector< std::vector<TypeOfField> > ret(lgth);
7804 for(int i=0;i<lgth;i++)
7805 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
7810 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
7812 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
7814 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
7817 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCopy() const
7819 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
7821 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7823 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
7824 ret->_time_steps[i]=(*it)->deepCopy();
7829 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
7831 std::size_t sz(_infos.size()),sz2(_time_steps.size());
7832 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7833 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7834 for(std::size_t i=0;i<sz;i++)
7836 ret[i]=shallowCpy();
7837 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7839 for(std::size_t i=0;i<sz2;i++)
7841 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7844 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7845 throw INTERP_KERNEL::Exception(oss.str());
7849 for(std::size_t i=0;i<sz;i++)
7850 for(std::size_t j=0;j<sz2;j++)
7851 ret[i]->_time_steps[j]=ts[j][i];
7856 * This method splits into discretization each time steps in \a this.
7857 * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
7859 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
7861 std::size_t sz(_time_steps.size());
7862 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7863 for(std::size_t i=0;i<sz;i++)
7865 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7868 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
7869 throw INTERP_KERNEL::Exception(oss.str());
7871 items[i]=timeStep->splitDiscretizations();
7874 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
7875 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
7876 std::vector< TypeOfField > types;
7877 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7878 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7880 std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
7882 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
7883 std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
7884 if(it2==types.end())
7885 types.push_back(ts[0]);
7887 ret.resize(types.size()); ret2.resize(types.size());
7888 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7889 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7891 TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
7892 std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
7893 ret2[pos].push_back(*it1);
7895 for(std::size_t i=0;i<types.size();i++)
7897 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7898 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
7899 elt->pushBackTimeStep(*it1);//also updates infos in elt
7901 elt->MEDFileFieldNameScope::operator=(*this);
7907 * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
7909 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
7911 std::size_t sz(_time_steps.size());
7912 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7913 std::size_t szOut(std::numeric_limits<std::size_t>::max());
7914 for(std::size_t i=0;i<sz;i++)
7916 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7919 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
7920 throw INTERP_KERNEL::Exception(oss.str());
7922 items[i]=timeStep->splitMultiDiscrPerGeoTypes();
7923 if(szOut==std::numeric_limits<std::size_t>::max())
7924 szOut=items[i].size();
7926 if(items[i].size()!=szOut)
7927 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
7929 if(szOut==std::numeric_limits<std::size_t>::max())
7930 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
7931 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
7932 for(std::size_t i=0;i<szOut;i++)
7934 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7935 for(std::size_t j=0;j<sz;j++)
7936 elt->pushBackTimeStep(items[j][i]);
7938 elt->MEDFileFieldNameScope::operator=(*this);
7943 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
7945 _name=field->getName();
7947 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
7949 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
7950 _infos=arr->getInfoOnComponents();
7953 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
7955 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
7956 if(_name!=field->getName())
7958 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
7959 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
7960 throw INTERP_KERNEL::Exception(oss.str());
7963 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
7964 checkThatComponentsMatch(arr->getInfoOnComponents());
7967 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
7969 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
7970 if(getInfo().size()!=compos.size())
7972 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
7973 oss << " number of components of element to append (" << compos.size() << ") !";
7974 throw INTERP_KERNEL::Exception(oss.str());
7978 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
7979 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
7980 oss << " But compo in input fields are : ";
7981 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
7983 throw INTERP_KERNEL::Exception(oss.str());
7987 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
7989 std::size_t sz=_infos.size();
7991 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
7993 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7995 if(elt->getInfo().size()!=sz)
7997 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
7998 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
7999 throw INTERP_KERNEL::Exception(oss.str());
8004 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
8007 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8008 if(!_time_steps.empty())
8009 checkCoherencyOfTinyInfo(field,arr);
8010 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8011 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8012 objC->setFieldNoProfileSBT(field,arr,glob,*this);
8013 copyTinyInfoFrom(field,arr);
8014 _time_steps.push_back(obj);
8017 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
8020 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8021 if(!_time_steps.empty())
8022 checkCoherencyOfTinyInfo(field,arr);
8023 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8024 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8025 objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
8026 copyTinyInfoFrom(field,arr);
8027 _time_steps.push_back(obj);
8030 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ts)
8032 int sz=(int)_time_steps.size();
8035 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
8036 throw INTERP_KERNEL::Exception(oss.str());
8038 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
8041 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
8043 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
8044 throw INTERP_KERNEL::Exception(oss.str());
8050 //= MEDFileFieldMultiTSWithoutSDA
8052 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)
8054 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8057 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
8061 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8066 * \param [in] fieldId field id in C mode
8068 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8069 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8072 catch(INTERP_KERNEL::Exception& e)
8075 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)
8076 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8079 catch(INTERP_KERNEL::Exception& e)
8082 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8084 return new MEDFileField1TSWithoutSDA;
8087 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8090 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8091 const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
8093 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8096 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const
8098 return MEDFileField1TSWithoutSDA::TYPE_STR;
8101 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const
8103 return new MEDFileFieldMultiTSWithoutSDA(*this);
8106 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const
8108 return new MEDFileFieldMultiTSWithoutSDA;
8112 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
8113 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
8115 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
8117 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
8118 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8120 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
8121 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
8124 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
8126 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
8127 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8129 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8131 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8134 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
8136 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
8137 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
8138 ret->setIteration(i,elt);
8144 //= MEDFileAnyTypeFieldMultiTS
8146 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
8150 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8151 try:MEDFileFieldGlobsReal(fid)
8153 _content=BuildContentFrom(fid,loadAll,ms);
8156 catch(INTERP_KERNEL::Exception& e)
8161 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8163 med_field_type typcha;
8164 std::vector<std::string> infos;
8167 MEDFileAnyTypeField1TS::LocateField(fid,fieldName,i,typcha,infos,dtunit);
8168 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8173 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8178 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8183 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::BuildContentFrom(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
8184 throw INTERP_KERNEL::Exception(oss.str());
8187 ret->setDtUnit(dtunit.c_str());
8191 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8193 med_field_type typcha;
8195 std::vector<std::string> infos;
8196 std::string dtunit,fieldName;
8197 MEDFileAnyTypeField1TS::LocateField2(fid,0,true,fieldName,typcha,infos,dtunit);
8198 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8203 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8208 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8213 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::BuildContentFrom(fid) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of the first field is not in [MED_FLOAT64, MED_INT32] !";
8214 throw INTERP_KERNEL::Exception(oss.str());
8217 ret->setDtUnit(dtunit.c_str());
8221 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c)
8224 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
8225 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
8227 MCAuto<MEDFileFieldMultiTS> ret(MEDFileFieldMultiTS::New());
8228 ret->_content=c; c->incrRef();
8231 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
8233 MCAuto<MEDFileIntFieldMultiTS> ret(MEDFileIntFieldMultiTS::New());
8234 ret->_content=c; c->incrRef();
8237 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
8240 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, med_idt fid)
8242 MEDFileAnyTypeFieldMultiTS *ret(BuildNewInstanceFromContent(c));
8243 std::string fileName(FileNameFromFID(fid));
8244 ret->setFileName(fileName);
8248 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8249 try:MEDFileFieldGlobsReal(fid)
8251 _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
8254 catch(INTERP_KERNEL::Exception& e)
8259 //= MEDFileIntFieldMultiTSWithoutSDA
8261 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)
8263 return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8266 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
8270 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8274 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)
8275 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8278 catch(INTERP_KERNEL::Exception& e)
8282 * \param [in] fieldId field id in C mode
8284 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8285 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8288 catch(INTERP_KERNEL::Exception& e)
8291 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8293 return new MEDFileIntField1TSWithoutSDA;
8296 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8299 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8300 const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
8302 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8305 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const
8307 return MEDFileIntField1TSWithoutSDA::TYPE_STR;
8310 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const
8312 return new MEDFileIntFieldMultiTSWithoutSDA(*this);
8315 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const
8317 return new MEDFileIntFieldMultiTSWithoutSDA;
8320 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const
8322 MCAuto<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
8323 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8325 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8327 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8330 const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
8332 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
8333 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
8334 ret->setIteration(i,elt);
8340 //= MEDFileAnyTypeFieldMultiTS
8343 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
8344 * that has been read from a specified MED file.
8345 * \param [in] fileName - the name of the MED file to read.
8346 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8347 * is to delete this field using decrRef() as it is no more needed.
8348 * \throw If reading the file fails.
8350 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
8352 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8353 return New(fid,loadAll);
8356 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, bool loadAll)
8358 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
8359 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8360 ret->loadGlobals(fid);
8365 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
8366 * that has been read from a specified MED file.
8367 * \param [in] fileName - the name of the MED file to read.
8368 * \param [in] fieldName - the name of the field to read.
8369 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8370 * is to delete this field using decrRef() as it is no more needed.
8371 * \throw If reading the file fails.
8372 * \throw If there is no field named \a fieldName in the file.
8374 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8376 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8377 return New(fid,fieldName,loadAll);
8380 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
8382 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
8383 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8384 ret->loadGlobals(fid);
8389 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8390 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8392 * \warning this is a shallow copy constructor
8394 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8396 if(!shallowCopyOfContent)
8398 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
8399 otherPtr->incrRef();
8400 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
8404 _content=other.shallowCpy();
8408 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
8410 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8412 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
8416 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
8418 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8420 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
8424 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
8426 return contentNotNullBase()->getPflsReallyUsed2();
8429 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
8431 return contentNotNullBase()->getLocsReallyUsed2();
8434 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
8436 return contentNotNullBase()->getPflsReallyUsedMulti2();
8439 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
8441 return contentNotNullBase()->getLocsReallyUsedMulti2();
8444 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8446 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
8449 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8451 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
8454 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
8456 return contentNotNullBase()->getNumberOfTS();
8459 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
8461 contentNotNullBase()->eraseEmptyTS();
8464 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
8466 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
8469 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
8471 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
8474 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
8476 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
8477 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8482 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
8484 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
8485 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8490 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
8492 return contentNotNullBase()->getIterations();
8495 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
8497 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
8498 pushBackTimeStep(*it);
8501 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
8504 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
8505 int nbOfTS(fmts->getNumberOfTS());
8506 for(int i=0;i<nbOfTS;i++)
8508 MCAuto<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
8509 pushBackTimeStep(elt);
8513 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
8516 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
8517 checkCoherencyOfType(f1ts);
8519 MCAuto<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
8520 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
8522 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
8523 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
8524 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
8525 _content->pushBackTimeStep(cSafe);
8526 appendGlobs(*f1ts,1e-12);
8529 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
8531 contentNotNullBase()->synchronizeNameScope();
8534 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
8536 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
8539 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
8541 return contentNotNullBase()->getPosGivenTime(time,eps);
8544 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8546 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
8549 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
8551 return contentNotNullBase()->getTypesOfFieldAvailable();
8554 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
8556 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
8559 std::string MEDFileAnyTypeFieldMultiTS::getName() const
8561 return contentNotNullBase()->getName();
8564 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
8566 contentNotNullBase()->setName(name);
8569 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
8571 return contentNotNullBase()->getDtUnit();
8574 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
8576 contentNotNullBase()->setDtUnit(dtUnit);
8579 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8581 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
8584 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
8586 return contentNotNullBase()->getTimeSteps(ret1);
8589 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
8591 return contentNotNullBase()->getMeshName();
8594 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
8596 contentNotNullBase()->setMeshName(newMeshName);
8599 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
8601 return contentNotNullBase()->changeMeshNames(modifTab);
8604 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
8606 return contentNotNullBase()->getInfo();
8609 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
8611 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
8614 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
8616 return contentNotNullBase()->setInfo(info);
8619 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
8621 const std::vector<std::string> ret=getInfo();
8622 return (int)ret.size();
8625 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
8627 writeGlobals(fid,*this);
8628 contentNotNullBase()->writeLL(fid,*this);
8632 * This method alloc the arrays and load potentially huge arrays contained in this field.
8633 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
8634 * This method can be also called to refresh or reinit values from a file.
8636 * \throw If the fileName is not set or points to a non readable MED file.
8638 void MEDFileAnyTypeFieldMultiTS::loadArrays()
8640 if(getFileName().empty())
8641 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
8642 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
8643 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
8647 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
8648 * But once data loaded once, this method does nothing.
8650 * \throw If the fileName is not set or points to a non readable MED file.
8651 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
8653 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
8655 if(!getFileName().empty())
8657 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
8658 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
8663 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
8664 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
8665 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
8667 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
8669 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
8671 contentNotNullBase()->unloadArrays();
8675 * 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.
8676 * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
8677 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
8679 * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
8681 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
8683 if(!getFileName().empty())
8684 contentNotNullBase()->unloadArrays();
8687 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
8689 std::ostringstream oss;
8690 contentNotNullBase()->simpleRepr(0,oss,-1);
8691 simpleReprGlobs(oss);
8695 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
8697 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
8700 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
8702 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
8703 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
8708 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
8709 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8710 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
8712 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
8714 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8716 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
8717 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
8718 std::size_t sz(contentsSplit.size());
8719 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8720 for(std::size_t i=0;i<sz;i++)
8722 ret[i]=shallowCpy();
8723 ret[i]->_content=contentsSplit[i];
8729 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
8730 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8732 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
8734 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8736 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
8737 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
8738 std::size_t sz(contentsSplit.size());
8739 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8740 for(std::size_t i=0;i<sz;i++)
8742 ret[i]=shallowCpy();
8743 ret[i]->_content=contentsSplit[i];
8749 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
8750 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8752 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
8754 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8756 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
8757 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
8758 std::size_t sz(contentsSplit.size());
8759 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8760 for(std::size_t i=0;i<sz;i++)
8762 ret[i]=shallowCpy();
8763 ret[i]->_content=contentsSplit[i];
8768 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCopy() const
8770 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8771 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
8772 ret->_content=_content->deepCopy();
8773 ret->deepCpyGlobs(*this);
8777 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
8783 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8784 * \param [in] iteration - the iteration number of a required time step.
8785 * \param [in] order - the iteration order number of required time step.
8786 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
8787 * delete this field using decrRef() as it is no more needed.
8788 * \throw If there is no required time step in \a this field.
8790 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
8792 int pos=getPosOfTimeStep(iteration,order);
8793 return getTimeStepAtPos(pos);
8797 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8798 * \param [in] time - the time of the time step of interest.
8799 * \param [in] eps - a precision used to compare time values.
8800 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8801 * delete this field using decrRef() as it is no more needed.
8802 * \throw If there is no required time step in \a this field.
8804 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
8806 int pos=getPosGivenTime(time,eps);
8807 return getTimeStepAtPos(pos);
8811 * 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.
8812 * The float64 value of time attached to the pair of integers are not considered here.
8813 * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
8815 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
8816 * \throw If there is a null pointer in \a vectFMTS.
8818 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
8820 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
8821 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8822 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8823 while(!lstFMTS.empty())
8825 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8826 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8828 throw INTERP_KERNEL::Exception(msg);
8829 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
8830 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8831 elt.push_back(curIt); it=lstFMTS.erase(it);
8832 while(it!=lstFMTS.end())
8836 throw INTERP_KERNEL::Exception(msg);
8837 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
8839 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8849 * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
8850 * All returned instances in a subvector can be safely loaded, rendered along time
8851 * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
8852 * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
8853 * 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).
8854 * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
8855 * 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.
8857 * \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().
8858 * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
8859 * \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.
8860 * \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.
8862 * \throw If an element in \a vectFMTS has not only one spatial discretization set.
8863 * \throw If an element in \a vectFMTS change of spatial discretization along time.
8864 * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
8865 * \thorw If some elements in \a vectFMTS do not have the same times steps.
8866 * \throw If mesh is null.
8867 * \throw If an element in \a vectFMTS is null.
8868 * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
8870 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& fsc)
8872 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
8874 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
8875 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8876 if(vectFMTS.empty())
8878 std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
8879 MEDFileAnyTypeFieldMultiTS *frstElt(*it);
8881 throw INTERP_KERNEL::Exception(msg);
8883 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
8884 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
8885 for(;it!=vectFMTS.end();it++,i++)
8888 throw INTERP_KERNEL::Exception(msg);
8889 TypeOfField tof0,tof1;
8890 if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
8893 vectFMTSNotNodes.push_back(*it);
8895 vectFMTSNodes.push_back(*it);
8898 vectFMTSNotNodes.push_back(*it);
8900 std::vector< MCAuto<MEDFileFastCellSupportComparator> > cmps;
8901 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
8903 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
8906 bool isFetched(false);
8907 for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
8910 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
8911 if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
8912 { ret[i].push_back(*it2); isFetched=true; }
8916 std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
8917 MCAuto<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
8918 ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
8926 * 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.
8927 * \param [out] cmps - same size than the returned vector.
8929 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& cmps)
8931 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8932 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8933 while(!lstFMTS.empty())
8935 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8936 MEDFileAnyTypeFieldMultiTS *ref(*it);
8937 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8938 elt.push_back(ref); it=lstFMTS.erase(it);
8939 MCAuto<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
8940 MCAuto<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
8941 while(it!=lstFMTS.end())
8943 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8944 if(cmp->isEqual(curIt))
8945 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8949 ret.push_back(elt); cmps.push_back(cmp);
8955 * 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.
8956 * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
8958 * \throw If \a f0 or \a f1 has not only one spatial discretization set.
8959 * \throw If \a f0 or \a f1 change of spatial discretization along time.
8960 * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
8961 * \thorw If \a f0 and \a f1 do not have the same times steps.
8962 * \throw If mesh is null.
8963 * \throw If \a f0 or \a f1 is null.
8964 * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
8966 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
8969 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
8971 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
8972 if(f0->getMeshName()!=mesh->getName())
8974 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8975 throw INTERP_KERNEL::Exception(oss.str());
8977 if(f1->getMeshName()!=mesh->getName())
8979 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8980 throw INTERP_KERNEL::Exception(oss.str());
8982 int nts=f0->getNumberOfTS();
8983 if(nts!=f1->getNumberOfTS())
8984 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
8987 for(int i=0;i<nts;i++)
8989 MCAuto<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
8990 MCAuto<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
8991 std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
8992 if(tofs0.size()!=1 || tofs1.size()!=1)
8993 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
8996 if(tof0!=tofs0[0] || tof1!=tofs1[0])
8997 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
9000 { tof0=tofs0[0]; tof1=tofs1[0]; }
9001 if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
9003 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() << ") !";
9004 throw INTERP_KERNEL::Exception(oss.str());
9006 if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
9008 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() << ") !";
9009 throw INTERP_KERNEL::Exception(oss.str());
9011 if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
9013 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() << ") !";
9014 throw INTERP_KERNEL::Exception(oss.str());
9021 * Return an extraction of \a this using \a extractDef map to specify the extraction.
9022 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
9024 * \return A new object that the caller is responsible to deallocate.
9026 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
9029 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::extractPart : mesh is null !");
9030 MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(buildNewEmpty());
9031 int nbTS(getNumberOfTS());
9032 for(int i=0;i<nbTS;i++)
9034 MCAuto<MEDFileAnyTypeField1TS> f1ts(getTimeStepAtPos(i));
9035 MCAuto<MEDFileAnyTypeField1TS> f1tsOut(f1ts->extractPart(extractDef,mm));
9036 fmtsOut->pushBackTimeStep(f1tsOut);
9038 return fmtsOut.retn();
9042 MCAuto<MEDFileAnyTypeField1TS> AggregateHelperF1TS(const std::vector< typename MLFieldTraits<T>::F1TSType const *>& f1tss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9044 MCAuto< typename MLFieldTraits<T>::F1TSType > ret(MLFieldTraits<T>::F1TSType::New());
9046 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : empty vector !");
9047 std::size_t sz(f1tss.size()),i(0);
9048 std::vector< typename MLFieldTraits<T>::F1TSWSDAType const *> f1tsw(sz);
9049 for(typename std::vector< typename MLFieldTraits<T>::F1TSType const *>::const_iterator it=f1tss.begin();it!=f1tss.end();it++,i++)
9051 typename MLFieldTraits<T>::F1TSType const *elt(*it);
9053 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : presence of a null pointer !");
9054 f1tsw[i]=dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType const *>(elt->contentNotNullBase());
9056 typename MLFieldTraits<T>::F1TSWSDAType *retc(dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType *>(ret->contentNotNullBase()));
9058 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : internal error 1 !");
9059 retc->aggregate(f1tsw,dts);
9060 ret->setDtUnit(f1tss[0]->getDtUnit());
9061 return DynamicCast<typename MLFieldTraits<T>::F1TSType , MEDFileAnyTypeField1TS>(ret);
9065 MCAuto< MEDFileAnyTypeFieldMultiTS > AggregateHelperFMTS(const std::vector< typename MLFieldTraits<T>::FMTSType const *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9067 MCAuto< typename MLFieldTraits<T>::FMTSType > ret(MLFieldTraits<T>::FMTSType::New());
9069 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : empty vector !");
9070 std::size_t sz(fmtss.size());
9071 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9073 typename MLFieldTraits<T>::FMTSType const *elt(*it);
9075 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : presence of null pointer !");
9077 int nbTS(fmtss[0]->getNumberOfTS());
9078 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9079 if((*it)->getNumberOfTS()!=nbTS)
9080 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : all fields must have the same number of TS !");
9081 for(int iterTS=0;iterTS<nbTS;iterTS++)
9084 std::vector< typename MLFieldTraits<T>::F1TSType const *> f1tss(sz);
9085 std::vector< MCAuto<typename MLFieldTraits<T>::F1TSType> > f1tss2(sz);
9086 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++,i++)
9087 { f1tss2[i]=(*it)->getTimeStepAtPos(iterTS); f1tss[i]=f1tss2[i]; }
9088 MCAuto<MEDFileAnyTypeField1TS> f1ts(AggregateHelperF1TS<T>(f1tss,dts));
9089 ret->pushBackTimeStep(f1ts);
9090 ret->setDtUnit(f1ts->getDtUnit());
9092 return DynamicCast<typename MLFieldTraits<T>::FMTSType , MEDFileAnyTypeFieldMultiTS>(ret);
9096 * \a dts and \a ftmss are expected to have same size.
9098 MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileAnyTypeFieldMultiTS::Aggregate(const std::vector<const MEDFileAnyTypeFieldMultiTS *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9101 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : input vector is empty !");
9102 std::size_t sz(fmtss.size());
9103 std::vector<const MEDFileFieldMultiTS *> fmtss1;
9104 std::vector<const MEDFileIntFieldMultiTS *> fmtss2;
9105 for(std::vector<const MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9108 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : presence of null instance in input vector !");
9109 const MEDFileFieldMultiTS *elt1(dynamic_cast<const MEDFileFieldMultiTS *>(*it));
9112 fmtss1.push_back(elt1);
9115 const MEDFileIntFieldMultiTS *elt2(dynamic_cast<const MEDFileIntFieldMultiTS *>(*it));
9118 fmtss2.push_back(elt2);
9121 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not recognized type !");
9123 if(fmtss1.size()!=sz && fmtss2.size()!=sz)
9124 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : type of data is not homogeneous !");
9125 if(fmtss1.size()==sz)
9126 return AggregateHelperFMTS<double>(fmtss1,dts);
9127 if(fmtss2.size()!=sz)
9128 return AggregateHelperFMTS<int>(fmtss2,dts);
9129 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not implemented yet !");
9132 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
9134 return new MEDFileAnyTypeFieldMultiTSIterator(this);
9137 //= MEDFileFieldMultiTS
9140 * Returns a new empty instance of MEDFileFieldMultiTS.
9141 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9142 * is to delete this field using decrRef() as it is no more needed.
9144 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
9146 return new MEDFileFieldMultiTS;
9150 * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
9151 * that has been read from a specified MED file.
9152 * \param [in] fileName - the name of the MED file to read.
9153 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9154 * is to delete this field using decrRef() as it is no more needed.
9155 * \throw If reading the file fails.
9157 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll)
9159 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9160 return New(fid,loadAll);
9163 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, bool loadAll)
9165 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,loadAll,0));
9166 ret->contentNotNull();//to check that content type matches with \a this type.
9171 * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
9172 * that has been read from a specified MED file.
9173 * \param [in] fileName - the name of the MED file to read.
9174 * \param [in] fieldName - the name of the field to read.
9175 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9176 * is to delete this field using decrRef() as it is no more needed.
9177 * \throw If reading the file fails.
9178 * \throw If there is no field named \a fieldName in the file.
9180 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9182 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9183 return New(fid,fieldName,loadAll);
9186 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
9188 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0));
9189 ret->contentNotNull();//to check that content type matches with \a this type.
9194 * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9195 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9197 * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
9198 * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9199 * \warning this is a shallow copy constructor
9200 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
9201 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9202 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9203 * is to delete this field using decrRef() as it is no more needed.
9205 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9207 return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
9210 MEDFileFieldMultiTS *MEDFileFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9212 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9213 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0,&entities));
9214 ret->contentNotNull();//to check that content type matches with \a this type.
9218 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
9220 return new MEDFileFieldMultiTS(*this);
9223 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9226 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9227 const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
9229 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
9233 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
9234 * following the given input policy.
9236 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9237 * By default (true) the globals are deeply copied.
9238 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
9240 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
9242 MCAuto<MEDFileIntFieldMultiTS> ret;
9243 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9246 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
9248 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
9249 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
9250 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc));
9253 ret=MEDFileIntFieldMultiTS::New();
9255 ret->deepCpyGlobs(*this);
9257 ret->shallowCpyGlobs(*this);
9262 * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
9263 * \param [in] pos - a time step id.
9264 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9265 * delete this field using decrRef() as it is no more needed.
9266 * \throw If \a pos is not a valid time step id.
9268 MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const
9270 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9273 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9274 throw INTERP_KERNEL::Exception(oss.str());
9276 const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
9279 MCAuto<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
9280 ret->shallowCpyGlobs(*this);
9283 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
9284 throw INTERP_KERNEL::Exception(oss.str());
9288 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9289 * mesh entities of a given dimension of the first mesh in MED file.
9290 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9291 * \param [in] type - a spatial discretization of interest.
9292 * \param [in] iteration - the iteration number of a required time step.
9293 * \param [in] order - the iteration order number of required time step.
9294 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9295 * \param [in] renumPol - specifies how to permute values of the result field according to
9296 * the optional numbers of cells and nodes, if any. The valid values are
9297 * - 0 - do not permute.
9298 * - 1 - permute cells.
9299 * - 2 - permute nodes.
9300 * - 3 - permute cells and nodes.
9302 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9303 * caller is to delete this field using decrRef() as it is no more needed.
9304 * \throw If the MED file is not readable.
9305 * \throw If there is no mesh in the MED file.
9306 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9307 * \throw If no field values of the required parameters are available.
9309 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9311 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9312 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9314 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
9315 MCAuto<DataArray> arrOut;
9316 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9317 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9322 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9323 * the top level cells of the first mesh in MED file.
9324 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9325 * \param [in] type - a spatial discretization of interest.
9326 * \param [in] iteration - the iteration number of a required time step.
9327 * \param [in] order - the iteration order number of required time step.
9328 * \param [in] renumPol - specifies how to permute values of the result field according to
9329 * the optional numbers of cells and nodes, if any. The valid values are
9330 * - 0 - do not permute.
9331 * - 1 - permute cells.
9332 * - 2 - permute nodes.
9333 * - 3 - permute cells and nodes.
9335 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9336 * caller is to delete this field using decrRef() as it is no more needed.
9337 * \throw If the MED file is not readable.
9338 * \throw If there is no mesh in the MED file.
9339 * \throw If no field values of the required parameters are available.
9341 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9343 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9344 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9346 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
9347 MCAuto<DataArray> arrOut;
9348 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9349 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9354 * This is the simplest version to fetch a field for MED structure. One drawback : if \a this is a complex field (multi spatial discretization inside a same field) this method will throw exception and more advance
9355 * method should be called (getFieldOnMeshAtLevel for example).
9356 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
9358 * \param [in] iteration - the iteration number of a required time step.
9359 * \param [in] order - the iteration order number of required time step.
9360 * \param [in] mesh - the mesh the field is lying on
9361 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9362 * caller is to delete this field using decrRef() as it is no more needed.
9364 MEDCouplingFieldDouble *MEDFileFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
9366 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9367 MCAuto<DataArray> arrOut;
9368 MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
9369 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9374 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9376 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9377 * \param [in] type - a spatial discretization of interest.
9378 * \param [in] iteration - the iteration number of a required time step.
9379 * \param [in] order - the iteration order number of required time step.
9380 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9381 * \param [in] mesh - the supporting mesh.
9382 * \param [in] renumPol - specifies how to permute values of the result field according to
9383 * the optional numbers of cells and nodes, if any. The valid values are
9384 * - 0 - do not permute.
9385 * - 1 - permute cells.
9386 * - 2 - permute nodes.
9387 * - 3 - permute cells and nodes.
9389 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9390 * caller is to delete this field using decrRef() as it is no more needed.
9391 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9392 * \throw If no field of \a this is lying on \a mesh.
9393 * \throw If no field values of the required parameters are available.
9395 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9397 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9398 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9400 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9401 MCAuto<DataArray> arrOut;
9402 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
9403 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9408 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9410 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9411 * \param [in] type - a spatial discretization of the new field.
9412 * \param [in] iteration - the iteration number of a required time step.
9413 * \param [in] order - the iteration order number of required time step.
9414 * \param [in] mesh - the supporting mesh.
9415 * \param [in] renumPol - specifies how to permute values of the result field according to
9416 * the optional numbers of cells and nodes, if any. The valid values are
9417 * - 0 - do not permute.
9418 * - 1 - permute cells.
9419 * - 2 - permute nodes.
9420 * - 3 - permute cells and nodes.
9422 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9423 * caller is to delete this field using decrRef() as it is no more needed.
9424 * \throw If no field of \a this is lying on \a mesh.
9425 * \throw If no field values of the required parameters are available.
9427 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
9429 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9430 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9432 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9433 MCAuto<DataArray> arrOut;
9434 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
9435 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9440 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
9441 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9442 * This method is useful for MED2 file format when field on different mesh was autorized.
9444 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
9446 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9447 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9449 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
9450 MCAuto<DataArray> arrOut;
9451 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
9452 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9457 * Returns values and a profile of the field of a given type, of a given time step,
9458 * lying on a given support.
9459 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9460 * \param [in] type - a spatial discretization of the field.
9461 * \param [in] iteration - the iteration number of a required time step.
9462 * \param [in] order - the iteration order number of required time step.
9463 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9464 * \param [in] mesh - the supporting mesh.
9465 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9466 * field of interest lies on. If the field lies on all entities of the given
9467 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9468 * using decrRef() as it is no more needed.
9469 * \param [in] glob - the global data storing profiles and localization.
9470 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
9471 * field. The caller is to delete this array using decrRef() as it is no more needed.
9472 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9473 * \throw If no field of \a this is lying on \a mesh.
9474 * \throw If no field values of the required parameters are available.
9476 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9478 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9479 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9481 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
9482 MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9483 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
9486 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const
9488 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9490 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
9491 const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
9493 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 !");
9497 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull()
9499 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9501 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
9502 MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
9504 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 !");
9509 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9510 * the given field is checked if its elements are sorted suitable for writing to MED file
9511 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9512 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9513 * \param [in] field - the field to add to \a this.
9514 * \throw If the name of \a field is empty.
9515 * \throw If the data array of \a field is not set.
9516 * \throw If existing time steps have different name or number of components than \a field.
9517 * \throw If the underlying mesh of \a field has no name.
9518 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9520 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
9522 const DataArrayDouble *arr=0;
9524 arr=field->getArray();
9525 contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
9529 * Adds a MEDCouplingFieldDouble to \a this as another time step.
9530 * The mesh support of input parameter \a field is ignored here, it can be NULL.
9531 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9534 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9535 * A new profile is added only if no equal profile is missing.
9536 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9537 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
9538 * \param [in] mesh - the supporting mesh of \a field.
9539 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9540 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
9541 * \throw If either \a field or \a mesh or \a profile has an empty name.
9542 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9543 * \throw If the data array of \a field is not set.
9544 * \throw If the data array of \a this is already allocated but has different number of
9545 * components than \a field.
9546 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9547 * \sa setFieldNoProfileSBT()
9549 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9551 const DataArrayDouble *arr=0;
9553 arr=field->getArray();
9554 contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
9557 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
9559 _content=new MEDFileFieldMultiTSWithoutSDA;
9562 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
9563 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
9566 catch(INTERP_KERNEL::Exception& e)
9569 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
9570 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
9573 catch(INTERP_KERNEL::Exception& e)
9576 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9580 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
9582 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
9585 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9587 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9590 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
9592 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
9595 MEDFileFieldMultiTS *MEDFileFieldMultiTS::buildNewEmpty() const
9597 return MEDFileFieldMultiTS::New();
9600 //= MEDFileAnyTypeFieldMultiTSIterator
9602 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
9607 _nb_iter=fmts->getNumberOfTS();
9611 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
9615 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
9617 if(_iter_id<_nb_iter)
9619 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
9621 return fmts->getTimeStepAtPos(_iter_id++);
9629 //= MEDFileIntFieldMultiTS
9632 * Returns a new empty instance of MEDFileFieldMultiTS.
9633 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9634 * is to delete this field using decrRef() as it is no more needed.
9636 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
9638 return new MEDFileIntFieldMultiTS;
9642 * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
9643 * that has been read from a specified MED file.
9644 * \param [in] fileName - the name of the MED file to read.
9645 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9646 * is to delete this field using decrRef() as it is no more needed.
9647 * \throw If reading the file fails.
9649 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll)
9651 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9652 return New(fid,loadAll);
9655 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, bool loadAll)
9657 MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,loadAll,0));
9658 ret->contentNotNull();//to check that content type matches with \a this type.
9663 * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
9664 * that has been read from a specified MED file.
9665 * \param [in] fileName - the name of the MED file to read.
9666 * \param [in] fieldName - the name of the field to read.
9667 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9668 * is to delete this field using decrRef() as it is no more needed.
9669 * \throw If reading the file fails.
9670 * \throw If there is no field named \a fieldName in the file.
9672 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9674 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9675 return New(fid,fieldName,loadAll);
9678 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
9680 MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0));
9681 ret->contentNotNull();//to check that content type matches with \a this type.
9686 * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9687 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9689 * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
9690 * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9691 * \warning this is a shallow copy constructor
9692 * \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
9693 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9694 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9695 * is to delete this field using decrRef() as it is no more needed.
9697 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9699 return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
9702 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9704 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9705 MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0,&entities));
9706 ret->contentNotNull();//to check that content type matches with \a this type.
9711 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
9712 * following the given input policy.
9714 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9715 * By default (true) the globals are deeply copied.
9716 * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
9718 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const
9720 MCAuto<MEDFileFieldMultiTS> ret;
9721 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9724 const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
9726 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
9727 MCAuto<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
9728 ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc));
9731 ret=MEDFileFieldMultiTS::New();
9733 ret->deepCpyGlobs(*this);
9735 ret->shallowCpyGlobs(*this);
9739 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const
9741 return new MEDFileIntFieldMultiTS(*this);
9744 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9747 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9748 const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
9750 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
9754 * This is the simplest version to fetch a field for MED structure. One drawback : if \a this is a complex field (multi spatial discretization inside a same field) this method will throw exception and more advance
9755 * method should be called (getFieldOnMeshAtLevel for example).
9756 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
9758 * \param [in] iteration - the iteration number of a required time step.
9759 * \param [in] order - the iteration order number of required time step.
9760 * \param [in] mesh - the mesh the field is lying on
9761 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
9762 * caller is to delete this field using decrRef() as it is no more needed.
9764 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
9766 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9767 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9769 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::field : mismatch of type of field expecting INT32 !");
9770 MCAuto<DataArray> arrOut;
9771 MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
9772 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arrOut));
9777 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
9778 * mesh entities of a given dimension of the first mesh in MED file.
9779 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9780 * \param [in] type - a spatial discretization of interest.
9781 * \param [in] iteration - the iteration number of a required time step.
9782 * \param [in] order - the iteration order number of required time step.
9783 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9784 * \param [in] renumPol - specifies how to permute values of the result field according to
9785 * the optional numbers of cells and nodes, if any. The valid values are
9786 * - 0 - do not permute.
9787 * - 1 - permute cells.
9788 * - 2 - permute nodes.
9789 * - 3 - permute cells and nodes.
9791 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9792 * caller is to delete this field using decrRef() as it is no more needed.
9793 * \throw If the MED file is not readable.
9794 * \throw If there is no mesh in the MED file.
9795 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9796 * \throw If no field values of the required parameters are available.
9798 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9800 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9801 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9803 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
9804 MCAuto<DataArray> arr;
9805 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase()));
9806 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9811 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
9812 * the top level cells of the first mesh in MED file.
9813 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9814 * \param [in] type - a spatial discretization of interest.
9815 * \param [in] iteration - the iteration number of a required time step.
9816 * \param [in] order - the iteration order number of required time step.
9817 * \param [in] renumPol - specifies how to permute values of the result field according to
9818 * the optional numbers of cells and nodes, if any. The valid values are
9819 * - 0 - do not permute.
9820 * - 1 - permute cells.
9821 * - 2 - permute nodes.
9822 * - 3 - permute cells and nodes.
9824 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9825 * caller is to delete this field using decrRef() as it is no more needed.
9826 * \throw If the MED file is not readable.
9827 * \throw If there is no mesh in the MED file.
9828 * \throw If no field values of the required parameters are available.
9830 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9832 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9833 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9835 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
9836 MCAuto<DataArray> arr;
9837 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase()));
9838 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9843 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
9845 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9846 * \param [in] type - a spatial discretization of interest.
9847 * \param [in] iteration - the iteration number of a required time step.
9848 * \param [in] order - the iteration order number of required time step.
9849 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9850 * \param [in] mesh - the supporting mesh.
9851 * \param [in] renumPol - specifies how to permute values of the result field according to
9852 * the optional numbers of cells and nodes, if any. The valid values are
9853 * - 0 - do not permute.
9854 * - 1 - permute cells.
9855 * - 2 - permute nodes.
9856 * - 3 - permute cells and nodes.
9858 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9859 * caller is to delete this field using decrRef() as it is no more needed.
9860 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9861 * \throw If no field of \a this is lying on \a mesh.
9862 * \throw If no field values of the required parameters are available.
9864 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9866 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9867 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9869 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9870 MCAuto<DataArray> arr;
9871 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase()));
9872 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9877 * Returns a new MEDCouplingFieldInt of given type, of a given time step, lying on a
9879 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9880 * \param [in] type - a spatial discretization of the new field.
9881 * \param [in] iteration - the iteration number of a required time step.
9882 * \param [in] order - the iteration order number of required time step.
9883 * \param [in] mesh - the supporting mesh.
9884 * \param [out] arrOut - the DataArrayInt containing values of field.
9885 * \param [in] renumPol - specifies how to permute values of the result field according to
9886 * the optional numbers of cells and nodes, if any. The valid values are
9887 * - 0 - do not permute.
9888 * - 1 - permute cells.
9889 * - 2 - permute nodes.
9890 * - 3 - permute cells and nodes.
9892 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9893 * caller is to delete this field using decrRef() as it is no more needed.
9894 * \throw If no field of \a this is lying on \a mesh.
9895 * \throw If no field values of the required parameters are available.
9897 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
9899 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9900 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9902 throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9903 MCAuto<DataArray> arr;
9904 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase()));
9905 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9910 * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
9911 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9912 * This method is useful for MED2 file format when field on different mesh was autorized.
9914 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol) const
9916 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9917 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9919 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9920 MCAuto<DataArray> arr;
9921 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase()));
9922 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9927 * Returns values and a profile of the field of a given type, of a given time step,
9928 * lying on a given support.
9929 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9930 * \param [in] type - a spatial discretization of the field.
9931 * \param [in] iteration - the iteration number of a required time step.
9932 * \param [in] order - the iteration order number of required time step.
9933 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9934 * \param [in] mesh - the supporting mesh.
9935 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9936 * field of interest lies on. If the field lies on all entities of the given
9937 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9938 * using decrRef() as it is no more needed.
9939 * \param [in] glob - the global data storing profiles and localization.
9940 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
9941 * field. The caller is to delete this array using decrRef() as it is no more needed.
9942 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9943 * \throw If no field of \a this is lying on \a mesh.
9944 * \throw If no field values of the required parameters are available.
9946 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9948 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9949 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9951 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
9952 MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9953 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
9957 * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
9958 * \param [in] pos - a time step id.
9959 * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
9960 * delete this field using decrRef() as it is no more needed.
9961 * \throw If \a pos is not a valid time step id.
9963 MEDFileIntField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
9965 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9968 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9969 throw INTERP_KERNEL::Exception(oss.str());
9971 const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
9974 MCAuto<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
9975 ret->shallowCpyGlobs(*this);
9978 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
9979 throw INTERP_KERNEL::Exception(oss.str());
9983 * Adds a MEDCouplingFieldInt to \a this as another time step. The underlying mesh of
9984 * the given field is checked if its elements are sorted suitable for writing to MED file
9985 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9986 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9987 * \param [in] field - the field to add to \a this.
9988 * \throw If the name of \a field is empty.
9989 * \throw If the data array of \a field is not set.
9990 * \throw If existing time steps have different name or number of components than \a field.
9991 * \throw If the underlying mesh of \a field has no name.
9992 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9994 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldInt *field)
9996 MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
9997 contentNotNull()->appendFieldNoProfileSBT(field2,field->getArray(),*this);
10001 * Adds a MEDCouplingFieldDouble to \a this as another time step.
10002 * The mesh support of input parameter \a field is ignored here, it can be NULL.
10003 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
10006 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
10007 * A new profile is added only if no equal profile is missing.
10008 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10009 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
10010 * \param [in] arrOfVals - the values of the field \a field used.
10011 * \param [in] mesh - the supporting mesh of \a field.
10012 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
10013 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
10014 * \throw If either \a field or \a mesh or \a profile has an empty name.
10015 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10016 * \throw If the data array of \a field is not set.
10017 * \throw If the data array of \a this is already allocated but has different number of
10018 * components than \a field.
10019 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
10020 * \sa setFieldNoProfileSBT()
10022 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
10024 MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
10025 contentNotNull()->appendFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this);
10028 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const
10030 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10032 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
10033 const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10035 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 !");
10039 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull()
10041 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10043 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
10044 MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10046 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 !");
10050 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
10052 _content=new MEDFileIntFieldMultiTSWithoutSDA;
10055 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
10059 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
10060 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
10063 catch(INTERP_KERNEL::Exception& e)
10066 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
10067 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
10070 catch(INTERP_KERNEL::Exception& e)
10073 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
10075 return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
10078 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::buildNewEmpty() const
10080 return MEDFileIntFieldMultiTS::New();
10085 MEDFileFields *MEDFileFields::New()
10087 return new MEDFileFields;
10090 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
10092 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10093 return New(fid,loadAll);
10096 MEDFileFields *MEDFileFields::New(med_idt fid, bool loadAll)
10098 return new MEDFileFields(fid,loadAll,0,0);
10101 MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
10103 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10104 return new MEDFileFields(fid,loadAll,ms,0);
10107 MEDFileFields *MEDFileFields::LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
10109 MEDFileUtilities::CheckFileForRead(fileName);
10110 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10111 return new MEDFileFields(fid,loadAll,0,&entities);
10114 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
10116 std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
10117 ret+=_fields.capacity()*sizeof(MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
10121 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
10123 std::vector<const BigMemoryObject *> ret;
10124 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10125 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
10129 MEDFileFields *MEDFileFields::deepCopy() const
10131 MCAuto<MEDFileFields> ret(shallowCpy());
10133 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10135 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10136 ret->_fields[i]=(*it)->deepCopy();
10138 ret->deepCpyGlobs(*this);
10142 MEDFileFields *MEDFileFields::shallowCpy() const
10144 return new MEDFileFields(*this);
10148 * 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
10149 * 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.
10150 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
10152 * \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.
10153 * \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.
10155 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10157 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
10159 std::set< std::pair<int,int> > s;
10160 bool firstShot=true;
10161 areThereSomeForgottenTS=false;
10162 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10164 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10166 std::vector< std::pair<int,int> > v=(*it)->getIterations();
10167 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
10169 { s=s1; firstShot=false; }
10172 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
10174 areThereSomeForgottenTS=true;
10178 std::vector< std::pair<int,int> > ret;
10179 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
10183 int MEDFileFields::getNumberOfFields() const
10185 return _fields.size();
10188 std::vector<std::string> MEDFileFields::getFieldsNames() const
10190 std::vector<std::string> ret(_fields.size());
10192 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10194 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
10197 ret[i]=f->getName();
10201 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
10202 throw INTERP_KERNEL::Exception(oss.str());
10208 std::vector<std::string> MEDFileFields::getMeshesNames() const
10210 std::vector<std::string> ret;
10211 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10213 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10215 ret.push_back(cur->getMeshName());
10220 std::string MEDFileFields::simpleRepr() const
10222 std::ostringstream oss;
10223 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
10228 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
10230 int nbOfFields(getNumberOfFields());
10231 std::string startLine(bkOffset,' ');
10232 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
10234 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10236 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10239 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
10243 oss << startLine << " - not defined !" << std::endl;
10247 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10249 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10250 std::string chapter(17,'0'+i);
10251 oss << startLine << chapter << std::endl;
10254 cur->simpleRepr(bkOffset+2,oss,i);
10258 oss << startLine << " - not defined !" << std::endl;
10260 oss << startLine << chapter << std::endl;
10262 simpleReprGlobs(oss);
10265 MEDFileFields::MEDFileFields()
10269 MEDFileFields::MEDFileFields(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
10270 try:MEDFileFieldGlobsReal(fid)
10272 int nbFields(MEDnField(fid));
10273 _fields.resize(nbFields);
10274 med_field_type typcha;
10275 for(int i=0;i<nbFields;i++)
10277 std::vector<std::string> infos;
10278 std::string fieldName,dtunit;
10279 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,i,false,fieldName,typcha,infos,dtunit));
10284 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10289 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10294 std::ostringstream oss; oss << "constructor MEDFileFields(fileName) : file \'" << FileNameFromFID(fid) << "\' at pos #" << i << " field has name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
10295 throw INTERP_KERNEL::Exception(oss.str());
10299 loadAllGlobals(fid);
10301 catch(INTERP_KERNEL::Exception& e)
10306 void MEDFileFields::writeLL(med_idt fid) const
10309 writeGlobals(fid,*this);
10310 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10312 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
10315 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
10316 throw INTERP_KERNEL::Exception(oss.str());
10318 elt->writeLL(fid,*this);
10323 * This method alloc the arrays and load potentially huge arrays contained in this field.
10324 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
10325 * This method can be also called to refresh or reinit values from a file.
10327 * \throw If the fileName is not set or points to a non readable MED file.
10329 void MEDFileFields::loadArrays()
10331 if(getFileName().empty())
10332 throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
10333 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
10334 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10336 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10338 elt->loadBigArraysRecursively(fid,*elt);
10343 * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
10344 * But once data loaded once, this method does nothing.
10346 * \throw If the fileName is not set or points to a non readable MED file.
10347 * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
10349 void MEDFileFields::loadArraysIfNecessary()
10351 if(!getFileName().empty())
10353 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
10354 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10356 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10358 elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
10364 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
10365 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
10366 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
10368 * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
10370 void MEDFileFields::unloadArrays()
10372 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10374 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10376 elt->unloadArrays();
10381 * 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.
10382 * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
10383 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
10385 * \sa MEDFileFields::loadArraysIfNecessary
10387 void MEDFileFields::unloadArraysWithoutDataLoss()
10389 if(!getFileName().empty())
10393 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
10395 std::vector<std::string> ret;
10396 std::set<std::string> ret2;
10397 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10399 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
10400 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10401 if(ret2.find(*it2)==ret2.end())
10403 ret.push_back(*it2);
10410 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
10412 std::vector<std::string> ret;
10413 std::set<std::string> ret2;
10414 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10416 std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
10417 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10418 if(ret2.find(*it2)==ret2.end())
10420 ret.push_back(*it2);
10427 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
10429 std::vector<std::string> ret;
10430 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10432 std::vector<std::string> tmp((*it)->getPflsReallyUsedMulti2());
10433 ret.insert(ret.end(),tmp.begin(),tmp.end());
10438 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
10440 std::vector<std::string> ret;
10441 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10443 std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
10444 ret.insert(ret.end(),tmp.begin(),tmp.end());
10449 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10451 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10452 (*it)->changePflsRefsNamesGen2(mapOfModif);
10455 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10457 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10458 (*it)->changeLocsRefsNamesGen2(mapOfModif);
10461 void MEDFileFields::resize(int newSize)
10463 _fields.resize(newSize);
10466 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
10468 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
10472 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
10475 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
10476 _fields.push_back(field->getContent());
10477 appendGlobs(*field,1e-12);
10480 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
10483 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
10484 if(i>=(int)_fields.size())
10485 _fields.resize(i+1);
10486 _fields[i]=field->getContent();
10487 appendGlobs(*field,1e-12);
10490 void MEDFileFields::destroyFieldAtPos(int i)
10492 destroyFieldsAtPos(&i,&i+1);
10495 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
10497 std::vector<bool> b(_fields.size(),true);
10498 for(const int *i=startIds;i!=endIds;i++)
10500 if(*i<0 || *i>=(int)_fields.size())
10502 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10503 throw INTERP_KERNEL::Exception(oss.str());
10507 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10509 for(std::size_t i=0;i<_fields.size();i++)
10511 fields[j++]=_fields[i];
10515 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
10517 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
10518 int nbOfEntriesToKill(DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg));
10519 std::vector<bool> b(_fields.size(),true);
10521 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
10523 if(k<0 || k>=(int)_fields.size())
10525 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
10526 throw INTERP_KERNEL::Exception(oss.str());
10530 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10532 for(std::size_t i=0;i<_fields.size();i++)
10534 fields[j++]=_fields[i];
10538 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
10541 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10543 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10545 ret=cur->changeMeshNames(modifTab) || ret;
10551 * \param [in] meshName the name of the mesh that will be renumbered.
10552 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
10553 * This code corresponds to the distribution of types in the corresponding mesh.
10554 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
10555 * \param [in] renumO2N the old to new renumber array.
10556 * \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
10557 * field in \a this.
10559 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
10562 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10564 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
10567 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
10574 * Return an extraction of \a this using \a extractDef map to specify the extraction.
10575 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
10577 * \return A new object that the caller is responsible to deallocate.
10579 MEDFileFields *MEDFileFields::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
10582 throw INTERP_KERNEL::Exception("MEDFileFields::extractPart : input mesh is NULL !");
10583 MCAuto<MEDFileFields> fsOut(MEDFileFields::New());
10584 int nbFields(getNumberOfFields());
10585 for(int i=0;i<nbFields;i++)
10587 MCAuto<MEDFileAnyTypeFieldMultiTS> fmts(getFieldAtPos(i));
10590 std::ostringstream oss; oss << "MEDFileFields::extractPart : at pos #" << i << " field is null !";
10591 throw INTERP_KERNEL::Exception(oss.str());
10593 MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(fmts->extractPart(extractDef,mm));
10594 fsOut->pushField(fmtsOut);
10596 return fsOut.retn();
10599 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
10601 if(i<0 || i>=(int)_fields.size())
10603 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
10604 throw INTERP_KERNEL::Exception(oss.str());
10606 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
10609 MCAuto<MEDFileAnyTypeFieldMultiTS> ret;
10610 const MEDFileFieldMultiTSWithoutSDA *fmtsC(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts));
10611 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts));
10613 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
10615 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
10618 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
10619 throw INTERP_KERNEL::Exception(oss.str());
10621 ret->shallowCpyGlobs(*this);
10626 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
10627 * This method is accessible in python using __getitem__ with a list in input.
10628 * \return a new object that the caller should deal with.
10630 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
10632 MCAuto<MEDFileFields> ret=shallowCpy();
10633 std::size_t sz=std::distance(startIds,endIds);
10634 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
10636 for(const int *i=startIds;i!=endIds;i++,j++)
10638 if(*i<0 || *i>=(int)_fields.size())
10640 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10641 throw INTERP_KERNEL::Exception(oss.str());
10643 fields[j]=_fields[*i];
10645 ret->_fields=fields;
10649 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
10651 return getFieldAtPos(getPosFromFieldName(fieldName));
10655 * This method removes, if any, fields in \a this having no time steps.
10656 * 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.
10658 * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
10660 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
10662 std::vector<MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
10663 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10665 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10668 if(elt->getNumberOfTS()>0)
10669 newFields.push_back(*it);
10672 if(_fields.size()==newFields.size())
10679 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
10680 * This method can be seen as a filter applied on \a this, that returns an object containing
10681 * 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
10682 * shallow copied from \a this.
10684 * \param [in] meshName - the name of the mesh on w
10685 * \return a new object that the caller should deal with.
10687 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
10689 MCAuto<MEDFileFields> ret(MEDFileFields::New());
10690 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10692 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10695 if(cur->getMeshName()==meshName)
10698 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
10699 ret->_fields.push_back(cur2);
10702 ret->shallowCpyOnlyUsedGlobs(*this);
10707 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
10708 * Input time steps are specified using a pair of integer (iteration, order).
10709 * 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,
10710 * but for each multitimestep only the time steps in \a timeSteps are kept.
10711 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
10713 * The returned object points to shallow copy of elements in \a this.
10715 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
10716 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
10717 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10719 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10721 MCAuto<MEDFileFields> ret(MEDFileFields::New());
10722 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10724 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10727 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
10728 ret->_fields.push_back(elt);
10730 ret->shallowCpyOnlyUsedGlobs(*this);
10735 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
10737 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10739 MCAuto<MEDFileFields> ret=MEDFileFields::New();
10740 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10742 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10745 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
10746 if(elt->getNumberOfTS()!=0)
10747 ret->_fields.push_back(elt);
10749 ret->shallowCpyOnlyUsedGlobs(*this);
10753 MEDFileFieldsIterator *MEDFileFields::iterator()
10755 return new MEDFileFieldsIterator(this);
10758 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
10760 std::string tmp(fieldName);
10761 std::vector<std::string> poss;
10762 for(std::size_t i=0;i<_fields.size();i++)
10764 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f(_fields[i]);
10767 std::string fname(f->getName());
10771 poss.push_back(fname);
10774 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
10775 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
10777 throw INTERP_KERNEL::Exception(oss.str());
10780 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
10785 _nb_iter=fs->getNumberOfFields();
10789 MEDFileFieldsIterator::~MEDFileFieldsIterator()
10793 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
10795 if(_iter_id<_nb_iter)
10797 MEDFileFields *fs(_fs);
10799 return fs->getFieldAtPos(_iter_id++);