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(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int profileIt, const PartDefinition *pd)
408 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt,pd);
411 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerTypeCommon *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(MEDFileFieldPerMeshPerTypeCommon *father) const
435 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret=new MEDFileFieldPerMeshPerTypePerDisc(*this);
440 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *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(MEDFileFieldPerMeshPerTypeCommon *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 MEDFileFieldPerMeshPerTypeCommon *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(MEDFileFieldPerMeshPerTypeCommon::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(MEDFileFieldPerMeshPerTypeCommon::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 MEDFileFieldPerMeshPerTypeCommon *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=MEDFileFieldPerMeshPerTypeCommon::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 ////////////////////////////////////
1052 void MEDFileFieldPerMeshPerTypeCommon::setFather(MEDFileFieldPerMesh *father)
1057 void MEDFileFieldPerMeshPerTypeCommon::deepCopyElements()
1060 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1062 if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
1063 _field_pm_pt_pd[i]=(*it)->deepCopy(this);
1067 std::size_t MEDFileFieldPerMeshPerTypeCommon::getHeapMemorySizeWithoutChildren() const
1069 return _field_pm_pt_pd.capacity()*sizeof(MCAuto<MEDFileFieldPerMeshPerTypePerDisc>);
1072 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypeCommon::getDirectChildrenWithNull() const
1074 std::vector<const BigMemoryObject *> ret;
1075 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1076 ret.push_back((const MEDFileFieldPerMeshPerTypePerDisc *)*it);
1080 void MEDFileFieldPerMeshPerTypeCommon::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1082 std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
1083 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1084 _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1088 * This method is the most general one. No optimization is done here.
1089 * \param [in] multiTypePfl is the end user profile specified in high level API
1090 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1091 * \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.
1092 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1093 * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1094 * \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.
1096 void MEDFileFieldPerMeshPerTypeCommon::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)
1098 std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1099 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1100 _field_pm_pt_pd[*it]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1103 void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1105 _field_pm_pt_pd.resize(1);
1106 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1107 _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1110 void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1112 MCAuto<DataArrayInt> pfl2=pfl->deepCopy();
1113 if(!arr || !arr->isAllocated())
1114 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile : input array is null, or not allocated !");
1115 _field_pm_pt_pd.resize(1);
1116 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1117 _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.
1120 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1122 TypeOfField type=field->getTypeOfField();
1123 if(type!=ON_GAUSS_PT)
1125 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1126 int sz=_field_pm_pt_pd.size();
1128 for(int j=0;j<sz && !found;j++)
1130 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1132 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1138 _field_pm_pt_pd.resize(sz+1);
1139 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1141 std::vector<int> ret(1,(int)sz);
1146 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1147 int sz2=ret2.size();
1148 std::vector<int> ret3(sz2);
1150 for(int i=0;i<sz2;i++)
1152 int sz=_field_pm_pt_pd.size();
1153 int locIdToFind=ret2[i];
1155 for(int j=0;j<sz && !found;j++)
1157 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1159 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1166 _field_pm_pt_pd.resize(sz+1);
1167 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1175 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1177 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1178 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1180 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1181 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1183 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1184 MCAuto<DataArrayInt> da2=da->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1);
1185 MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1186 if(retTmp->presenceOfValue(-1))
1187 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1188 std::vector<int> ret(retTmp->begin(),retTmp->end());
1192 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1194 TypeOfField type=field->getTypeOfField();
1195 if(type!=ON_GAUSS_PT)
1197 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1198 int sz=_field_pm_pt_pd.size();
1200 for(int j=0;j<sz && !found;j++)
1202 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1204 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1210 _field_pm_pt_pd.resize(sz+1);
1211 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1213 std::vector<int> ret(1,0);
1218 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1219 int sz2=ret2.size();
1220 std::vector<int> ret3(sz2);
1222 for(int i=0;i<sz2;i++)
1224 int sz=_field_pm_pt_pd.size();
1225 int locIdToFind=ret2[i];
1227 for(int j=0;j<sz && !found;j++)
1229 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1231 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1238 _field_pm_pt_pd.resize(sz+1);
1239 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1247 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1249 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1250 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1252 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1253 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1255 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1256 MCAuto<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1257 MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1258 if(retTmp->presenceOfValue(-1))
1259 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1260 std::vector<int> ret(retTmp->begin(),retTmp->end());
1264 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerTypeCommon::getFather() const
1269 void MEDFileFieldPerMeshPerTypeCommon::getDimension(int& dim) const
1271 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1272 int curDim((int)cm.getDimension());
1273 dim=std::max(dim,curDim);
1276 bool MEDFileFieldPerMeshPerTypeCommon::isUniqueLevel(int& dim) const
1278 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1279 int curDim((int)cm.getDimension());
1280 if(dim!=std::numeric_limits<int>::max())
1290 void MEDFileFieldPerMeshPerTypeCommon::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1292 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1294 (*it)->fillTypesOfFieldAvailable(types);
1298 void MEDFileFieldPerMeshPerTypeCommon::fillFieldSplitedByType(std::vector< std::pair<int,int> >& dads, std::vector<TypeOfField>& types, std::vector<std::string>& pfls, std::vector<std::string>& locs) const
1300 int sz=_field_pm_pt_pd.size();
1301 dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1302 for(int i=0;i<sz;i++)
1304 _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1308 int MEDFileFieldPerMeshPerTypeCommon::getIteration() const
1310 return _father->getIteration();
1313 int MEDFileFieldPerMeshPerTypeCommon::getOrder() const
1315 return _father->getOrder();
1318 double MEDFileFieldPerMeshPerTypeCommon::getTime() const
1320 return _father->getTime();
1323 std::string MEDFileFieldPerMeshPerTypeCommon::getMeshName() const
1325 return _father->getMeshName();
1328 void MEDFileFieldPerMeshPerTypeCommon::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1330 const char startLine[]=" ## ";
1331 std::string startLine2(bkOffset,' ');
1332 std::string startLine3(startLine2);
1333 startLine3+=startLine;
1334 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1336 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1337 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1340 oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1341 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1343 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1345 const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1347 cur->simpleRepr(bkOffset,oss,i);
1350 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1355 void MEDFileFieldPerMeshPerTypeCommon::getSizes(int& globalSz, int& nbOfEntries) const
1357 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1359 globalSz+=(*it)->getNumberOfTuples();
1361 nbOfEntries+=(int)_field_pm_pt_pd.size();
1364 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypeCommon::getGeoType() const
1370 int MEDFileFieldPerMeshPerTypeCommon::getNumberOfComponents() const
1372 return _father->getNumberOfComponents();
1375 bool MEDFileFieldPerMeshPerTypeCommon::presenceOfMultiDiscPerGeoType() const
1378 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1380 const MEDFileFieldPerMeshPerTypePerDisc *fmtd(*it);
1387 DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray()
1389 return _father->getOrCreateAndGetArray();
1392 const DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray() const
1394 const MEDFileFieldPerMesh *fath=_father;
1395 return fath->getOrCreateAndGetArray();
1398 const std::vector<std::string>& MEDFileFieldPerMeshPerTypeCommon::getInfo() const
1400 return _father->getInfo();
1403 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsed() const
1405 std::vector<std::string> ret;
1406 std::set<std::string> ret2;
1407 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1409 std::string tmp=(*it1)->getProfile();
1411 if(ret2.find(tmp)==ret2.end())
1420 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsed() const
1422 std::vector<std::string> ret;
1423 std::set<std::string> ret2;
1424 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1426 std::string tmp=(*it1)->getLocalization();
1427 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1428 if(ret2.find(tmp)==ret2.end())
1437 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsedMulti() const
1439 std::vector<std::string> ret;
1440 std::set<std::string> ret2;
1441 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1443 std::string tmp=(*it1)->getProfile();
1450 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsedMulti() const
1452 std::vector<std::string> ret;
1453 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1455 std::string tmp=(*it1)->getLocalization();
1456 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1462 void MEDFileFieldPerMeshPerTypeCommon::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1464 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1465 (*it1)->changePflsRefsNamesGen(mapOfModif);
1468 void MEDFileFieldPerMeshPerTypeCommon::changeLocsRefsNamesGen(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)->changeLocsRefsNamesGen(mapOfModif);
1474 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId)
1476 if(_field_pm_pt_pd.empty())
1478 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1479 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1480 throw INTERP_KERNEL::Exception(oss.str());
1482 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1483 return _field_pm_pt_pd[locId];
1484 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1485 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
1486 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1487 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1488 return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1491 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId) const
1493 if(_field_pm_pt_pd.empty())
1495 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1496 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1497 throw INTERP_KERNEL::Exception(oss.str());
1499 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1500 return _field_pm_pt_pd[locId];
1501 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1502 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
1503 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1504 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1505 return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1508 void MEDFileFieldPerMeshPerTypeCommon::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
1510 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1512 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1513 if(meshDim!=(int)cm.getDimension())
1516 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1517 (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1520 void MEDFileFieldPerMeshPerTypeCommon::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1523 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1525 (*it)->fillValues(i,startEntryId,entries);
1529 void MEDFileFieldPerMeshPerTypeCommon::setLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
1531 _field_pm_pt_pd=leaves;
1532 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1533 (*it)->setFather(this);
1537 * \param [in,out] globalNum a global numbering counter for the renumbering.
1538 * \param [out] its - list of pair (start,stop) kept
1539 * \return bool - false if the type of field \a tof is not contained in \a this.
1541 bool MEDFileFieldPerMeshPerTypeCommon::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
1544 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1545 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1546 if((*it)->getType()==tof)
1548 newPmPtPd.push_back(*it);
1549 std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1550 (*it)->setNewStart(globalNum);
1551 globalNum=(*it)->getEnd();
1552 its.push_back(bgEnd);
1556 _field_pm_pt_pd=newPmPtPd;
1561 * \param [in,out] globalNum a global numbering counter for the renumbering.
1562 * \param [out] its - list of pair (start,stop) kept
1563 * \return bool - false if the type of field \a tof is not contained in \a this.
1565 bool MEDFileFieldPerMeshPerTypeCommon::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
1567 if(_field_pm_pt_pd.size()<=idOfDisc)
1569 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt(_field_pm_pt_pd[idOfDisc]);
1570 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd(1,elt);
1571 std::pair<int,int> bgEnd; bgEnd.first=_field_pm_pt_pd[idOfDisc]->getStart(); bgEnd.second=_field_pm_pt_pd[idOfDisc]->getEnd();
1572 elt->setNewStart(globalNum);
1573 globalNum=elt->getEnd();
1574 its.push_back(bgEnd);
1575 _field_pm_pt_pd=newPmPtPd;
1579 MEDFileFieldPerMeshPerTypeCommon::MEDFileFieldPerMeshPerTypeCommon(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):_father(fath),_geo_type(geoType)
1581 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1582 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1583 med_geometry_type mgeoti;
1584 med_entity_type menti(ConvertIntoMEDFileType(type,geoType,mgeoti));
1585 int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName));
1586 _field_pm_pt_pd.resize(nbProfiles);
1587 for(int i=0;i<nbProfiles;i++)
1589 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i,pd);
1593 int nbProfiles2(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName));
1594 for(int i=0;i<nbProfiles2;i++)
1595 _field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i,pd));
1599 void MEDFileFieldPerMeshPerTypeCommon::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
1601 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1602 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1605 void MEDFileFieldPerMeshPerTypeCommon::loadBigArraysRecursively(med_idt fid, 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)->loadBigArray(fid,nasc);
1611 void MEDFileFieldPerMeshPerTypeCommon::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1613 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1615 (*it)->copyOptionsFrom(*this);
1616 (*it)->writeLL(fid,nasc);
1620 med_entity_type MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1625 medfGeoType=typmai3[(int)ikGeoType];
1628 medfGeoType=MED_NONE;
1631 medfGeoType=typmai3[(int)ikGeoType];
1632 return MED_NODE_ELEMENT;
1634 medfGeoType=typmai3[(int)ikGeoType];
1637 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1639 return MED_UNDEF_ENTITY_TYPE;
1642 //////////////////////////////////////////////////
1644 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd)
1646 return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc,pd);
1649 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType)
1651 return new MEDFileFieldPerMeshPerType(fath,geoType);
1654 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCopy(MEDFileFieldPerMesh *father) const
1656 MCAuto<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
1657 ret->setFather(father);
1658 ret->deepCopyElements();
1662 //////////////////////////////////////////////////
1664 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const MEDFileEntities *entities)
1666 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm,entities);
1669 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1671 return new MEDFileFieldPerMesh(fath,mesh);
1674 std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
1676 return _mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MCAuto< MEDFileFieldPerMeshPerType >);
1679 std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildrenWithNull() const
1681 std::vector<const BigMemoryObject *> ret;
1682 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1683 ret.push_back((const MEDFileFieldPerMeshPerType *)*it);
1687 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCopy(MEDFileAnyTypeField1TSWithoutSDA *father) const
1689 MCAuto< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1690 ret->_father=father;
1692 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1694 if((const MEDFileFieldPerMeshPerType *)*it)
1695 ret->_field_pm_pt[i]=(*it)->deepCopy((MEDFileFieldPerMesh *)(ret));
1700 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1702 std::string startLine(bkOffset,' ');
1703 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1704 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1706 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1708 const MEDFileFieldPerMeshPerType *cur=*it;
1710 cur->simpleRepr(bkOffset,oss,i);
1713 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1718 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh)
1720 _mesh_name=mesh->getName();
1721 mesh->getTime(_mesh_iteration,_mesh_order);
1724 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1726 int nbOfTypes=code.size()/3;
1728 for(int i=0;i<nbOfTypes;i++)
1730 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1731 int nbOfCells=code[3*i+1];
1732 int pos=addNewEntryIfNecessary(type);
1733 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1739 * This method is the most general one. No optimization is done here.
1740 * \param [in] multiTypePfl is the end user profile specified in high level API
1741 * \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].
1742 * \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.
1743 * \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.
1744 * \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.
1745 * \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.
1747 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)
1749 int nbOfTypes(code.size()/3);
1750 for(int i=0;i<nbOfTypes;i++)
1752 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1753 int pos=addNewEntryIfNecessary(type);
1754 DataArrayInt *pfl=0;
1756 pfl=idsPerType[code[3*i+2]];
1757 int nbOfTupes2=code2.size()/3;
1759 for(;found<nbOfTupes2;found++)
1760 if(code[3*i]==code2[3*found])
1762 if(found==nbOfTupes2)
1763 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1764 _field_pm_pt[pos]->assignFieldProfile(nbOfTypes==1,start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1768 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1770 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1771 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1774 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1776 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1777 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1780 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
1782 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1783 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1786 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1788 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1789 (*it)->loadBigArraysRecursively(fid,nasc);
1792 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1794 int nbOfTypes=_field_pm_pt.size();
1795 for(int i=0;i<nbOfTypes;i++)
1797 _field_pm_pt[i]->copyOptionsFrom(*this);
1798 _field_pm_pt[i]->writeLL(fid,nasc);
1802 void MEDFileFieldPerMesh::getDimension(int& dim) const
1804 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1805 (*it)->getDimension(dim);
1808 bool MEDFileFieldPerMesh::isUniqueLevel(int& dim) const
1810 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1811 if(!(*it)->isUniqueLevel(dim))
1816 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1818 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1819 (*it)->fillTypesOfFieldAvailable(types);
1822 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
1824 int sz=_field_pm_pt.size();
1825 std::vector< std::vector<std::pair<int,int> > > ret(sz);
1826 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1827 for(int i=0;i<sz;i++)
1829 types[i]=_field_pm_pt[i]->getGeoType();
1830 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1835 double MEDFileFieldPerMesh::getTime() const
1838 return _father->getTime(tmp1,tmp2);
1841 int MEDFileFieldPerMesh::getIteration() const
1843 return _father->getIteration();
1846 int MEDFileFieldPerMesh::getOrder() const
1848 return _father->getOrder();
1851 int MEDFileFieldPerMesh::getNumberOfComponents() const
1853 return _father->getNumberOfComponents();
1856 bool MEDFileFieldPerMesh::presenceOfMultiDiscPerGeoType() const
1858 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1860 const MEDFileFieldPerMeshPerType *fpmt(*it);
1863 if(fpmt->presenceOfMultiDiscPerGeoType())
1869 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
1872 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1873 return _father->getOrCreateAndGetArray();
1876 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
1879 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1880 return _father->getOrCreateAndGetArray();
1883 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1885 return _father->getInfo();
1889 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
1890 * 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.
1891 * It returns 2 output vectors :
1892 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
1893 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
1894 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
1896 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)
1898 int notNullPflsSz=0;
1899 int nbOfArrs=geoTypes.size();
1900 for(int i=0;i<nbOfArrs;i++)
1903 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
1904 int nbOfDiffGeoTypes=geoTypes3.size();
1905 code.resize(3*nbOfDiffGeoTypes);
1906 notNullPfls.resize(notNullPflsSz);
1909 for(int i=0;i<nbOfDiffGeoTypes;i++)
1912 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
1913 std::vector<const DataArrayInt *> notNullTmp;
1915 notNullTmp.push_back(pfls[j]);
1917 for(;j<nbOfArrs;j++)
1918 if(geoTypes[j]==refType)
1921 notNullTmp.push_back(pfls[j]);
1925 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
1926 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
1927 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
1928 code[3*i]=(int)refType;
1929 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
1930 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
1931 if(notNullTmp.empty())
1935 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
1936 code[3*i+2]=notNullPflsSz++;
1942 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
1944 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)
1948 for(int i=0;i<sz;i++)
1952 if(type!=ON_GAUSS_NE)
1953 ret+=dads[i].second-dads[i].first;
1956 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
1957 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
1962 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
1963 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
1969 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
1971 std::vector<std::string> ret;
1972 std::set<std::string> ret2;
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)->getPflsReallyUsed();
1976 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1977 if(ret2.find(*it2)==ret2.end())
1979 ret.push_back(*it2);
1986 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
1988 std::vector<std::string> ret;
1989 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1991 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
1992 ret.insert(ret.end(),tmp.begin(),tmp.end());
1997 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
1999 std::vector<std::string> ret;
2000 std::set<std::string> ret2;
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)->getLocsReallyUsed();
2004 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
2005 if(ret2.find(*it2)==ret2.end())
2007 ret.push_back(*it2);
2014 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
2016 std::vector<std::string> ret;
2017 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2019 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
2020 ret.insert(ret.end(),tmp.begin(),tmp.end());
2025 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
2027 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
2029 if((*it).first==_mesh_name)
2031 _mesh_name=(*it).second;
2038 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
2039 MEDFileFieldGlobsReal& glob)
2041 if(_mesh_name!=meshName)
2043 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
2044 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
2045 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
2046 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
2047 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
2048 getUndergroundDataArrayExt(entries);
2049 DataArray *arr0(getOrCreateAndGetArray());//tony
2051 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
2052 DataArrayDouble *arr(dynamic_cast<DataArrayDouble *>(arr0));//tony
2054 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
2057 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
2058 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
2060 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
2062 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2063 sz+=(*it).second.second-(*it).second.first;
2066 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2068 MCAuto<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
2069 ////////////////////
2070 MCAuto<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
2071 int *workI2=explicitIdsOldInMesh->getPointer();
2072 int sz1=0,sz2=0,sid=1;
2073 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
2074 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
2075 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
2077 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
2078 MCAuto<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
2079 int *workI=explicitIdsOldInArr->getPointer();
2080 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
2082 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
2083 (*itL2)->setLocId(sz2);
2084 (*itL2)->_tmp_work1=(*itL2)->getStart();
2085 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
2087 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
2089 explicitIdsOldInMesh->reAlloc(sz2);
2090 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
2091 ////////////////////
2092 MCAuto<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
2093 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
2094 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
2095 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
2097 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
2098 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
2099 otherEntriesNew.back()->setLocId((*it)->getGeoType());
2101 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
2102 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
2103 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
2105 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
2106 int newStart=elt->getLocId();
2107 elt->setLocId((*it)->getGeoType());
2108 elt->setNewStart(newStart);
2109 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
2110 entriesKeptNew.push_back(elt);
2111 entriesKeptNew2.push_back(elt);
2113 MCAuto<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
2114 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
2115 MCAuto<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
2116 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
2118 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
2121 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
2123 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
2124 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
2126 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
2127 glob,arr2,otherEntriesNew) || ret;
2131 // Assign new dispatching
2132 assignNewLeaves(otherEntriesNew);
2133 arr->deepCopyFrom(*arr2);
2138 * \param [in,out] globalNum a global numbering counter for the renumbering.
2139 * \param [out] its - list of pair (start,stop) kept
2141 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
2143 std::vector< MCAuto< MEDFileFieldPerMeshPerType > > ret;
2144 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2146 std::vector< std::pair<int,int> > its2;
2147 if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
2150 its.insert(its.end(),its2.begin(),its2.end());
2157 * \param [in,out] globalNum a global numbering counter for the renumbering.
2158 * \param [out] its - list of pair (start,stop) kept
2160 void MEDFileFieldPerMesh::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
2162 std::vector< MCAuto< MEDFileFieldPerMeshPerType > > ret;
2163 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2165 std::vector< std::pair<int,int> > its2;
2166 if((*it)->keepOnlyGaussDiscretization(idOfDisc,globalNum,its2))
2169 its.insert(its.end(),its2.begin(),its2.end());
2175 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
2177 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > > types;
2178 for( std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
2179 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
2181 std::vector< MCAuto< MEDFileFieldPerMeshPerType > > fieldPmPt(types.size());
2182 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
2183 std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it2=fieldPmPt.begin();
2184 for(;it1!=types.end();it1++,it2++)
2186 MCAuto<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
2187 elt->setLeaves((*it1).second);
2190 _field_pm_pt=fieldPmPt;
2193 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2195 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2196 (*it)->changePflsRefsNamesGen(mapOfModif);
2199 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2201 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2202 (*it)->changeLocsRefsNamesGen(mapOfModif);
2206 * \param [in] mesh is the whole mesh
2208 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2210 if(_field_pm_pt.empty())
2211 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2213 std::vector< std::pair<int,int> > dads;
2214 std::vector<const DataArrayInt *> pfls;
2215 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2216 std::vector<int> locs,code;
2217 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2218 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2219 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2221 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2224 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2225 throw INTERP_KERNEL::Exception(oss.str());
2228 std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2229 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2232 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2234 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2237 MCAuto<DataArrayInt> arr2(arr);
2238 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2244 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2248 if(nb!=mesh->getNumberOfNodes())
2250 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2251 oss << " nodes in mesh !";
2252 throw INTERP_KERNEL::Exception(oss.str());
2254 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2257 return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2261 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
2263 if(_field_pm_pt.empty())
2264 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2266 std::vector<std::pair<int,int> > dads;
2267 std::vector<const DataArrayInt *> pfls;
2268 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2269 std::vector<int> locs,code;
2270 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2271 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2272 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2274 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2277 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2278 throw INTERP_KERNEL::Exception(oss.str());
2280 std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2281 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2284 MCAuto<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2285 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2290 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2294 if(nb!=mesh->getNumberOfNodes())
2296 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2297 oss << " nodes in mesh !";
2298 throw INTERP_KERNEL::Exception(oss.str());
2301 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2307 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
2311 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2313 (*it)->getSizes(globalSz,nbOfEntries);
2315 entries.resize(nbOfEntries);
2317 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2319 (*it)->fillValues(nbOfEntries,entries);
2323 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
2325 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2327 if((*it)->getGeoType()==typ)
2328 return (*it)->getLeafGivenLocId(locId);
2330 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2331 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2332 oss << "Possiblities are : ";
2333 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2335 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2336 oss << "\"" << cm2.getRepr() << "\", ";
2338 throw INTERP_KERNEL::Exception(oss.str());
2341 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
2343 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2345 if((*it)->getGeoType()==typ)
2346 return (*it)->getLeafGivenLocId(locId);
2348 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2349 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2350 oss << "Possiblities are : ";
2351 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2353 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2354 oss << "\"" << cm2.getRepr() << "\", ";
2356 throw INTERP_KERNEL::Exception(oss.str());
2360 * \param [in,out] start - Integer that gives the current position in the final aggregated array
2361 * \param [in] pms - list of elements to aggregate. integer gives the mesh id
2362 * \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.
2363 * \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.
2365 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)
2367 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret(new MEDFileFieldPerMeshPerTypePerDisc(father,tof));
2369 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : empty input vector !");
2370 for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it=pms.begin();it!=pms.end();it++)
2373 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : presence of null pointer !");
2374 if(!(*it).second->getProfile().empty())
2375 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for profiles !");
2376 if(!(*it).second->getLocalization().empty())
2377 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for gauss pts !");
2379 INTERP_KERNEL::NormalizedCellType gt(pms[0].second->getGeoType());
2381 std::vector< std::pair<int,int> > filteredDTS;
2382 for(std::vector< std::vector< std::pair<int,int> > >::const_iterator it=dts.begin();it!=dts.end();it++,i++)
2383 for(std::vector< std::pair<int,int> >::const_iterator it2=(*it).begin();it2!=(*it).end();it2++)
2384 if((*it2).first==gt)
2385 filteredDTS.push_back(std::pair<int,int>(i,(*it2).second));
2386 if(pms.size()!=filteredDTS.size())
2387 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles !");
2388 std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it1(pms.begin());
2389 std::vector< std::pair<int,int> >::const_iterator it2(filteredDTS.begin());
2390 int zeStart(start),nval(0);
2391 for(;it1!=pms.end();it1++,it2++)
2393 if((*it1).first!=(*it2).first)
2394 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles 2 !");
2395 int s1((*it1).second->getStart()),e1((*it1).second->getEnd());
2396 extractInfo.push_back(std::pair<int, std::pair<int,int> >((*it1).first,std::pair<int,int>(s1,e1)));
2398 nval+=((*it1).second)->getNumberOfVals();
2400 ret->_start=zeStart; ret->_end=start; ret->_nval=nval;
2404 MCAuto<MEDFileFieldPerMeshPerType> MEDFileFieldPerMeshPerTypeCommon::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)
2406 MCAuto<MEDFileFieldPerMeshPerType> ret(new MEDFileFieldPerMeshPerType(father,gt));
2407 std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > > m;
2408 for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerType *> >::const_iterator it=pms.begin();it!=pms.end();it++)
2410 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it2=(*it).second->_field_pm_pt_pd.begin();it2!=(*it).second->_field_pm_pt_pd.end();it2++)
2411 m[(*it2)->getType()].push_back(std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * >((*it).first,*it2));
2413 for(std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > >::const_iterator it=m.begin();it!=m.end();it++)
2415 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> agg(MEDFileFieldPerMeshPerTypePerDisc::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
2416 ret->_field_pm_pt_pd.push_back(agg);
2421 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)
2423 MCAuto<MEDFileFieldPerMesh> ret(new MEDFileFieldPerMesh(father,pms[0]->getMeshName(),pms[0]->getMeshIteration(),pms[0]->getMeshOrder()));
2424 std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > > m;
2426 for(std::vector<const MEDFileFieldPerMesh *>::const_iterator it=pms.begin();it!=pms.end();it++,i++)
2428 const std::vector< MCAuto< MEDFileFieldPerMeshPerType > >& v((*it)->_field_pm_pt);
2429 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it2=v.begin();it2!=v.end();it2++)
2431 INTERP_KERNEL::NormalizedCellType gt((*it2)->getGeoType());
2432 m[gt].push_back(std::pair<int,const MEDFileFieldPerMeshPerType *>(i,*it2));
2435 for(std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > >::const_iterator it=m.begin();it!=m.end();it++)
2437 MCAuto<MEDFileFieldPerMeshPerType> agg(MEDFileFieldPerMeshPerTypeCommon::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
2438 ret->_field_pm_pt.push_back(agg);
2443 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2446 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2447 std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it2=_field_pm_pt.begin();
2448 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2450 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2455 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2460 int ret=std::distance(_field_pm_pt.begin(),it2);
2461 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2466 * 'dads' and 'locs' input parameters have the same number of elements
2467 * \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
2469 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2470 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2471 const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2474 MCAuto<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2475 ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2476 MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2477 const std::vector<std::string>& infos=getInfo();
2478 da->setInfoOnComponents(infos);
2480 if(type==ON_GAUSS_PT)
2483 int nbOfArrs=dads.size();
2484 for(int i=0;i<nbOfArrs;i++)
2486 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2487 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2488 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2489 MCAuto<DataArrayInt> di=DataArrayInt::New();
2490 di->alloc(nbOfElems,1);
2492 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2493 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2502 * 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.
2503 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2504 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2505 * The order of cells in the returned field is those imposed by the profile.
2506 * \param [in] mesh is the global mesh.
2508 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2509 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2510 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2511 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2513 if(da->isIota(mesh->getNumberOfCells()))
2514 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2515 MCAuto<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2516 m2->setName(mesh->getName().c_str());
2517 MCAuto<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2523 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2525 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2526 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2527 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2529 if(da->isIota(mesh->getNumberOfNodes()))
2530 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2531 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2532 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2535 if(meshu->getNodalConnectivity()==0)
2537 MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2538 int nb=da->getNbOfElems();
2539 const int *ptr=da->getConstPointer();
2540 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2541 meshuc->allocateCells(nb);
2542 for(int i=0;i<nb;i++)
2543 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2544 meshuc->finishInsertingCells();
2545 ret->setMesh(meshuc);
2546 const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2547 if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2548 disc->checkCoherencyBetween(meshuc,arrOut);
2553 MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2555 DataArrayInt *arr2=0;
2556 MCAuto<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2557 MCAuto<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2558 MCAuto<DataArrayInt> arr3(arr2);
2559 int nnodes=mesh2->getNumberOfNodes();
2560 if(nnodes==(int)da->getNbOfElems())
2562 MCAuto<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2563 arrOut->renumberInPlace(da3->getConstPointer());
2564 mesh2->setName(mesh->getName().c_str());
2565 ret->setMesh(mesh2);
2570 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 !!!";
2571 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2572 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2573 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2574 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2575 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2576 throw INTERP_KERNEL::Exception(oss.str());
2582 * This method is the most light method of field retrieving.
2584 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
2588 pflOut=DataArrayInt::New();
2589 pflOut->alloc(nbOfElems,1);
2594 pflOut=const_cast<DataArrayInt*>(pflIn);
2597 MCAuto<DataArrayInt> safePfl(pflOut);
2598 MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2599 const std::vector<std::string>& infos=getInfo();
2600 int nbOfComp=infos.size();
2601 for(int i=0;i<nbOfComp;i++)
2602 da->setInfoOnComponent(i,infos[i].c_str());
2613 static MFFPMIter *NewCell(const MEDFileEntities *entities);
2614 static bool IsPresenceOfNode(const MEDFileEntities *entities);
2615 virtual ~MFFPMIter() { }
2616 virtual void begin() = 0;
2617 virtual bool finished() const = 0;
2618 virtual void next() = 0;
2619 virtual int current() const = 0;
2622 class MFFPMIterSimple : public MFFPMIter
2625 MFFPMIterSimple():_pos(0) { }
2626 void begin() { _pos=0; }
2627 bool finished() const { return _pos>=MED_N_CELL_FIXED_GEO; }
2628 void next() { _pos++; }
2629 int current() const { return _pos; }
2634 class MFFPMIter2 : public MFFPMIter
2637 MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts);
2638 void begin() { _it=_ids.begin(); }
2639 bool finished() const { return _it==_ids.end(); }
2640 void next() { _it++; }
2641 int current() const { return *_it; }
2643 std::vector<int> _ids;
2644 std::vector<int>::const_iterator _it;
2647 MFFPMIter *MFFPMIter::NewCell(const MEDFileEntities *entities)
2650 return new MFFPMIterSimple;
2653 const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
2656 std::vector<INTERP_KERNEL::NormalizedCellType> tmp;
2657 const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
2658 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
2660 if((*it).first==ON_CELLS || (*it).first==ON_GAUSS_NE || (*it).first==ON_GAUSS_PT)
2661 tmp.push_back((*it).second);
2663 return new MFFPMIter2(tmp);
2666 throw INTERP_KERNEL::Exception("MFFPMIter::NewCell : not recognized type !");
2670 bool MFFPMIter::IsPresenceOfNode(const MEDFileEntities *entities)
2676 const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
2679 const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
2680 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
2681 if((*it).first==ON_NODES)
2686 throw INTERP_KERNEL::Exception("MFFPMIter::IsPresenceOfNode : not recognized type !");
2690 MFFPMIter2::MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts)
2692 std::size_t sz(cts.size());
2694 for(std::size_t i=0;i<sz;i++)
2696 INTERP_KERNEL::NormalizedCellType *loc(std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,cts[i]));
2697 if(loc!=typmai2+MED_N_CELL_FIXED_GEO)
2698 _ids[i]=(int)std::distance(typmai2,loc);
2700 throw INTERP_KERNEL::Exception("MFFPMIter2 : The specified geo type does not exists !");
2706 MEDFileFieldPerMesh::MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const MEDFileEntities *entities):_mesh_iteration(meshIteration),_mesh_order(meshOrder),
2709 INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2710 INTERP_KERNEL::AutoPtr<char> pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2711 INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2712 const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
2713 INTERP_KERNEL::AutoCppPtr<MFFPMIter> iter0(MFFPMIter::NewCell(entities));
2714 for(iter0->begin();!iter0->finished();iter0->next())
2716 int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL ,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2717 std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2718 int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2719 std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2720 if(nbProfile>0 || nbProfile2>0)
2722 const PartDefinition *pd(0);
2724 pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[iter0->current()]),typmai2[iter0->current()]);
2725 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nasc,pd));
2732 if(MFFPMIter::IsPresenceOfNode(entities))
2734 int nbProfile(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName));
2737 const PartDefinition *pd(0);
2739 pd=mmu->getPartDefAtLevel(1,INTERP_KERNEL::NORM_ERROR);
2740 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd));
2741 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2746 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2748 copyTinyInfoFrom(mesh);
2751 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
2753 if(id>=(int)_pfls.size())
2755 _pfls[id]=DataArrayInt::New();
2756 int lgth(MEDprofileSizeByName(fid,pflName.c_str()));
2757 _pfls[id]->setName(pflName);
2758 _pfls[id]->alloc(lgth,1);
2759 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName.c_str(),_pfls[id]->getPointer()));
2760 _pfls[id]->applyLin(1,-1,0);//Converting into C format
2763 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2765 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2767 MEDFILESAFECALLERRD0(MEDprofileInfo,(fid,i+1,pflName,&sz));
2768 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2769 if(i>=(int)_pfls.size())
2771 _pfls[i]=DataArrayInt::New();
2772 _pfls[i]->alloc(sz,1);
2773 _pfls[i]->setName(pflCpp.c_str());
2774 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName,_pfls[i]->getPointer()));
2775 _pfls[i]->applyLin(1,-1,0);//Converting into C format
2778 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
2780 int nbOfPfls=_pfls.size();
2781 for(int i=0;i<nbOfPfls;i++)
2783 MCAuto<DataArrayInt> cpy=_pfls[i]->deepCopy();
2784 cpy->applyLin(1,1,0);
2785 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2786 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2787 MEDFILESAFECALLERWR0(MEDprofileWr,(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer()));
2790 int nbOfLocs=_locs.size();
2791 for(int i=0;i<nbOfLocs;i++)
2792 _locs[i]->writeLL(fid);
2795 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
2797 std::vector<std::string> pfls=getPfls();
2798 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2800 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2803 _pfls.push_back(*it);
2807 int id=std::distance(pfls.begin(),it2);
2808 if(!(*it)->isEqual(*_pfls[id]))
2810 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2811 throw INTERP_KERNEL::Exception(oss.str());
2815 std::vector<std::string> locs=getLocs();
2816 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
2818 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2821 _locs.push_back(*it);
2825 int id=std::distance(locs.begin(),it2);
2826 if(!(*it)->isEqual(*_locs[id],eps))
2828 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2829 throw INTERP_KERNEL::Exception(oss.str());
2835 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
2837 for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
2838 getProfile((*it).c_str());
2841 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
2843 for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
2844 getLocalization((*it).c_str());
2847 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
2849 std::vector<std::string> profiles=real.getPflsReallyUsed();
2850 int sz=profiles.size();
2852 for(int i=0;i<sz;i++)
2853 loadProfileInFile(fid,i,profiles[i].c_str());
2855 std::vector<std::string> locs=real.getLocsReallyUsed();
2858 for(int i=0;i<sz;i++)
2859 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2862 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid)
2864 int nProfil=MEDnProfile(fid);
2865 for(int i=0;i<nProfil;i++)
2866 loadProfileInFile(fid,i);
2867 int sz=MEDnLocalization(fid);
2869 for(int i=0;i<sz;i++)
2871 _locs[i]=MEDFileFieldLoc::New(fid,i);
2875 MEDFileFieldGlobs *MEDFileFieldGlobs::New(med_idt fid)
2877 return new MEDFileFieldGlobs(fid);
2880 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2882 return new MEDFileFieldGlobs;
2885 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
2887 return _file_name.capacity()+_pfls.capacity()*sizeof(MCAuto<DataArrayInt>)+_locs.capacity()*sizeof(MCAuto<MEDFileFieldLoc>);
2890 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildrenWithNull() const
2892 std::vector<const BigMemoryObject *> ret;
2893 for(std::vector< MCAuto< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2894 ret.push_back((const DataArrayInt *)*it);
2895 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2896 ret.push_back((const MEDFileFieldLoc *)*it);
2900 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCopy() const
2902 MCAuto<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
2904 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2906 if((const DataArrayInt *)*it)
2907 ret->_pfls[i]=(*it)->deepCopy();
2910 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2912 if((const MEDFileFieldLoc*)*it)
2913 ret->_locs[i]=(*it)->deepCopy();
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::deepCpyPart
2923 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(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::shallowCpyPart : internal error ! pfl null !");
2932 MCAuto<DataArrayInt> pfl2(pfl);
2933 ret->_pfls.push_back(pfl2);
2935 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2937 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2939 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
2941 MCAuto<MEDFileFieldLoc> loc2(loc);
2942 ret->_locs.push_back(loc2);
2944 ret->setFileName(getFileName());
2949 * \throw if a profile in \a pfls in not in \a this.
2950 * \throw if a localization in \a locs in not in \a this.
2951 * \sa MEDFileFieldGlobs::shallowCpyPart
2953 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2955 MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2956 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2958 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2960 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
2961 ret->_pfls.push_back(pfl->deepCopy());
2963 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2965 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2967 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
2968 ret->_locs.push_back(loc->deepCopy());
2970 ret->setFileName(getFileName());
2974 MEDFileFieldGlobs::MEDFileFieldGlobs(med_idt fid):_file_name(MEDFileWritable::FileNameFromFID(fid))
2978 MEDFileFieldGlobs::MEDFileFieldGlobs()
2982 MEDFileFieldGlobs::~MEDFileFieldGlobs()
2986 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
2988 oss << "Profiles :\n";
2989 std::size_t n=_pfls.size();
2990 for(std::size_t i=0;i<n;i++)
2992 oss << " - #" << i << " ";
2993 const DataArrayInt *pfl=_pfls[i];
2995 oss << "\"" << pfl->getName() << "\"\n";
3000 oss << "Localizations :\n";
3001 for(std::size_t i=0;i<n;i++)
3003 oss << " - #" << i << " ";
3004 const MEDFileFieldLoc *loc=_locs[i];
3006 loc->simpleRepr(oss);
3012 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3014 for(std::vector< MCAuto<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
3016 DataArrayInt *elt(*it);
3019 std::string name(elt->getName());
3020 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3022 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3024 elt->setName((*it2).second.c_str());
3032 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3034 for(std::vector< MCAuto<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
3036 MEDFileFieldLoc *elt(*it);
3039 std::string name(elt->getName());
3040 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3042 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3044 elt->setName((*it2).second.c_str());
3052 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
3054 if(locId<0 || locId>=(int)_locs.size())
3055 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
3056 return _locs[locId]->getNbOfGaussPtPerCell();
3059 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
3061 return getLocalizationFromId(getLocalizationId(locName));
3064 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
3066 if(locId<0 || locId>=(int)_locs.size())
3067 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3068 return *_locs[locId];
3072 namespace MEDCouplingImpl
3077 LocFinder(const std::string& loc):_loc(loc) { }
3078 bool operator() (const MCAuto<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
3080 const std::string &_loc;
3086 PflFinder(const std::string& pfl):_pfl(pfl) { }
3087 bool operator() (const MCAuto<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
3089 const std::string& _pfl;
3094 int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
3096 std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),MEDCouplingImpl::LocFinder(loc));
3099 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
3100 for(it=_locs.begin();it!=_locs.end();it++)
3101 oss << "\"" << (*it)->getName() << "\", ";
3102 throw INTERP_KERNEL::Exception(oss.str());
3104 return std::distance(_locs.begin(),it);
3108 * The returned value is never null.
3110 const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
3112 std::string pflNameCpp(pflName);
3113 std::vector< MCAuto<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3116 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3117 for(it=_pfls.begin();it!=_pfls.end();it++)
3118 oss << "\"" << (*it)->getName() << "\", ";
3119 throw INTERP_KERNEL::Exception(oss.str());
3124 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
3126 if(pflId<0 || pflId>=(int)_pfls.size())
3127 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3128 return _pfls[pflId];
3131 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
3133 if(locId<0 || locId>=(int)_locs.size())
3134 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3135 return *_locs[locId];
3138 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
3140 return getLocalizationFromId(getLocalizationId(locName));
3144 * The returned value is never null.
3146 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
3148 std::string pflNameCpp(pflName);
3149 std::vector< MCAuto<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3152 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3153 for(it=_pfls.begin();it!=_pfls.end();it++)
3154 oss << "\"" << (*it)->getName() << "\", ";
3155 throw INTERP_KERNEL::Exception(oss.str());
3160 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
3162 if(pflId<0 || pflId>=(int)_pfls.size())
3163 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3164 return _pfls[pflId];
3167 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
3169 std::vector< MCAuto<DataArrayInt> > newPfls;
3171 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3173 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
3174 newPfls.push_back(*it);
3179 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
3181 std::vector< MCAuto<MEDFileFieldLoc> > newLocs;
3183 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3185 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
3186 newLocs.push_back(*it);
3191 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
3193 int sz=_pfls.size();
3194 std::vector<std::string> ret(sz);
3195 for(int i=0;i<sz;i++)
3196 ret[i]=_pfls[i]->getName();
3200 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
3202 int sz=_locs.size();
3203 std::vector<std::string> ret(sz);
3204 for(int i=0;i<sz;i++)
3205 ret[i]=_locs[i]->getName();
3209 bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
3211 std::vector<std::string> v=getPfls();
3212 std::string s(pflName);
3213 return std::find(v.begin(),v.end(),s)!=v.end();
3216 bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
3218 std::vector<std::string> v=getLocs();
3219 std::string s(locName);
3220 return std::find(v.begin(),v.end(),s)!=v.end();
3223 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
3225 std::map<int,std::vector<int> > m;
3227 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3229 const DataArrayInt *tmp=(*it);
3232 m[tmp->getHashCode()].push_back(i);
3235 std::vector< std::vector<int> > ret;
3236 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
3238 if((*it2).second.size()>1)
3240 std::vector<int> ret0;
3241 bool equalityOrNot=false;
3242 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
3244 std::vector<int>::const_iterator it4=it3; it4++;
3245 for(;it4!=(*it2).second.end();it4++)
3247 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
3250 ret0.push_back(*it3);
3251 ret0.push_back(*it4);
3257 ret.push_back(ret0);
3263 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
3265 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
3268 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
3270 std::string name(pfl->getName());
3272 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
3273 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3274 if(name==(*it)->getName())
3276 if(!pfl->isEqual(*(*it)))
3278 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
3279 throw INTERP_KERNEL::Exception(oss.str());
3283 _pfls.push_back(pfl);
3286 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)
3288 std::string name(locName);
3290 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
3291 MCAuto<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
3292 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3293 if((*it)->isName(locName))
3295 if(!(*it)->isEqual(*obj,1e-12))
3297 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
3298 throw INTERP_KERNEL::Exception(oss.str());
3301 _locs.push_back(obj);
3304 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
3306 std::vector<std::string> names=getPfls();
3307 return CreateNewNameNotIn("NewPfl_",names);
3310 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
3312 std::vector<std::string> names=getLocs();
3313 return CreateNewNameNotIn("NewLoc_",names);
3316 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
3318 for(std::size_t sz=0;sz<100000;sz++)
3320 std::ostringstream tryName;
3321 tryName << prefix << sz;
3322 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
3323 return tryName.str();
3325 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
3329 * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
3330 * \param [in] fname - the file name.
3332 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(med_idt fid):_globals(MEDFileFieldGlobs::New(fid))
3337 * Creates an empty MEDFileFieldGlobsReal.
3339 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
3343 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
3348 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildrenWithNull() const
3350 std::vector<const BigMemoryObject *> ret;
3351 ret.push_back((const MEDFileFieldGlobs *)_globals);
3356 * Returns a string describing profiles and Gauss points held in \a this.
3357 * \return std::string - the description string.
3359 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
3361 const MEDFileFieldGlobs *glob=_globals;
3362 std::ostringstream oss2; oss2 << glob;
3363 std::string stars(oss2.str().length(),'*');
3364 oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n";
3366 glob->simpleRepr(oss);
3368 oss << "NO GLOBAL INFORMATION !\n";
3371 void MEDFileFieldGlobsReal::resetContent()
3373 _globals=MEDFileFieldGlobs::New();
3376 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
3381 * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
3382 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3384 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3386 _globals=other._globals;
3390 * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3391 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3393 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3395 const MEDFileFieldGlobs *otherg(other._globals);
3398 _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3402 * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3403 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3405 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3407 const MEDFileFieldGlobs *otherg(other._globals);
3410 _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3413 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3415 _globals=other._globals;
3416 if((const MEDFileFieldGlobs *)_globals)
3417 _globals=other._globals->deepCopy();
3421 * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3422 * \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3423 * \param [in] eps - a precision used to compare Gauss points with same name held by
3424 * \a this and \a other MEDFileFieldGlobsReal.
3425 * \throw If \a this and \a other hold profiles with equal names but different ids.
3426 * \throw If \a this and \a other hold different Gauss points with equal names.
3428 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
3430 const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3431 if(thisGlobals==otherGlobals)
3435 _globals=other._globals;
3438 _globals->appendGlobs(*other._globals,eps);
3441 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
3443 checkGlobsPflsPartCoherency();
3444 checkGlobsLocsPartCoherency();
3447 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
3449 contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3452 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
3454 contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3457 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3459 contentNotNull()->loadProfileInFile(fid,id,pflName);
3462 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3464 contentNotNull()->loadProfileInFile(fid,id);
3467 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
3469 contentNotNull()->loadGlobals(fid,*this);
3472 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid)
3474 contentNotNull()->loadAllGlobals(fid);
3477 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3479 contentNotNull()->writeGlobals(fid,opt);
3483 * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3484 * or getPflsReallyUsedMulti().
3485 * \return std::vector<std::string> - a sequence of names of all profiles.
3487 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3489 return contentNotNull()->getPfls();
3493 * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3494 * or getLocsReallyUsedMulti().
3495 * \return std::vector<std::string> - a sequence of names of all localizations.
3497 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3499 return contentNotNull()->getLocs();
3503 * Checks if the profile with a given name exists.
3504 * \param [in] pflName - the profile name of interest.
3505 * \return bool - \c true if the profile named \a pflName exists.
3507 bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
3509 return contentNotNull()->existsPfl(pflName);
3513 * Checks if the localization with a given name exists.
3514 * \param [in] locName - the localization name of interest.
3515 * \return bool - \c true if the localization named \a locName exists.
3517 bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
3519 return contentNotNull()->existsLoc(locName);
3522 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
3524 return contentNotNull()->createNewNameOfPfl();
3527 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
3529 return contentNotNull()->createNewNameOfLoc();
3533 * Sets the name of a MED file.
3534 * \param [inout] fileName - the file name.
3536 void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
3538 contentNotNull()->setFileName(fileName);
3542 * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3543 * in the same order.
3544 * \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3545 * Each item of this sequence is a vector containing ids of equal profiles.
3547 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3549 return contentNotNull()->whichAreEqualProfiles();
3553 * Finds equal localizations.
3554 * \param [in] eps - a precision used to compare real values of the localizations.
3555 * \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3556 * Each item of this sequence is a vector containing ids of equal localizations.
3558 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3560 return contentNotNull()->whichAreEqualLocs(eps);
3564 * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3565 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3566 * this sequence is a pair whose
3567 * - the first item is a vector of profile names to replace by the second item,
3568 * - the second item is a profile name to replace every profile name of the first item.
3570 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3572 contentNotNull()->changePflsNamesInStruct(mapOfModif);
3576 * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3577 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3578 * this sequence is a pair whose
3579 * - the first item is a vector of localization names to replace by the second item,
3580 * - the second item is a localization name to replace every localization name of the first item.
3582 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3584 contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3588 * Replaces references to some profiles (a reference is a profile name) by references
3589 * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3590 * them-selves accordingly. <br>
3591 * This method is a generalization of changePflName().
3592 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3593 * this sequence is a pair whose
3594 * - the first item is a vector of profile names to replace by the second item,
3595 * - the second item is a profile name to replace every profile of the first item.
3596 * \sa changePflsRefsNamesGen()
3597 * \sa changePflName()
3599 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3601 changePflsRefsNamesGen(mapOfModif);
3602 changePflsNamesInStruct(mapOfModif);
3606 * Replaces references to some localizations (a reference is a localization name) by references
3607 * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3608 * them-selves accordingly. <br>
3609 * This method is a generalization of changeLocName().
3610 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3611 * this sequence is a pair whose
3612 * - the first item is a vector of localization names to replace by the second item,
3613 * - the second item is a localization name to replace every localization of the first item.
3614 * \sa changeLocsRefsNamesGen()
3615 * \sa changeLocName()
3617 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3619 changeLocsRefsNamesGen(mapOfModif);
3620 changeLocsNamesInStruct(mapOfModif);
3624 * Renames the profile having a given name and updates references to this profile.
3625 * \param [in] oldName - the name of the profile to rename.
3626 * \param [in] newName - a new name of the profile.
3627 * \sa changePflsNames().
3629 void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
3631 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3632 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3634 changePflsNames(mapOfModif);
3638 * Renames the localization having a given name and updates references to this localization.
3639 * \param [in] oldName - the name of the localization to rename.
3640 * \param [in] newName - a new name of the localization.
3641 * \sa changeLocsNames().
3643 void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
3645 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3646 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3648 changeLocsNames(mapOfModif);
3652 * Removes duplicated profiles. Returns a map used to update references to removed
3653 * profiles via changePflsRefsNamesGen().
3654 * Equal profiles are found using whichAreEqualProfiles().
3655 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3656 * a sequence describing the performed replacements of profiles. Each element of
3657 * this sequence is a pair whose
3658 * - the first item is a vector of profile names replaced by the second item,
3659 * - the second item is a profile name replacing every profile of the first item.
3661 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
3663 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3664 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3666 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3668 std::vector< std::string > tmp((*it).size());
3670 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3671 tmp[j]=std::string(getProfileFromId(*it2)->getName());
3672 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3674 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3675 killProfileIds(tmp2);
3677 changePflsRefsNamesGen(ret);
3682 * Removes duplicated localizations. Returns a map used to update references to removed
3683 * localizations via changeLocsRefsNamesGen().
3684 * Equal localizations are found using whichAreEqualLocs().
3685 * \param [in] eps - a precision used to compare real values of the localizations.
3686 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3687 * a sequence describing the performed replacements of localizations. Each element of
3688 * this sequence is a pair whose
3689 * - the first item is a vector of localization names replaced by the second item,
3690 * - the second item is a localization name replacing every localization of the first item.
3692 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
3694 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3695 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3697 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3699 std::vector< std::string > tmp((*it).size());
3701 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3702 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3703 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3705 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3706 killLocalizationIds(tmp2);
3708 changeLocsRefsNamesGen(ret);
3713 * Returns number of Gauss points per cell in a given localization.
3714 * \param [in] locId - an id of the localization of interest.
3715 * \return int - the number of the Gauss points per cell.
3717 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
3719 return contentNotNull()->getNbOfGaussPtPerCell(locId);
3723 * Returns an id of a localization by its name.
3724 * \param [in] loc - the localization name of interest.
3725 * \return int - the id of the localization.
3726 * \throw If there is no a localization named \a loc.
3728 int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
3730 return contentNotNull()->getLocalizationId(loc);
3734 * Returns the name of the MED file.
3735 * \return const std::string& - the MED file name.
3737 std::string MEDFileFieldGlobsReal::getFileName() const
3739 return contentNotNull()->getFileName();
3743 * Returns a localization object by its name.
3744 * \param [in] locName - the name of the localization of interest.
3745 * \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3746 * \throw If there is no a localization named \a locName.
3748 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
3750 return contentNotNull()->getLocalization(locName);
3754 * Returns a localization object by its id.
3755 * \param [in] locId - the id of the localization of interest.
3756 * \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3757 * \throw If there is no a localization with id \a locId.
3759 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
3761 return contentNotNull()->getLocalizationFromId(locId);
3765 * Returns a profile array by its name.
3766 * \param [in] pflName - the name of the profile of interest.
3767 * \return const DataArrayInt * - the profile array having the name \a pflName.
3768 * \throw If there is no a profile named \a pflName.
3770 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
3772 return contentNotNull()->getProfile(pflName);
3776 * Returns a profile array by its id.
3777 * \param [in] pflId - the id of the profile of interest.
3778 * \return const DataArrayInt * - the profile array having the id \a pflId.
3779 * \throw If there is no a profile with id \a pflId.
3781 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
3783 return contentNotNull()->getProfileFromId(pflId);
3787 * Returns a localization object, apt for modification, by its id.
3788 * \param [in] locId - the id of the localization of interest.
3789 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3790 * having the id \a locId.
3791 * \throw If there is no a localization with id \a locId.
3793 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
3795 return contentNotNull()->getLocalizationFromId(locId);
3799 * Returns a localization object, apt for modification, by its name.
3800 * \param [in] locName - the name of the localization of interest.
3801 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3802 * having the name \a locName.
3803 * \throw If there is no a localization named \a locName.
3805 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
3807 return contentNotNull()->getLocalization(locName);
3811 * Returns a profile array, apt for modification, by its name.
3812 * \param [in] pflName - the name of the profile of interest.
3813 * \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3814 * \throw If there is no a profile named \a pflName.
3816 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
3818 return contentNotNull()->getProfile(pflName);
3822 * Returns a profile array, apt for modification, by its id.
3823 * \param [in] pflId - the id of the profile of interest.
3824 * \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3825 * \throw If there is no a profile with id \a pflId.
3827 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
3829 return contentNotNull()->getProfileFromId(pflId);
3833 * Removes profiles given by their ids. No data is updated to track this removal.
3834 * \param [in] pflIds - a sequence of ids of the profiles to remove.
3836 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
3838 contentNotNull()->killProfileIds(pflIds);
3842 * Removes localizations given by their ids. No data is updated to track this removal.
3843 * \param [in] locIds - a sequence of ids of the localizations to remove.
3845 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
3847 contentNotNull()->killLocalizationIds(locIds);
3851 * Stores a profile array.
3852 * \param [in] pfl - the profile array to store.
3853 * \throw If the name of \a pfl is empty.
3854 * \throw If a profile with the same name as that of \a pfl already exists but contains
3857 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
3859 contentNotNull()->appendProfile(pfl);
3863 * Adds a new localization of Gauss points.
3864 * \param [in] locName - the name of the new localization.
3865 * \param [in] geoType - a geometrical type of the reference cell.
3866 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
3867 * must be \c nbOfNodesPerCell * \c dimOfType.
3868 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
3869 * must be _wg_.size() * \c dimOfType.
3870 * \param [in] w - the weights of Gauss points.
3871 * \throw If \a locName is empty.
3872 * \throw If a localization with the name \a locName already exists but is
3873 * different form the new one.
3875 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)
3877 contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
3880 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
3882 MEDFileFieldGlobs *g(_globals);
3884 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
3888 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
3890 const MEDFileFieldGlobs *g(_globals);
3892 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
3896 //= MEDFileFieldNameScope
3898 MEDFileFieldNameScope::MEDFileFieldNameScope()
3902 MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName):_name(fieldName)
3907 * Returns the name of \a this field.
3908 * \return std::string - a string containing the field name.
3910 std::string MEDFileFieldNameScope::getName() const
3916 * Sets name of \a this field
3917 * \param [in] name - the new field name.
3919 void MEDFileFieldNameScope::setName(const std::string& fieldName)
3924 std::string MEDFileFieldNameScope::getDtUnit() const
3929 void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
3934 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
3937 _dt_unit=other._dt_unit;
3940 //= MEDFileAnyTypeField1TSWithoutSDA
3942 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
3944 _field_per_mesh.resize(other._field_per_mesh.size());
3946 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
3948 if((const MEDFileFieldPerMesh *)*it)
3949 _field_per_mesh[i]=(*it)->deepCopy(this);
3954 * Prints a string describing \a this field into a stream. This string is outputted
3955 * by \c print Python command.
3956 * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
3957 * \param [in,out] oss - the out stream.
3958 * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
3959 * info id printed, else, not.
3961 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
3963 std::string startOfLine(bkOffset,' ');
3964 oss << startOfLine << "Field ";
3966 oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
3967 oss << "on one time Step ";
3969 oss << "(" << f1tsId << ") ";
3970 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
3971 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
3972 const DataArray *arr=getUndergroundDataArray();
3975 const std::vector<std::string> &comps=arr->getInfoOnComponents();
3978 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
3979 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
3980 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
3982 if(arr->isAllocated())
3984 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
3987 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
3991 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
3993 oss << startOfLine << "----------------------" << std::endl;
3994 if(!_field_per_mesh.empty())
3997 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
3999 const MEDFileFieldPerMesh *cur=(*it2);
4001 cur->simpleRepr(bkOffset,oss,i);
4003 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
4008 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
4010 oss << startOfLine << "----------------------" << std::endl;
4013 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
4015 const DataArray *arr(getUndergroundDataArray());
4017 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
4018 int nbOfCompo=arr->getNumberOfComponents();
4019 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
4020 for(int i=0;i<nbOfCompo;i++)
4023 std::vector<int> v(1,i);
4024 MCAuto<DataArray> arr2=arr->keepSelectedComponents(v);
4025 ret[i]->setArray(arr2);
4030 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)
4034 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
4039 * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
4040 * empty. Returns -1 if this in on nodes.
4041 * \return int - the dimension of \a this.
4043 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
4046 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4047 (*it)->getDimension(ret);
4052 * Returns the mesh name.
4053 * \return std::string - a string holding the mesh name.
4054 * \throw If \c _field_per_mesh.empty()
4056 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const
4058 if(_field_per_mesh.empty())
4059 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
4060 return _field_per_mesh[0]->getMeshName();
4063 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const std::string& newMeshName)
4065 std::string oldName(getMeshName());
4066 std::vector< std::pair<std::string,std::string> > v(1);
4067 v[0].first=oldName; v[0].second=newMeshName;
4071 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
4074 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4076 MEDFileFieldPerMesh *cur(*it);
4078 ret=cur->changeMeshNames(modifTab) || ret;
4084 * Returns the number of iteration of the state of underlying mesh.
4085 * \return int - the iteration number.
4086 * \throw If \c _field_per_mesh.empty()
4088 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
4090 if(_field_per_mesh.empty())
4091 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
4092 return _field_per_mesh[0]->getMeshIteration();
4096 * Returns the order number of iteration of the state of underlying mesh.
4097 * \return int - the order number.
4098 * \throw If \c _field_per_mesh.empty()
4100 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
4102 if(_field_per_mesh.empty())
4103 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
4104 return _field_per_mesh[0]->getMeshOrder();
4108 * Checks if \a this field is tagged by a given iteration number and a given
4109 * iteration order number.
4110 * \param [in] iteration - the iteration number of interest.
4111 * \param [in] order - the iteration order number of interest.
4112 * \return bool - \c true if \a this->getIteration() == \a iteration &&
4113 * \a this->getOrder() == \a order.
4115 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
4117 return iteration==_iteration && order==_order;
4121 * Returns number of iteration and order number of iteration when
4122 * \a this field has been calculated.
4123 * \return std::pair<int,int> - a pair of the iteration number and the iteration
4126 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
4128 std::pair<int,int> p;
4134 * Returns number of iteration and order number of iteration when
4135 * \a this field has been calculated.
4136 * \param [in,out] p - a pair returning the iteration number and the iteration
4139 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
4146 * Returns all types of spatial discretization of \a this field.
4147 * \param [in,out] types - a sequence of types of \a this field.
4149 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
4151 std::set<TypeOfField> types2;
4152 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4154 (*it)->fillTypesOfFieldAvailable(types2);
4156 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
4157 std::copy(types2.begin(),types2.end(),bi);
4161 * Returns all types of spatial discretization of \a this field.
4162 * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
4165 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
4167 std::vector<TypeOfField> ret;
4168 fillTypesOfFieldAvailable(ret);
4172 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
4174 std::vector<std::string> ret;
4175 std::set<std::string> ret2;
4176 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4178 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
4179 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4180 if(ret2.find(*it2)==ret2.end())
4182 ret.push_back(*it2);
4189 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
4191 std::vector<std::string> ret;
4192 std::set<std::string> ret2;
4193 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4195 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
4196 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4197 if(ret2.find(*it2)==ret2.end())
4199 ret.push_back(*it2);
4206 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
4208 std::vector<std::string> ret;
4209 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4211 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
4212 ret.insert(ret.end(),tmp.begin(),tmp.end());
4217 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
4219 std::vector<std::string> ret;
4220 std::set<std::string> ret2;
4221 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4223 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
4224 ret.insert(ret.end(),tmp.begin(),tmp.end());
4229 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4231 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4232 (*it)->changePflsRefsNamesGen(mapOfModif);
4235 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4237 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4238 (*it)->changeLocsRefsNamesGen(mapOfModif);
4242 * Returns all attributes of parts of \a this field lying on a given mesh.
4243 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4244 * item of every of returned sequences refers to the _i_-th part of \a this field.
4245 * Thus all sequences returned by this method are of the same length equal to number
4246 * of different types of supporting entities.<br>
4247 * A field part can include sub-parts with several different spatial discretizations,
4248 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
4249 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4250 * of a nested sequence corresponds to a type of spatial discretization.<br>
4251 * This method allows for iteration over MEDFile DataStructure without any overhead.
4252 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4253 * for the case with only one underlying mesh. (Actually, the number of meshes is
4254 * not checked if \a mname == \c NULL).
4255 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4256 * a field part is returned.
4257 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4258 * This sequence is of the same length as \a types.
4259 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4260 * discretization. A profile name can be empty.
4261 * Length of this and of nested sequences is the same as that of \a typesF.
4262 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4263 * discretization. A localization name can be empty.
4264 * Length of this and of nested sequences is the same as that of \a typesF.
4265 * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
4266 * of ids of tuples within the data array, per each type of spatial
4267 * discretization within one mesh entity type.
4268 * Length of this and of nested sequences is the same as that of \a typesF.
4269 * \throw If no field is lying on \a mname.
4271 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
4275 meshId=getMeshIdFromMeshName(mname);
4277 if(_field_per_mesh.empty())
4278 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4279 return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4283 * Returns dimensions of mesh elements \a this field lies on. The returned value is a
4284 * maximal absolute dimension and values returned via the out parameter \a levs are
4285 * dimensions relative to the maximal absolute dimension. <br>
4286 * This method is designed for MEDFileField1TS instances that have a discretization
4287 * \ref MEDCoupling::ON_CELLS "ON_CELLS",
4288 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT",
4289 * \ref MEDCoupling::ON_GAUSS_NE "ON_GAUSS_NE".
4290 * Only these 3 discretizations will be taken into account here. If \a this is
4291 * \ref MEDCoupling::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
4292 * This method is useful to make the link between the dimension of the underlying mesh
4293 * and the levels of \a this, because it is possible that the highest dimension of \a this
4294 * field is not equal to the dimension of the underlying mesh.
4296 * Let's consider the following case:
4297 * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
4298 * TETRA4, HEXA8, TRI3 and SEG2.
4299 * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
4300 * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
4302 * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
4303 * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
4304 * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
4305 * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
4306 * parameter of getFieldAtLevel() is computed basing on the returned values as this:
4307 * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
4309 * to retrieve the highest level of
4310 * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br>
4311 * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
4312 * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
4313 * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
4314 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4315 * for the case with only one underlying mesh. (Actually, the number of meshes is
4316 * not checked if \a mname == \c NULL).
4317 * \param [in,out] levs - a sequence returning the dimensions relative to the maximal
4318 * absolute one. They are in decreasing order. This sequence is cleared before
4320 * \return int - the maximal absolute dimension of elements \a this fields lies on.
4321 * \throw If no field is lying on \a mname.
4323 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
4326 int meshId=getMeshIdFromMeshName(mname);
4327 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4328 std::vector< std::vector<TypeOfField> > typesF;
4329 std::vector< std::vector<std::string> > pfls, locs;
4330 _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4332 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
4333 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
4334 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
4336 st.erase(INTERP_KERNEL::NORM_ERROR);
4338 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
4340 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
4341 ret1.insert((int)cm.getDimension());
4343 int ret=*std::max_element(ret1.begin(),ret1.end());
4344 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
4345 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
4350 * \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.
4351 * \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.
4352 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4353 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4355 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
4357 int mid=getMeshIdFromMeshName(mName);
4358 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4362 * \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.
4363 * \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.
4364 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4365 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4367 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
4369 int mid=getMeshIdFromMeshName(mName);
4370 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4374 * \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.
4376 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
4378 if(_field_per_mesh.empty())
4379 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4382 std::string mName2(mName);
4384 std::vector<std::string> msg;
4385 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4386 if(mName2==(*it)->getMeshName())
4389 msg.push_back((*it)->getMeshName());
4390 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4391 oss << "Possible meshes are : ";
4392 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4393 oss << "\"" << (*it2) << "\" ";
4394 throw INTERP_KERNEL::Exception(oss.str());
4397 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
4400 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4401 std::string tmp(mesh->getName());
4403 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4404 std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4406 for(;it!=_field_per_mesh.end();it++,i++)
4408 if((*it)->getMeshName()==tmp)
4411 int sz=_field_per_mesh.size();
4412 _field_per_mesh.resize(sz+1);
4413 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4417 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4418 MEDFileFieldGlobsReal& glob)
4421 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4423 MEDFileFieldPerMesh *fpm(*it);
4425 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4431 * This method splits \a this into several sub-parts so that each sub parts have exactly one spatial discretization. This method implements the minimal
4432 * splitting that leads to single spatial discretization of this.
4434 * \sa splitMultiDiscrPerGeoTypes
4436 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
4438 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4439 std::vector< std::vector<TypeOfField> > typesF;
4440 std::vector< std::vector<std::string> > pfls,locs;
4441 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4442 std::set<TypeOfField> allEnt;
4443 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4444 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4445 allEnt.insert(*it2);
4446 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4447 std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4448 for(std::size_t i=0;i<allEnt.size();i++,it3++)
4450 std::vector< std::pair<int,int> > its;
4451 ret[i]=shallowCpy();
4452 int newLgth(ret[i]->keepOnlySpatialDiscretization(*it3,its));
4453 ret[i]->updateData(newLgth,its);
4459 * This method performs a sub splitting as splitDiscretizations does but finer. This is the finest spliting level that can be done.
4460 * This method implements the minimal splitting so that each returned elements are mono Gauss discretization per geometric type.
4462 * \sa splitDiscretizations
4464 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes() const
4466 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4467 std::vector< std::vector<TypeOfField> > typesF;
4468 std::vector< std::vector<std::string> > pfls,locs;
4469 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4470 std::set<TypeOfField> allEnt;
4471 std::size_t nbOfMDPGT(0),ii(0);
4472 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++,ii++)
4474 nbOfMDPGT=std::max(nbOfMDPGT,locs[ii].size());
4475 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4476 allEnt.insert(*it2);
4478 if(allEnt.size()!=1)
4479 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : this field is expected to be defined only on one spatial discretization !");
4481 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
4484 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret0(1);
4485 ret0[0]=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(this); this->incrRef();
4488 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfMDPGT);
4489 for(std::size_t i=0;i<nbOfMDPGT;i++)
4491 std::vector< std::pair<int,int> > its;
4492 ret[i]=shallowCpy();
4493 int newLgth(ret[i]->keepOnlyGaussDiscretization(i,its));
4494 ret[i]->updateData(newLgth,its);
4499 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
4501 int globalCounter(0);
4502 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4503 (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4504 return globalCounter;
4507 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlyGaussDiscretization(std::size_t idOfDisc, std::vector< std::pair<int,int> >& its)
4509 int globalCounter(0);
4510 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4511 (*it)->keepOnlyGaussDiscretization(idOfDisc,globalCounter,its);
4512 return globalCounter;
4515 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
4517 if(_nb_of_tuples_to_be_allocated>=0)
4519 _nb_of_tuples_to_be_allocated=newLgth;
4520 const DataArray *oldArr(getUndergroundDataArray());
4523 MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4524 newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
4526 _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
4530 if(_nb_of_tuples_to_be_allocated==-1)
4532 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4534 const DataArray *oldArr(getUndergroundDataArray());
4535 if(!oldArr || !oldArr->isAllocated())
4536 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4537 MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4538 newArr->alloc(newLgth,getNumberOfComponents());
4540 newArr->copyStringInfoFrom(*oldArr);
4542 for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4544 if((*it).second<(*it).first)
4545 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4546 newArr->setContigPartOfSelectedValuesSlice(pos,oldArr,(*it).first,(*it).second,1);
4547 pos+=(*it).second-(*it).first;
4552 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4555 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
4557 if(_field_per_mesh.empty())
4558 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4559 if(_field_per_mesh.size()>1)
4560 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4561 _field_per_mesh[0]->copyOptionsFrom(opts);
4562 _field_per_mesh[0]->writeLL(fid,nasc);
4566 * 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.
4567 * If false is returned the memory allocation is not required.
4569 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
4571 if(_nb_of_tuples_to_be_allocated>=0)
4573 getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4574 _nb_of_tuples_to_be_allocated=-2;
4577 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4579 if(_nb_of_tuples_to_be_allocated==-1)
4580 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4581 if(_nb_of_tuples_to_be_allocated<-3)
4582 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4583 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4586 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
4588 med_int numdt,numit;
4592 med_int meshnumdt,meshnumit;
4593 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4594 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt));
4595 MEDFILESAFECALLERRD0(MEDfield23ComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit));
4596 if(_iteration!=numdt || _order!=numit)
4597 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4598 _field_per_mesh.resize(nmesh);
4603 std::string meshNameCpp(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
4604 mm=ms->getMeshWithName(meshNameCpp);
4607 for(int i=0;i<nmesh;i++)
4608 _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i,meshnumdt,meshnumit,nasc,mm,entities);
4609 _nb_of_tuples_to_be_allocated=0;
4610 for(int i=0;i<nmesh;i++)
4611 _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4614 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
4616 allocIfNecessaryTheArrayToReceiveDataFromFile();
4617 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4618 (*it)->loadBigArraysRecursively(fid,nasc);
4621 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
4623 if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4624 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4625 (*it)->loadBigArraysRecursively(fid,nasc);
4628 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
4630 loadOnlyStructureOfDataRecursively(fid,nasc,ms,entities);
4631 loadBigArraysRecursively(fid,nasc);
4634 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
4636 DataArray *thisArr(getUndergroundDataArray());
4637 if(thisArr && thisArr->isAllocated())
4639 _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
4640 thisArr->desallocate();
4644 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
4646 return _dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MCAuto< MEDFileFieldPerMesh >);
4649 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
4651 std::vector<const BigMemoryObject *> ret;
4652 if(getUndergroundDataArray())
4653 ret.push_back(getUndergroundDataArray());
4654 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4655 ret.push_back((const MEDFileFieldPerMesh *)*it);
4660 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4661 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4662 * "Sort By Type"), if not, an exception is thrown.
4663 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
4664 * \param [in] arr - the array of values.
4665 * \param [in,out] glob - the global data where profiles and localization present in
4666 * \a field, if any, are added.
4667 * \throw If the name of \a field is empty.
4668 * \throw If the data array of \a field is not set.
4669 * \throw If \a this->_arr is already allocated but has different number of components
4671 * \throw If the underlying mesh of \a field has no name.
4672 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4674 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4676 const MEDCouplingMesh *mesh=field->getMesh();
4678 TypeOfField type=field->getTypeOfField();
4679 std::vector<DataArrayInt *> dummy;
4680 int start=copyTinyInfoFrom(field,arr);
4681 int pos=addNewEntryIfNecessary(mesh);
4684 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4685 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4688 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4692 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4693 * of a given mesh are used as the support of the given field (a real support is not used).
4694 * Elements of the given mesh must be sorted suitable for writing to MED file.
4695 * Order of underlying mesh entities of the given field specified by \a profile parameter
4696 * is not prescribed; this method permutes field values to have them sorted by element
4697 * type as required for writing to MED file. A new profile is added only if no equal
4698 * profile is missing.
4699 * \param [in] field - the field to add to \a this. The field double values are ignored.
4700 * \param [in] arrOfVals - the values of the field \a field used.
4701 * \param [in] mesh - the supporting mesh of \a field.
4702 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4703 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
4704 * \param [in,out] glob - the global data where profiles and localization present in
4705 * \a field, if any, are added.
4706 * \throw If either \a field or \a mesh or \a profile has an empty name.
4707 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4708 * \throw If the data array of \a field is not set.
4709 * \throw If \a this->_arr is already allocated but has different number of components
4711 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4712 * \sa setFieldNoProfileSBT()
4714 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4717 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
4718 if(!arrOfVals || !arrOfVals->isAllocated())
4719 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
4720 TypeOfField type=field->getTypeOfField();
4721 std::vector<DataArrayInt *> idsInPflPerType;
4722 std::vector<DataArrayInt *> idsPerType;
4723 std::vector<int> code,code2;
4724 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
4727 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4728 std::vector< MCAuto<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
4729 std::vector< MCAuto<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin());
4730 std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
4732 MCAuto<MEDCouplingFieldDouble> field2=field->clone(false);
4733 int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
4734 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4736 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4737 throw INTERP_KERNEL::Exception(oss.str());
4740 int start=copyTinyInfoFrom(field,arrOfVals);
4741 code2=m->getDistributionOfTypes();
4743 int pos=addNewEntryIfNecessary(m);
4744 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4748 if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
4749 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
4750 std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
4751 std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
4752 int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
4753 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4755 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4756 throw INTERP_KERNEL::Exception(oss.str());
4758 int start=copyTinyInfoFrom(field,arrOfVals);
4759 int pos=addNewEntryIfNecessary(m);
4760 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4765 * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
4767 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
4769 if(_nb_of_tuples_to_be_allocated>=0)
4770 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 !");
4771 DataArray *arr(getOrCreateAndGetArray());
4772 arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
4773 _nb_of_tuples_to_be_allocated=-3;
4777 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4778 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4779 * larger by the size of \a field. Returns an id of the first not filled
4780 * tuple of \a this->_arr.
4781 * \param [in] field - the field to copy the info on components and the name from.
4782 * \return int - the id of first not initialized tuple of \a this->_arr.
4783 * \throw If the name of \a field is empty.
4784 * \throw If the data array of \a field is not set.
4785 * \throw If \a this->_arr is already allocated but has different number of components
4788 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
4791 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4792 std::string name(field->getName());
4793 setName(name.c_str());
4794 setDtUnit(field->getTimeUnit());
4796 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4798 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4799 if(!arr->isAllocated())
4800 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
4801 _dt=field->getTime(_iteration,_order);
4802 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4803 if(!getOrCreateAndGetArray()->isAllocated())
4805 allocNotFromFile(arr->getNumberOfTuples());
4810 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4811 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4812 getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
4813 _nb_of_tuples_to_be_allocated=-3;
4814 return oldNbOfTuples;
4819 * Returns number of components in \a this field
4820 * \return int - the number of components.
4822 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4824 return getOrCreateAndGetArray()->getNumberOfComponents();
4828 * Change info on components in \a this.
4829 * \throw If size of \a infos is not equal to the number of components already in \a this.
4831 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
4833 DataArray *arr=getOrCreateAndGetArray();
4834 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
4838 * Returns info on components of \a this field.
4839 * \return const std::vector<std::string>& - a sequence of strings each being an
4840 * information on _i_-th component.
4842 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
4844 const DataArray *arr=getOrCreateAndGetArray();
4845 return arr->getInfoOnComponents();
4849 * Returns a mutable info on components of \a this field.
4850 * \return std::vector<std::string>& - a sequence of strings each being an
4851 * information on _i_-th component.
4853 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
4855 DataArray *arr=getOrCreateAndGetArray();
4856 return arr->getInfoOnComponents();
4859 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const
4861 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4863 const MEDFileFieldPerMesh *fpm(*it);
4866 if(fpm->presenceOfMultiDiscPerGeoType())
4872 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh(const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4874 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 !";
4875 if(_field_per_mesh.empty())
4876 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is empty ! Nothing to extract !");
4877 if(_field_per_mesh.size()>1)
4878 throw INTERP_KERNEL::Exception(MSG0);
4879 if(_field_per_mesh[0].isNull())
4880 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is inconsistent !");
4881 const MEDFileFieldPerMesh *pm(_field_per_mesh[0]);
4882 std::set<TypeOfField> types;
4883 pm->fillTypesOfFieldAvailable(types);
4885 throw INTERP_KERNEL::Exception(MSG0);
4886 TypeOfField type(*types.begin());
4887 int meshDimRelToMax(0);
4892 int myDim(std::numeric_limits<int>::max());
4893 bool isUnique(pm->isUniqueLevel(myDim));
4895 throw INTERP_KERNEL::Exception(MSG0);
4896 meshDimRelToMax=myDim-mesh->getMeshDimension();
4897 if(meshDimRelToMax>0)
4898 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the mesh attached to field is not compatible with the field !");
4900 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,0/*renumPol*/,glob,mesh,arrOut,nasc);
4904 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4905 * \param [in] type - a spatial discretization of the new field.
4906 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4907 * \param [in] mName - a name of the supporting mesh.
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 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4917 * caller is to delete this field using decrRef() as it is no more needed.
4918 * \throw If the MED file is not readable.
4919 * \throw If there is no mesh named \a mName in the MED file.
4920 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4921 * \throw If no field of \a this is lying on the mesh \a mName.
4922 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4924 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4926 MCAuto<MEDFileMesh> mm;
4928 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4930 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4931 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4935 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4936 * \param [in] type - a spatial discretization of the new field.
4937 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
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 * \param [in] mesh - the supporting mesh.
4947 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4948 * caller is to delete this field using decrRef() as it is no more needed.
4949 * \throw If the MED file is not readable.
4950 * \throw If no field of \a this is lying on \a mesh.
4951 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4952 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4954 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4956 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax,false));
4957 const DataArrayInt *d(mesh->getNumberFieldAtLevel(meshDimRelToMax)),*e(mesh->getNumberFieldAtLevel(1));
4958 if(meshDimRelToMax==1)
4959 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
4960 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
4964 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
4966 * \param [in] type - a spatial discretization of the new field.
4967 * \param [in] mName - a name of the supporting mesh.
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 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4977 * caller is to delete this field using decrRef() as it is no more needed.
4978 * \throw If the MED file is not readable.
4979 * \throw If there is no mesh named \a mName in the MED file.
4980 * \throw If there are no mesh entities in the mesh.
4981 * \throw If no field values of the given \a type are available.
4983 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4985 MCAuto<MEDFileMesh> mm;
4987 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4989 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4990 int absDim=getDimension();
4991 int meshDimRelToMax=absDim-mm->getMeshDimension();
4992 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4996 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4997 * \param [in] type - a spatial discretization of the new field.
4998 * \param [in] renumPol - specifies how to permute values of the result field according to
4999 * the optional numbers of cells and nodes, if any. The valid values are
5000 * - 0 - do not permute.
5001 * - 1 - permute cells.
5002 * - 2 - permute nodes.
5003 * - 3 - permute cells and nodes.
5005 * \param [in] glob - the global data storing profiles and localization.
5006 * \param [in] mesh - the supporting mesh.
5007 * \param [in] cellRenum - the cell numbers array used for permutation of the result
5008 * field according to \a renumPol.
5009 * \param [in] nodeRenum - the node numbers array used for permutation of the result
5010 * field according to \a renumPol.
5011 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5012 * caller is to delete this field using decrRef() as it is no more needed.
5013 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5014 * \throw If no field of \a this is lying on \a mesh.
5015 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5017 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
5019 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
5020 int meshId=getMeshIdFromMeshName(mesh->getName());
5022 MCAuto<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
5027 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5034 throw INTERP_KERNEL::Exception(msg1);
5035 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5038 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
5040 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5041 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
5042 throw INTERP_KERNEL::Exception(oss.str());
5044 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
5045 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
5046 std::vector<DataArray *> arrOut2(1,arrOut);
5047 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
5048 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
5049 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
5056 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5058 throw INTERP_KERNEL::Exception(msg1);
5061 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
5063 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5064 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
5065 throw INTERP_KERNEL::Exception(oss.str());
5067 MCAuto<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
5068 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
5069 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
5070 ret->renumberNodes(nodeRenumSafe->getConstPointer());
5075 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
5080 * Returns values and a profile of the field of a given type lying on a given support.
5081 * \param [in] type - a spatial discretization of the field.
5082 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5083 * \param [in] mesh - the supporting mesh.
5084 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
5085 * field of interest lies on. If the field lies on all entities of the given
5086 * dimension, all ids in \a pfl are zero. The caller is to delete this array
5087 * using decrRef() as it is no more needed.
5088 * \param [in] glob - the global data storing profiles and localization.
5089 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
5090 * field. The caller is to delete this array using decrRef() as it is no more needed.
5091 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
5092 * \throw If no field of \a this is lying on \a mesh.
5093 * \throw If no field values of the given \a type are available.
5095 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
5097 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
5098 int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
5099 MCAuto<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
5100 ret->setName(nasc.getName().c_str());
5104 //= MEDFileField1TSWithoutSDA
5107 * Throws if a given value is not a valid (non-extended) relative dimension.
5108 * \param [in] meshDimRelToMax - the relative dimension value.
5109 * \throw If \a meshDimRelToMax > 0.
5111 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
5113 if(meshDimRelToMax>0)
5114 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
5118 * Checks if elements of a given mesh are in the order suitable for writing
5119 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
5120 * vector describing types of elements and their number.
5121 * \param [in] mesh - the mesh to check.
5122 * \return std::vector<int> - a vector holding for each element type (1) item of
5123 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
5124 * These values are in full-interlace mode.
5125 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
5127 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
5130 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
5131 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
5132 int nbOfTypes=geoTypes.size();
5133 std::vector<int> code(3*nbOfTypes);
5134 MCAuto<DataArrayInt> arr1=DataArrayInt::New();
5135 arr1->alloc(nbOfTypes,1);
5136 int *arrPtr=arr1->getPointer();
5137 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
5138 for(int i=0;i<nbOfTypes;i++,it++)
5139 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
5140 MCAuto<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
5141 const int *arrPtr2=arr2->getConstPointer();
5143 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
5146 int nbCells=mesh->getNumberOfCellsWithType(*it);
5147 code[3*pos]=(int)(*it);
5148 code[3*pos+1]=nbCells;
5149 code[3*pos+2]=-1;//no profiles
5151 std::vector<const DataArrayInt *> idsPerType;//no profiles
5152 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
5156 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
5161 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5163 return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5167 * Returns all attributes and values of parts of \a this field lying on a given mesh.
5168 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
5169 * item of every of returned sequences refers to the _i_-th part of \a this field.
5170 * Thus all sequences returned by this method are of the same length equal to number
5171 * of different types of supporting entities.<br>
5172 * A field part can include sub-parts with several different spatial discretizations,
5173 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
5174 * for example. Hence, some of the returned sequences contains nested sequences, and an item
5175 * of a nested sequence corresponds to a type of spatial discretization.<br>
5176 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
5177 * The overhead is due to selecting values into new instances of DataArrayDouble.
5178 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
5179 * for the case with only one underlying mesh. (Actually, the number of meshes is
5180 * not checked if \a mname == \c NULL).
5181 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
5182 * a field part is returned.
5183 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
5184 * A field part can include sub-parts with several different spatial discretizations,
5185 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and
5186 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT" for example.
5187 * This sequence is of the same length as \a types.
5188 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
5189 * discretization. A profile name can be empty.
5190 * Length of this and of nested sequences is the same as that of \a typesF.
5191 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
5192 * discretization. A localization name can be empty.
5193 * Length of this and of nested sequences is the same as that of \a typesF.
5194 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
5195 * per each type of spatial discretization within one mesh entity type.
5196 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
5197 * Length of this and of nested sequences is the same as that of \a typesF.
5198 * \throw If no field is lying on \a mname.
5200 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
5204 meshId=getMeshIdFromMeshName(mname);
5206 if(_field_per_mesh.empty())
5207 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
5208 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
5209 int nbOfRet=ret0.size();
5210 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
5211 for(int i=0;i<nbOfRet;i++)
5213 const std::vector< std::pair<int,int> >& p=ret0[i];
5214 int nbOfRet1=p.size();
5215 ret[i].resize(nbOfRet1);
5216 for(int j=0;j<nbOfRet1;j++)
5218 DataArrayDouble *tmp=_arr->selectByTupleIdSafeSlice(p[j].first,p[j].second,1);
5225 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
5230 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
5232 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
5233 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5234 ret->deepCpyLeavesFrom(*this);
5235 const DataArrayDouble *arr(_arr);
5238 MCAuto<DataArrayInt> arr2(arr->convertToIntArr());
5239 ret->setArray(arr2);
5245 * Returns a pointer to the underground DataArrayDouble instance and a
5246 * sequence describing parameters of a support of each part of \a this field. The
5247 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5248 * direct access to the field values. This method is intended for the field lying on one
5250 * \param [in,out] entries - the sequence describing parameters of a support of each
5251 * part of \a this field. Each item of this sequence consists of two parts. The
5252 * first part describes a type of mesh entity and an id of discretization of a
5253 * current field part. The second part describes a range of values [begin,end)
5254 * within the returned array relating to the current field part.
5255 * \return DataArrayDouble * - the pointer to the field values array.
5256 * \throw If the number of underlying meshes is not equal to 1.
5257 * \throw If no field values are available.
5258 * \sa getUndergroundDataArray()
5260 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5262 if(_field_per_mesh.size()!=1)
5263 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5264 if(_field_per_mesh[0]==0)
5265 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5266 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5267 return getUndergroundDataArrayTemplate();
5271 * Returns a pointer to the underground DataArrayDouble instance and a
5272 * sequence describing parameters of a support of each part of \a this field. The
5273 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5274 * direct access to the field values. This method is intended for the field lying on one
5276 * \param [in,out] entries - the sequence describing parameters of a support of each
5277 * part of \a this field. Each item of this sequence consists of two parts. The
5278 * first part describes a type of mesh entity and an id of discretization of a
5279 * current field part. The second part describes a range of values [begin,end)
5280 * within the returned array relating to the current field part.
5281 * \return DataArrayDouble * - the pointer to the field values array.
5282 * \throw If the number of underlying meshes is not equal to 1.
5283 * \throw If no field values are available.
5284 * \sa getUndergroundDataArray()
5286 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5288 return getUndergroundDataArrayDoubleExt(entries);
5291 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<double>(fieldName,csit,iteration,order)
5293 DataArrayDouble *arr(getOrCreateAndGetArrayTemplate());
5294 arr->setInfoAndChangeNbOfCompo(infos);
5297 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<double>()
5301 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
5303 MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
5304 ret->deepCpyLeavesFrom(*this);
5308 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCopy() const
5310 MCAuto<MEDFileField1TSWithoutSDA> ret=static_cast<MEDFileField1TSWithoutSDA *>(shallowCpy());
5311 if((const DataArrayDouble *)_arr)
5312 ret->_arr=_arr->deepCopy();
5316 //= MEDFileIntField1TSWithoutSDA
5318 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5320 return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5323 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<int>()
5327 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order,
5328 const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<int>(fieldName,csit,iteration,order)
5330 DataArrayInt *arr(getOrCreateAndGetArrayTemplate());
5331 arr->setInfoAndChangeNbOfCompo(infos);
5334 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
5339 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const
5341 MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
5342 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5343 ret->deepCpyLeavesFrom(*this);
5344 const DataArrayInt *arr(_arr);
5347 MCAuto<DataArrayDouble> arr2(arr->convertToDblArr());
5348 ret->setArray(arr2);
5354 * Returns a pointer to the underground DataArrayInt instance and a
5355 * sequence describing parameters of a support of each part of \a this field. The
5356 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5357 * direct access to the field values. This method is intended for the field lying on one
5359 * \param [in,out] entries - the sequence describing parameters of a support of each
5360 * part of \a this field. Each item of this sequence consists of two parts. The
5361 * first part describes a type of mesh entity and an id of discretization of a
5362 * current field part. The second part describes a range of values [begin,end)
5363 * within the returned array relating to the current field part.
5364 * \return DataArrayInt * - the pointer to the field values array.
5365 * \throw If the number of underlying meshes is not equal to 1.
5366 * \throw If no field values are available.
5367 * \sa getUndergroundDataArray()
5369 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5371 return getUndergroundDataArrayIntExt(entries);
5375 * Returns a pointer to the underground DataArrayInt instance and a
5376 * sequence describing parameters of a support of each part of \a this field. The
5377 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5378 * direct access to the field values. This method is intended for the field lying on one
5380 * \param [in,out] entries - the sequence describing parameters of a support of each
5381 * part of \a this field. Each item of this sequence consists of two parts. The
5382 * first part describes a type of mesh entity and an id of discretization of a
5383 * current field part. The second part describes a range of values [begin,end)
5384 * within the returned array relating to the current field part.
5385 * \return DataArrayInt * - the pointer to the field values array.
5386 * \throw If the number of underlying meshes is not equal to 1.
5387 * \throw If no field values are available.
5388 * \sa getUndergroundDataArray()
5390 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5392 if(_field_per_mesh.size()!=1)
5393 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5394 if(_field_per_mesh[0]==0)
5395 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5396 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5397 return getUndergroundDataArrayTemplate();
5400 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5402 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5403 ret->deepCpyLeavesFrom(*this);
5407 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCopy() const
5409 MCAuto<MEDFileIntField1TSWithoutSDA> ret=static_cast<MEDFileIntField1TSWithoutSDA *>(shallowCpy());
5410 if((const DataArrayInt *)_arr)
5411 ret->_arr=_arr->deepCopy();
5415 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5419 //= MEDFileAnyTypeField1TS
5421 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
5423 med_field_type typcha;
5425 std::vector<std::string> infos;
5426 std::string dtunit,fieldName;
5427 LocateField2(fid,0,true,fieldName,typcha,infos,dtunit);
5428 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5433 ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5438 ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5443 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] !";
5444 throw INTERP_KERNEL::Exception(oss.str());
5447 ret->setDtUnit(dtunit.c_str());
5448 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5450 med_int numdt,numit;
5452 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5453 ret->setTime(numdt,numit,dt);
5456 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5458 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5462 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
5463 try:MEDFileFieldGlobsReal(fid)
5465 _content=BuildContentFrom(fid,loadAll,ms);
5468 catch(INTERP_KERNEL::Exception& e)
5473 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5475 med_field_type typcha;
5476 std::vector<std::string> infos;
5479 int nbSteps=LocateField(fid,fieldName,iii,typcha,infos,dtunit);
5480 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5485 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5490 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5495 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] !";
5496 throw INTERP_KERNEL::Exception(oss.str());
5499 ret->setDtUnit(dtunit.c_str());
5500 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5504 std::ostringstream oss; oss << "MEDFileField1TS(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5505 throw INTERP_KERNEL::Exception(oss.str());
5508 med_int numdt,numit;
5510 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5511 ret->setTime(numdt,numit,dt);
5514 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5516 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5520 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5521 try:MEDFileFieldGlobsReal(fid)
5523 _content=BuildContentFrom(fid,fieldName,loadAll,ms);
5526 catch(INTERP_KERNEL::Exception& e)
5531 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c)
5534 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5535 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5537 MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
5538 ret->_content=c; c->incrRef();
5541 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5543 MCAuto<MEDFileIntField1TS> ret(MEDFileIntField1TS::New());
5544 ret->_content=c; c->incrRef();
5547 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5550 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, med_idt fid)
5552 MEDFileAnyTypeField1TS *ret(BuildNewInstanceFromContent(c));
5553 ret->setFileName(FileNameFromFID(fid));
5557 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
5559 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5560 return New(fid,loadAll);
5563 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, bool loadAll)
5565 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
5566 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5567 ret->loadGlobals(fid);
5571 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
5573 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5574 return New(fid,fieldName,loadAll);
5577 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
5579 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0));
5580 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5581 ret->loadGlobals(fid);
5585 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
5587 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5588 return New(fid,fieldName,iteration,order,loadAll);
5591 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
5593 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0));
5594 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5595 ret->loadGlobals(fid);
5599 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5601 med_field_type typcha;
5602 std::vector<std::string> infos;
5605 int nbOfStep2(LocateField(fid,fieldName,iii,typcha,infos,dtunit));
5606 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5611 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5616 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5621 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] !";
5622 throw INTERP_KERNEL::Exception(oss.str());
5625 ret->setDtUnit(dtunit.c_str());
5626 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5629 std::vector< std::pair<int,int> > dtits(nbOfStep2);
5630 for(int i=0;i<nbOfStep2 && !found;i++)
5632 med_int numdt,numit;
5634 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt));
5635 if(numdt==iteration && numit==order)
5641 dtits[i]=std::pair<int,int>(numdt,numit);
5645 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available iterations are : ";
5646 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5647 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5648 throw INTERP_KERNEL::Exception(oss.str());
5651 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5653 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5657 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5658 try:MEDFileFieldGlobsReal(fid)
5660 _content=BuildContentFrom(fid,fieldName,iteration,order,loadAll,ms);
5663 catch(INTERP_KERNEL::Exception& e)
5669 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5670 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5672 * \warning this is a shallow copy constructor
5674 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5676 if(!shallowCopyOfContent)
5678 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5679 otherPtr->incrRef();
5680 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5684 _content=other.shallowCpy();
5688 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)
5692 int nbFields=MEDnField(fid);
5693 if(fieldIdCFormat>=nbFields)
5695 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << FileNameFromFID(fid) << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5696 throw INTERP_KERNEL::Exception(oss.str());
5699 int ncomp(MEDfieldnComponent(fid,fieldIdCFormat+1));
5700 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5701 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5702 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5703 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5704 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5707 MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep));
5708 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5709 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5710 infos.clear(); infos.resize(ncomp);
5711 for(int j=0;j<ncomp;j++)
5712 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5717 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5720 * \return in case of success the number of time steps available for the field with name \a fieldName.
5722 int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const std::string& fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
5724 int nbFields=MEDnField(fid);
5726 std::vector<std::string> fns(nbFields);
5728 for(int i=0;i<nbFields && !found;i++)
5731 nbOfStep2=LocateField2(fid,i,false,tmp,typcha,infos,dtunitOut);
5733 found=(tmp==fieldName);
5739 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available fields are : ";
5740 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5741 oss << "\"" << *it << "\" ";
5742 throw INTERP_KERNEL::Exception(oss.str());
5748 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5749 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5750 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5751 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5752 * to keep a valid instance.
5753 * 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.
5754 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5755 * 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.
5757 * \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.
5758 * \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.
5759 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5760 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5761 * \param [in] newLocName is the new localization name.
5762 * \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.
5763 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5765 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
5767 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5768 std::string oldPflName=disc->getProfile();
5769 std::vector<std::string> vv=getPflsReallyUsedMulti();
5770 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5771 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5773 disc->setProfile(newPflName);
5774 DataArrayInt *pfl=getProfile(oldPflName.c_str());
5775 pfl->setName(newPflName);
5779 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5780 throw INTERP_KERNEL::Exception(oss.str());
5785 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5786 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5787 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5788 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5789 * to keep a valid instance.
5790 * 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.
5791 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5792 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5793 * 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.
5795 * \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.
5796 * \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.
5797 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5798 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5799 * \param [in] newLocName is the new localization name.
5800 * \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.
5801 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
5803 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
5805 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5806 std::string oldLocName=disc->getLocalization();
5807 std::vector<std::string> vv=getLocsReallyUsedMulti();
5808 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
5809 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
5811 disc->setLocalization(newLocName);
5812 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
5813 loc.setName(newLocName);
5817 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
5818 throw INTERP_KERNEL::Exception(oss.str());
5822 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
5824 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5826 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
5830 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
5832 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5834 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
5839 * This method alloc the arrays and load potentially huge arrays contained in this field.
5840 * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
5841 * This method can be also called to refresh or reinit values from a file.
5843 * \throw If the fileName is not set or points to a non readable MED file.
5844 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5846 void MEDFileAnyTypeField1TS::loadArrays()
5848 if(getFileName().empty())
5849 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
5850 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
5851 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
5855 * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
5856 * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
5857 * this method does not throw if \a this does not come from file read.
5859 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
5861 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
5863 if(!getFileName().empty())
5865 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
5866 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
5871 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
5872 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
5873 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
5875 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
5877 void MEDFileAnyTypeField1TS::unloadArrays()
5879 contentNotNullBase()->unloadArrays();
5883 * 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.
5884 * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
5885 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
5887 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5889 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
5891 if(!getFileName().empty())
5892 contentNotNullBase()->unloadArrays();
5895 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
5897 int nbComp(getNumberOfComponents());
5898 INTERP_KERNEL::AutoPtr<char> comp(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
5899 INTERP_KERNEL::AutoPtr<char> unit(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
5900 for(int i=0;i<nbComp;i++)
5902 std::string info=getInfo()[i];
5904 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
5905 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
5906 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
5908 if(getName().empty())
5909 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
5910 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
5911 writeGlobals(fid,*this);
5912 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
5915 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
5917 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
5920 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
5922 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
5923 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
5928 * Returns a string describing \a this field. This string is outputted
5929 * by \c print Python command.
5931 std::string MEDFileAnyTypeField1TS::simpleRepr() const
5933 std::ostringstream oss;
5934 contentNotNullBase()->simpleRepr(0,oss,-1);
5935 simpleReprGlobs(oss);
5940 * This method returns all profiles whose name is non empty used.
5941 * \b WARNING If profile is used several times it will be reported \b only \b once.
5942 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
5944 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
5946 return contentNotNullBase()->getPflsReallyUsed2();
5950 * This method returns all localizations whose name is non empty used.
5951 * \b WARNING If localization is used several times it will be reported \b only \b once.
5953 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
5955 return contentNotNullBase()->getLocsReallyUsed2();
5959 * This method returns all profiles whose name is non empty used.
5960 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
5962 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
5964 return contentNotNullBase()->getPflsReallyUsedMulti2();
5968 * This method returns all localizations whose name is non empty used.
5969 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
5971 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
5973 return contentNotNullBase()->getLocsReallyUsedMulti2();
5976 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5978 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
5981 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5983 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
5986 int MEDFileAnyTypeField1TS::getDimension() const
5988 return contentNotNullBase()->getDimension();
5991 int MEDFileAnyTypeField1TS::getIteration() const
5993 return contentNotNullBase()->getIteration();
5996 int MEDFileAnyTypeField1TS::getOrder() const
5998 return contentNotNullBase()->getOrder();
6001 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
6003 return contentNotNullBase()->getTime(iteration,order);
6006 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
6008 contentNotNullBase()->setTime(iteration,order,val);
6011 std::string MEDFileAnyTypeField1TS::getName() const
6013 return contentNotNullBase()->getName();
6016 void MEDFileAnyTypeField1TS::setName(const std::string& name)
6018 contentNotNullBase()->setName(name);
6021 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
6023 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
6026 std::string MEDFileAnyTypeField1TS::getDtUnit() const
6028 return contentNotNullBase()->getDtUnit();
6031 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
6033 contentNotNullBase()->setDtUnit(dtUnit);
6036 std::string MEDFileAnyTypeField1TS::getMeshName() const
6038 return contentNotNullBase()->getMeshName();
6041 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
6043 contentNotNullBase()->setMeshName(newMeshName);
6046 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
6048 return contentNotNullBase()->changeMeshNames(modifTab);
6051 int MEDFileAnyTypeField1TS::getMeshIteration() const
6053 return contentNotNullBase()->getMeshIteration();
6056 int MEDFileAnyTypeField1TS::getMeshOrder() const
6058 return contentNotNullBase()->getMeshOrder();
6061 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
6063 return contentNotNullBase()->getNumberOfComponents();
6066 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
6068 return contentNotNullBase()->isDealingTS(iteration,order);
6071 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
6073 return contentNotNullBase()->getDtIt();
6076 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
6078 contentNotNullBase()->fillIteration(p);
6081 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
6083 contentNotNullBase()->fillTypesOfFieldAvailable(types);
6086 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
6088 contentNotNullBase()->setInfo(infos);
6091 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
6093 return contentNotNullBase()->getInfo();
6095 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
6097 return contentNotNullBase()->getInfo();
6100 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
6102 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
6105 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
6107 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6110 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
6112 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6115 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
6117 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
6120 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
6122 return contentNotNullBase()->getTypesOfFieldAvailable();
6125 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,
6126 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6128 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
6132 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
6133 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
6134 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
6136 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
6138 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6140 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
6141 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
6142 std::size_t sz(contentsSplit.size());
6143 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6144 for(std::size_t i=0;i<sz;i++)
6146 ret[i]=shallowCpy();
6147 ret[i]->_content=contentsSplit[i];
6153 * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
6154 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6156 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
6158 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6160 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
6161 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
6162 std::size_t sz(contentsSplit.size());
6163 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6164 for(std::size_t i=0;i<sz;i++)
6166 ret[i]=shallowCpy();
6167 ret[i]->_content=contentsSplit[i];
6173 * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this.
6174 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6176 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const
6178 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6180 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !");
6181 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
6182 std::size_t sz(contentsSplit.size());
6183 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6184 for(std::size_t i=0;i<sz;i++)
6186 ret[i]=shallowCpy();
6187 ret[i]->_content=contentsSplit[i];
6192 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCopy() const
6194 MCAuto<MEDFileAnyTypeField1TS> ret=shallowCpy();
6195 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
6196 ret->_content=_content->deepCopy();
6197 ret->deepCpyGlobs(*this);
6201 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
6203 return contentNotNullBase()->copyTinyInfoFrom(field,arr);
6209 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6210 * the first field that has been read from a specified MED file.
6211 * \param [in] fileName - the name of the MED file to read.
6212 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6213 * is to delete this field using decrRef() as it is no more needed.
6214 * \throw If reading the file fails.
6216 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll)
6218 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6219 return New(fid,loadAll);
6222 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, bool loadAll)
6224 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,loadAll,0));
6225 ret->contentNotNull();
6230 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6231 * a given field that has been read from a specified MED file.
6232 * \param [in] fileName - the name of the MED file to read.
6233 * \param [in] fieldName - the name of the field to read.
6234 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6235 * is to delete this field using decrRef() as it is no more needed.
6236 * \throw If reading the file fails.
6237 * \throw If there is no field named \a fieldName in the file.
6239 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6241 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6242 return New(fid,fieldName,loadAll);
6245 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
6247 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,fieldName,loadAll,0));
6248 ret->contentNotNull();
6253 * Returns a new instance of MEDFileField1TS holding data of a given time step of
6254 * a given field that has been read from a specified MED file.
6255 * \param [in] fileName - the name of the MED file to read.
6256 * \param [in] fieldName - the name of the field to read.
6257 * \param [in] iteration - the iteration number of a required time step.
6258 * \param [in] order - the iteration order number of required time step.
6259 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6260 * is to delete this field using decrRef() as it is no more needed.
6261 * \throw If reading the file fails.
6262 * \throw If there is no field named \a fieldName in the file.
6263 * \throw If the required time step is missing from the file.
6265 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6267 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6268 return New(fid,fieldName,iteration,order,loadAll);
6271 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
6273 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,fieldName,iteration,order,loadAll,0));
6274 ret->contentNotNull();
6279 * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6280 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6282 * Returns a new instance of MEDFileField1TS holding either a shallow copy
6283 * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
6284 * \warning this is a shallow copy constructor
6285 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
6286 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
6287 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6288 * is to delete this field using decrRef() as it is no more needed.
6290 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6292 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(other,shallowCopyOfContent));
6293 ret->contentNotNull();
6298 * Returns a new empty instance of MEDFileField1TS.
6299 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6300 * is to delete this field using decrRef() as it is no more needed.
6302 MEDFileField1TS *MEDFileField1TS::New()
6304 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS);
6305 ret->contentNotNull();
6310 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
6311 * following the given input policy.
6313 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6314 * By default (true) the globals are deeply copied.
6315 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
6317 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
6319 MCAuto<MEDFileIntField1TS> ret;
6320 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6323 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
6325 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
6326 MCAuto<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
6327 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc));
6330 ret=MEDFileIntField1TS::New();
6332 ret->deepCpyGlobs(*this);
6334 ret->shallowCpyGlobs(*this);
6338 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const
6340 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6342 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
6343 const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
6345 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 !");
6349 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull()
6351 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6353 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
6354 MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
6356 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 !");
6360 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
6363 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
6365 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
6366 DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6368 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6369 f->setArray(arrOutC);
6372 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MCAuto<DataArray>& arr)
6375 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
6376 DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6378 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6384 * Return an extraction of \a this using \a extractDef map to specify the extraction.
6385 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
6387 * \return A new object that the caller is responsible to deallocate.
6388 * \sa MEDFileUMesh::deduceNodeSubPartFromCellSubPart , MEDFileUMesh::extractPart
6390 MEDFileField1TS *MEDFileField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
6393 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : input mesh is NULL !");
6394 MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
6395 std::vector<TypeOfField> tof(getTypesOfFieldAvailable());
6396 for(std::vector<TypeOfField>::const_iterator it0=tof.begin();it0!=tof.end();it0++)
6398 if((*it0)!=ON_NODES)
6400 std::vector<int> levs;
6401 getNonEmptyLevels(mm->getName(),levs);
6402 for(std::vector<int>::const_iterator lev=levs.begin();lev!=levs.end();lev++)
6404 std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(*lev));
6405 if(it2!=extractDef.end())
6407 MCAuto<DataArrayInt> t((*it2).second);
6409 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6410 MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_CELLS,(*lev),mm));
6411 MCAuto<MEDCouplingFieldDouble> fOut(f->buildSubPart(t));
6412 ret->setFieldNoProfileSBT(fOut);
6418 std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(1));
6419 if(it2==extractDef.end())
6420 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a NODE field and no extract array available for NODE !");
6421 MCAuto<DataArrayInt> t((*it2).second);
6423 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6424 MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_NODES,0,mm));
6425 MCAuto<MEDCouplingFieldDouble> fOut(f->deepCopy());
6426 DataArrayDouble *arr(f->getArray());
6427 MCAuto<DataArrayDouble> newArr(arr->selectByTupleIdSafe(t->begin(),t->end()));
6428 fOut->setArray(newArr);
6429 ret->setFieldNoProfileSBT(fOut);
6435 MEDFileField1TS::MEDFileField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
6436 try:MEDFileAnyTypeField1TS(fid,loadAll,ms)
6439 catch(INTERP_KERNEL::Exception& e)
6442 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6443 try:MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms)
6446 catch(INTERP_KERNEL::Exception& e)
6449 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6450 try:MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms)
6453 catch(INTERP_KERNEL::Exception& e)
6457 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6458 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6460 * \warning this is a shallow copy constructor
6462 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6463 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6466 catch(INTERP_KERNEL::Exception& e)
6469 MEDFileField1TS::MEDFileField1TS()
6471 _content=new MEDFileField1TSWithoutSDA;
6475 * 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
6476 * method should be called (getFieldOnMeshAtLevel for example).
6477 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
6479 * \param [in] mesh - the mesh the field is lying on
6480 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6481 * caller is to delete this field using decrRef() as it is no more needed.
6483 MEDCouplingFieldDouble *MEDFileField1TS::field(const MEDFileMesh *mesh) const
6485 MCAuto<DataArray> arrOut;
6486 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
6487 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6492 * Returns a new MEDCouplingFieldDouble of a given type lying on
6493 * mesh entities of a given dimension of the first mesh in MED file. If \a this field
6494 * has not been constructed via file reading, an exception is thrown.
6495 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6496 * \param [in] type - a spatial discretization of interest.
6497 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6498 * \param [in] renumPol - specifies how to permute values of the result field according to
6499 * the optional numbers of cells and nodes, if any. The valid values are
6500 * - 0 - do not permute.
6501 * - 1 - permute cells.
6502 * - 2 - permute nodes.
6503 * - 3 - permute cells and nodes.
6505 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6506 * caller is to delete this field using decrRef() as it is no more needed.
6507 * \throw If \a this field has not been constructed via file reading.
6508 * \throw If the MED file is not readable.
6509 * \throw If there is no mesh in the MED file.
6510 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6511 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6512 * \sa getFieldOnMeshAtLevel()
6514 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6516 if(getFileName().empty())
6517 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6518 MCAuto<DataArray> arrOut;
6519 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
6520 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6525 * Returns a new MEDCouplingFieldDouble of a given type lying on
6526 * the top level cells of the first mesh in MED file. If \a this field
6527 * has not been constructed via file reading, an exception is thrown.
6528 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6529 * \param [in] type - a spatial discretization of interest.
6530 * \param [in] renumPol - specifies how to permute values of the result field according to
6531 * the optional numbers of cells and nodes, if any. The valid values are
6532 * - 0 - do not permute.
6533 * - 1 - permute cells.
6534 * - 2 - permute nodes.
6535 * - 3 - permute cells and nodes.
6537 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6538 * caller is to delete this field using decrRef() as it is no more needed.
6539 * \throw If \a this field has not been constructed via file reading.
6540 * \throw If the MED file is not readable.
6541 * \throw If there is no mesh in the MED file.
6542 * \throw If no field values of the given \a type.
6543 * \throw If no field values lying on the top level support.
6544 * \sa getFieldAtLevel()
6546 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
6548 if(getFileName().empty())
6549 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6550 MCAuto<DataArray> arrOut;
6551 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
6552 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6557 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6558 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6559 * \param [in] type - a spatial discretization of the new field.
6560 * \param [in] mesh - the supporting mesh.
6561 * \param [in] renumPol - specifies how to permute values of the result field according to
6562 * the optional numbers of cells and nodes, if any. The valid values are
6563 * - 0 - do not permute.
6564 * - 1 - permute cells.
6565 * - 2 - permute nodes.
6566 * - 3 - permute cells and nodes.
6568 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6569 * caller is to delete this field using decrRef() as it is no more needed.
6570 * \throw If no field of \a this is lying on \a mesh.
6571 * \throw If the mesh is empty.
6572 * \throw If no field values of the given \a type are available.
6573 * \sa getFieldAtLevel()
6574 * \sa getFieldOnMeshAtLevel()
6576 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
6578 MCAuto<DataArray> arrOut;
6579 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
6580 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6585 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6586 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6587 * \param [in] type - a spatial discretization of interest.
6588 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6589 * \param [in] mesh - the supporting mesh.
6590 * \param [in] renumPol - specifies how to permute values of the result field according to
6591 * the optional numbers of cells and nodes, if any. The valid values are
6592 * - 0 - do not permute.
6593 * - 1 - permute cells.
6594 * - 2 - permute nodes.
6595 * - 3 - permute cells and nodes.
6597 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6598 * caller is to delete this field using decrRef() as it is no more needed.
6599 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6600 * \throw If no field of \a this is lying on \a mesh.
6601 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6602 * \sa getFieldAtLevel()
6603 * \sa getFieldOnMeshAtLevel()
6605 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
6607 MCAuto<DataArray> arrOut;
6608 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
6609 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6614 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6615 * This method is called "Old" because in MED3 norm a field has only one meshName
6616 * attached, so this method is for readers of MED2 files. If \a this field
6617 * has not been constructed via file reading, an exception is thrown.
6618 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6619 * \param [in] type - a spatial discretization of interest.
6620 * \param [in] mName - a name of the supporting mesh.
6621 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6622 * \param [in] renumPol - specifies how to permute values of the result field according to
6623 * the optional numbers of cells and nodes, if any. The valid values are
6624 * - 0 - do not permute.
6625 * - 1 - permute cells.
6626 * - 2 - permute nodes.
6627 * - 3 - permute cells and nodes.
6629 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6630 * caller is to delete this field using decrRef() as it is no more needed.
6631 * \throw If the MED file is not readable.
6632 * \throw If there is no mesh named \a mName in the MED file.
6633 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6634 * \throw If \a this field has not been constructed via file reading.
6635 * \throw If no field of \a this is lying on the mesh named \a mName.
6636 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6637 * \sa getFieldAtLevel()
6639 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
6641 if(getFileName().empty())
6642 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6643 MCAuto<DataArray> arrOut;
6644 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull()));
6645 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6650 * Returns values and a profile of the field of a given type lying on a given support.
6651 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6652 * \param [in] type - a spatial discretization of the field.
6653 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6654 * \param [in] mesh - the supporting mesh.
6655 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6656 * field of interest lies on. If the field lies on all entities of the given
6657 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6658 * using decrRef() as it is no more needed.
6659 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6660 * field. The caller is to delete this array using decrRef() as it is no more needed.
6661 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6662 * \throw If no field of \a this is lying on \a mesh.
6663 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6665 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6667 MCAuto<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6668 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
6672 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6673 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6674 * "Sort By Type"), if not, an exception is thrown.
6675 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6676 * \param [in] field - the field to add to \a this.
6677 * \throw If the name of \a field is empty.
6678 * \throw If the data array of \a field is not set.
6679 * \throw If the data array is already allocated but has different number of components
6681 * \throw If the underlying mesh of \a field has no name.
6682 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6684 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
6687 contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
6691 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6692 * can be an aggregation of several MEDCouplingFieldDouble instances.
6693 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6694 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6697 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6698 * A new profile is added only if no equal profile is missing.
6699 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6700 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
6701 * \param [in] mesh - the supporting mesh of \a field.
6702 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6703 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6704 * \throw If either \a field or \a mesh or \a profile has an empty name.
6705 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6706 * \throw If the data array of \a field is not set.
6707 * \throw If the data array of \a this is already allocated but has different number of
6708 * components than \a field.
6709 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6710 * \sa setFieldNoProfileSBT()
6712 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6715 contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6718 MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const
6720 return new MEDFileField1TS(*this);
6723 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const
6725 return contentNotNull()->getUndergroundDataArrayTemplate();
6728 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
6730 return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
6733 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6734 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6736 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6739 //= MEDFileIntField1TS
6741 MEDFileIntField1TS *MEDFileIntField1TS::New()
6743 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS);
6744 ret->contentNotNull();
6748 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll)
6750 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6751 return MEDFileIntField1TS::New(fid,loadAll);
6754 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, bool loadAll)
6756 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,loadAll,0));
6757 ret->contentNotNull();
6761 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6763 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6764 return MEDFileIntField1TS::New(fid,fieldName,loadAll);
6767 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
6769 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,loadAll,0));
6770 ret->contentNotNull();
6774 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6776 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6777 return MEDFileIntField1TS::New(fid,fieldName,iteration,order,loadAll);
6780 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
6782 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,iteration,order,loadAll,0));
6783 ret->contentNotNull();
6787 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6789 MCAuto<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6790 ret->contentNotNull();
6794 MEDFileIntField1TS::MEDFileIntField1TS()
6796 _content=new MEDFileIntField1TSWithoutSDA;
6799 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
6800 try:MEDFileAnyTypeField1TS(fid,loadAll,ms)
6803 catch(INTERP_KERNEL::Exception& e)
6806 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6807 try:MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms)
6810 catch(INTERP_KERNEL::Exception& e)
6813 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6814 try:MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms)
6817 catch(INTERP_KERNEL::Exception& e)
6821 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6822 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6824 * \warning this is a shallow copy constructor
6826 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6830 MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const
6832 return new MEDFileIntField1TS(*this);
6836 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
6837 * following the given input policy.
6839 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6840 * By default (true) the globals are deeply copied.
6841 * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
6843 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const
6845 MCAuto<MEDFileField1TS> ret;
6846 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6849 const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
6851 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
6852 MCAuto<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
6853 ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc));
6856 ret=MEDFileField1TS::New();
6858 ret->deepCpyGlobs(*this);
6860 ret->shallowCpyGlobs(*this);
6865 * Adds a MEDCouplingFieldInt to \a this. The underlying mesh of the given field is
6866 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6867 * "Sort By Type"), if not, an exception is thrown.
6868 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6869 * \param [in] field - the field to add to \a this.
6870 * \throw If the name of \a field is empty.
6871 * \throw If the data array of \a field is not set.
6872 * \throw If the data array is already allocated but has different number of components
6874 * \throw If the underlying mesh of \a field has no name.
6875 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6877 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldInt *field)
6879 MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
6881 contentNotNull()->setFieldNoProfileSBT(field2,field->getArray(),*this,*contentNotNull());
6885 * Adds a MEDCouplingFieldInt to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6886 * can be an aggregation of several MEDCouplingFieldDouble instances.
6887 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6888 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6891 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6892 * A new profile is added only if no equal profile is missing.
6893 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6894 * \param [in] field - the field to add to \a this.
6895 * \param [in] mesh - the supporting mesh of \a field.
6896 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6897 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6898 * \throw If either \a field or \a mesh or \a profile has an empty name.
6899 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6900 * \throw If the data array of \a field is not set.
6901 * \throw If the data array of \a this is already allocated but has different number of
6902 * components than \a field.
6903 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6904 * \sa setFieldNoProfileSBT()
6906 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6908 MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
6910 contentNotNull()->setFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6913 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const
6915 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6917 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
6918 const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
6920 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 !");
6924 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6926 if(getFileName().empty())
6927 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6928 MCAuto<DataArray> arrOut;
6929 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
6930 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
6934 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MCAuto<DataArray>& arr)
6937 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
6938 DataArrayInt *arrC(dynamic_cast<DataArrayInt *>((DataArray *)arr));
6940 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
6945 MCAuto<MEDCouplingFieldInt> MEDFileIntField1TS::SetDataArrayDoubleInIntField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
6948 double t0(f->getTime(t1,t2));
6949 MCAuto<DataArrayInt> arr2(DynamicCastSafe<DataArray,DataArrayInt>(arr));
6950 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
6951 MCAuto<MEDCouplingFieldInt> ret(MEDCouplingFieldInt::New(*ft));
6952 ret->setTime(t0,t1,t2); ret->setArray(arr2);
6956 MCAuto<MEDCouplingFieldDouble> MEDFileIntField1TS::ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f)
6959 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ConvertFieldIntToFieldDouble : null input field !");
6961 double t0(f->getTime(t1,t2));
6962 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
6963 MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(*ft));
6964 ret->setTime(t0,t1,t2);
6968 MEDFileIntField1TS *MEDFileIntField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
6970 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::extractPart : not implemented yet !");
6974 * 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
6975 * method should be called (getFieldOnMeshAtLevel for example).
6976 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
6978 * \param [in] mesh - the mesh the field is lying on
6979 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
6980 * caller is to delete this field using decrRef() as it is no more needed.
6982 MEDCouplingFieldInt *MEDFileIntField1TS::field(const MEDFileMesh *mesh) const
6984 MCAuto<DataArray> arrOut;
6985 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
6986 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
6991 * Returns a new MEDCouplingFieldInt of a given type lying on
6992 * the top level cells of the first mesh in MED file. If \a this field
6993 * has not been constructed via file reading, an exception is thrown.
6994 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6995 * \param [in] type - a spatial discretization of interest.
6996 * \param [in] renumPol - specifies how to permute values of the result field according to
6997 * the optional numbers of cells and nodes, if any. The valid values are
6998 * - 0 - do not permute.
6999 * - 1 - permute cells.
7000 * - 2 - permute nodes.
7001 * - 3 - permute cells and nodes.
7003 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7004 * caller is to delete this field using decrRef() as it is no more needed.
7005 * \throw If \a this field has not been constructed via file reading.
7006 * \throw If the MED file is not readable.
7007 * \throw If there is no mesh in the MED file.
7008 * \throw If no field values of the given \a type.
7009 * \throw If no field values lying on the top level support.
7010 * \sa getFieldAtLevel()
7012 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
7014 if(getFileName().empty())
7015 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
7016 MCAuto<DataArray> arrOut;
7017 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
7018 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7023 * Returns a new MEDCouplingFieldInt of given type lying on a given mesh.
7024 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7025 * \param [in] type - a spatial discretization of the new field.
7026 * \param [in] mesh - the supporting mesh.
7027 * \param [in] renumPol - specifies how to permute values of the result field according to
7028 * the optional numbers of cells and nodes, if any. The valid values are
7029 * - 0 - do not permute.
7030 * - 1 - permute cells.
7031 * - 2 - permute nodes.
7032 * - 3 - permute cells and nodes.
7034 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7035 * caller is to delete this field using decrRef() as it is no more needed.
7036 * \throw If no field of \a this is lying on \a mesh.
7037 * \throw If the mesh is empty.
7038 * \throw If no field values of the given \a type are available.
7039 * \sa getFieldAtLevel()
7040 * \sa getFieldOnMeshAtLevel()
7042 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
7044 MCAuto<DataArray> arrOut;
7045 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
7046 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7051 * Returns a new MEDCouplingFieldInt of a given type lying on a given support.
7052 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7053 * \param [in] type - a spatial discretization of interest.
7054 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7055 * \param [in] mesh - the supporting mesh.
7056 * \param [in] renumPol - specifies how to permute values of the result field according to
7057 * the optional numbers of cells and nodes, if any. The valid values are
7058 * - 0 - do not permute.
7059 * - 1 - permute cells.
7060 * - 2 - permute nodes.
7061 * - 3 - permute cells and nodes.
7063 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7064 * caller is to delete this field using decrRef() as it is no more needed.
7065 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7066 * \throw If no field of \a this is lying on \a mesh.
7067 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7068 * \sa getFieldAtLevel()
7069 * \sa getFieldOnMeshAtLevel()
7071 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
7073 MCAuto<DataArray> arrOut;
7074 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
7075 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7080 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
7081 * This method is called "Old" because in MED3 norm a field has only one meshName
7082 * attached, so this method is for readers of MED2 files. If \a this field
7083 * has not been constructed via file reading, an exception is thrown.
7084 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7085 * \param [in] type - a spatial discretization of interest.
7086 * \param [in] mName - a name of the supporting mesh.
7087 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7088 * \param [in] renumPol - specifies how to permute values of the result field according to
7089 * the optional numbers of cells and nodes, if any. The valid values are
7090 * - 0 - do not permute.
7091 * - 1 - permute cells.
7092 * - 2 - permute nodes.
7093 * - 3 - permute cells and nodes.
7095 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7096 * caller is to delete this field using decrRef() as it is no more needed.
7097 * \throw If the MED file is not readable.
7098 * \throw If there is no mesh named \a mName in the MED file.
7099 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7100 * \throw If \a this field has not been constructed via file reading.
7101 * \throw If no field of \a this is lying on the mesh named \a mName.
7102 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7103 * \sa getFieldAtLevel()
7105 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
7107 if(getFileName().empty())
7108 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7109 MCAuto<DataArray> arrOut;
7110 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
7111 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7116 * Returns values and a profile of the field of a given type lying on a given support.
7117 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7118 * \param [in] type - a spatial discretization of the field.
7119 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7120 * \param [in] mesh - the supporting mesh.
7121 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
7122 * field of interest lies on. If the field lies on all entities of the given
7123 * dimension, all ids in \a pfl are zero. The caller is to delete this array
7124 * using decrRef() as it is no more needed.
7125 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
7126 * field. The caller is to delete this array using decrRef() as it is no more needed.
7127 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7128 * \throw If no field of \a this is lying on \a mesh.
7129 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7131 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
7133 MCAuto<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
7134 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
7137 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull()
7139 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7141 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
7142 MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
7144 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 !");
7148 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const
7150 return contentNotNull()->getUndergroundDataArrayTemplate();
7153 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
7155 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
7159 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileFieldNameScope(fieldName)
7164 * \param [in] fieldId field id in C mode
7166 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7168 med_field_type typcha;
7169 std::string dtunitOut;
7170 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fieldId,false,_name,typcha,_infos,dtunitOut));
7171 setDtUnit(dtunitOut.c_str());
7172 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities);
7175 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 MEDFileEntities *entities)
7176 try:MEDFileFieldNameScope(fieldName),_infos(infos)
7178 setDtUnit(dtunit.c_str());
7179 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities);
7181 catch(INTERP_KERNEL::Exception& e)
7186 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
7188 std::size_t ret(_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MCAuto<MEDFileField1TSWithoutSDA>));
7189 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7190 ret+=(*it).capacity();
7194 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
7196 std::vector<const BigMemoryObject *> ret;
7197 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7198 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
7203 * 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
7206 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
7208 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7209 ret->setInfo(_infos);
7210 int sz=(int)_time_steps.size();
7211 for(const int *id=startIds;id!=endIds;id++)
7213 if(*id>=0 && *id<sz)
7215 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
7216 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7220 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7222 ret->pushBackTimeStep(tse2);
7226 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
7227 oss << " ! Should be in [0," << sz << ") !";
7228 throw INTERP_KERNEL::Exception(oss.str());
7231 if(ret->getNumberOfTS()>0)
7232 ret->synchronizeNameScope();
7233 ret->copyNameScope(*this);
7238 * 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
7241 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
7243 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
7244 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7245 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7246 ret->setInfo(_infos);
7247 int sz=(int)_time_steps.size();
7249 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
7253 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
7254 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7258 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7260 ret->pushBackTimeStep(tse2);
7264 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
7265 oss << " ! Should be in [0," << sz << ") !";
7266 throw INTERP_KERNEL::Exception(oss.str());
7269 if(ret->getNumberOfTS()>0)
7270 ret->synchronizeNameScope();
7271 ret->copyNameScope(*this);
7275 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7278 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7279 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7281 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7284 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7285 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
7286 ids->pushBackSilent(id);
7288 return buildFromTimeStepIds(ids->begin(),ids->end());
7291 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7294 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7295 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7297 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7300 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7301 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
7302 ids->pushBackSilent(id);
7304 return buildFromTimeStepIds(ids->begin(),ids->end());
7307 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
7309 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7311 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7314 if(cur->presenceOfMultiDiscPerGeoType())
7320 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
7325 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
7330 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
7333 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7335 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
7336 if(pt->isDealingTS(iteration,order))
7339 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
7340 std::vector< std::pair<int,int> > vp=getIterations();
7341 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
7342 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
7343 throw INTERP_KERNEL::Exception(oss.str());
7346 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
7348 return *_time_steps[getTimeStepPos(iteration,order)];
7351 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
7353 return *_time_steps[getTimeStepPos(iteration,order)];
7356 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const
7358 if(_time_steps.empty())
7359 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
7360 return _time_steps[0]->getMeshName();
7363 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const std::string& newMeshName)
7365 std::string oldName(getMeshName());
7366 std::vector< std::pair<std::string,std::string> > v(1);
7367 v[0].first=oldName; v[0].second=newMeshName;
7371 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
7374 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7376 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7378 ret=cur->changeMeshNames(modifTab) || ret;
7384 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
7386 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
7388 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
7392 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
7394 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7396 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
7399 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
7400 MEDFileFieldGlobsReal& glob)
7403 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7405 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
7407 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
7412 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7414 std::string startLine(bkOffset,' ');
7415 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
7417 oss << " (" << fmtsId << ")";
7418 oss << " has the following name: \"" << _name << "\"." << std::endl;
7419 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
7420 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7422 oss << startLine << " - \"" << *it << "\"" << std::endl;
7425 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7427 std::string chapter(17,'0'+i);
7428 oss << startLine << chapter << std::endl;
7429 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7431 cur->simpleRepr(bkOffset+2,oss,i);
7433 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
7434 oss << startLine << chapter << std::endl;
7438 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
7440 std::size_t sz=_time_steps.size();
7441 std::vector< std::pair<int,int> > ret(sz);
7443 for(std::size_t i=0;i<sz;i++)
7445 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
7448 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
7452 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
7453 throw INTERP_KERNEL::Exception(oss.str());
7459 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MCAuto<MEDFileAnyTypeField1TSWithoutSDA>& tse)
7461 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
7463 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
7464 checkCoherencyOfType(tse2);
7465 if(_time_steps.empty())
7467 setName(tse2->getName().c_str());
7468 setInfo(tse2->getInfo());
7470 checkThatComponentsMatch(tse2->getInfo());
7471 if(getDtUnit().empty() && !tse->getDtUnit().empty())
7472 setDtUnit(tse->getDtUnit());
7473 _time_steps.push_back(tse);
7476 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
7478 std::size_t nbOfCompo=_infos.size();
7479 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7481 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7484 if((cur->getInfo()).size()!=nbOfCompo)
7486 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
7487 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
7488 throw INTERP_KERNEL::Exception(oss.str());
7490 cur->copyNameScope(*this);
7495 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7497 _time_steps.resize(nbPdt);
7498 for(int i=0;i<nbPdt;i++)
7500 std::vector< std::pair<int,int> > ts;
7501 med_int numdt=0,numo=0;
7503 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt));
7508 _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7513 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7517 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
7520 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities);
7522 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entities);
7523 synchronizeNameScope();
7527 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
7529 if(_time_steps.empty())
7530 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
7531 checkThatNbOfCompoOfTSMatchThis();
7532 std::vector<std::string> infos(getInfo());
7533 int nbComp=infos.size();
7534 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7535 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7536 for(int i=0;i<nbComp;i++)
7538 std::string info=infos[i];
7540 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7541 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7542 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7545 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7546 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
7547 int nbOfTS=_time_steps.size();
7548 for(int i=0;i<nbOfTS;i++)
7549 _time_steps[i]->writeLL(fid,opts,*this);
7552 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
7554 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7556 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7558 elt->loadBigArraysRecursively(fid,nasc);
7562 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
7564 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7566 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7568 elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7572 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
7574 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7576 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7578 elt->unloadArrays();
7582 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7584 return _time_steps.size();
7587 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
7589 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7590 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7592 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7594 newTS.push_back(*it);
7599 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
7601 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7602 int maxId=(int)_time_steps.size();
7604 std::set<int> idsToDel;
7605 for(const int *id=startIds;id!=endIds;id++,ii++)
7607 if(*id>=0 && *id<maxId)
7609 idsToDel.insert(*id);
7613 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7614 throw INTERP_KERNEL::Exception(oss.str());
7617 for(int iii=0;iii<maxId;iii++)
7618 if(idsToDel.find(iii)==idsToDel.end())
7619 newTS.push_back(_time_steps[iii]);
7623 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
7625 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7626 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7627 if(nbOfEntriesToKill==0)
7629 std::size_t sz=_time_steps.size();
7630 std::vector<bool> b(sz,true);
7632 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7634 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7635 for(std::size_t i=0;i<sz;i++)
7637 newTS.push_back(_time_steps[i]);
7641 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
7644 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
7645 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7647 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7651 tmp->getTime(it2,ord);
7652 if(it2==iteration && order==ord)
7655 oss << "(" << it2 << "," << ord << "), ";
7658 throw INTERP_KERNEL::Exception(oss.str());
7661 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
7664 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
7666 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7668 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7672 double ti=tmp->getTime(it2,ord);
7673 if(fabs(time-ti)<eps)
7679 throw INTERP_KERNEL::Exception(oss.str());
7682 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
7684 int lgth=_time_steps.size();
7685 std::vector< std::pair<int,int> > ret(lgth);
7686 for(int i=0;i<lgth;i++)
7687 _time_steps[i]->fillIteration(ret[i]);
7692 * 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'
7693 * This method returns two things.
7694 * - The absolute dimension of 'this' in first parameter.
7695 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7696 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
7698 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7699 * Only these 3 discretizations will be taken into account here.
7701 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7702 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7703 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7705 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7706 * 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'.
7708 * Let's consider the typical following case :
7709 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7710 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7711 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7713 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7715 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7717 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7718 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7719 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7720 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7722 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
7724 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7727 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
7729 if(pos<0 || pos>=(int)_time_steps.size())
7731 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7732 throw INTERP_KERNEL::Exception(oss.str());
7734 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7737 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7738 oss << "\nTry to use following method eraseEmptyTS !";
7739 throw INTERP_KERNEL::Exception(oss.str());
7744 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
7746 if(pos<0 || pos>=(int)_time_steps.size())
7748 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7749 throw INTERP_KERNEL::Exception(oss.str());
7751 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7754 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7755 oss << "\nTry to use following method eraseEmptyTS !";
7756 throw INTERP_KERNEL::Exception(oss.str());
7761 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
7763 std::vector<std::string> ret;
7764 std::set<std::string> ret2;
7765 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7767 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
7768 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7769 if(ret2.find(*it2)==ret2.end())
7771 ret.push_back(*it2);
7778 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
7780 std::vector<std::string> ret;
7781 std::set<std::string> ret2;
7782 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7784 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
7785 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7786 if(ret2.find(*it2)==ret2.end())
7788 ret.push_back(*it2);
7795 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
7797 std::vector<std::string> ret;
7798 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7800 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
7801 ret.insert(ret.end(),tmp.begin(),tmp.end());
7806 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
7808 std::vector<std::string> ret;
7809 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7811 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
7812 ret.insert(ret.end(),tmp.begin(),tmp.end());
7817 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7819 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7820 (*it)->changePflsRefsNamesGen2(mapOfModif);
7823 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7825 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7826 (*it)->changeLocsRefsNamesGen2(mapOfModif);
7829 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
7831 int lgth=_time_steps.size();
7832 std::vector< std::vector<TypeOfField> > ret(lgth);
7833 for(int i=0;i<lgth;i++)
7834 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
7839 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
7841 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
7843 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
7846 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCopy() const
7848 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
7850 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7852 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
7853 ret->_time_steps[i]=(*it)->deepCopy();
7858 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
7860 std::size_t sz(_infos.size()),sz2(_time_steps.size());
7861 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7862 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7863 for(std::size_t i=0;i<sz;i++)
7865 ret[i]=shallowCpy();
7866 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7868 for(std::size_t i=0;i<sz2;i++)
7870 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7873 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7874 throw INTERP_KERNEL::Exception(oss.str());
7878 for(std::size_t i=0;i<sz;i++)
7879 for(std::size_t j=0;j<sz2;j++)
7880 ret[i]->_time_steps[j]=ts[j][i];
7885 * This method splits into discretization each time steps in \a this.
7886 * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
7888 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
7890 std::size_t sz(_time_steps.size());
7891 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7892 for(std::size_t i=0;i<sz;i++)
7894 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7897 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
7898 throw INTERP_KERNEL::Exception(oss.str());
7900 items[i]=timeStep->splitDiscretizations();
7903 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
7904 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
7905 std::vector< TypeOfField > types;
7906 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7907 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7909 std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
7911 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
7912 std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
7913 if(it2==types.end())
7914 types.push_back(ts[0]);
7916 ret.resize(types.size()); ret2.resize(types.size());
7917 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7918 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7920 TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
7921 std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
7922 ret2[pos].push_back(*it1);
7924 for(std::size_t i=0;i<types.size();i++)
7926 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7927 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
7928 elt->pushBackTimeStep(*it1);//also updates infos in elt
7930 elt->MEDFileFieldNameScope::operator=(*this);
7936 * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
7938 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
7940 std::size_t sz(_time_steps.size());
7941 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7942 std::size_t szOut(std::numeric_limits<std::size_t>::max());
7943 for(std::size_t i=0;i<sz;i++)
7945 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7948 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
7949 throw INTERP_KERNEL::Exception(oss.str());
7951 items[i]=timeStep->splitMultiDiscrPerGeoTypes();
7952 if(szOut==std::numeric_limits<std::size_t>::max())
7953 szOut=items[i].size();
7955 if(items[i].size()!=szOut)
7956 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
7958 if(szOut==std::numeric_limits<std::size_t>::max())
7959 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
7960 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
7961 for(std::size_t i=0;i<szOut;i++)
7963 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7964 for(std::size_t j=0;j<sz;j++)
7965 elt->pushBackTimeStep(items[j][i]);
7967 elt->MEDFileFieldNameScope::operator=(*this);
7972 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
7974 _name=field->getName();
7976 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
7978 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
7979 _infos=arr->getInfoOnComponents();
7982 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
7984 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
7985 if(_name!=field->getName())
7987 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
7988 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
7989 throw INTERP_KERNEL::Exception(oss.str());
7992 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
7993 checkThatComponentsMatch(arr->getInfoOnComponents());
7996 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
7998 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
7999 if(getInfo().size()!=compos.size())
8001 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
8002 oss << " number of components of element to append (" << compos.size() << ") !";
8003 throw INTERP_KERNEL::Exception(oss.str());
8007 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
8008 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
8009 oss << " But compo in input fields are : ";
8010 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
8012 throw INTERP_KERNEL::Exception(oss.str());
8016 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
8018 std::size_t sz=_infos.size();
8020 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
8022 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
8024 if(elt->getInfo().size()!=sz)
8026 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
8027 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
8028 throw INTERP_KERNEL::Exception(oss.str());
8033 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
8036 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8037 if(!_time_steps.empty())
8038 checkCoherencyOfTinyInfo(field,arr);
8039 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8040 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8041 objC->setFieldNoProfileSBT(field,arr,glob,*this);
8042 copyTinyInfoFrom(field,arr);
8043 _time_steps.push_back(obj);
8046 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
8049 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8050 if(!_time_steps.empty())
8051 checkCoherencyOfTinyInfo(field,arr);
8052 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8053 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8054 objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
8055 copyTinyInfoFrom(field,arr);
8056 _time_steps.push_back(obj);
8059 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ts)
8061 int sz=(int)_time_steps.size();
8064 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
8065 throw INTERP_KERNEL::Exception(oss.str());
8067 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
8070 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
8072 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
8073 throw INTERP_KERNEL::Exception(oss.str());
8079 //= MEDFileFieldMultiTSWithoutSDA
8081 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 MEDFileEntities *entities)
8083 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8086 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
8090 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8095 * \param [in] fieldId field id in C mode
8097 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8098 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8101 catch(INTERP_KERNEL::Exception& e)
8104 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 MEDFileEntities *entities)
8105 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8108 catch(INTERP_KERNEL::Exception& e)
8111 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8113 return new MEDFileField1TSWithoutSDA;
8116 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8119 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8120 const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
8122 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8125 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const
8127 return MEDFileField1TSWithoutSDA::TYPE_STR;
8130 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const
8132 return new MEDFileFieldMultiTSWithoutSDA(*this);
8135 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const
8137 return new MEDFileFieldMultiTSWithoutSDA;
8141 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
8142 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
8144 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
8146 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
8147 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8149 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
8150 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
8153 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
8155 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
8156 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8158 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8160 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8163 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
8165 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
8166 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
8167 ret->setIteration(i,elt);
8173 //= MEDFileAnyTypeFieldMultiTS
8175 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
8179 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8180 try:MEDFileFieldGlobsReal(fid)
8182 _content=BuildContentFrom(fid,loadAll,ms);
8185 catch(INTERP_KERNEL::Exception& e)
8190 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8192 med_field_type typcha;
8193 std::vector<std::string> infos;
8196 MEDFileAnyTypeField1TS::LocateField(fid,fieldName,i,typcha,infos,dtunit);
8197 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8202 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8207 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8212 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] !";
8213 throw INTERP_KERNEL::Exception(oss.str());
8216 ret->setDtUnit(dtunit.c_str());
8220 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8222 med_field_type typcha;
8224 std::vector<std::string> infos;
8225 std::string dtunit,fieldName;
8226 MEDFileAnyTypeField1TS::LocateField2(fid,0,true,fieldName,typcha,infos,dtunit);
8227 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8232 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8237 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8242 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] !";
8243 throw INTERP_KERNEL::Exception(oss.str());
8246 ret->setDtUnit(dtunit.c_str());
8250 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c)
8253 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
8254 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
8256 MCAuto<MEDFileFieldMultiTS> ret(MEDFileFieldMultiTS::New());
8257 ret->_content=c; c->incrRef();
8260 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
8262 MCAuto<MEDFileIntFieldMultiTS> ret(MEDFileIntFieldMultiTS::New());
8263 ret->_content=c; c->incrRef();
8266 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
8269 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, med_idt fid)
8271 MEDFileAnyTypeFieldMultiTS *ret(BuildNewInstanceFromContent(c));
8272 std::string fileName(FileNameFromFID(fid));
8273 ret->setFileName(fileName);
8277 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8278 try:MEDFileFieldGlobsReal(fid)
8280 _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
8283 catch(INTERP_KERNEL::Exception& e)
8288 //= MEDFileIntFieldMultiTSWithoutSDA
8290 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 MEDFileEntities *entities)
8292 return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8295 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
8299 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8303 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 MEDFileEntities *entities)
8304 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8307 catch(INTERP_KERNEL::Exception& e)
8311 * \param [in] fieldId field id in C mode
8313 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8314 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8317 catch(INTERP_KERNEL::Exception& e)
8320 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8322 return new MEDFileIntField1TSWithoutSDA;
8325 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8328 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8329 const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
8331 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8334 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const
8336 return MEDFileIntField1TSWithoutSDA::TYPE_STR;
8339 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const
8341 return new MEDFileIntFieldMultiTSWithoutSDA(*this);
8344 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const
8346 return new MEDFileIntFieldMultiTSWithoutSDA;
8349 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const
8351 MCAuto<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
8352 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8354 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8356 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8359 const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
8361 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
8362 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
8363 ret->setIteration(i,elt);
8369 //= MEDFileAnyTypeFieldMultiTS
8372 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
8373 * that has been read from a specified MED file.
8374 * \param [in] fileName - the name of the MED file to read.
8375 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8376 * is to delete this field using decrRef() as it is no more needed.
8377 * \throw If reading the file fails.
8379 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
8381 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8382 return New(fid,loadAll);
8385 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, bool loadAll)
8387 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
8388 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8389 ret->loadGlobals(fid);
8394 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
8395 * that has been read from a specified MED file.
8396 * \param [in] fileName - the name of the MED file to read.
8397 * \param [in] fieldName - the name of the field to read.
8398 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8399 * is to delete this field using decrRef() as it is no more needed.
8400 * \throw If reading the file fails.
8401 * \throw If there is no field named \a fieldName in the file.
8403 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8405 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8406 return New(fid,fieldName,loadAll);
8409 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
8411 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
8412 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8413 ret->loadGlobals(fid);
8418 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8419 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8421 * \warning this is a shallow copy constructor
8423 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8425 if(!shallowCopyOfContent)
8427 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
8428 otherPtr->incrRef();
8429 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
8433 _content=other.shallowCpy();
8437 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
8439 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8441 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
8445 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
8447 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8449 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
8453 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
8455 return contentNotNullBase()->getPflsReallyUsed2();
8458 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
8460 return contentNotNullBase()->getLocsReallyUsed2();
8463 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
8465 return contentNotNullBase()->getPflsReallyUsedMulti2();
8468 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
8470 return contentNotNullBase()->getLocsReallyUsedMulti2();
8473 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8475 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
8478 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8480 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
8483 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
8485 return contentNotNullBase()->getNumberOfTS();
8488 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
8490 contentNotNullBase()->eraseEmptyTS();
8493 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
8495 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
8498 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
8500 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
8503 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
8505 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
8506 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8511 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
8513 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
8514 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8519 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
8521 return contentNotNullBase()->getIterations();
8524 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
8526 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
8527 pushBackTimeStep(*it);
8530 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
8533 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
8534 int nbOfTS(fmts->getNumberOfTS());
8535 for(int i=0;i<nbOfTS;i++)
8537 MCAuto<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
8538 pushBackTimeStep(elt);
8542 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
8545 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
8546 checkCoherencyOfType(f1ts);
8548 MCAuto<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
8549 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
8551 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
8552 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
8553 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
8554 _content->pushBackTimeStep(cSafe);
8555 appendGlobs(*f1ts,1e-12);
8558 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
8560 contentNotNullBase()->synchronizeNameScope();
8563 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
8565 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
8568 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
8570 return contentNotNullBase()->getPosGivenTime(time,eps);
8573 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8575 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
8578 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
8580 return contentNotNullBase()->getTypesOfFieldAvailable();
8583 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
8585 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
8588 std::string MEDFileAnyTypeFieldMultiTS::getName() const
8590 return contentNotNullBase()->getName();
8593 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
8595 contentNotNullBase()->setName(name);
8598 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
8600 return contentNotNullBase()->getDtUnit();
8603 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
8605 contentNotNullBase()->setDtUnit(dtUnit);
8608 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8610 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
8613 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
8615 return contentNotNullBase()->getTimeSteps(ret1);
8618 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
8620 return contentNotNullBase()->getMeshName();
8623 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
8625 contentNotNullBase()->setMeshName(newMeshName);
8628 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
8630 return contentNotNullBase()->changeMeshNames(modifTab);
8633 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
8635 return contentNotNullBase()->getInfo();
8638 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
8640 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
8643 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
8645 return contentNotNullBase()->setInfo(info);
8648 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
8650 const std::vector<std::string> ret=getInfo();
8651 return (int)ret.size();
8654 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
8656 writeGlobals(fid,*this);
8657 contentNotNullBase()->writeLL(fid,*this);
8661 * This method alloc the arrays and load potentially huge arrays contained in this field.
8662 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
8663 * This method can be also called to refresh or reinit values from a file.
8665 * \throw If the fileName is not set or points to a non readable MED file.
8667 void MEDFileAnyTypeFieldMultiTS::loadArrays()
8669 if(getFileName().empty())
8670 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
8671 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
8672 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
8676 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
8677 * But once data loaded once, this method does nothing.
8679 * \throw If the fileName is not set or points to a non readable MED file.
8680 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
8682 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
8684 if(!getFileName().empty())
8686 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
8687 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
8692 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
8693 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
8694 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
8696 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
8698 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
8700 contentNotNullBase()->unloadArrays();
8704 * 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.
8705 * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
8706 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
8708 * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
8710 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
8712 if(!getFileName().empty())
8713 contentNotNullBase()->unloadArrays();
8716 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
8718 std::ostringstream oss;
8719 contentNotNullBase()->simpleRepr(0,oss,-1);
8720 simpleReprGlobs(oss);
8724 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
8726 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
8729 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
8731 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
8732 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
8737 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
8738 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8739 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
8741 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
8743 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8745 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
8746 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
8747 std::size_t sz(contentsSplit.size());
8748 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8749 for(std::size_t i=0;i<sz;i++)
8751 ret[i]=shallowCpy();
8752 ret[i]->_content=contentsSplit[i];
8758 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
8759 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8761 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
8763 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8765 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
8766 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
8767 std::size_t sz(contentsSplit.size());
8768 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8769 for(std::size_t i=0;i<sz;i++)
8771 ret[i]=shallowCpy();
8772 ret[i]->_content=contentsSplit[i];
8778 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
8779 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8781 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
8783 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8785 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
8786 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
8787 std::size_t sz(contentsSplit.size());
8788 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8789 for(std::size_t i=0;i<sz;i++)
8791 ret[i]=shallowCpy();
8792 ret[i]->_content=contentsSplit[i];
8797 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCopy() const
8799 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8800 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
8801 ret->_content=_content->deepCopy();
8802 ret->deepCpyGlobs(*this);
8806 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
8812 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8813 * \param [in] iteration - the iteration number of a required time step.
8814 * \param [in] order - the iteration order number of required time step.
8815 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
8816 * delete this field using decrRef() as it is no more needed.
8817 * \throw If there is no required time step in \a this field.
8819 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
8821 int pos=getPosOfTimeStep(iteration,order);
8822 return getTimeStepAtPos(pos);
8826 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8827 * \param [in] time - the time of the time step of interest.
8828 * \param [in] eps - a precision used to compare time values.
8829 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8830 * delete this field using decrRef() as it is no more needed.
8831 * \throw If there is no required time step in \a this field.
8833 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
8835 int pos=getPosGivenTime(time,eps);
8836 return getTimeStepAtPos(pos);
8840 * 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.
8841 * The float64 value of time attached to the pair of integers are not considered here.
8842 * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
8844 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
8845 * \throw If there is a null pointer in \a vectFMTS.
8847 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
8849 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
8850 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8851 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8852 while(!lstFMTS.empty())
8854 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8855 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8857 throw INTERP_KERNEL::Exception(msg);
8858 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
8859 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8860 elt.push_back(curIt); it=lstFMTS.erase(it);
8861 while(it!=lstFMTS.end())
8865 throw INTERP_KERNEL::Exception(msg);
8866 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
8868 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8878 * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
8879 * All returned instances in a subvector can be safely loaded, rendered along time
8880 * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
8881 * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
8882 * 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).
8883 * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
8884 * 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.
8886 * \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().
8887 * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
8888 * \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.
8889 * \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.
8891 * \throw If an element in \a vectFMTS has not only one spatial discretization set.
8892 * \throw If an element in \a vectFMTS change of spatial discretization along time.
8893 * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
8894 * \thorw If some elements in \a vectFMTS do not have the same times steps.
8895 * \throw If mesh is null.
8896 * \throw If an element in \a vectFMTS is null.
8897 * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
8899 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& fsc)
8901 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
8903 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
8904 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8905 if(vectFMTS.empty())
8907 std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
8908 MEDFileAnyTypeFieldMultiTS *frstElt(*it);
8910 throw INTERP_KERNEL::Exception(msg);
8912 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
8913 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
8914 for(;it!=vectFMTS.end();it++,i++)
8917 throw INTERP_KERNEL::Exception(msg);
8918 TypeOfField tof0,tof1;
8919 if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
8922 vectFMTSNotNodes.push_back(*it);
8924 vectFMTSNodes.push_back(*it);
8927 vectFMTSNotNodes.push_back(*it);
8929 std::vector< MCAuto<MEDFileFastCellSupportComparator> > cmps;
8930 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
8932 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
8935 bool isFetched(false);
8936 for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
8939 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
8940 if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
8941 { ret[i].push_back(*it2); isFetched=true; }
8945 std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
8946 MCAuto<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
8947 ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
8955 * 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.
8956 * \param [out] cmps - same size than the returned vector.
8958 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& cmps)
8960 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8961 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8962 while(!lstFMTS.empty())
8964 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8965 MEDFileAnyTypeFieldMultiTS *ref(*it);
8966 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8967 elt.push_back(ref); it=lstFMTS.erase(it);
8968 MCAuto<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
8969 MCAuto<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
8970 while(it!=lstFMTS.end())
8972 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8973 if(cmp->isEqual(curIt))
8974 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8978 ret.push_back(elt); cmps.push_back(cmp);
8984 * 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.
8985 * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
8987 * \throw If \a f0 or \a f1 has not only one spatial discretization set.
8988 * \throw If \a f0 or \a f1 change of spatial discretization along time.
8989 * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
8990 * \thorw If \a f0 and \a f1 do not have the same times steps.
8991 * \throw If mesh is null.
8992 * \throw If \a f0 or \a f1 is null.
8993 * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
8995 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
8998 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
9000 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
9001 if(f0->getMeshName()!=mesh->getName())
9003 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9004 throw INTERP_KERNEL::Exception(oss.str());
9006 if(f1->getMeshName()!=mesh->getName())
9008 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9009 throw INTERP_KERNEL::Exception(oss.str());
9011 int nts=f0->getNumberOfTS();
9012 if(nts!=f1->getNumberOfTS())
9013 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
9016 for(int i=0;i<nts;i++)
9018 MCAuto<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
9019 MCAuto<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
9020 std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
9021 if(tofs0.size()!=1 || tofs1.size()!=1)
9022 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
9025 if(tof0!=tofs0[0] || tof1!=tofs1[0])
9026 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
9029 { tof0=tofs0[0]; tof1=tofs1[0]; }
9030 if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
9032 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() << ") !";
9033 throw INTERP_KERNEL::Exception(oss.str());
9035 if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
9037 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() << ") !";
9038 throw INTERP_KERNEL::Exception(oss.str());
9040 if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
9042 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() << ") !";
9043 throw INTERP_KERNEL::Exception(oss.str());
9050 * Return an extraction of \a this using \a extractDef map to specify the extraction.
9051 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
9053 * \return A new object that the caller is responsible to deallocate.
9055 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
9058 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::extractPart : mesh is null !");
9059 MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(buildNewEmpty());
9060 int nbTS(getNumberOfTS());
9061 for(int i=0;i<nbTS;i++)
9063 MCAuto<MEDFileAnyTypeField1TS> f1ts(getTimeStepAtPos(i));
9064 MCAuto<MEDFileAnyTypeField1TS> f1tsOut(f1ts->extractPart(extractDef,mm));
9065 fmtsOut->pushBackTimeStep(f1tsOut);
9067 return fmtsOut.retn();
9071 MCAuto<MEDFileAnyTypeField1TS> AggregateHelperF1TS(const std::vector< typename MLFieldTraits<T>::F1TSType const *>& f1tss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9073 MCAuto< typename MLFieldTraits<T>::F1TSType > ret(MLFieldTraits<T>::F1TSType::New());
9075 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : empty vector !");
9076 std::size_t sz(f1tss.size()),i(0);
9077 std::vector< typename MLFieldTraits<T>::F1TSWSDAType const *> f1tsw(sz);
9078 for(typename std::vector< typename MLFieldTraits<T>::F1TSType const *>::const_iterator it=f1tss.begin();it!=f1tss.end();it++,i++)
9080 typename MLFieldTraits<T>::F1TSType const *elt(*it);
9082 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : presence of a null pointer !");
9083 f1tsw[i]=dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType const *>(elt->contentNotNullBase());
9085 typename MLFieldTraits<T>::F1TSWSDAType *retc(dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType *>(ret->contentNotNullBase()));
9087 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : internal error 1 !");
9088 retc->aggregate(f1tsw,dts);
9089 ret->setDtUnit(f1tss[0]->getDtUnit());
9090 return DynamicCast<typename MLFieldTraits<T>::F1TSType , MEDFileAnyTypeField1TS>(ret);
9094 MCAuto< MEDFileAnyTypeFieldMultiTS > AggregateHelperFMTS(const std::vector< typename MLFieldTraits<T>::FMTSType const *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9096 MCAuto< typename MLFieldTraits<T>::FMTSType > ret(MLFieldTraits<T>::FMTSType::New());
9098 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : empty vector !");
9099 std::size_t sz(fmtss.size());
9100 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9102 typename MLFieldTraits<T>::FMTSType const *elt(*it);
9104 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : presence of null pointer !");
9106 int nbTS(fmtss[0]->getNumberOfTS());
9107 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9108 if((*it)->getNumberOfTS()!=nbTS)
9109 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : all fields must have the same number of TS !");
9110 for(int iterTS=0;iterTS<nbTS;iterTS++)
9113 std::vector< typename MLFieldTraits<T>::F1TSType const *> f1tss(sz);
9114 std::vector< MCAuto<typename MLFieldTraits<T>::F1TSType> > f1tss2(sz);
9115 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++,i++)
9116 { f1tss2[i]=(*it)->getTimeStepAtPos(iterTS); f1tss[i]=f1tss2[i]; }
9117 MCAuto<MEDFileAnyTypeField1TS> f1ts(AggregateHelperF1TS<T>(f1tss,dts));
9118 ret->pushBackTimeStep(f1ts);
9119 ret->setDtUnit(f1ts->getDtUnit());
9121 return DynamicCast<typename MLFieldTraits<T>::FMTSType , MEDFileAnyTypeFieldMultiTS>(ret);
9125 * \a dts and \a ftmss are expected to have same size.
9127 MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileAnyTypeFieldMultiTS::Aggregate(const std::vector<const MEDFileAnyTypeFieldMultiTS *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9130 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : input vector is empty !");
9131 std::size_t sz(fmtss.size());
9132 std::vector<const MEDFileFieldMultiTS *> fmtss1;
9133 std::vector<const MEDFileIntFieldMultiTS *> fmtss2;
9134 for(std::vector<const MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9137 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : presence of null instance in input vector !");
9138 const MEDFileFieldMultiTS *elt1(dynamic_cast<const MEDFileFieldMultiTS *>(*it));
9141 fmtss1.push_back(elt1);
9144 const MEDFileIntFieldMultiTS *elt2(dynamic_cast<const MEDFileIntFieldMultiTS *>(*it));
9147 fmtss2.push_back(elt2);
9150 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not recognized type !");
9152 if(fmtss1.size()!=sz && fmtss2.size()!=sz)
9153 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : type of data is not homogeneous !");
9154 if(fmtss1.size()==sz)
9155 return AggregateHelperFMTS<double>(fmtss1,dts);
9156 if(fmtss2.size()!=sz)
9157 return AggregateHelperFMTS<int>(fmtss2,dts);
9158 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not implemented yet !");
9161 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
9163 return new MEDFileAnyTypeFieldMultiTSIterator(this);
9166 //= MEDFileFieldMultiTS
9169 * Returns a new empty instance of MEDFileFieldMultiTS.
9170 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9171 * is to delete this field using decrRef() as it is no more needed.
9173 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
9175 return new MEDFileFieldMultiTS;
9179 * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
9180 * that has been read from a specified MED file.
9181 * \param [in] fileName - the name of the MED file to read.
9182 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9183 * is to delete this field using decrRef() as it is no more needed.
9184 * \throw If reading the file fails.
9186 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll)
9188 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9189 return New(fid,loadAll);
9192 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, bool loadAll)
9194 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,loadAll,0));
9195 ret->contentNotNull();//to check that content type matches with \a this type.
9200 * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
9201 * that has been read from a specified MED file.
9202 * \param [in] fileName - the name of the MED file to read.
9203 * \param [in] fieldName - the name of the field to read.
9204 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9205 * is to delete this field using decrRef() as it is no more needed.
9206 * \throw If reading the file fails.
9207 * \throw If there is no field named \a fieldName in the file.
9209 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9211 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9212 return New(fid,fieldName,loadAll);
9215 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
9217 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0));
9218 ret->contentNotNull();//to check that content type matches with \a this type.
9223 * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9224 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9226 * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
9227 * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9228 * \warning this is a shallow copy constructor
9229 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
9230 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9231 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9232 * is to delete this field using decrRef() as it is no more needed.
9234 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9236 return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
9239 MEDFileFieldMultiTS *MEDFileFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9241 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9242 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
9243 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0,ent));
9244 ret->contentNotNull();//to check that content type matches with \a this type.
9248 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
9250 return new MEDFileFieldMultiTS(*this);
9253 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9256 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9257 const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
9259 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
9263 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
9264 * following the given input policy.
9266 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9267 * By default (true) the globals are deeply copied.
9268 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
9270 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
9272 MCAuto<MEDFileIntFieldMultiTS> ret;
9273 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9276 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
9278 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
9279 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
9280 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc));
9283 ret=MEDFileIntFieldMultiTS::New();
9285 ret->deepCpyGlobs(*this);
9287 ret->shallowCpyGlobs(*this);
9292 * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
9293 * \param [in] pos - a time step id.
9294 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9295 * delete this field using decrRef() as it is no more needed.
9296 * \throw If \a pos is not a valid time step id.
9298 MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const
9300 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9303 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9304 throw INTERP_KERNEL::Exception(oss.str());
9306 const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
9309 MCAuto<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
9310 ret->shallowCpyGlobs(*this);
9313 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
9314 throw INTERP_KERNEL::Exception(oss.str());
9318 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9319 * mesh entities of a given dimension of the first mesh in MED file.
9320 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9321 * \param [in] type - a spatial discretization of interest.
9322 * \param [in] iteration - the iteration number of a required time step.
9323 * \param [in] order - the iteration order number of required time step.
9324 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9325 * \param [in] renumPol - specifies how to permute values of the result field according to
9326 * the optional numbers of cells and nodes, if any. The valid values are
9327 * - 0 - do not permute.
9328 * - 1 - permute cells.
9329 * - 2 - permute nodes.
9330 * - 3 - permute cells and nodes.
9332 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9333 * caller is to delete this field using decrRef() as it is no more needed.
9334 * \throw If the MED file is not readable.
9335 * \throw If there is no mesh in the MED file.
9336 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9337 * \throw If no field values of the required parameters are available.
9339 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9341 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9342 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9344 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
9345 MCAuto<DataArray> arrOut;
9346 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9347 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9352 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9353 * the top level cells of the first mesh in MED file.
9354 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9355 * \param [in] type - a spatial discretization of interest.
9356 * \param [in] iteration - the iteration number of a required time step.
9357 * \param [in] order - the iteration order number of required time step.
9358 * \param [in] renumPol - specifies how to permute values of the result field according to
9359 * the optional numbers of cells and nodes, if any. The valid values are
9360 * - 0 - do not permute.
9361 * - 1 - permute cells.
9362 * - 2 - permute nodes.
9363 * - 3 - permute cells and nodes.
9365 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9366 * caller is to delete this field using decrRef() as it is no more needed.
9367 * \throw If the MED file is not readable.
9368 * \throw If there is no mesh in the MED file.
9369 * \throw If no field values of the required parameters are available.
9371 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9373 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9374 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9376 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
9377 MCAuto<DataArray> arrOut;
9378 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9379 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9384 * 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
9385 * method should be called (getFieldOnMeshAtLevel for example).
9386 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
9388 * \param [in] iteration - the iteration number of a required time step.
9389 * \param [in] order - the iteration order number of required time step.
9390 * \param [in] mesh - the mesh the field is lying on
9391 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9392 * caller is to delete this field using decrRef() as it is no more needed.
9394 MEDCouplingFieldDouble *MEDFileFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
9396 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9397 MCAuto<DataArray> arrOut;
9398 MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
9399 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9404 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9406 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9407 * \param [in] type - a spatial discretization of interest.
9408 * \param [in] iteration - the iteration number of a required time step.
9409 * \param [in] order - the iteration order number of required time step.
9410 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9411 * \param [in] mesh - the supporting mesh.
9412 * \param [in] renumPol - specifies how to permute values of the result field according to
9413 * the optional numbers of cells and nodes, if any. The valid values are
9414 * - 0 - do not permute.
9415 * - 1 - permute cells.
9416 * - 2 - permute nodes.
9417 * - 3 - permute cells and nodes.
9419 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9420 * caller is to delete this field using decrRef() as it is no more needed.
9421 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9422 * \throw If no field of \a this is lying on \a mesh.
9423 * \throw If no field values of the required parameters are available.
9425 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9427 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9428 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9430 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9431 MCAuto<DataArray> arrOut;
9432 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
9433 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9438 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9440 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9441 * \param [in] type - a spatial discretization of the new field.
9442 * \param [in] iteration - the iteration number of a required time step.
9443 * \param [in] order - the iteration order number of required time step.
9444 * \param [in] mesh - the supporting mesh.
9445 * \param [in] renumPol - specifies how to permute values of the result field according to
9446 * the optional numbers of cells and nodes, if any. The valid values are
9447 * - 0 - do not permute.
9448 * - 1 - permute cells.
9449 * - 2 - permute nodes.
9450 * - 3 - permute cells and nodes.
9452 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9453 * caller is to delete this field using decrRef() as it is no more needed.
9454 * \throw If no field of \a this is lying on \a mesh.
9455 * \throw If no field values of the required parameters are available.
9457 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
9459 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9460 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9462 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9463 MCAuto<DataArray> arrOut;
9464 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
9465 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9470 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
9471 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9472 * This method is useful for MED2 file format when field on different mesh was autorized.
9474 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
9476 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9477 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9479 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
9480 MCAuto<DataArray> arrOut;
9481 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
9482 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9487 * Returns values and a profile of the field of a given type, of a given time step,
9488 * lying on a given support.
9489 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9490 * \param [in] type - a spatial discretization of the field.
9491 * \param [in] iteration - the iteration number of a required time step.
9492 * \param [in] order - the iteration order number of required time step.
9493 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9494 * \param [in] mesh - the supporting mesh.
9495 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9496 * field of interest lies on. If the field lies on all entities of the given
9497 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9498 * using decrRef() as it is no more needed.
9499 * \param [in] glob - the global data storing profiles and localization.
9500 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
9501 * field. The caller is to delete this array using decrRef() as it is no more needed.
9502 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9503 * \throw If no field of \a this is lying on \a mesh.
9504 * \throw If no field values of the required parameters are available.
9506 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9508 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9509 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9511 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
9512 MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9513 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
9516 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const
9518 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9520 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
9521 const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
9523 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 !");
9527 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull()
9529 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9531 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
9532 MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
9534 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 !");
9539 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9540 * the given field is checked if its elements are sorted suitable for writing to MED file
9541 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9542 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9543 * \param [in] field - the field to add to \a this.
9544 * \throw If the name of \a field is empty.
9545 * \throw If the data array of \a field is not set.
9546 * \throw If existing time steps have different name or number of components than \a field.
9547 * \throw If the underlying mesh of \a field has no name.
9548 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9550 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
9552 const DataArrayDouble *arr=0;
9554 arr=field->getArray();
9555 contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
9559 * Adds a MEDCouplingFieldDouble to \a this as another time step.
9560 * The mesh support of input parameter \a field is ignored here, it can be NULL.
9561 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9564 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9565 * A new profile is added only if no equal profile is missing.
9566 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9567 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
9568 * \param [in] mesh - the supporting mesh of \a field.
9569 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9570 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
9571 * \throw If either \a field or \a mesh or \a profile has an empty name.
9572 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9573 * \throw If the data array of \a field is not set.
9574 * \throw If the data array of \a this is already allocated but has different number of
9575 * components than \a field.
9576 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9577 * \sa setFieldNoProfileSBT()
9579 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9581 const DataArrayDouble *arr=0;
9583 arr=field->getArray();
9584 contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
9587 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
9589 _content=new MEDFileFieldMultiTSWithoutSDA;
9592 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
9593 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
9596 catch(INTERP_KERNEL::Exception& e)
9599 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
9600 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
9603 catch(INTERP_KERNEL::Exception& e)
9606 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9610 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
9612 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
9615 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9617 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9620 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
9622 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
9625 MEDFileFieldMultiTS *MEDFileFieldMultiTS::buildNewEmpty() const
9627 return MEDFileFieldMultiTS::New();
9630 //= MEDFileAnyTypeFieldMultiTSIterator
9632 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
9637 _nb_iter=fmts->getNumberOfTS();
9641 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
9645 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
9647 if(_iter_id<_nb_iter)
9649 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
9651 return fmts->getTimeStepAtPos(_iter_id++);
9659 //= MEDFileIntFieldMultiTS
9662 * Returns a new empty instance of MEDFileFieldMultiTS.
9663 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9664 * is to delete this field using decrRef() as it is no more needed.
9666 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
9668 return new MEDFileIntFieldMultiTS;
9672 * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
9673 * that has been read from a specified MED file.
9674 * \param [in] fileName - the name of the MED file to read.
9675 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9676 * is to delete this field using decrRef() as it is no more needed.
9677 * \throw If reading the file fails.
9679 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll)
9681 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9682 return New(fid,loadAll);
9685 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, bool loadAll)
9687 MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,loadAll,0));
9688 ret->contentNotNull();//to check that content type matches with \a this type.
9693 * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
9694 * that has been read from a specified MED file.
9695 * \param [in] fileName - the name of the MED file to read.
9696 * \param [in] fieldName - the name of the field to read.
9697 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9698 * is to delete this field using decrRef() as it is no more needed.
9699 * \throw If reading the file fails.
9700 * \throw If there is no field named \a fieldName in the file.
9702 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9704 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9705 return New(fid,fieldName,loadAll);
9708 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
9710 MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0));
9711 ret->contentNotNull();//to check that content type matches with \a this type.
9716 * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9717 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9719 * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
9720 * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9721 * \warning this is a shallow copy constructor
9722 * \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
9723 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9724 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9725 * is to delete this field using decrRef() as it is no more needed.
9727 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9729 return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
9732 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9734 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9735 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
9736 MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0,ent));
9737 ret->contentNotNull();//to check that content type matches with \a this type.
9742 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
9743 * following the given input policy.
9745 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9746 * By default (true) the globals are deeply copied.
9747 * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
9749 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const
9751 MCAuto<MEDFileFieldMultiTS> ret;
9752 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9755 const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
9757 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
9758 MCAuto<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
9759 ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc));
9762 ret=MEDFileFieldMultiTS::New();
9764 ret->deepCpyGlobs(*this);
9766 ret->shallowCpyGlobs(*this);
9770 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const
9772 return new MEDFileIntFieldMultiTS(*this);
9775 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9778 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9779 const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
9781 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
9785 * 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
9786 * method should be called (getFieldOnMeshAtLevel for example).
9787 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
9789 * \param [in] iteration - the iteration number of a required time step.
9790 * \param [in] order - the iteration order number of required time step.
9791 * \param [in] mesh - the mesh the field is lying on
9792 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
9793 * caller is to delete this field using decrRef() as it is no more needed.
9795 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
9797 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9798 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9800 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::field : mismatch of type of field expecting INT32 !");
9801 MCAuto<DataArray> arrOut;
9802 MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
9803 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arrOut));
9808 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
9809 * mesh entities of a given dimension of the first mesh in MED file.
9810 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9811 * \param [in] type - a spatial discretization of interest.
9812 * \param [in] iteration - the iteration number of a required time step.
9813 * \param [in] order - the iteration order number of required time step.
9814 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9815 * \param [in] renumPol - specifies how to permute values of the result field according to
9816 * the optional numbers of cells and nodes, if any. The valid values are
9817 * - 0 - do not permute.
9818 * - 1 - permute cells.
9819 * - 2 - permute nodes.
9820 * - 3 - permute cells and nodes.
9822 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9823 * caller is to delete this field using decrRef() as it is no more needed.
9824 * \throw If the MED file is not readable.
9825 * \throw If there is no mesh in the MED file.
9826 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9827 * \throw If no field values of the required parameters are available.
9829 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9831 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9832 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9834 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
9835 MCAuto<DataArray> arr;
9836 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase()));
9837 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9842 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
9843 * the top level cells of the first mesh in MED file.
9844 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9845 * \param [in] type - a spatial discretization of interest.
9846 * \param [in] iteration - the iteration number of a required time step.
9847 * \param [in] order - the iteration order number of required time step.
9848 * \param [in] renumPol - specifies how to permute values of the result field according to
9849 * the optional numbers of cells and nodes, if any. The valid values are
9850 * - 0 - do not permute.
9851 * - 1 - permute cells.
9852 * - 2 - permute nodes.
9853 * - 3 - permute cells and nodes.
9855 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9856 * caller is to delete this field using decrRef() as it is no more needed.
9857 * \throw If the MED file is not readable.
9858 * \throw If there is no mesh in the MED file.
9859 * \throw If no field values of the required parameters are available.
9861 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9863 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9864 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9866 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
9867 MCAuto<DataArray> arr;
9868 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase()));
9869 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9874 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
9876 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9877 * \param [in] type - a spatial discretization of interest.
9878 * \param [in] iteration - the iteration number of a required time step.
9879 * \param [in] order - the iteration order number of required time step.
9880 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9881 * \param [in] mesh - the supporting mesh.
9882 * \param [in] renumPol - specifies how to permute values of the result field according to
9883 * the optional numbers of cells and nodes, if any. The valid values are
9884 * - 0 - do not permute.
9885 * - 1 - permute cells.
9886 * - 2 - permute nodes.
9887 * - 3 - permute cells and nodes.
9889 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9890 * caller is to delete this field using decrRef() as it is no more needed.
9891 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9892 * \throw If no field of \a this is lying on \a mesh.
9893 * \throw If no field values of the required parameters are available.
9895 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9897 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9898 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9900 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9901 MCAuto<DataArray> arr;
9902 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase()));
9903 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9908 * Returns a new MEDCouplingFieldInt of given type, of a given time step, lying on a
9910 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9911 * \param [in] type - a spatial discretization of the new field.
9912 * \param [in] iteration - the iteration number of a required time step.
9913 * \param [in] order - the iteration order number of required time step.
9914 * \param [in] mesh - the supporting mesh.
9915 * \param [out] arrOut - the DataArrayInt containing values of field.
9916 * \param [in] renumPol - specifies how to permute values of the result field according to
9917 * the optional numbers of cells and nodes, if any. The valid values are
9918 * - 0 - do not permute.
9919 * - 1 - permute cells.
9920 * - 2 - permute nodes.
9921 * - 3 - permute cells and nodes.
9923 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9924 * caller is to delete this field using decrRef() as it is no more needed.
9925 * \throw If no field of \a this is lying on \a mesh.
9926 * \throw If no field values of the required parameters are available.
9928 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
9930 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9931 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9933 throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9934 MCAuto<DataArray> arr;
9935 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase()));
9936 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9941 * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
9942 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9943 * This method is useful for MED2 file format when field on different mesh was autorized.
9945 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol) const
9947 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9948 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9950 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9951 MCAuto<DataArray> arr;
9952 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase()));
9953 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9958 * Returns values and a profile of the field of a given type, of a given time step,
9959 * lying on a given support.
9960 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9961 * \param [in] type - a spatial discretization of the field.
9962 * \param [in] iteration - the iteration number of a required time step.
9963 * \param [in] order - the iteration order number of required time step.
9964 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9965 * \param [in] mesh - the supporting mesh.
9966 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9967 * field of interest lies on. If the field lies on all entities of the given
9968 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9969 * using decrRef() as it is no more needed.
9970 * \param [in] glob - the global data storing profiles and localization.
9971 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
9972 * field. The caller is to delete this array using decrRef() as it is no more needed.
9973 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9974 * \throw If no field of \a this is lying on \a mesh.
9975 * \throw If no field values of the required parameters are available.
9977 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9979 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9980 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9982 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
9983 MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9984 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
9988 * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
9989 * \param [in] pos - a time step id.
9990 * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
9991 * delete this field using decrRef() as it is no more needed.
9992 * \throw If \a pos is not a valid time step id.
9994 MEDFileIntField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
9996 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9999 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
10000 throw INTERP_KERNEL::Exception(oss.str());
10002 const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
10005 MCAuto<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
10006 ret->shallowCpyGlobs(*this);
10009 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
10010 throw INTERP_KERNEL::Exception(oss.str());
10014 * Adds a MEDCouplingFieldInt to \a this as another time step. The underlying mesh of
10015 * the given field is checked if its elements are sorted suitable for writing to MED file
10016 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
10017 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10018 * \param [in] field - the field to add to \a this.
10019 * \throw If the name of \a field is empty.
10020 * \throw If the data array of \a field is not set.
10021 * \throw If existing time steps have different name or number of components than \a field.
10022 * \throw If the underlying mesh of \a field has no name.
10023 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
10025 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldInt *field)
10027 MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
10028 contentNotNull()->appendFieldNoProfileSBT(field2,field->getArray(),*this);
10032 * Adds a MEDCouplingFieldDouble to \a this as another time step.
10033 * The mesh support of input parameter \a field is ignored here, it can be NULL.
10034 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
10037 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
10038 * A new profile is added only if no equal profile is missing.
10039 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10040 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
10041 * \param [in] arrOfVals - the values of the field \a field used.
10042 * \param [in] mesh - the supporting mesh of \a field.
10043 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
10044 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
10045 * \throw If either \a field or \a mesh or \a profile has an empty name.
10046 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10047 * \throw If the data array of \a field is not set.
10048 * \throw If the data array of \a this is already allocated but has different number of
10049 * components than \a field.
10050 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
10051 * \sa setFieldNoProfileSBT()
10053 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
10055 MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
10056 contentNotNull()->appendFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this);
10059 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const
10061 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10063 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
10064 const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10066 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 !");
10070 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull()
10072 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10074 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
10075 MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10077 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 !");
10081 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
10083 _content=new MEDFileIntFieldMultiTSWithoutSDA;
10086 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
10090 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
10091 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
10094 catch(INTERP_KERNEL::Exception& e)
10097 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10098 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
10101 catch(INTERP_KERNEL::Exception& e)
10104 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
10106 return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
10109 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::buildNewEmpty() const
10111 return MEDFileIntFieldMultiTS::New();
10116 MEDFileFields *MEDFileFields::New()
10118 return new MEDFileFields;
10121 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
10123 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10124 return New(fid,loadAll);
10127 MEDFileFields *MEDFileFields::NewWithDynGT(const std::string& fileName, const MEDFileStructureElements *se, bool loadAll)
10129 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10131 throw INTERP_KERNEL::Exception("MEDFileFields::NewWithDynGT : null struct element pointer !");
10132 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> entities(MEDFileEntities::BuildFrom(*se));
10133 return new MEDFileFields(fid,loadAll,0,entities);
10136 MEDFileFields *MEDFileFields::New(med_idt fid, bool loadAll)
10138 return new MEDFileFields(fid,loadAll,0,0);
10141 MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
10143 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10144 return new MEDFileFields(fid,loadAll,ms,0);
10147 MEDFileFields *MEDFileFields::LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
10149 MEDFileUtilities::CheckFileForRead(fileName);
10150 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
10151 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10152 return new MEDFileFields(fid,loadAll,0,ent);
10155 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
10157 std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
10158 ret+=_fields.capacity()*sizeof(MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
10162 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
10164 std::vector<const BigMemoryObject *> ret;
10165 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10166 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
10170 MEDFileFields *MEDFileFields::deepCopy() const
10172 MCAuto<MEDFileFields> ret(shallowCpy());
10174 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10176 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10177 ret->_fields[i]=(*it)->deepCopy();
10179 ret->deepCpyGlobs(*this);
10183 MEDFileFields *MEDFileFields::shallowCpy() const
10185 return new MEDFileFields(*this);
10189 * 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
10190 * 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.
10191 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
10193 * \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.
10194 * \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.
10196 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10198 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
10200 std::set< std::pair<int,int> > s;
10201 bool firstShot=true;
10202 areThereSomeForgottenTS=false;
10203 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10205 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10207 std::vector< std::pair<int,int> > v=(*it)->getIterations();
10208 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
10210 { s=s1; firstShot=false; }
10213 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
10215 areThereSomeForgottenTS=true;
10219 std::vector< std::pair<int,int> > ret;
10220 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
10224 int MEDFileFields::getNumberOfFields() const
10226 return _fields.size();
10229 std::vector<std::string> MEDFileFields::getFieldsNames() const
10231 std::vector<std::string> ret(_fields.size());
10233 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10235 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
10238 ret[i]=f->getName();
10242 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
10243 throw INTERP_KERNEL::Exception(oss.str());
10249 std::vector<std::string> MEDFileFields::getMeshesNames() const
10251 std::vector<std::string> ret;
10252 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10254 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10256 ret.push_back(cur->getMeshName());
10261 std::string MEDFileFields::simpleRepr() const
10263 std::ostringstream oss;
10264 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
10269 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
10271 int nbOfFields(getNumberOfFields());
10272 std::string startLine(bkOffset,' ');
10273 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
10275 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10277 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10280 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
10284 oss << startLine << " - not defined !" << std::endl;
10288 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10290 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10291 std::string chapter(17,'0'+i);
10292 oss << startLine << chapter << std::endl;
10295 cur->simpleRepr(bkOffset+2,oss,i);
10299 oss << startLine << " - not defined !" << std::endl;
10301 oss << startLine << chapter << std::endl;
10303 simpleReprGlobs(oss);
10306 MEDFileFields::MEDFileFields()
10310 MEDFileFields::MEDFileFields(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10311 try:MEDFileFieldGlobsReal(fid)
10313 int nbFields(MEDnField(fid));
10314 _fields.resize(nbFields);
10315 med_field_type typcha;
10316 for(int i=0;i<nbFields;i++)
10318 std::vector<std::string> infos;
10319 std::string fieldName,dtunit;
10320 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,i,false,fieldName,typcha,infos,dtunit));
10325 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10330 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10335 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] !";
10336 throw INTERP_KERNEL::Exception(oss.str());
10340 loadAllGlobals(fid);
10342 catch(INTERP_KERNEL::Exception& e)
10347 void MEDFileFields::writeLL(med_idt fid) const
10350 writeGlobals(fid,*this);
10351 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10353 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
10356 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
10357 throw INTERP_KERNEL::Exception(oss.str());
10359 elt->writeLL(fid,*this);
10364 * This method alloc the arrays and load potentially huge arrays contained in this field.
10365 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
10366 * This method can be also called to refresh or reinit values from a file.
10368 * \throw If the fileName is not set or points to a non readable MED file.
10370 void MEDFileFields::loadArrays()
10372 if(getFileName().empty())
10373 throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
10374 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
10375 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10377 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10379 elt->loadBigArraysRecursively(fid,*elt);
10384 * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
10385 * But once data loaded once, this method does nothing.
10387 * \throw If the fileName is not set or points to a non readable MED file.
10388 * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
10390 void MEDFileFields::loadArraysIfNecessary()
10392 if(!getFileName().empty())
10394 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
10395 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10397 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10399 elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
10405 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
10406 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
10407 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
10409 * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
10411 void MEDFileFields::unloadArrays()
10413 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10415 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10417 elt->unloadArrays();
10422 * 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.
10423 * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
10424 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
10426 * \sa MEDFileFields::loadArraysIfNecessary
10428 void MEDFileFields::unloadArraysWithoutDataLoss()
10430 if(!getFileName().empty())
10434 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
10436 std::vector<std::string> ret;
10437 std::set<std::string> ret2;
10438 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10440 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
10441 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10442 if(ret2.find(*it2)==ret2.end())
10444 ret.push_back(*it2);
10451 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
10453 std::vector<std::string> ret;
10454 std::set<std::string> ret2;
10455 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10457 std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
10458 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10459 if(ret2.find(*it2)==ret2.end())
10461 ret.push_back(*it2);
10468 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
10470 std::vector<std::string> ret;
10471 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10473 std::vector<std::string> tmp((*it)->getPflsReallyUsedMulti2());
10474 ret.insert(ret.end(),tmp.begin(),tmp.end());
10479 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
10481 std::vector<std::string> ret;
10482 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10484 std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
10485 ret.insert(ret.end(),tmp.begin(),tmp.end());
10490 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10492 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10493 (*it)->changePflsRefsNamesGen2(mapOfModif);
10496 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10498 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10499 (*it)->changeLocsRefsNamesGen2(mapOfModif);
10502 void MEDFileFields::resize(int newSize)
10504 _fields.resize(newSize);
10507 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
10509 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
10513 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
10516 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
10517 _fields.push_back(field->getContent());
10518 appendGlobs(*field,1e-12);
10521 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
10524 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
10525 if(i>=(int)_fields.size())
10526 _fields.resize(i+1);
10527 _fields[i]=field->getContent();
10528 appendGlobs(*field,1e-12);
10531 void MEDFileFields::destroyFieldAtPos(int i)
10533 destroyFieldsAtPos(&i,&i+1);
10536 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
10538 std::vector<bool> b(_fields.size(),true);
10539 for(const int *i=startIds;i!=endIds;i++)
10541 if(*i<0 || *i>=(int)_fields.size())
10543 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10544 throw INTERP_KERNEL::Exception(oss.str());
10548 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10550 for(std::size_t i=0;i<_fields.size();i++)
10552 fields[j++]=_fields[i];
10556 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
10558 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
10559 int nbOfEntriesToKill(DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg));
10560 std::vector<bool> b(_fields.size(),true);
10562 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
10564 if(k<0 || k>=(int)_fields.size())
10566 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
10567 throw INTERP_KERNEL::Exception(oss.str());
10571 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10573 for(std::size_t i=0;i<_fields.size();i++)
10575 fields[j++]=_fields[i];
10579 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
10582 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10584 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10586 ret=cur->changeMeshNames(modifTab) || ret;
10592 * \param [in] meshName the name of the mesh that will be renumbered.
10593 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
10594 * This code corresponds to the distribution of types in the corresponding mesh.
10595 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
10596 * \param [in] renumO2N the old to new renumber array.
10597 * \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
10598 * field in \a this.
10600 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
10603 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10605 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
10608 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
10615 * Return an extraction of \a this using \a extractDef map to specify the extraction.
10616 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
10618 * \return A new object that the caller is responsible to deallocate.
10620 MEDFileFields *MEDFileFields::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
10623 throw INTERP_KERNEL::Exception("MEDFileFields::extractPart : input mesh is NULL !");
10624 MCAuto<MEDFileFields> fsOut(MEDFileFields::New());
10625 int nbFields(getNumberOfFields());
10626 for(int i=0;i<nbFields;i++)
10628 MCAuto<MEDFileAnyTypeFieldMultiTS> fmts(getFieldAtPos(i));
10631 std::ostringstream oss; oss << "MEDFileFields::extractPart : at pos #" << i << " field is null !";
10632 throw INTERP_KERNEL::Exception(oss.str());
10634 MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(fmts->extractPart(extractDef,mm));
10635 fsOut->pushField(fmtsOut);
10637 return fsOut.retn();
10640 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
10642 if(i<0 || i>=(int)_fields.size())
10644 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
10645 throw INTERP_KERNEL::Exception(oss.str());
10647 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
10650 MCAuto<MEDFileAnyTypeFieldMultiTS> ret;
10651 const MEDFileFieldMultiTSWithoutSDA *fmtsC(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts));
10652 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts));
10654 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
10656 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
10659 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
10660 throw INTERP_KERNEL::Exception(oss.str());
10662 ret->shallowCpyGlobs(*this);
10667 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
10668 * This method is accessible in python using __getitem__ with a list in input.
10669 * \return a new object that the caller should deal with.
10671 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
10673 MCAuto<MEDFileFields> ret=shallowCpy();
10674 std::size_t sz=std::distance(startIds,endIds);
10675 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
10677 for(const int *i=startIds;i!=endIds;i++,j++)
10679 if(*i<0 || *i>=(int)_fields.size())
10681 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10682 throw INTERP_KERNEL::Exception(oss.str());
10684 fields[j]=_fields[*i];
10686 ret->_fields=fields;
10690 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
10692 return getFieldAtPos(getPosFromFieldName(fieldName));
10696 * This method removes, if any, fields in \a this having no time steps.
10697 * 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.
10699 * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
10701 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
10703 std::vector<MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
10704 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10706 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10709 if(elt->getNumberOfTS()>0)
10710 newFields.push_back(*it);
10713 if(_fields.size()==newFields.size())
10720 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
10721 * This method can be seen as a filter applied on \a this, that returns an object containing
10722 * 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
10723 * shallow copied from \a this.
10725 * \param [in] meshName - the name of the mesh on w
10726 * \return a new object that the caller should deal with.
10728 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
10730 MCAuto<MEDFileFields> ret(MEDFileFields::New());
10731 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10733 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10736 if(cur->getMeshName()==meshName)
10739 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
10740 ret->_fields.push_back(cur2);
10743 ret->shallowCpyOnlyUsedGlobs(*this);
10748 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
10749 * Input time steps are specified using a pair of integer (iteration, order).
10750 * 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,
10751 * but for each multitimestep only the time steps in \a timeSteps are kept.
10752 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
10754 * The returned object points to shallow copy of elements in \a this.
10756 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
10757 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
10758 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10760 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10762 MCAuto<MEDFileFields> ret(MEDFileFields::New());
10763 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10765 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10768 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
10769 ret->_fields.push_back(elt);
10771 ret->shallowCpyOnlyUsedGlobs(*this);
10776 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
10778 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10780 MCAuto<MEDFileFields> ret=MEDFileFields::New();
10781 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10783 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10786 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
10787 if(elt->getNumberOfTS()!=0)
10788 ret->_fields.push_back(elt);
10790 ret->shallowCpyOnlyUsedGlobs(*this);
10794 MEDFileFieldsIterator *MEDFileFields::iterator()
10796 return new MEDFileFieldsIterator(this);
10799 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
10801 std::string tmp(fieldName);
10802 std::vector<std::string> poss;
10803 for(std::size_t i=0;i<_fields.size();i++)
10805 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f(_fields[i]);
10808 std::string fname(f->getName());
10812 poss.push_back(fname);
10815 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
10816 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
10818 throw INTERP_KERNEL::Exception(oss.str());
10821 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
10826 _nb_iter=fs->getNumberOfFields();
10830 MEDFileFieldsIterator::~MEDFileFieldsIterator()
10834 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
10836 if(_iter_id<_nb_iter)
10838 MEDFileFields *fs(_fs);
10840 return fs->getFieldAtPos(_iter_id++);