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 (EDF R&D)
21 #include "MEDFileField.txx"
22 #include "MEDFileMesh.hxx"
23 #include "MEDLoaderBase.hxx"
24 #include "MEDLoaderTraits.hxx"
25 #include "MEDFileSafeCaller.txx"
26 #include "MEDFileFieldOverView.hxx"
27 #include "MEDFileBlowStrEltUp.hxx"
28 #include "MEDFileFieldVisitor.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 MEDCoupling::MEDFileField1TSTemplateWithoutSDA<int>;
46 template class MEDCoupling::MEDFileField1TSTemplateWithoutSDA<float>;
47 template class MEDCoupling::MEDFileField1TSTemplateWithoutSDA<double>;
48 template class MEDCoupling::MEDFileField1TSNDTemplateWithoutSDA<int>;
49 template class MEDCoupling::MEDFileField1TSNDTemplateWithoutSDA<float>;
50 template class MEDCoupling::MEDFileNDTemplateFieldMultiTSWithoutSDA<int>;
51 template class MEDCoupling::MEDFileNDTemplateFieldMultiTSWithoutSDA<float>;
52 template class MEDCoupling::MEDFileTemplateField1TS<int>;
53 template class MEDCoupling::MEDFileTemplateField1TS<float>;
54 template class MEDCoupling::MEDFileTemplateField1TS<double>;
55 template class MEDCoupling::MEDFileNDTemplateField1TS<int>;
56 template class MEDCoupling::MEDFileNDTemplateField1TS<float>;
57 template class MEDCoupling::MEDFileTemplateFieldMultiTS<int>;
58 template class MEDCoupling::MEDFileTemplateFieldMultiTS<float>;
59 template class MEDCoupling::MEDFileTemplateFieldMultiTS<double>;
60 template class MEDCoupling::MEDFileNDTemplateFieldMultiTS<int>;
61 template class MEDCoupling::MEDFileNDTemplateFieldMultiTS<float>;
63 const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64";
64 const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32";
65 const char MEDFileFloatField1TSWithoutSDA::TYPE_STR[]="FLOAT32";
67 MEDFileGTKeeper::~MEDFileGTKeeper()
71 MEDFileGTKeeper *MEDFileGTKeeperSta::deepCopy() const
73 return new MEDFileGTKeeperSta(_geo_type);
76 INTERP_KERNEL::NormalizedCellType MEDFileGTKeeperSta::getGeoType() const
81 std::string MEDFileGTKeeperSta::getRepr() const
83 return INTERP_KERNEL::CellModel::GetCellModel(_geo_type).getRepr();
86 bool MEDFileGTKeeperSta::isEqual(const MEDFileGTKeeper *other) const
88 const MEDFileGTKeeperSta *otherC(dynamic_cast<const MEDFileGTKeeperSta *>(other));
91 return _geo_type==otherC->_geo_type;
94 MEDFileGTKeeperDyn::MEDFileGTKeeperDyn(const MEDFileUMesh *mesh, const MEDFileUMesh *section, const MEDFileStructureElement *se):_mesh(mesh),_section(section),_se(se)
102 if(_mesh.isNull() || _section.isNull() || _se.isNull())
103 throw INTERP_KERNEL::Exception("MEDFileGTKeeperDyn constructor : null pointer not allowed !");
106 MEDFileGTKeeper *MEDFileGTKeeperDyn::deepCopy() const
108 return new MEDFileGTKeeperDyn(_mesh,_section,_se);
111 INTERP_KERNEL::NormalizedCellType MEDFileGTKeeperDyn::getGeoType() const
113 throw INTERP_KERNEL::Exception("MEDFileGTKeeperDyn::getGeoType : not valid !");
116 std::string MEDFileGTKeeperDyn::getRepr() const
118 std::ostringstream oss;
119 oss << _se->getDynGT();
123 bool MEDFileGTKeeperDyn::isEqual(const MEDFileGTKeeper *other) const
125 const MEDFileGTKeeperDyn *otherC(dynamic_cast<const MEDFileGTKeeperDyn *>(other));
131 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const std::string& locName)
133 return new MEDFileFieldLoc(fid,locName);
136 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, int id, const MEDFileEntities *entities)
138 return new MEDFileFieldLoc(fid,id,entities);
141 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)
143 return new MEDFileFieldLoc(locName,geoType,refCoo,gsCoo,w);
146 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, const std::string& locName):_name(locName)
148 med_geometry_type geotype;
149 med_geometry_type sectiongeotype;
150 int nsectionmeshcell;
151 INTERP_KERNEL::AutoPtr<char> geointerpname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
152 INTERP_KERNEL::AutoPtr<char> sectionmeshname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
153 MEDlocalizationInfoByName(fid,locName.c_str(),&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
154 _gt=new MEDFileGTKeeperSta((INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype))));
155 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
156 _nb_node_per_cell=cm.getNumberOfNodes();
157 _ref_coo.resize(_dim*_nb_node_per_cell);
158 _gs_coo.resize(_dim*_nb_gauss_pt);
159 _w.resize(_nb_gauss_pt);
160 MEDlocalizationRd(fid,locName.c_str(),MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
163 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id, const MEDFileEntities *entities)
165 med_geometry_type geotype;
166 med_geometry_type sectiongeotype;
167 int nsectionmeshcell;
168 INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
169 INTERP_KERNEL::AutoPtr<char> geointerpname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
170 INTERP_KERNEL::AutoPtr<char> sectionmeshname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
171 MEDlocalizationInfo(fid,id+1,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
173 std::string sectionName(MEDLoaderBase::buildStringFromFortran(sectionmeshname,MED_NAME_SIZE));
174 if(sectionName.empty())
176 _gt=new MEDFileGTKeeperSta((INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype))));
177 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
178 _nb_node_per_cell=cm.getNumberOfNodes();
182 const MEDFileAllStaticEntitiesPlusDyn *entities2(dynamic_cast<const MEDFileAllStaticEntitiesPlusDyn *>(entities));
185 std::ostringstream oss; oss << "MEDFileFieldLoc cstr : for loc \"" << _name << "\" presence of non static type ! Expect entities !";
186 throw INTERP_KERNEL::Exception(oss.str());
188 const MEDFileStructureElement *se(entities2->getWithGT(geotype));
189 const MEDFileUMesh *um(entities2->getSupMeshWithName(se->getMeshName()));
190 const MEDFileUMesh *section(entities2->getSupMeshWithName(sectionName));
191 _gt=new MEDFileGTKeeperDyn(um,section,se);
194 MEDFILESAFECALLERWR0(MEDmeshGeotypeParameter,(fid,geotype,&dummy,&_nb_node_per_cell));
197 _ref_coo.resize(_dim*_nb_node_per_cell);
198 _gs_coo.resize(_dim*_nb_gauss_pt);
199 _w.resize(_nb_gauss_pt);
200 MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
203 MEDFileFieldLoc::MEDFileFieldLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType,
204 const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w):_name(locName),_gt(new MEDFileGTKeeperSta(geoType)),_ref_coo(refCoo),_gs_coo(gsCoo),_w(w)
206 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
207 _dim=cm.getDimension();
208 _nb_node_per_cell=cm.getNumberOfNodes();
209 _nb_gauss_pt=_w.size();
213 MEDFileFieldLoc::MEDFileFieldLoc(const MEDFileFieldLoc& other):_dim(other._dim),_nb_gauss_pt(other._nb_gauss_pt),_gt(other._gt->deepCopy()),_nb_node_per_cell(other._nb_node_per_cell),_name(other._name),_ref_coo(other._ref_coo),_gs_coo(other._gs_coo),_w(other._w)
217 MEDFileFieldLoc *MEDFileFieldLoc::deepCopy() const
219 return new MEDFileFieldLoc(*this);
222 bool MEDFileFieldLoc::isOnStructureElement() const
224 const MEDFileGTKeeper *gt(_gt);
226 throw INTERP_KERNEL::Exception("MEDFileFieldLoc::isOnStructureElement : null pointer !");
227 const MEDFileGTKeeperDyn *gt2(dynamic_cast<const MEDFileGTKeeperDyn *>(gt));
231 std::size_t MEDFileFieldLoc::getHeapMemorySizeWithoutChildren() const
233 return (_ref_coo.capacity()+_gs_coo.capacity()+_w.capacity())*sizeof(double)+_name.capacity();
236 std::vector<const BigMemoryObject *> MEDFileFieldLoc::getDirectChildrenWithNull() const
238 return std::vector<const BigMemoryObject *>();
241 void MEDFileFieldLoc::simpleRepr(std::ostream& oss) const
243 static const char OFF7[]="\n ";
244 oss << "\"" << _name << "\"" << OFF7;
245 oss << "GeoType=" << _gt->getRepr() << OFF7;
246 oss << "Dimension=" << _dim << OFF7;
247 oss << "Number of Gauss points=" << _nb_gauss_pt << OFF7;
248 oss << "Number of nodes per cell=" << _nb_node_per_cell << OFF7;
249 oss << "RefCoords="; std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
250 oss << "Weights="; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
251 oss << "GaussPtsCoords="; std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," ")); oss << std::endl;
254 void MEDFileFieldLoc::setName(const std::string& name)
259 bool MEDFileFieldLoc::isEqual(const MEDFileFieldLoc& other, double eps) const
261 if(_name!=other._name)
265 if(_nb_gauss_pt!=other._nb_gauss_pt)
267 if(_nb_node_per_cell!=other._nb_node_per_cell)
269 if(!_gt->isEqual(other._gt))
271 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_ref_coo,other._ref_coo,eps))
273 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_gs_coo,other._gs_coo,eps))
275 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_w,other._w,eps))
281 void MEDFileFieldLoc::writeLL(med_idt fid) const
283 MEDlocalizationWr(fid,_name.c_str(),typmai3[(int)getGeoType()],_dim,&_ref_coo[0],MED_FULL_INTERLACE,_nb_gauss_pt,&_gs_coo[0],&_w[0],MED_NO_INTERPOLATION,MED_NO_MESH_SUPPORT);
286 std::string MEDFileFieldLoc::repr() const
288 std::ostringstream oss; oss.precision(15);
289 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
290 oss << "Localization \"" << _name << "\" :\n" << " - Geometric Type : " << cm.getRepr();
291 oss << "\n - Dimension : " << _dim << "\n - Number of gauss points : ";
292 oss << _nb_gauss_pt << "\n - Number of nodes in cell : " << _nb_node_per_cell;
293 oss << "\n - Ref coords are : ";
294 int sz=_ref_coo.size();
297 int nbOfTuples=sz/_dim;
298 for(int i=0;i<nbOfTuples;i++)
301 for(int j=0;j<_dim;j++)
302 { oss << _ref_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
307 std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," "));
308 oss << "\n - Gauss coords in reference element : ";
312 int nbOfTuples=sz/_dim;
313 for(int i=0;i<nbOfTuples;i++)
316 for(int j=0;j<_dim;j++)
317 { oss << _gs_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
322 std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," "));
323 oss << "\n - Weights of Gauss coords are : "; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," "));
327 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldTemplate *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
329 _type=field->getTypeOfField();
335 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,offset,offset+nbOfCells,1);
336 _end=_start+nbOfCells;
342 MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
343 const int *arrPtr=arr->getConstPointer();
344 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,arrPtr[offset],arrPtr[offset+nbOfCells],1);
345 _end=_start+(arrPtr[offset+nbOfCells]-arrPtr[offset]);
351 const MEDCouplingFieldDiscretization *disc(field->getDiscretization());
352 const MEDCouplingGaussLocalization& gsLoc(field->getGaussLocalization(_loc_id));
353 const MEDCouplingFieldDiscretizationGauss *disc2(dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc));
355 throw INTERP_KERNEL::Exception("assignFieldNoProfile : invalid call to this method ! Internal Error !");
356 const DataArrayInt *dai(disc2->getArrayOfDiscIds());
357 MCAuto<DataArrayInt> dai2(disc2->getOffsetArr(field->getMesh()));
358 const int *dai2Ptr(dai2->getConstPointer());
359 int nbi(gsLoc.getWeights().size());
360 MCAuto<DataArrayInt> da2(dai->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1));
361 MCAuto<DataArrayInt> da3(da2->findIdsEqual(_loc_id));
362 const int *da3Ptr(da3->getConstPointer());
363 if(da3->getNumberOfTuples()!=nbOfCells)
364 {//profile : for gauss even in NoProfile !!!
365 std::ostringstream oss; oss << "Pfl_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
367 da3->setName(_profile.c_str());
368 glob.appendProfile(da3);
370 MCAuto<DataArrayInt> da4(DataArrayInt::New());
371 _nval=da3->getNbOfElems();
372 da4->alloc(_nval*nbi,1);
373 int *da4Ptr(da4->getPointer());
374 for(int i=0;i<_nval;i++)
376 int ref=dai2Ptr[offset+da3Ptr[i]];
377 for(int j=0;j<nbi;j++)
380 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
381 _localization=oss2.str();
382 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,da4);
383 _end=_start+_nval*nbi;
384 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
388 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile : not implemented yet for such discretization type of field !");
394 * Leaf method of field with profile assignement. This method is the most general one. No optimization is done here.
395 * \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).
396 * \param [in] multiTypePfl is the end user profile specified in high level API
397 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
398 * \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.
399 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
400 * \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.
402 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldTemplate *field, const DataArray *arrr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
405 _type=field->getTypeOfField();
406 std::string pflName(multiTypePfl->getName());
407 std::ostringstream oss; oss << pflName;
411 { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType()); oss << "_" << cm.getRepr(); }
418 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : existing profile with empty name !");
419 if(_type!=ON_GAUSS_PT)
421 locIds->setName(oss.str());
422 glob.appendProfile(locIds);
431 _nval=idsInPfl->getNumberOfTuples();
432 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,0,arrr->getNumberOfTuples(),1);
438 _nval=idsInPfl->getNumberOfTuples();
439 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,idsInPfl);
445 MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
446 MCAuto<DataArrayInt> arr2=arr->deltaShiftIndex();
447 MCAuto<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->begin(),multiTypePfl->end());
448 arr3->computeOffsetsFull();
449 MCAuto<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
450 int trueNval=tmp->getNumberOfTuples();
451 _nval=idsInPfl->getNumberOfTuples();
452 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
453 _end=_start+trueNval;
458 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(field->getDiscretization());
460 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
461 const DataArrayInt *da1=disc2->getArrayOfDiscIds();
462 const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
463 MCAuto<DataArrayInt> da2=da1->selectByTupleId(idsInPfl->begin(),idsInPfl->end());
464 MCAuto<DataArrayInt> da3=da2->findIdsEqual(_loc_id);
465 MCAuto<DataArrayInt> da4=idsInPfl->selectByTupleId(da3->begin(),da3->end());
467 MCAuto<MEDCouplingMesh> mesh2=mesh->buildPart(multiTypePfl->begin(),multiTypePfl->end());
468 MCAuto<DataArrayInt> arr=disc2->getOffsetArr(mesh2);
470 MCAuto<DataArrayInt> tmp=DataArrayInt::New();
472 for(const int *pt=da4->begin();pt!=da4->end();pt++)
473 trueNval+=arr->getIJ(*pt+1,0)-arr->getIJ(*pt,0);
474 tmp->alloc(trueNval,1);
475 int *tmpPtr=tmp->getPointer();
476 for(const int *pt=da4->begin();pt!=da4->end();pt++)
477 for(int j=arr->getIJ(*pt,0);j<arr->getIJ(*pt+1,0);j++)
480 _nval=da4->getNumberOfTuples();
481 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
482 _end=_start+trueNval;
483 oss << "_loc_" << _loc_id;
486 MCAuto<DataArrayInt> da5=locIds->selectByTupleId(da3->begin(),da3->end());
487 da5->setName(oss.str());
488 glob.appendProfile(da5);
493 if(!da3->isIota(nbOfEltsInWholeMesh))
495 da3->setName(oss.str());
496 glob.appendProfile(da3);
500 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
501 _localization=oss2.str();
502 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
506 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for such discretization type of field !");
511 void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldTemplate *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob)
514 _nval=arrr->getNumberOfTuples();
515 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,0,_nval,1);
520 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int profileIt, const PartDefinition *pd)
522 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt,pd);
525 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int locId)
527 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string());
530 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(const MEDFileFieldPerMeshPerTypePerDisc& other)
532 return new MEDFileFieldPerMeshPerTypePerDisc(other);
535 std::size_t MEDFileFieldPerMeshPerTypePerDisc::getHeapMemorySizeWithoutChildren() const
537 return _profile.capacity()+_localization.capacity()+sizeof(MEDFileFieldPerMeshPerTypePerDisc);
540 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypePerDisc::getDirectChildrenWithNull() const
542 std::vector<const BigMemoryObject *> ret(1);
543 ret[0]=(const PartDefinition*)_pd;
547 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCopy(MEDFileFieldPerMeshPerTypeCommon *father) const
549 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret(new MEDFileFieldPerMeshPerTypePerDisc(*this));
554 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField atype, int profileIt, const PartDefinition *pd)
555 try:_type(atype),_father(fath),_profile_it(profileIt),_pd(const_cast<PartDefinition *>(pd))
560 catch(INTERP_KERNEL::Exception& e)
565 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
569 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)
573 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(0),_start(-std::numeric_limits<int>::max()),_end(-std::numeric_limits<int>::max()),
574 _nval(-std::numeric_limits<int>::max()),_loc_id(-std::numeric_limits<int>::max())
578 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)
580 const PartDefinition *pd(_pd);
583 INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
585 med_int nbValsInFile(MEDfieldnValueWithProfileByName(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile.c_str(),MED_COMPACT_PFLMODE,&tmp1,locname,&nbi));
586 if(_end-_start!=nbValsInFile*nbi)
588 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 !";
589 throw INTERP_KERNEL::Exception(oss.str());
591 MEDFILESAFECALLERRD0(MEDfieldValueWithProfileRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,_profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,startFeedingPtr));
595 if(!_profile.empty())
596 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : not implemented !");
597 INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)),locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
599 int overallNval(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
600 const SlicePartDefinition *spd(dynamic_cast<const SlicePartDefinition *>(pd));
604 spd->getSlice(start,stop,step);
605 int nbOfEltsToLoad(DataArray::GetNumberOfItemGivenBES(start,stop,step,"MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile"));
606 med_filter filter=MED_FILTER_INIT;
607 MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
608 MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
609 /*start*/start+1,/*stride*/step,/*count*/1,/*blocksize*/nbOfEltsToLoad,
610 /*lastblocksize=useless because count=1*/0,&filter);
611 MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,startFeedingPtr));
612 MEDfilterClose(&filter);
615 const DataArrayPartDefinition *dpd(dynamic_cast<const DataArrayPartDefinition *>(pd));
618 dpd->checkConsistencyLight();
619 MCAuto<DataArrayInt> myIds(dpd->toDAI());
620 int a(myIds->getMinValueInArray()),b(myIds->getMaxValueInArray());
621 myIds=myIds->deepCopy();// WARNING deep copy here because _pd is modified by applyLin !!!
622 myIds->applyLin(1,-a);
623 int nbOfEltsToLoad(b-a+1);
624 med_filter filter=MED_FILTER_INIT;
625 {//TODO : manage int32 !
626 MCAuto<DataArrayDouble> tmp(DataArrayDouble::New());
627 tmp->alloc(nbOfEltsToLoad,nbOfCompo);
628 MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
629 MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
630 /*start*/a+1,/*stride*/1,/*count*/1,/*blocksize*/nbOfEltsToLoad,
631 /*lastblocksize=useless because count=1*/0,&filter);
632 MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,reinterpret_cast<unsigned char *>(tmp->getPointer())));
633 MCAuto<DataArrayDouble> feeder(DataArrayDouble::New());
634 feeder->useExternalArrayWithRWAccess(reinterpret_cast<double *>(startFeedingPtr),_nval,nbOfCompo);
635 feeder->setContigPartOfSelectedValues(0,tmp,myIds);
637 MEDfilterClose(&filter);
640 throw INTERP_KERNEL::Exception("Not implemented yet for not slices!");
644 const MEDFileFieldPerMeshPerTypeCommon *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
649 void MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
651 INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
652 INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
653 std::string fieldName(nasc.getName()),meshName(getMeshName());
654 int iteration(getIteration()),order(getOrder()),profilesize,nbi;
655 TypeOfField type(getType());
656 med_geometry_type mgeoti;
657 med_entity_type menti;
658 _father->entriesForMEDfile(type,mgeoti,menti);
659 int zeNVal(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
660 _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
661 _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
662 const PartDefinition *pd(_pd);
669 if(!_profile.empty())
670 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively : profiles are not managed yet with part of def !");
671 _nval=pd->getNumberOfElems();
674 _end=start+_nval*nbi;
676 if(type==ON_CELLS && !_localization.empty())
678 if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
679 setType(ON_GAUSS_PT);
682 setType(ON_GAUSS_NE);
683 _localization.clear();
688 void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, const MEDFileFieldNameScope& nasc)
690 std::string fieldName(nasc.getName()),meshName(getMeshName());
691 int iteration(getIteration()),order(getOrder());
692 TypeOfField type(getType());
693 med_geometry_type mgeoti;
694 med_entity_type menti;
695 _father->entriesForMEDfile(type,mgeoti,menti);
697 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !");
700 DataArray *arr(getOrCreateAndGetArray());//arr is not null due to the spec of getOrCreateAndGetArray
701 if(_start<0 || _start>=arr->getNumberOfTuples())
703 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << ") !";
704 throw INTERP_KERNEL::Exception(oss.str());
706 if(_end<0 || _end>arr->getNumberOfTuples())
708 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !";
709 throw INTERP_KERNEL::Exception(oss.str());
711 int nbOfCompo(arr->getNumberOfComponents());
712 DataArrayDouble *arrD(dynamic_cast<DataArrayDouble *>(arr));
715 double *startFeeding(arrD->getPointer()+_start*nbOfCompo);
716 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
719 DataArrayInt *arrI(dynamic_cast<DataArrayInt *>(arr));
722 int *startFeeding(arrI->getPointer()+_start*nbOfCompo);
723 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
726 throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
730 * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
732 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart)
734 int delta=_end-_start;
735 _start=newValueOfStart;
739 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
741 return _father->getIteration();
744 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
746 return _father->getOrder();
749 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
751 return _father->getTime();
754 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
756 return _father->getMeshName();
759 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
761 const char startLine[]=" ## ";
762 std::string startLine2(bkOffset,' ');
763 startLine2+=startLine;
764 INTERP_KERNEL::AutoCppPtr<MEDCouplingFieldDiscretization> tmp(MEDCouplingFieldDiscretization::New(_type));
765 oss << startLine2 << "Localization #" << id << "." << std::endl;
766 oss << startLine2 << " Type=" << tmp->getRepr() << "." << std::endl;
767 oss << startLine2 << " This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
768 oss << startLine2 << " This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
769 oss << startLine2 << " This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
772 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
777 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
779 return _father->getGeoType();
782 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
787 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
792 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
794 return _father->getNumberOfComponents();
797 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
802 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray()
804 return _father->getOrCreateAndGetArray();
807 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const
809 const MEDFileFieldPerMeshPerTypeCommon *fath=_father;
810 return fath->getOrCreateAndGetArray();
813 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
815 return _father->getInfo();
818 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
823 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const std::string& newPflName)
828 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
830 return _localization;
833 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const std::string& newLocName)
835 _localization=newLocName;
838 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
840 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
842 if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
844 _profile=(*it2).second;
850 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
852 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
854 if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
856 _localization=(*it2).second;
862 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
866 dads.push_back(std::pair<int,int>(_start,_end));
867 geoTypes.push_back(getGeoType());
872 pfls.push_back(glob->getProfile(_profile.c_str()));
874 if(_localization.empty())
878 locs.push_back(glob->getLocalizationId(_localization.c_str()));
882 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
884 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));
888 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
890 TypeOfField type=getType();
891 INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
892 med_geometry_type mgeoti;
893 med_entity_type menti;
894 _father->entriesForMEDfile(getType(),mgeoti,menti);
895 const DataArray *arr(getOrCreateAndGetArray());
897 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
898 if(!arr->isAllocated())
899 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : the array to be written is not allocated !");
900 const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
901 const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
902 const unsigned char *locToWrite=0;
904 locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
906 locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
908 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
909 MEDFILESAFECALLERWR0(MEDfieldValueWithProfileWr,(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
910 MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
914 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const
919 dad.first=_start; dad.second=_end;
923 * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
924 * This code corresponds to the distribution of types in the corresponding mesh.
925 * \param [out] ptToFill memory zone where the output will be stored.
926 * \return the size of data pushed into output param \a ptToFill
928 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const
931 std::ostringstream oss;
932 std::size_t nbOfType=codeOfMesh.size()/3;
934 for(std::size_t i=0;i<nbOfType && found==-1;i++)
935 if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
939 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
940 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
941 throw INTERP_KERNEL::Exception(oss.str());
946 if(_nval!=codeOfMesh[3*found+1])
948 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
949 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
950 oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
951 throw INTERP_KERNEL::Exception(oss.str());
953 for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
958 const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
959 if(pfl->getNumberOfTuples()!=_nval)
961 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
962 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
964 oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
965 throw INTERP_KERNEL::Exception(oss.str());
967 int offset2=codeOfMesh[3*found+2];
968 for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
970 if(*pflId<codeOfMesh[3*found+1])
971 *work++=offset2+*pflId;
977 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const
979 for(int i=_start;i<_end;i++)
984 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId)
995 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
999 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
1002 std::map<std::pair<std::string,TypeOfField>,int> m;
1003 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
1004 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
1005 if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
1006 m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
1008 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
1009 ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
1014 * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
1016 * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
1017 * \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.
1018 * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
1019 * \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)
1020 * \param [in,out] glob if necessary by the method, new profiles can be added to it
1021 * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
1022 * \param [out] result All new entries will be appended on it.
1023 * \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 !)
1025 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
1026 const DataArrayInt *explicitIdsInMesh,
1027 const std::vector<int>& newCode,
1028 MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
1029 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >& result)
1031 if(entriesOnSameDisc.empty())
1033 TypeOfField type=entriesOnSameDisc[0]->getType();
1034 int szEntities=0,szTuples=0;
1035 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
1036 { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
1037 int nbi=szTuples/szEntities;
1038 if(szTuples%szEntities!=0)
1039 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
1040 MCAuto<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
1041 MCAuto<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
1042 std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
1043 std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
1044 std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
1045 std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
1046 MCAuto<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
1048 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
1050 int startOfEltIdOfChunk=(*it)->_start;
1051 MCAuto<DataArrayInt> newEltIds=explicitIdsInMesh->subArray(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
1052 MCAuto<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
1053 MCAuto<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
1055 MCAuto<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
1056 newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
1058 newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
1059 newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
1061 MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
1062 MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
1063 MCAuto<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
1064 MCAuto<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
1066 MCAuto<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
1068 MCAuto<DataArrayDouble> arrPart=arr->subArray(offset,offset+szTuples);
1069 arrPart->renumberInPlace(renumTupleIds->begin());
1070 arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
1072 const int *idIt=diffVals->begin();
1073 std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
1075 for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
1077 MCAuto<DataArrayInt> ids=newGeoTypesEltIdsAllGather->findIdsEqual(*idIt);
1078 MCAuto<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
1079 int nbEntityElts=subIds->getNumberOfTuples();
1081 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
1082 NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIota(newCode[3*(*idIt)+1]),nbi,
1086 result.push_back(eltToAdd);
1087 offset2+=nbEntityElts*nbi;
1089 ret=ret || li.empty();
1094 * \param [in] typeF type of field of new chunk
1095 * \param [in] geoType the geometric type of the chunk
1096 * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
1097 * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
1098 * \param [in] nbi number of integration points
1099 * \param [in] offset The offset in the **global array of data**.
1100 * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
1101 * to the new chunk to create.
1102 * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
1103 * \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
1104 * and corresponding entry erased from \a entriesOnSameDisc.
1105 * \return a newly allocated chunk
1107 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
1108 bool isPfl, int nbi, int offset,
1109 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
1110 MEDFileFieldGlobsReal& glob,
1111 bool ¬InExisting)
1113 int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
1114 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
1115 for(;it!=entriesOnSameDisc.end();it++)
1117 if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
1121 if((*it)->_profile.empty())
1124 if(!(*it)->_profile.empty())
1126 const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
1127 if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
1133 if(it==entriesOnSameDisc.end())
1136 MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
1138 ret->_loc_id=(int)geoType;
1139 ret->_nval=nbMeshEntities;
1141 ret->_end=ret->_start+ret->_nval*nbi;
1144 idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
1145 glob.appendProfile(idsOfMeshElt);
1146 ret->_profile=idsOfMeshElt->getName();
1148 //tony treatment of localization
1153 notInExisting=false;
1154 MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1155 ret->_loc_id=(int)geoType;
1156 ret->setNewStart(offset);
1157 entriesOnSameDisc.erase(it);
1163 ////////////////////////////////////
1165 MEDFileFieldPerMeshPerTypeCommon::~MEDFileFieldPerMeshPerTypeCommon()
1169 void MEDFileFieldPerMeshPerTypeCommon::setFather(MEDFileFieldPerMesh *father)
1174 void MEDFileFieldPerMeshPerTypeCommon::accept(MEDFileFieldVisitor& visitor) const
1176 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1177 if((*it).isNotNull())
1179 visitor.newPerMeshPerTypePerDisc(*it);
1183 void MEDFileFieldPerMeshPerTypeCommon::deepCopyElements()
1186 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1188 if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
1189 _field_pm_pt_pd[i]=(*it)->deepCopy(this);
1193 std::size_t MEDFileFieldPerMeshPerTypeCommon::getHeapMemorySizeWithoutChildren() const
1195 return _field_pm_pt_pd.capacity()*sizeof(MCAuto<MEDFileFieldPerMeshPerTypePerDisc>);
1198 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypeCommon::getDirectChildrenWithNull() const
1200 std::vector<const BigMemoryObject *> ret;
1201 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1202 ret.push_back((const MEDFileFieldPerMeshPerTypePerDisc *)*it);
1206 void MEDFileFieldPerMeshPerTypeCommon::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1208 std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
1209 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1210 _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1214 * This method is the most general one. No optimization is done here.
1215 * \param [in] multiTypePfl is the end user profile specified in high level API
1216 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1217 * \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.
1218 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1219 * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1220 * \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.
1222 void MEDFileFieldPerMeshPerTypeCommon::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldTemplate *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1224 std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1225 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1226 _field_pm_pt_pd[*it]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1229 void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1231 _field_pm_pt_pd.resize(1);
1232 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1233 _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1236 void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1238 MCAuto<DataArrayInt> pfl2=pfl->deepCopy();
1239 if(!arr || !arr->isAllocated())
1240 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile : input array is null, or not allocated !");
1241 _field_pm_pt_pd.resize(1);
1242 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1243 _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.
1246 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldTemplate *field, int offset, int nbOfCells)
1248 TypeOfField type=field->getTypeOfField();
1249 if(type!=ON_GAUSS_PT)
1251 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1252 int sz=_field_pm_pt_pd.size();
1254 for(int j=0;j<sz && !found;j++)
1256 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1258 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1264 _field_pm_pt_pd.resize(sz+1);
1265 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1267 std::vector<int> ret(1,(int)sz);
1272 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1273 int sz2=ret2.size();
1274 std::vector<int> ret3(sz2);
1276 for(int i=0;i<sz2;i++)
1278 int sz=_field_pm_pt_pd.size();
1279 int locIdToFind=ret2[i];
1281 for(int j=0;j<sz && !found;j++)
1283 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1285 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1292 _field_pm_pt_pd.resize(sz+1);
1293 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1301 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldTemplate *field, int offset, int nbOfCells)
1303 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1304 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1306 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1307 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1309 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1310 MCAuto<DataArrayInt> da2=da->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1);
1311 MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1312 if(retTmp->presenceOfValue(-1))
1313 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1314 std::vector<int> ret(retTmp->begin(),retTmp->end());
1318 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldTemplate *field, const DataArrayInt *subCells)
1320 TypeOfField type=field->getTypeOfField();
1321 if(type!=ON_GAUSS_PT)
1323 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1324 int sz=_field_pm_pt_pd.size();
1326 for(int j=0;j<sz && !found;j++)
1328 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1330 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1336 _field_pm_pt_pd.resize(sz+1);
1337 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1339 std::vector<int> ret(1,0);
1344 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1345 int sz2=ret2.size();
1346 std::vector<int> ret3(sz2);
1348 for(int i=0;i<sz2;i++)
1350 int sz=_field_pm_pt_pd.size();
1351 int locIdToFind=ret2[i];
1353 for(int j=0;j<sz && !found;j++)
1355 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1357 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1364 _field_pm_pt_pd.resize(sz+1);
1365 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1373 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldTemplate *field, const DataArrayInt *subCells)
1375 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1376 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1378 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1379 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1381 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1382 MCAuto<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1383 MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1384 if(retTmp->presenceOfValue(-1))
1385 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1386 std::vector<int> ret(retTmp->begin(),retTmp->end());
1390 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerTypeCommon::getFather() const
1395 bool MEDFileFieldPerMeshPerTypeCommon::isUniqueLevel(int& dim) const
1397 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
1398 int curDim((int)cm.getDimension());
1399 if(dim!=std::numeric_limits<int>::max())
1409 void MEDFileFieldPerMeshPerTypeCommon::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1411 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1413 (*it)->fillTypesOfFieldAvailable(types);
1417 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
1419 int sz=_field_pm_pt_pd.size();
1420 dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1421 for(int i=0;i<sz;i++)
1423 _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1427 int MEDFileFieldPerMeshPerTypeCommon::getIteration() const
1429 return _father->getIteration();
1432 int MEDFileFieldPerMeshPerTypeCommon::getOrder() const
1434 return _father->getOrder();
1437 double MEDFileFieldPerMeshPerTypeCommon::getTime() const
1439 return _father->getTime();
1442 std::string MEDFileFieldPerMeshPerTypeCommon::getMeshName() const
1444 return _father->getMeshName();
1447 void MEDFileFieldPerMeshPerTypeCommon::getSizes(int& globalSz, int& nbOfEntries) const
1449 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1451 globalSz+=(*it)->getNumberOfTuples();
1453 nbOfEntries+=(int)_field_pm_pt_pd.size();
1456 int MEDFileFieldPerMeshPerTypeCommon::getNumberOfComponents() const
1458 return _father->getNumberOfComponents();
1461 bool MEDFileFieldPerMeshPerTypeCommon::presenceOfMultiDiscPerGeoType() const
1464 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1466 const MEDFileFieldPerMeshPerTypePerDisc *fmtd(*it);
1473 void MEDFileFieldPerMeshPerTypeCommon::pushDiscretization(MEDFileFieldPerMeshPerTypePerDisc *disc)
1475 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt;
1477 _field_pm_pt_pd.push_back(elt);
1480 DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray()
1482 return _father->getOrCreateAndGetArray();
1485 const DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray() const
1487 const MEDFileFieldPerMesh *fath=_father;
1488 return fath->getOrCreateAndGetArray();
1491 const std::vector<std::string>& MEDFileFieldPerMeshPerTypeCommon::getInfo() const
1493 return _father->getInfo();
1496 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsed() const
1498 std::vector<std::string> ret;
1499 std::set<std::string> ret2;
1500 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1502 std::string tmp=(*it1)->getProfile();
1504 if(ret2.find(tmp)==ret2.end())
1513 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsed() const
1515 std::vector<std::string> ret;
1516 std::set<std::string> ret2;
1517 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1519 std::string tmp=(*it1)->getLocalization();
1520 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1521 if(ret2.find(tmp)==ret2.end())
1530 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsedMulti() const
1532 std::vector<std::string> ret;
1533 std::set<std::string> ret2;
1534 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1536 std::string tmp=(*it1)->getProfile();
1543 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsedMulti() const
1545 std::vector<std::string> ret;
1546 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1548 std::string tmp=(*it1)->getLocalization();
1549 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1555 void MEDFileFieldPerMeshPerTypeCommon::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1557 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1558 (*it1)->changePflsRefsNamesGen(mapOfModif);
1561 void MEDFileFieldPerMeshPerTypeCommon::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1563 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1564 (*it1)->changeLocsRefsNamesGen(mapOfModif);
1567 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId)
1569 if(_field_pm_pt_pd.empty())
1571 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << getGeoTypeRepr() << "\" !";
1572 throw INTERP_KERNEL::Exception(oss.str());
1574 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1575 return _field_pm_pt_pd[locId];
1576 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
1577 oss2 << ") for geometric type \"" << getGeoTypeRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1578 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1579 return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1582 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId) const
1584 if(_field_pm_pt_pd.empty())
1586 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << getGeoTypeRepr() << "\" !";
1587 throw INTERP_KERNEL::Exception(oss.str());
1589 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1590 return _field_pm_pt_pd[locId];
1591 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
1592 oss2 << ") for geometric type \"" << getGeoTypeRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1593 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1594 return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1597 void MEDFileFieldPerMeshPerTypeCommon::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1600 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1602 (*it)->fillValues(i,startEntryId,entries);
1606 void MEDFileFieldPerMeshPerTypeCommon::setLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
1608 _field_pm_pt_pd=leaves;
1609 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1610 (*it)->setFather(this);
1614 * \param [in,out] globalNum a global numbering counter for the renumbering.
1615 * \param [out] its - list of pair (start,stop) kept
1616 * \return bool - false if the type of field \a tof is not contained in \a this.
1618 bool MEDFileFieldPerMeshPerTypeCommon::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
1621 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1622 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1623 if((*it)->getType()==tof)
1625 newPmPtPd.push_back(*it);
1626 std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1627 (*it)->setNewStart(globalNum);
1628 globalNum=(*it)->getEnd();
1629 its.push_back(bgEnd);
1633 _field_pm_pt_pd=newPmPtPd;
1638 * \param [in,out] globalNum a global numbering counter for the renumbering.
1639 * \param [out] its - list of pair (start,stop) kept
1640 * \return bool - false if the type of field \a tof is not contained in \a this.
1642 bool MEDFileFieldPerMeshPerTypeCommon::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
1644 if(_field_pm_pt_pd.size()<=idOfDisc)
1646 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt(_field_pm_pt_pd[idOfDisc]);
1647 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd(1,elt);
1648 std::pair<int,int> bgEnd; bgEnd.first=_field_pm_pt_pd[idOfDisc]->getStart(); bgEnd.second=_field_pm_pt_pd[idOfDisc]->getEnd();
1649 elt->setNewStart(globalNum);
1650 globalNum=elt->getEnd();
1651 its.push_back(bgEnd);
1652 _field_pm_pt_pd=newPmPtPd;
1656 void MEDFileFieldPerMeshPerTypeCommon::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
1658 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1659 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1662 void MEDFileFieldPerMeshPerTypeCommon::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1664 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1665 (*it)->loadBigArray(fid,nasc);
1668 void MEDFileFieldPerMeshPerTypeCommon::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1670 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1672 (*it)->copyOptionsFrom(*this);
1673 (*it)->writeLL(fid,nasc);
1677 med_entity_type MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1682 medfGeoType=typmai3[(int)ikGeoType];
1685 medfGeoType=MED_NONE;
1688 medfGeoType=typmai3[(int)ikGeoType];
1689 return MED_NODE_ELEMENT;
1691 medfGeoType=typmai3[(int)ikGeoType];
1694 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1696 return MED_UNDEF_ENTITY_TYPE;
1699 //////////////////////////////////////////////////
1701 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd)
1703 return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc,pd);
1706 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType)
1708 return new MEDFileFieldPerMeshPerType(fath,geoType);
1711 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCopy(MEDFileFieldPerMesh *father) const
1713 MCAuto<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
1714 ret->setFather(father);
1715 ret->deepCopyElements();
1719 void MEDFileFieldPerMeshPerType::getFieldAtLevel(int meshDim, TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
1721 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1723 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1724 if(meshDim!=(int)cm.getDimension())
1727 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1728 (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1731 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1736 void MEDFileFieldPerMeshPerType::entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const
1738 ent=MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(mct,_geo_type,gt);
1741 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1743 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1744 int curDim((int)cm.getDimension());
1745 dim=std::max(dim,curDim);
1748 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1750 const char startLine[]=" ## ";
1751 std::string startLine2(bkOffset,' ');
1752 std::string startLine3(startLine2);
1753 startLine3+=startLine;
1754 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1756 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1757 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1760 oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1761 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1763 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1765 const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1767 cur->simpleRepr(bkOffset,oss,i);
1770 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1775 std::string MEDFileFieldPerMeshPerType::getGeoTypeRepr() const
1777 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1778 return std::string(cm.getRepr());
1781 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *father, INTERP_KERNEL::NormalizedCellType gt):MEDFileFieldPerMeshPerTypeCommon(father),_geo_type(gt)
1785 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):MEDFileFieldPerMeshPerTypeCommon(fath),_geo_type(geoType)
1787 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1788 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1789 med_geometry_type mgeoti;
1790 med_entity_type menti(ConvertIntoMEDFileType(type,geoType,mgeoti));
1791 int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName));
1792 _field_pm_pt_pd.resize(nbProfiles);
1793 for(int i=0;i<nbProfiles;i++)
1795 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i,pd);
1799 int nbProfiles2(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName));
1800 for(int i=0;i<nbProfiles2;i++)
1801 _field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i,pd));
1805 MCAuto<MEDFileFieldPerMeshPerType> MEDFileFieldPerMeshPerType::Aggregate(int &start, const std::vector<std::pair<int,const MEDFileFieldPerMeshPerType *> >& pms, const std::vector< std::vector< std::pair<int,int> > >& dts, INTERP_KERNEL::NormalizedCellType gt, MEDFileFieldPerMesh *father, std::vector<std::pair< int, std::pair<int,int> > >& extractInfo)
1807 MCAuto<MEDFileFieldPerMeshPerType> ret(MEDFileFieldPerMeshPerType::New(father,gt));
1808 std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > > m;
1809 for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerType *> >::const_iterator it=pms.begin();it!=pms.end();it++)
1811 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it2=(*it).second->_field_pm_pt_pd.begin();it2!=(*it).second->_field_pm_pt_pd.end();it2++)
1812 m[(*it2)->getType()].push_back(std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * >((*it).first,*it2));
1814 for(std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > >::const_iterator it=m.begin();it!=m.end();it++)
1816 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> agg(MEDFileFieldPerMeshPerTypePerDisc::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
1817 ret->_field_pm_pt_pd.push_back(agg);
1822 //////////////////////////////////////////////////
1824 MEDFileFieldPerMeshPerTypeDyn *MEDFileFieldPerMeshPerTypeDyn::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileEntities *entities, int idGT, const MEDFileFieldNameScope& nasc)
1827 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeDyn::NewOnRead : null pointer !");
1828 const MEDFileAllStaticEntitiesPlusDyn *entities2(dynamic_cast<const MEDFileAllStaticEntitiesPlusDyn *>(entities));
1830 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeDyn::NewOnRead : invalid type of entities !");
1831 const MEDFileStructureElement *se(entities2->getWithGT(idGT));
1832 return new MEDFileFieldPerMeshPerTypeDyn(fid,fath,se,nasc);
1835 MEDFileFieldPerMeshPerTypeDyn::MEDFileFieldPerMeshPerTypeDyn(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileStructureElement *se, const MEDFileFieldNameScope& nasc):MEDFileFieldPerMeshPerTypeCommon(fath)
1838 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1839 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1840 int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,_se->getDynGT(),pflName,locName));
1841 _field_pm_pt_pd.resize(nbProfiles);
1842 for(int i=0;i<nbProfiles;i++)
1844 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,_se->getEntity(),i,NULL);
1848 int MEDFileFieldPerMeshPerTypeDyn::getDynGT() const
1850 return _se->getDynGT();
1853 std::string MEDFileFieldPerMeshPerTypeDyn::getModelName() const
1855 return _se->getName();
1858 void MEDFileFieldPerMeshPerTypeDyn::getDimension(int& dim) const
1860 throw INTERP_KERNEL::Exception("not implemented yet !");
1863 void MEDFileFieldPerMeshPerTypeDyn::entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const
1866 ent=MED_STRUCT_ELEMENT;
1869 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypeDyn::getGeoType() const
1871 throw INTERP_KERNEL::Exception("not implemented yet !");
1874 void MEDFileFieldPerMeshPerTypeDyn::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1876 const char startLine[]=" ## ";
1877 std::string startLine2(bkOffset,' ');
1878 std::string startLine3(startLine2);
1879 startLine3+=startLine;
1880 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry STRUCTURE_ELEMENT type " << getDynGT() << "." << std::endl;
1881 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1883 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1885 if((*it).isNotNull())
1886 (*it)->simpleRepr(bkOffset,oss,i);
1889 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1894 std::string MEDFileFieldPerMeshPerTypeDyn::getGeoTypeRepr() const
1896 throw INTERP_KERNEL::Exception("not implemented yet !");
1899 MEDFileFieldPerMeshPerTypeDyn *MEDFileFieldPerMeshPerTypeDyn::deepCopy(MEDFileFieldPerMesh *father) const
1901 MCAuto<MEDFileFieldPerMeshPerTypeDyn> ret(new MEDFileFieldPerMeshPerTypeDyn(*this));
1902 ret->setFather(father);
1903 ret->deepCopyElements();
1907 void MEDFileFieldPerMeshPerTypeDyn::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
1909 throw INTERP_KERNEL::Exception("not implemented yet !");
1912 //////////////////////////////////////////////////
1914 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const MEDFileEntities *entities)
1916 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm,entities);
1919 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1921 return new MEDFileFieldPerMesh(fath,mesh);
1924 std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
1926 return _field_pm_pt.capacity()*sizeof(MCAuto< MEDFileFieldPerMeshPerType >);
1929 std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildrenWithNull() const
1931 std::vector<const BigMemoryObject *> ret;
1932 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1937 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCopy(MEDFileAnyTypeField1TSWithoutSDA *father) const
1939 MCAuto< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1940 ret->_father=father;
1942 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1944 if((*it).isNotNull())
1945 ret->_field_pm_pt[i]=(*it)->deepCopy((MEDFileFieldPerMesh *)(ret));
1950 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1952 std::string startLine(bkOffset,' ');
1953 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << getMeshName() << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1954 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1956 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1958 if((*it).isNotNull())
1959 (*it)->simpleRepr(bkOffset,oss,i);
1962 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1967 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh)
1969 mesh->getTime(_mesh_iteration,_mesh_order);
1972 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1974 int nbOfTypes=code.size()/3;
1976 for(int i=0;i<nbOfTypes;i++)
1978 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1979 int nbOfCells=code[3*i+1];
1980 int pos=addNewEntryIfNecessary(type);
1981 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1987 * This method is the most general one. No optimization is done here.
1988 * \param [in] multiTypePfl is the end user profile specified in high level API
1989 * \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].
1990 * \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.
1991 * \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.
1992 * \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.
1993 * \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.
1995 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 MEDCouplingFieldTemplate *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1997 int nbOfTypes(code.size()/3);
1998 for(int i=0;i<nbOfTypes;i++)
2000 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
2001 int pos=addNewEntryIfNecessary(type);
2002 DataArrayInt *pfl=0;
2004 pfl=idsPerType[code[3*i+2]];
2005 int nbOfTupes2=code2.size()/3;
2007 for(;found<nbOfTupes2;found++)
2008 if(code[3*i]==code2[3*found])
2010 if(found==nbOfTupes2)
2011 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
2012 _field_pm_pt[pos]->assignFieldProfile(nbOfTypes==1,start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
2016 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
2018 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
2019 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
2022 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
2024 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
2025 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
2028 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
2030 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2031 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
2034 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
2036 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2037 (*it)->loadBigArraysRecursively(fid,nasc);
2040 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
2042 int nbOfTypes=_field_pm_pt.size();
2043 for(int i=0;i<nbOfTypes;i++)
2045 _field_pm_pt[i]->copyOptionsFrom(*this);
2046 _field_pm_pt[i]->writeLL(fid,nasc);
2050 void MEDFileFieldPerMesh::getDimension(int& dim) const
2052 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2053 (*it)->getDimension(dim);
2056 bool MEDFileFieldPerMesh::isUniqueLevel(int& dim) const
2058 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2059 if(!(*it)->isUniqueLevel(dim))
2064 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
2066 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2067 (*it)->fillTypesOfFieldAvailable(types);
2070 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
2072 int sz=_field_pm_pt.size();
2073 std::vector< std::vector<std::pair<int,int> > > ret(sz);
2074 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
2075 for(int i=0;i<sz;i++)
2077 types[i]=_field_pm_pt[i]->getGeoType();
2078 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
2083 double MEDFileFieldPerMesh::getTime() const
2086 return _father->getTime(tmp1,tmp2);
2089 int MEDFileFieldPerMesh::getIteration() const
2091 return _father->getIteration();
2094 int MEDFileFieldPerMesh::getOrder() const
2096 return _father->getOrder();
2099 int MEDFileFieldPerMesh::getNumberOfComponents() const
2101 return _father->getNumberOfComponents();
2104 std::string MEDFileFieldPerMesh::getMeshName() const
2106 return _father->getMeshName();
2109 void MEDFileFieldPerMesh::setMeshName(const std::string& meshName)
2111 _father->setMeshName(meshName);
2114 bool MEDFileFieldPerMesh::presenceOfMultiDiscPerGeoType() const
2116 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2120 if((*it)->presenceOfMultiDiscPerGeoType())
2126 bool MEDFileFieldPerMesh::presenceOfStructureElements() const
2128 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2129 if((*it).isNotNull())
2131 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2138 bool MEDFileFieldPerMesh::onlyStructureElements() const
2140 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2141 if((*it).isNotNull())
2143 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2150 void MEDFileFieldPerMesh::killStructureElements()
2152 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
2153 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2155 if((*it).isNotNull())
2157 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2165 void MEDFileFieldPerMesh::keepOnlyStructureElements()
2167 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
2168 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2170 if((*it).isNotNull())
2172 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2180 void MEDFileFieldPerMesh::keepOnlyOnSE(const std::string& seName)
2182 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
2183 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2185 if((*it).isNotNull())
2187 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2189 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::keepOnlyOnSE : presence of non SE !");
2190 if(pt->getModelName()==seName)
2197 void MEDFileFieldPerMesh::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
2199 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2201 if((*it).isNotNull())
2203 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2206 ps.push_back(std::pair<std::string,std::string>(getMeshName(),pt->getModelName()));
2209 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getMeshSENames : presence of a non structure element part !");
2214 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
2217 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
2218 return _father->getOrCreateAndGetArray();
2221 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
2224 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
2225 return _father->getOrCreateAndGetArray();
2228 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
2230 return _father->getInfo();
2234 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
2235 * 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.
2236 * It returns 2 output vectors :
2237 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
2238 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
2239 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
2241 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)
2243 int notNullPflsSz=0;
2244 int nbOfArrs=geoTypes.size();
2245 for(int i=0;i<nbOfArrs;i++)
2248 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
2249 int nbOfDiffGeoTypes=geoTypes3.size();
2250 code.resize(3*nbOfDiffGeoTypes);
2251 notNullPfls.resize(notNullPflsSz);
2254 for(int i=0;i<nbOfDiffGeoTypes;i++)
2257 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
2258 std::vector<const DataArrayInt *> notNullTmp;
2260 notNullTmp.push_back(pfls[j]);
2262 for(;j<nbOfArrs;j++)
2263 if(geoTypes[j]==refType)
2266 notNullTmp.push_back(pfls[j]);
2270 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
2271 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
2272 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
2273 code[3*i]=(int)refType;
2274 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
2275 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
2276 if(notNullTmp.empty())
2280 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
2281 code[3*i+2]=notNullPflsSz++;
2287 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
2289 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)
2293 for(int i=0;i<sz;i++)
2297 if(type!=ON_GAUSS_NE)
2298 ret+=dads[i].second-dads[i].first;
2301 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
2302 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
2307 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
2308 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
2314 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
2316 std::vector<std::string> ret;
2317 std::set<std::string> ret2;
2318 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2320 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
2321 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
2322 if(ret2.find(*it2)==ret2.end())
2324 ret.push_back(*it2);
2331 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
2333 std::vector<std::string> ret;
2334 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2336 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
2337 ret.insert(ret.end(),tmp.begin(),tmp.end());
2342 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
2344 std::vector<std::string> ret;
2345 std::set<std::string> ret2;
2346 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2348 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
2349 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
2350 if(ret2.find(*it2)==ret2.end())
2352 ret.push_back(*it2);
2359 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
2361 std::vector<std::string> ret;
2362 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2364 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
2365 ret.insert(ret.end(),tmp.begin(),tmp.end());
2370 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
2372 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
2374 if((*it).first==getMeshName())
2376 setMeshName((*it).second);
2383 void MEDFileFieldPerMesh::convertMedBallIntoClassic()
2385 if(_field_pm_pt.size()!=1)
2386 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : Only managed for single mesh !");
2387 if(_field_pm_pt[0].isNull())
2388 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : null pointer !");
2389 MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<MEDFileFieldPerMeshPerTypeDyn *>((MEDFileFieldPerMeshPerTypeCommon *)_field_pm_pt[0]));
2391 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : this is expected to be marked as structure element !");
2392 if(pt->getNumberOfLoc()!=1)
2393 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : only one loc managed !");
2394 const MEDFileFieldPerMeshPerTypePerDisc *disc(pt->getLeafGivenLocId(0));
2396 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : internal error !");
2397 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> disc2(MEDFileFieldPerMeshPerTypePerDisc::New(*disc));
2398 disc2->setType(ON_NODES);
2399 MCAuto<MEDFileFieldPerMeshPerType> pt2(MEDFileFieldPerMeshPerType::New(this,INTERP_KERNEL::NORM_ERROR));
2400 disc2->setFather(pt2);
2401 pt2->setFather(this);
2402 pt2->pushDiscretization(disc2);
2403 _field_pm_pt[0]=DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(pt2);
2406 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
2407 MEDFileFieldGlobsReal& glob)
2409 if(getMeshName()!=meshName)
2411 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
2412 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
2413 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
2414 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
2415 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
2416 getUndergroundDataArrayExt(entries);
2417 DataArray *arr0(getOrCreateAndGetArray());//tony
2419 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
2420 DataArrayDouble *arr(dynamic_cast<DataArrayDouble *>(arr0));//tony
2422 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
2425 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
2426 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
2428 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
2430 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2431 sz+=(*it).second.second-(*it).second.first;
2434 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2436 MCAuto<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
2437 ////////////////////
2438 MCAuto<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
2439 int *workI2=explicitIdsOldInMesh->getPointer();
2440 int sz1=0,sz2=0,sid=1;
2441 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
2442 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
2443 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
2445 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
2446 MCAuto<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
2447 int *workI=explicitIdsOldInArr->getPointer();
2448 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
2450 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
2451 (*itL2)->setLocId(sz2);
2452 (*itL2)->_tmp_work1=(*itL2)->getStart();
2453 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
2455 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
2457 explicitIdsOldInMesh->reAlloc(sz2);
2458 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
2459 ////////////////////
2460 MCAuto<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
2461 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
2462 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
2463 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
2465 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
2466 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
2467 otherEntriesNew.back()->setLocId((*it)->getGeoType());
2469 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
2470 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
2471 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
2473 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
2474 int newStart=elt->getLocId();
2475 elt->setLocId((*it)->getGeoType());
2476 elt->setNewStart(newStart);
2477 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
2478 entriesKeptNew.push_back(elt);
2479 entriesKeptNew2.push_back(elt);
2481 MCAuto<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
2482 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
2483 MCAuto<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
2484 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
2486 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
2489 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
2491 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
2492 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
2494 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
2495 glob,arr2,otherEntriesNew) || ret;
2499 // Assign new dispatching
2500 assignNewLeaves(otherEntriesNew);
2501 arr->deepCopyFrom(*arr2);
2506 * \param [in,out] globalNum a global numbering counter for the renumbering.
2507 * \param [out] its - list of pair (start,stop) kept
2509 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
2511 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > ret;
2512 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2514 std::vector< std::pair<int,int> > its2;
2515 if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
2518 its.insert(its.end(),its2.begin(),its2.end());
2525 * \param [in,out] globalNum a global numbering counter for the renumbering.
2526 * \param [out] its - list of pair (start,stop) kept
2528 void MEDFileFieldPerMesh::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
2530 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > ret;
2531 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2533 std::vector< std::pair<int,int> > its2;
2534 if((*it)->keepOnlyGaussDiscretization(idOfDisc,globalNum,its2))
2537 its.insert(its.end(),its2.begin(),its2.end());
2543 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
2545 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > > types;
2546 for( std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
2547 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
2549 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > fieldPmPt(types.size());
2550 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
2551 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it2=fieldPmPt.begin();
2552 for(;it1!=types.end();it1++,it2++)
2554 MCAuto<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
2555 elt->setLeaves((*it1).second);
2556 MCAuto<MEDFileFieldPerMeshPerTypeCommon> elt2(DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(elt));
2559 _field_pm_pt=fieldPmPt;
2562 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2564 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2565 (*it)->changePflsRefsNamesGen(mapOfModif);
2568 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2570 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2571 (*it)->changeLocsRefsNamesGen(mapOfModif);
2575 * \param [in] mesh is the whole mesh
2577 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2579 if(_field_pm_pt.empty())
2580 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2582 std::vector< std::pair<int,int> > dads;
2583 std::vector<const DataArrayInt *> pfls;
2584 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2585 std::vector<int> locs,code;
2586 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2587 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2588 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2590 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2593 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2594 throw INTERP_KERNEL::Exception(oss.str());
2597 std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2598 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2601 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2603 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2606 MCAuto<DataArrayInt> arr2(arr);
2607 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2613 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2617 if(nb!=mesh->getNumberOfNodes())
2619 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2620 oss << " nodes in mesh !";
2621 throw INTERP_KERNEL::Exception(oss.str());
2623 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2626 return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2630 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
2632 if(_field_pm_pt.empty())
2633 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2635 std::vector<std::pair<int,int> > dads;
2636 std::vector<const DataArrayInt *> pfls;
2637 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2638 std::vector<int> locs,code;
2639 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2640 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2641 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2643 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2646 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2647 throw INTERP_KERNEL::Exception(oss.str());
2649 std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2650 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2653 MCAuto<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2654 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2659 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2663 if(nb!=mesh->getNumberOfNodes())
2665 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2666 oss << " nodes in mesh !";
2667 throw INTERP_KERNEL::Exception(oss.str());
2670 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2676 void MEDFileFieldPerMesh::accept(MEDFileFieldVisitor& visitor) const
2678 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2679 if((*it).isNotNull())
2681 visitor.newPerMeshPerTypeEntry(*it);
2682 (*it)->accept(visitor);
2683 visitor.endPerMeshPerTypeEntry(*it);
2687 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
2691 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2693 (*it)->getSizes(globalSz,nbOfEntries);
2695 entries.resize(nbOfEntries);
2697 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2699 (*it)->fillValues(nbOfEntries,entries);
2703 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
2705 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2707 if((*it)->getGeoType()==typ)
2708 return (*it)->getLeafGivenLocId(locId);
2710 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2711 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2712 oss << "Possiblities are : ";
2713 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2715 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2716 oss << "\"" << cm2.getRepr() << "\", ";
2718 throw INTERP_KERNEL::Exception(oss.str());
2721 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
2723 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2725 if((*it)->getGeoType()==typ)
2726 return (*it)->getLeafGivenLocId(locId);
2728 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2729 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2730 oss << "Possiblities are : ";
2731 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2733 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2734 oss << "\"" << cm2.getRepr() << "\", ";
2736 throw INTERP_KERNEL::Exception(oss.str());
2740 * \param [in,out] start - Integer that gives the current position in the final aggregated array
2741 * \param [in] pms - list of elements to aggregate. integer gives the mesh id
2742 * \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.
2743 * \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.
2745 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)
2747 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret(new MEDFileFieldPerMeshPerTypePerDisc(father,tof));
2749 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : empty input vector !");
2750 for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it=pms.begin();it!=pms.end();it++)
2753 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : presence of null pointer !");
2754 if(!(*it).second->getProfile().empty())
2755 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for profiles !");
2756 if(!(*it).second->getLocalization().empty())
2757 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for gauss pts !");
2759 INTERP_KERNEL::NormalizedCellType gt(pms[0].second->getGeoType());
2761 std::vector< std::pair<int,int> > filteredDTS;
2762 for(std::vector< std::vector< std::pair<int,int> > >::const_iterator it=dts.begin();it!=dts.end();it++,i++)
2763 for(std::vector< std::pair<int,int> >::const_iterator it2=(*it).begin();it2!=(*it).end();it2++)
2764 if((*it2).first==gt)
2765 filteredDTS.push_back(std::pair<int,int>(i,(*it2).second));
2766 if(pms.size()!=filteredDTS.size())
2767 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles !");
2768 std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it1(pms.begin());
2769 std::vector< std::pair<int,int> >::const_iterator it2(filteredDTS.begin());
2770 int zeStart(start),nval(0);
2771 for(;it1!=pms.end();it1++,it2++)
2773 if((*it1).first!=(*it2).first)
2774 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles 2 !");
2775 int s1((*it1).second->getStart()),e1((*it1).second->getEnd());
2776 extractInfo.push_back(std::pair<int, std::pair<int,int> >((*it1).first,std::pair<int,int>(s1,e1)));
2778 nval+=((*it1).second)->getNumberOfVals();
2780 ret->_start=zeStart; ret->_end=start; ret->_nval=nval;
2784 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)
2786 MCAuto<MEDFileFieldPerMesh> ret(new MEDFileFieldPerMesh(father,pms[0]->getMeshName(),pms[0]->getMeshIteration(),pms[0]->getMeshOrder()));
2787 std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > > m;
2789 for(std::vector<const MEDFileFieldPerMesh *>::const_iterator it=pms.begin();it!=pms.end();it++,i++)
2791 const std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >& v((*it)->_field_pm_pt);
2792 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it2=v.begin();it2!=v.end();it2++)
2794 INTERP_KERNEL::NormalizedCellType gt((*it2)->getGeoType());
2795 const MEDFileFieldPerMeshPerType *elt(dynamic_cast<const MEDFileFieldPerMeshPerType *>((const MEDFileFieldPerMeshPerTypeCommon *)(*it2)));
2797 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::Aggregate : not managed for structelement !");
2798 m[gt].push_back(std::pair<int,const MEDFileFieldPerMeshPerType *>(i,elt));
2801 for(std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > >::const_iterator it=m.begin();it!=m.end();it++)
2803 MCAuto<MEDFileFieldPerMeshPerType> agg(MEDFileFieldPerMeshPerType::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
2804 MCAuto<MEDFileFieldPerMeshPerTypeCommon> agg2(DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(agg));
2805 ret->_field_pm_pt.push_back(agg2);
2810 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2813 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2814 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it2=_field_pm_pt.begin();
2815 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2817 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2822 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2827 int ret=std::distance(_field_pm_pt.begin(),it2);
2828 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2833 * 'dads' and 'locs' input parameters have the same number of elements
2834 * \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
2836 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2837 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2838 const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2841 MCAuto<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2842 ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2843 MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2844 const std::vector<std::string>& infos=getInfo();
2845 da->setInfoOnComponents(infos);
2847 if(type==ON_GAUSS_PT)
2850 int nbOfArrs=dads.size();
2851 for(int i=0;i<nbOfArrs;i++)
2853 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2854 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2855 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2856 MCAuto<DataArrayInt> di=DataArrayInt::New();
2857 di->alloc(nbOfElems,1);
2859 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2860 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2869 * 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.
2870 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2871 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2872 * The order of cells in the returned field is those imposed by the profile.
2873 * \param [in] mesh is the global mesh.
2875 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2876 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2877 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2878 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2880 if(da->isIota(mesh->getNumberOfCells()))
2881 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2882 MCAuto<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2883 m2->setName(mesh->getName().c_str());
2884 MCAuto<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2890 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2892 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2893 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2894 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2896 if(da->isIota(mesh->getNumberOfNodes()))
2897 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2898 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2899 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2902 if(meshu->getNodalConnectivity()==0)
2904 MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2905 int nb=da->getNbOfElems();
2906 const int *ptr=da->getConstPointer();
2907 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2908 meshuc->allocateCells(nb);
2909 for(int i=0;i<nb;i++)
2910 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2911 meshuc->finishInsertingCells();
2912 ret->setMesh(meshuc);
2913 const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2914 if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2915 disc->checkCoherencyBetween(meshuc,arrOut);
2920 MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2922 DataArrayInt *arr2=0;
2923 MCAuto<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2924 MCAuto<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2925 MCAuto<DataArrayInt> arr3(arr2);
2926 int nnodes=mesh2->getNumberOfNodes();
2927 if(nnodes==(int)da->getNbOfElems())
2929 MCAuto<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2930 arrOut->renumberInPlace(da3->getConstPointer());
2931 mesh2->setName(mesh->getName().c_str());
2932 ret->setMesh(mesh2);
2937 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 !!!";
2938 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2939 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2940 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2941 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2942 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2943 throw INTERP_KERNEL::Exception(oss.str());
2949 * This method is the most light method of field retrieving.
2951 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
2955 pflOut=DataArrayInt::New();
2956 pflOut->alloc(nbOfElems,1);
2961 pflOut=const_cast<DataArrayInt*>(pflIn);
2964 MCAuto<DataArrayInt> safePfl(pflOut);
2965 MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2966 const std::vector<std::string>& infos=getInfo();
2967 int nbOfComp=infos.size();
2968 for(int i=0;i<nbOfComp;i++)
2969 da->setInfoOnComponent(i,infos[i].c_str());
2980 static MFFPMIter *NewCell(const MEDFileEntities *entities);
2981 static bool IsPresenceOfNode(const MEDFileEntities *entities);
2982 virtual ~MFFPMIter() { }
2983 virtual void begin() = 0;
2984 virtual bool finished() const = 0;
2985 virtual void next() = 0;
2986 virtual int current() const = 0;
2989 class MFFPMIterSimple : public MFFPMIter
2992 MFFPMIterSimple():_pos(0) { }
2993 void begin() { _pos=0; }
2994 bool finished() const { return _pos>=MED_N_CELL_FIXED_GEO; }
2995 void next() { _pos++; }
2996 int current() const { return _pos; }
3001 class MFFPMIter2 : public MFFPMIter
3004 MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts);
3005 void begin() { _it=_ids.begin(); }
3006 bool finished() const { return _it==_ids.end(); }
3007 void next() { _it++; }
3008 int current() const { return *_it; }
3010 std::vector<int> _ids;
3011 std::vector<int>::const_iterator _it;
3014 MFFPMIter *MFFPMIter::NewCell(const MEDFileEntities *entities)
3017 return new MFFPMIterSimple;
3020 const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
3023 std::vector<INTERP_KERNEL::NormalizedCellType> tmp;
3024 const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
3025 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
3027 if((*it).first==ON_CELLS || (*it).first==ON_GAUSS_NE || (*it).first==ON_GAUSS_PT)
3028 tmp.push_back((*it).second);
3030 return new MFFPMIter2(tmp);
3032 return new MFFPMIterSimple;// for MEDFileAllStaticEntites and MEDFileAllStaticEntitiesPlusDyn cells are in
3036 bool MFFPMIter::IsPresenceOfNode(const MEDFileEntities *entities)
3042 const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
3045 const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
3046 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
3047 if((*it).first==ON_NODES)
3051 return true;// for MEDFileAllStaticEntites and MEDFileAllStaticEntitiesPlusDyn nodes are in
3055 MFFPMIter2::MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts)
3057 std::size_t sz(cts.size());
3059 for(std::size_t i=0;i<sz;i++)
3061 INTERP_KERNEL::NormalizedCellType *loc(std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,cts[i]));
3062 if(loc!=typmai2+MED_N_CELL_FIXED_GEO)
3063 _ids[i]=(int)std::distance(typmai2,loc);
3065 throw INTERP_KERNEL::Exception("MFFPMIter2 : The specified geo type does not exists !");
3071 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),
3074 INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
3075 INTERP_KERNEL::AutoPtr<char> pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
3076 INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
3077 const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
3078 INTERP_KERNEL::AutoCppPtr<MFFPMIter> iter0(MFFPMIter::NewCell(entities));
3079 for(iter0->begin();!iter0->finished();iter0->next())
3081 int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL ,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
3082 std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
3083 int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
3084 std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
3085 if(nbProfile>0 || nbProfile2>0)
3087 const PartDefinition *pd(0);
3089 pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[iter0->current()]),typmai2[iter0->current()]);
3090 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nasc,pd));
3097 if(MFFPMIter::IsPresenceOfNode(entities))
3099 int nbProfile(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName));
3102 const PartDefinition *pd(0);
3104 pd=mmu->getPartDefAtLevel(1,INTERP_KERNEL::NORM_ERROR);
3105 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd));
3106 setMeshName(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE));
3111 std::vector<int> dynGT(entities->getDynGTAvail());
3112 for(std::vector<int>::const_iterator it=dynGT.begin();it!=dynGT.end();it++)
3114 int nbPfl(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,*it,pflName,locName));
3117 _field_pm_pt.push_back(MEDFileFieldPerMeshPerTypeDyn::NewOnRead(fid,this,entities,*it,nasc));
3118 setMeshName(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE));
3123 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
3125 copyTinyInfoFrom(mesh);
3128 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3130 if(id>=(int)_pfls.size())
3132 _pfls[id]=DataArrayInt::New();
3133 int lgth(MEDprofileSizeByName(fid,pflName.c_str()));
3134 _pfls[id]->setName(pflName);
3135 _pfls[id]->alloc(lgth,1);
3136 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName.c_str(),_pfls[id]->getPointer()));
3137 _pfls[id]->applyLin(1,-1,0);//Converting into C format
3140 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
3142 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
3144 MEDFILESAFECALLERRD0(MEDprofileInfo,(fid,i+1,pflName,&sz));
3145 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
3146 if(i>=(int)_pfls.size())
3148 _pfls[i]=DataArrayInt::New();
3149 _pfls[i]->alloc(sz,1);
3150 _pfls[i]->setName(pflCpp.c_str());
3151 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName,_pfls[i]->getPointer()));
3152 _pfls[i]->applyLin(1,-1,0);//Converting into C format
3155 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3157 int nbOfPfls=_pfls.size();
3158 for(int i=0;i<nbOfPfls;i++)
3160 MCAuto<DataArrayInt> cpy=_pfls[i]->deepCopy();
3161 cpy->applyLin(1,1,0);
3162 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
3163 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
3164 MEDFILESAFECALLERWR0(MEDprofileWr,(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer()));
3167 int nbOfLocs=_locs.size();
3168 for(int i=0;i<nbOfLocs;i++)
3169 _locs[i]->writeLL(fid);
3172 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
3174 std::vector<std::string> pfls=getPfls();
3175 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
3177 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
3180 _pfls.push_back(*it);
3184 int id=std::distance(pfls.begin(),it2);
3185 if(!(*it)->isEqual(*_pfls[id]))
3187 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
3188 throw INTERP_KERNEL::Exception(oss.str());
3192 std::vector<std::string> locs=getLocs();
3193 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
3195 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
3198 _locs.push_back(*it);
3202 int id=std::distance(locs.begin(),it2);
3203 if(!(*it)->isEqual(*_locs[id],eps))
3205 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
3206 throw INTERP_KERNEL::Exception(oss.str());
3212 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
3214 for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
3215 getProfile((*it).c_str());
3218 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
3220 for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
3221 getLocalization((*it).c_str());
3224 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
3226 std::vector<std::string> profiles=real.getPflsReallyUsed();
3227 int sz=profiles.size();
3229 for(int i=0;i<sz;i++)
3230 loadProfileInFile(fid,i,profiles[i].c_str());
3232 std::vector<std::string> locs=real.getLocsReallyUsed();
3235 for(int i=0;i<sz;i++)
3236 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
3239 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid, const MEDFileEntities *entities)
3241 int nProfil=MEDnProfile(fid);
3242 for(int i=0;i<nProfil;i++)
3243 loadProfileInFile(fid,i);
3244 int sz=MEDnLocalization(fid);
3246 for(int i=0;i<sz;i++)
3248 _locs[i]=MEDFileFieldLoc::New(fid,i,entities);
3252 MEDFileFieldGlobs *MEDFileFieldGlobs::New(med_idt fid)
3254 return new MEDFileFieldGlobs(fid);
3257 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
3259 return new MEDFileFieldGlobs;
3262 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
3264 return _file_name.capacity()+_pfls.capacity()*sizeof(MCAuto<DataArrayInt>)+_locs.capacity()*sizeof(MCAuto<MEDFileFieldLoc>);
3267 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildrenWithNull() const
3269 std::vector<const BigMemoryObject *> ret;
3270 for(std::vector< MCAuto< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3271 ret.push_back((const DataArrayInt *)*it);
3272 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3273 ret.push_back((const MEDFileFieldLoc *)*it);
3277 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCopy() const
3279 MCAuto<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
3281 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3283 if((const DataArrayInt *)*it)
3284 ret->_pfls[i]=(*it)->deepCopy();
3287 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3289 if((const MEDFileFieldLoc*)*it)
3290 ret->_locs[i]=(*it)->deepCopy();
3296 * \throw if a profile in \a pfls in not in \a this.
3297 * \throw if a localization in \a locs in not in \a this.
3298 * \sa MEDFileFieldGlobs::deepCpyPart
3300 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
3302 MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
3303 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
3305 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
3307 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
3309 MCAuto<DataArrayInt> pfl2(pfl);
3310 ret->_pfls.push_back(pfl2);
3312 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
3314 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
3316 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
3318 MCAuto<MEDFileFieldLoc> loc2(loc);
3319 ret->_locs.push_back(loc2);
3321 ret->setFileName(getFileName());
3326 * \throw if a profile in \a pfls in not in \a this.
3327 * \throw if a localization in \a locs in not in \a this.
3328 * \sa MEDFileFieldGlobs::shallowCpyPart
3330 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
3332 MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
3333 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
3335 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
3337 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
3338 ret->_pfls.push_back(pfl->deepCopy());
3340 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
3342 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
3344 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
3345 ret->_locs.push_back(loc->deepCopy());
3347 ret->setFileName(getFileName());
3351 MEDFileFieldGlobs::MEDFileFieldGlobs(med_idt fid):_file_name(MEDFileWritable::FileNameFromFID(fid))
3355 MEDFileFieldGlobs::MEDFileFieldGlobs()
3359 MEDFileFieldGlobs::~MEDFileFieldGlobs()
3363 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
3365 oss << "Profiles :\n";
3366 std::size_t n=_pfls.size();
3367 for(std::size_t i=0;i<n;i++)
3369 oss << " - #" << i << " ";
3370 const DataArrayInt *pfl=_pfls[i];
3372 oss << "\"" << pfl->getName() << "\"\n";
3377 oss << "Localizations :\n";
3378 for(std::size_t i=0;i<n;i++)
3380 oss << " - #" << i << " ";
3381 const MEDFileFieldLoc *loc=_locs[i];
3383 loc->simpleRepr(oss);
3389 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3391 for(std::vector< MCAuto<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
3393 DataArrayInt *elt(*it);
3396 std::string name(elt->getName());
3397 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3399 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3401 elt->setName((*it2).second.c_str());
3409 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3411 for(std::vector< MCAuto<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
3413 MEDFileFieldLoc *elt(*it);
3416 std::string name(elt->getName());
3417 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3419 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3421 elt->setName((*it2).second.c_str());
3429 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
3431 if(locId<0 || locId>=(int)_locs.size())
3432 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
3433 return _locs[locId]->getNbOfGaussPtPerCell();
3436 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
3438 return getLocalizationFromId(getLocalizationId(locName));
3441 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
3443 if(locId<0 || locId>=(int)_locs.size())
3444 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3445 return *_locs[locId];
3449 namespace MEDCouplingImpl
3454 LocFinder(const std::string& loc):_loc(loc) { }
3455 bool operator() (const MCAuto<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
3457 const std::string &_loc;
3463 PflFinder(const std::string& pfl):_pfl(pfl) { }
3464 bool operator() (const MCAuto<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
3466 const std::string& _pfl;
3471 int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
3473 std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),MEDCouplingImpl::LocFinder(loc));
3476 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
3477 for(it=_locs.begin();it!=_locs.end();it++)
3478 oss << "\"" << (*it)->getName() << "\", ";
3479 throw INTERP_KERNEL::Exception(oss.str());
3481 return std::distance(_locs.begin(),it);
3485 * The returned value is never null.
3487 const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
3489 std::string pflNameCpp(pflName);
3490 std::vector< MCAuto<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3493 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3494 for(it=_pfls.begin();it!=_pfls.end();it++)
3495 oss << "\"" << (*it)->getName() << "\", ";
3496 throw INTERP_KERNEL::Exception(oss.str());
3501 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
3503 if(pflId<0 || pflId>=(int)_pfls.size())
3504 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3505 return _pfls[pflId];
3508 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
3510 if(locId<0 || locId>=(int)_locs.size())
3511 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3512 return *_locs[locId];
3515 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
3517 return getLocalizationFromId(getLocalizationId(locName));
3521 * The returned value is never null.
3523 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
3525 std::string pflNameCpp(pflName);
3526 std::vector< MCAuto<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3529 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3530 for(it=_pfls.begin();it!=_pfls.end();it++)
3531 oss << "\"" << (*it)->getName() << "\", ";
3532 throw INTERP_KERNEL::Exception(oss.str());
3537 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
3539 if(pflId<0 || pflId>=(int)_pfls.size())
3540 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3541 return _pfls[pflId];
3544 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
3546 std::vector< MCAuto<DataArrayInt> > newPfls;
3548 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3550 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
3551 newPfls.push_back(*it);
3556 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
3558 std::vector< MCAuto<MEDFileFieldLoc> > newLocs;
3560 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3562 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
3563 newLocs.push_back(*it);
3568 void MEDFileFieldGlobs::killStructureElementsInGlobs()
3570 std::vector< MCAuto<MEDFileFieldLoc> > newLocs;
3571 for(std::vector< MCAuto<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
3575 if(!(*it)->isOnStructureElement())
3576 newLocs.push_back(*it);
3581 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
3583 int sz=_pfls.size();
3584 std::vector<std::string> ret(sz);
3585 for(int i=0;i<sz;i++)
3586 ret[i]=_pfls[i]->getName();
3590 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
3592 int sz=_locs.size();
3593 std::vector<std::string> ret(sz);
3594 for(int i=0;i<sz;i++)
3595 ret[i]=_locs[i]->getName();
3599 bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
3601 std::vector<std::string> v=getPfls();
3602 std::string s(pflName);
3603 return std::find(v.begin(),v.end(),s)!=v.end();
3606 bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
3608 std::vector<std::string> v=getLocs();
3609 std::string s(locName);
3610 return std::find(v.begin(),v.end(),s)!=v.end();
3613 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
3615 std::map<int,std::vector<int> > m;
3617 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3619 const DataArrayInt *tmp=(*it);
3622 m[tmp->getHashCode()].push_back(i);
3625 std::vector< std::vector<int> > ret;
3626 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
3628 if((*it2).second.size()>1)
3630 std::vector<int> ret0;
3631 bool equalityOrNot=false;
3632 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
3634 std::vector<int>::const_iterator it4=it3; it4++;
3635 for(;it4!=(*it2).second.end();it4++)
3637 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
3640 ret0.push_back(*it3);
3641 ret0.push_back(*it4);
3647 ret.push_back(ret0);
3653 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
3655 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
3658 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
3660 std::string name(pfl->getName());
3662 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
3663 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3664 if(name==(*it)->getName())
3666 if(!pfl->isEqual(*(*it)))
3668 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
3669 throw INTERP_KERNEL::Exception(oss.str());
3673 _pfls.push_back(pfl);
3676 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)
3678 std::string name(locName);
3680 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
3681 MCAuto<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
3682 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3683 if((*it)->isName(locName))
3685 if(!(*it)->isEqual(*obj,1e-12))
3687 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
3688 throw INTERP_KERNEL::Exception(oss.str());
3691 _locs.push_back(obj);
3694 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
3696 std::vector<std::string> names=getPfls();
3697 return CreateNewNameNotIn("NewPfl_",names);
3700 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
3702 std::vector<std::string> names=getLocs();
3703 return CreateNewNameNotIn("NewLoc_",names);
3706 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
3708 for(std::size_t sz=0;sz<100000;sz++)
3710 std::ostringstream tryName;
3711 tryName << prefix << sz;
3712 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
3713 return tryName.str();
3715 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
3719 * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
3720 * \param [in] fname - the file name.
3722 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(med_idt fid):_globals(MEDFileFieldGlobs::New(fid))
3727 * Creates an empty MEDFileFieldGlobsReal.
3729 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
3733 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
3738 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildrenWithNull() const
3740 std::vector<const BigMemoryObject *> ret;
3741 ret.push_back((const MEDFileFieldGlobs *)_globals);
3746 * Returns a string describing profiles and Gauss points held in \a this.
3747 * \return std::string - the description string.
3749 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
3751 const MEDFileFieldGlobs *glob=_globals;
3752 std::ostringstream oss2; oss2 << glob;
3753 std::string stars(oss2.str().length(),'*');
3754 oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n";
3756 glob->simpleRepr(oss);
3758 oss << "NO GLOBAL INFORMATION !\n";
3761 void MEDFileFieldGlobsReal::resetContent()
3763 _globals=MEDFileFieldGlobs::New();
3766 void MEDFileFieldGlobsReal::killStructureElementsInGlobs()
3768 contentNotNull()->killStructureElementsInGlobs();
3771 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
3776 * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
3777 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3779 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3781 _globals=other._globals;
3785 * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3786 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3788 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3790 const MEDFileFieldGlobs *otherg(other._globals);
3793 _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3797 * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3798 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3800 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3802 const MEDFileFieldGlobs *otherg(other._globals);
3805 _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3808 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3810 _globals=other._globals;
3811 if((const MEDFileFieldGlobs *)_globals)
3812 _globals=other._globals->deepCopy();
3816 * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3817 * \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3818 * \param [in] eps - a precision used to compare Gauss points with same name held by
3819 * \a this and \a other MEDFileFieldGlobsReal.
3820 * \throw If \a this and \a other hold profiles with equal names but different ids.
3821 * \throw If \a this and \a other hold different Gauss points with equal names.
3823 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
3825 const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3826 if(thisGlobals==otherGlobals)
3830 _globals=other._globals;
3833 _globals->appendGlobs(*other._globals,eps);
3836 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
3838 checkGlobsPflsPartCoherency();
3839 checkGlobsLocsPartCoherency();
3842 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
3844 contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3847 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
3849 contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3852 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3854 contentNotNull()->loadProfileInFile(fid,id,pflName);
3857 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3859 contentNotNull()->loadProfileInFile(fid,id);
3862 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
3864 contentNotNull()->loadGlobals(fid,*this);
3867 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid, const MEDFileEntities *entities)
3869 contentNotNull()->loadAllGlobals(fid,entities);
3872 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3874 contentNotNull()->writeGlobals(fid,opt);
3878 * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3879 * or getPflsReallyUsedMulti().
3880 * \return std::vector<std::string> - a sequence of names of all profiles.
3882 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3884 return contentNotNull()->getPfls();
3888 * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3889 * or getLocsReallyUsedMulti().
3890 * \return std::vector<std::string> - a sequence of names of all localizations.
3892 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3894 return contentNotNull()->getLocs();
3898 * Checks if the profile with a given name exists.
3899 * \param [in] pflName - the profile name of interest.
3900 * \return bool - \c true if the profile named \a pflName exists.
3902 bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
3904 return contentNotNull()->existsPfl(pflName);
3908 * Checks if the localization with a given name exists.
3909 * \param [in] locName - the localization name of interest.
3910 * \return bool - \c true if the localization named \a locName exists.
3912 bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
3914 return contentNotNull()->existsLoc(locName);
3917 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
3919 return contentNotNull()->createNewNameOfPfl();
3922 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
3924 return contentNotNull()->createNewNameOfLoc();
3928 * Sets the name of a MED file.
3929 * \param [inout] fileName - the file name.
3931 void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
3933 contentNotNull()->setFileName(fileName);
3937 * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3938 * in the same order.
3939 * \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3940 * Each item of this sequence is a vector containing ids of equal profiles.
3942 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3944 return contentNotNull()->whichAreEqualProfiles();
3948 * Finds equal localizations.
3949 * \param [in] eps - a precision used to compare real values of the localizations.
3950 * \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3951 * Each item of this sequence is a vector containing ids of equal localizations.
3953 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3955 return contentNotNull()->whichAreEqualLocs(eps);
3959 * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3960 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3961 * this sequence is a pair whose
3962 * - the first item is a vector of profile names to replace by the second item,
3963 * - the second item is a profile name to replace every profile name of the first item.
3965 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3967 contentNotNull()->changePflsNamesInStruct(mapOfModif);
3971 * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3972 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3973 * this sequence is a pair whose
3974 * - the first item is a vector of localization names to replace by the second item,
3975 * - the second item is a localization name to replace every localization name of the first item.
3977 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3979 contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3983 * Replaces references to some profiles (a reference is a profile name) by references
3984 * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3985 * them-selves accordingly. <br>
3986 * This method is a generalization of changePflName().
3987 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3988 * this sequence is a pair whose
3989 * - the first item is a vector of profile names to replace by the second item,
3990 * - the second item is a profile name to replace every profile of the first item.
3991 * \sa changePflsRefsNamesGen()
3992 * \sa changePflName()
3994 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3996 changePflsRefsNamesGen(mapOfModif);
3997 changePflsNamesInStruct(mapOfModif);
4001 * Replaces references to some localizations (a reference is a localization name) by references
4002 * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
4003 * them-selves accordingly. <br>
4004 * This method is a generalization of changeLocName().
4005 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
4006 * this sequence is a pair whose
4007 * - the first item is a vector of localization names to replace by the second item,
4008 * - the second item is a localization name to replace every localization of the first item.
4009 * \sa changeLocsRefsNamesGen()
4010 * \sa changeLocName()
4012 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4014 changeLocsRefsNamesGen(mapOfModif);
4015 changeLocsNamesInStruct(mapOfModif);
4019 * Renames the profile having a given name and updates references to this profile.
4020 * \param [in] oldName - the name of the profile to rename.
4021 * \param [in] newName - a new name of the profile.
4022 * \sa changePflsNames().
4024 void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
4026 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
4027 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
4029 changePflsNames(mapOfModif);
4033 * Renames the localization having a given name and updates references to this localization.
4034 * \param [in] oldName - the name of the localization to rename.
4035 * \param [in] newName - a new name of the localization.
4036 * \sa changeLocsNames().
4038 void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
4040 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
4041 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
4043 changeLocsNames(mapOfModif);
4047 * Removes duplicated profiles. Returns a map used to update references to removed
4048 * profiles via changePflsRefsNamesGen().
4049 * Equal profiles are found using whichAreEqualProfiles().
4050 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
4051 * a sequence describing the performed replacements of profiles. Each element of
4052 * this sequence is a pair whose
4053 * - the first item is a vector of profile names replaced by the second item,
4054 * - the second item is a profile name replacing every profile of the first item.
4056 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
4058 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
4059 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
4061 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
4063 std::vector< std::string > tmp((*it).size());
4065 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
4066 tmp[j]=std::string(getProfileFromId(*it2)->getName());
4067 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
4069 std::vector<int> tmp2((*it).begin()+1,(*it).end());
4070 killProfileIds(tmp2);
4072 changePflsRefsNamesGen(ret);
4077 * Removes duplicated localizations. Returns a map used to update references to removed
4078 * localizations via changeLocsRefsNamesGen().
4079 * Equal localizations are found using whichAreEqualLocs().
4080 * \param [in] eps - a precision used to compare real values of the localizations.
4081 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
4082 * a sequence describing the performed replacements of localizations. Each element of
4083 * this sequence is a pair whose
4084 * - the first item is a vector of localization names replaced by the second item,
4085 * - the second item is a localization name replacing every localization of the first item.
4087 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
4089 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
4090 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
4092 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
4094 std::vector< std::string > tmp((*it).size());
4096 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
4097 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
4098 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
4100 std::vector<int> tmp2((*it).begin()+1,(*it).end());
4101 killLocalizationIds(tmp2);
4103 changeLocsRefsNamesGen(ret);
4108 * Returns number of Gauss points per cell in a given localization.
4109 * \param [in] locId - an id of the localization of interest.
4110 * \return int - the number of the Gauss points per cell.
4112 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
4114 return contentNotNull()->getNbOfGaussPtPerCell(locId);
4118 * Returns an id of a localization by its name.
4119 * \param [in] loc - the localization name of interest.
4120 * \return int - the id of the localization.
4121 * \throw If there is no a localization named \a loc.
4123 int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
4125 return contentNotNull()->getLocalizationId(loc);
4129 * Returns the name of the MED file.
4130 * \return const std::string& - the MED file name.
4132 std::string MEDFileFieldGlobsReal::getFileName() const
4134 return contentNotNull()->getFileName();
4138 * Returns a localization object by its name.
4139 * \param [in] locName - the name of the localization of interest.
4140 * \return const MEDFileFieldLoc& - the localization object having the name \a locName.
4141 * \throw If there is no a localization named \a locName.
4143 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
4145 return contentNotNull()->getLocalization(locName);
4149 * Returns a localization object by its id.
4150 * \param [in] locId - the id of the localization of interest.
4151 * \return const MEDFileFieldLoc& - the localization object having the id \a locId.
4152 * \throw If there is no a localization with id \a locId.
4154 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
4156 return contentNotNull()->getLocalizationFromId(locId);
4160 * Returns a profile array by its name.
4161 * \param [in] pflName - the name of the profile of interest.
4162 * \return const DataArrayInt * - the profile array having the name \a pflName.
4163 * \throw If there is no a profile named \a pflName.
4165 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
4167 return contentNotNull()->getProfile(pflName);
4171 * Returns a profile array by its id.
4172 * \param [in] pflId - the id of the profile of interest.
4173 * \return const DataArrayInt * - the profile array having the id \a pflId.
4174 * \throw If there is no a profile with id \a pflId.
4176 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
4178 return contentNotNull()->getProfileFromId(pflId);
4182 * Returns a localization object, apt for modification, by its id.
4183 * \param [in] locId - the id of the localization of interest.
4184 * \return MEDFileFieldLoc& - a non-const reference to the localization object
4185 * having the id \a locId.
4186 * \throw If there is no a localization with id \a locId.
4188 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
4190 return contentNotNull()->getLocalizationFromId(locId);
4194 * Returns a localization object, apt for modification, by its name.
4195 * \param [in] locName - the name of the localization of interest.
4196 * \return MEDFileFieldLoc& - a non-const reference to the localization object
4197 * having the name \a locName.
4198 * \throw If there is no a localization named \a locName.
4200 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
4202 return contentNotNull()->getLocalization(locName);
4206 * Returns a profile array, apt for modification, by its name.
4207 * \param [in] pflName - the name of the profile of interest.
4208 * \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
4209 * \throw If there is no a profile named \a pflName.
4211 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
4213 return contentNotNull()->getProfile(pflName);
4217 * Returns a profile array, apt for modification, by its id.
4218 * \param [in] pflId - the id of the profile of interest.
4219 * \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
4220 * \throw If there is no a profile with id \a pflId.
4222 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
4224 return contentNotNull()->getProfileFromId(pflId);
4228 * Removes profiles given by their ids. No data is updated to track this removal.
4229 * \param [in] pflIds - a sequence of ids of the profiles to remove.
4231 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
4233 contentNotNull()->killProfileIds(pflIds);
4237 * Removes localizations given by their ids. No data is updated to track this removal.
4238 * \param [in] locIds - a sequence of ids of the localizations to remove.
4240 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
4242 contentNotNull()->killLocalizationIds(locIds);
4246 * Stores a profile array.
4247 * \param [in] pfl - the profile array to store.
4248 * \throw If the name of \a pfl is empty.
4249 * \throw If a profile with the same name as that of \a pfl already exists but contains
4252 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
4254 contentNotNull()->appendProfile(pfl);
4258 * Adds a new localization of Gauss points.
4259 * \param [in] locName - the name of the new localization.
4260 * \param [in] geoType - a geometrical type of the reference cell.
4261 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
4262 * must be \c nbOfNodesPerCell * \c dimOfType.
4263 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
4264 * must be _wg_.size() * \c dimOfType.
4265 * \param [in] w - the weights of Gauss points.
4266 * \throw If \a locName is empty.
4267 * \throw If a localization with the name \a locName already exists but is
4268 * different form the new one.
4270 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)
4272 contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
4275 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
4277 MEDFileFieldGlobs *g(_globals);
4279 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
4283 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
4285 const MEDFileFieldGlobs *g(_globals);
4287 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
4291 //= MEDFileFieldNameScope
4293 MEDFileFieldNameScope::MEDFileFieldNameScope()
4297 MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName, const std::string& meshName):_name(fieldName),_mesh_name(meshName)
4302 * Returns the name of \a this field.
4303 * \return std::string - a string containing the field name.
4305 std::string MEDFileFieldNameScope::getName() const
4311 * Sets name of \a this field
4312 * \param [in] name - the new field name.
4314 void MEDFileFieldNameScope::setName(const std::string& fieldName)
4319 std::string MEDFileFieldNameScope::getDtUnit() const
4324 void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
4329 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
4332 _mesh_name=other._mesh_name;
4333 _dt_unit=other._dt_unit;
4337 * Returns the mesh name.
4338 * \return std::string - a string holding the mesh name.
4339 * \throw If \c _field_per_mesh.empty()
4341 std::string MEDFileFieldNameScope::getMeshName() const
4346 void MEDFileFieldNameScope::setMeshName(const std::string& meshName)
4348 _mesh_name=meshName;
4351 //= MEDFileAnyTypeField1TSWithoutSDA
4353 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
4355 _field_per_mesh.resize(other._field_per_mesh.size());
4357 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
4359 if((const MEDFileFieldPerMesh *)*it)
4360 _field_per_mesh[i]=(*it)->deepCopy(this);
4364 void MEDFileAnyTypeField1TSWithoutSDA::accept(MEDFileFieldVisitor& visitor) const
4366 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4367 if((*it).isNotNull())
4369 visitor.newMeshEntry(*it);
4370 (*it)->accept(visitor);
4371 visitor.endMeshEntry(*it);
4376 * Prints a string describing \a this field into a stream. This string is outputted
4377 * by \c print Python command.
4378 * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
4379 * \param [in,out] oss - the out stream.
4380 * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
4381 * info id printed, else, not.
4383 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
4385 std::string startOfLine(bkOffset,' ');
4386 oss << startOfLine << "Field ";
4388 oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
4389 oss << "on one time Step ";
4391 oss << "(" << f1tsId << ") ";
4392 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
4393 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
4394 const DataArray *arr=getUndergroundDataArray();
4397 const std::vector<std::string> &comps=arr->getInfoOnComponents();
4400 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
4401 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
4402 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
4404 if(arr->isAllocated())
4406 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
4409 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
4413 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
4415 oss << startOfLine << "----------------------" << std::endl;
4416 if(!_field_per_mesh.empty())
4419 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
4421 const MEDFileFieldPerMesh *cur=(*it2);
4423 cur->simpleRepr(bkOffset,oss,i);
4425 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
4430 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
4432 oss << startOfLine << "----------------------" << std::endl;
4435 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
4437 const DataArray *arr(getUndergroundDataArray());
4439 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
4440 int nbOfCompo=arr->getNumberOfComponents();
4441 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
4442 for(int i=0;i<nbOfCompo;i++)
4445 std::vector<int> v(1,i);
4446 MCAuto<DataArray> arr2=arr->keepSelectedComponents(v);
4447 ret[i]->setArray(arr2);
4452 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order):MEDFileFieldNameScope(fieldName,meshName),_iteration(iteration),_order(order),_csit(csit),_nb_of_tuples_to_be_allocated(-2)
4456 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
4461 * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
4462 * empty. Returns -1 if this in on nodes.
4463 * \return int - the dimension of \a this.
4465 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
4468 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4469 (*it)->getDimension(ret);
4473 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
4476 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4478 MEDFileFieldPerMesh *cur(*it);
4480 ret=cur->changeMeshNames(modifTab) || ret;
4486 * Returns the number of iteration of the state of underlying mesh.
4487 * \return int - the iteration number.
4488 * \throw If \c _field_per_mesh.empty()
4490 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
4492 if(_field_per_mesh.empty())
4493 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
4494 return _field_per_mesh[0]->getMeshIteration();
4498 * Returns the order number of iteration of the state of underlying mesh.
4499 * \return int - the order number.
4500 * \throw If \c _field_per_mesh.empty()
4502 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
4504 if(_field_per_mesh.empty())
4505 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
4506 return _field_per_mesh[0]->getMeshOrder();
4510 * Checks if \a this field is tagged by a given iteration number and a given
4511 * iteration order number.
4512 * \param [in] iteration - the iteration number of interest.
4513 * \param [in] order - the iteration order number of interest.
4514 * \return bool - \c true if \a this->getIteration() == \a iteration &&
4515 * \a this->getOrder() == \a order.
4517 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
4519 return iteration==_iteration && order==_order;
4523 * Returns number of iteration and order number of iteration when
4524 * \a this field has been calculated.
4525 * \return std::pair<int,int> - a pair of the iteration number and the iteration
4528 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
4530 std::pair<int,int> p;
4536 * Returns number of iteration and order number of iteration when
4537 * \a this field has been calculated.
4538 * \param [in,out] p - a pair returning the iteration number and the iteration
4541 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
4548 * Returns all types of spatial discretization of \a this field.
4549 * \param [in,out] types - a sequence of types of \a this field.
4551 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
4553 std::set<TypeOfField> types2;
4554 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4556 (*it)->fillTypesOfFieldAvailable(types2);
4558 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
4559 std::copy(types2.begin(),types2.end(),bi);
4563 * Returns all types of spatial discretization of \a this field.
4564 * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
4567 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
4569 std::vector<TypeOfField> ret;
4570 fillTypesOfFieldAvailable(ret);
4574 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
4576 std::vector<std::string> ret;
4577 std::set<std::string> ret2;
4578 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4580 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
4581 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4582 if(ret2.find(*it2)==ret2.end())
4584 ret.push_back(*it2);
4591 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
4593 std::vector<std::string> ret;
4594 std::set<std::string> ret2;
4595 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4597 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
4598 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4599 if(ret2.find(*it2)==ret2.end())
4601 ret.push_back(*it2);
4608 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
4610 std::vector<std::string> ret;
4611 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4613 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
4614 ret.insert(ret.end(),tmp.begin(),tmp.end());
4619 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
4621 std::vector<std::string> ret;
4622 std::set<std::string> ret2;
4623 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4625 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
4626 ret.insert(ret.end(),tmp.begin(),tmp.end());
4631 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4633 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4634 (*it)->changePflsRefsNamesGen(mapOfModif);
4637 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4639 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4640 (*it)->changeLocsRefsNamesGen(mapOfModif);
4644 * Returns all attributes of parts of \a this field lying on a given mesh.
4645 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4646 * item of every of returned sequences refers to the _i_-th part of \a this field.
4647 * Thus all sequences returned by this method are of the same length equal to number
4648 * of different types of supporting entities.<br>
4649 * A field part can include sub-parts with several different spatial discretizations,
4650 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
4651 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4652 * of a nested sequence corresponds to a type of spatial discretization.<br>
4653 * This method allows for iteration over MEDFile DataStructure without any overhead.
4654 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4655 * for the case with only one underlying mesh. (Actually, the number of meshes is
4656 * not checked if \a mname == \c NULL).
4657 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4658 * a field part is returned.
4659 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4660 * This sequence is of the same length as \a types.
4661 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4662 * discretization. A profile name can be empty.
4663 * Length of this and of nested sequences is the same as that of \a typesF.
4664 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4665 * discretization. A localization name can be empty.
4666 * Length of this and of nested sequences is the same as that of \a typesF.
4667 * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
4668 * of ids of tuples within the data array, per each type of spatial
4669 * discretization within one mesh entity type.
4670 * Length of this and of nested sequences is the same as that of \a typesF.
4671 * \throw If no field is lying on \a mname.
4673 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
4675 if(_field_per_mesh.empty())
4676 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4677 return _field_per_mesh[0]->getFieldSplitedByType(types,typesF,pfls,locs);
4681 * Returns dimensions of mesh elements \a this field lies on. The returned value is a
4682 * maximal absolute dimension and values returned via the out parameter \a levs are
4683 * dimensions relative to the maximal absolute dimension. <br>
4684 * This method is designed for MEDFileField1TS instances that have a discretization
4685 * \ref MEDCoupling::ON_CELLS "ON_CELLS",
4686 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT",
4687 * \ref MEDCoupling::ON_GAUSS_NE "ON_GAUSS_NE".
4688 * Only these 3 discretizations will be taken into account here. If \a this is
4689 * \ref MEDCoupling::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
4690 * This method is useful to make the link between the dimension of the underlying mesh
4691 * and the levels of \a this, because it is possible that the highest dimension of \a this
4692 * field is not equal to the dimension of the underlying mesh.
4694 * Let's consider the following case:
4695 * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
4696 * TETRA4, HEXA8, TRI3 and SEG2.
4697 * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
4698 * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
4700 * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
4701 * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
4702 * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
4703 * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
4704 * parameter of getFieldAtLevel() is computed basing on the returned values as this:
4705 * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
4707 * to retrieve the highest level of
4708 * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br>
4709 * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
4710 * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
4711 * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
4712 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4713 * for the case with only one underlying mesh. (Actually, the number of meshes is
4714 * not checked if \a mname == \c NULL).
4715 * \param [in,out] levs - a sequence returning the dimensions relative to the maximal
4716 * absolute one. They are in decreasing order. This sequence is cleared before
4718 * \return int - the maximal absolute dimension of elements \a this fields lies on.
4719 * \throw If no field is lying on \a mname.
4721 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
4724 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4725 std::vector< std::vector<TypeOfField> > typesF;
4726 std::vector< std::vector<std::string> > pfls, locs;
4727 if(_field_per_mesh.empty())
4728 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels : This is empty !");
4729 _field_per_mesh[0]->getFieldSplitedByType(types,typesF,pfls,locs);
4731 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
4732 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
4733 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
4735 st.erase(INTERP_KERNEL::NORM_ERROR);
4737 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
4739 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
4740 ret1.insert((int)cm.getDimension());
4742 int ret=*std::max_element(ret1.begin(),ret1.end());
4743 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
4744 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
4748 void MEDFileAnyTypeField1TSWithoutSDA::convertMedBallIntoClassic()
4750 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it<_field_per_mesh.end();it++)
4751 if((*it).isNotNull())
4752 (*it)->convertMedBallIntoClassic();
4755 void MEDFileAnyTypeField1TSWithoutSDA::makeReduction(INTERP_KERNEL::NormalizedCellType ct, TypeOfField tof, const DataArrayInt *pfl)
4758 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : null pfl !");
4759 std::string name(pfl->getName());
4760 pfl->checkAllocated();
4761 if(pfl->getNumberOfComponents()!=1)
4762 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : non mono compo array !");
4764 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : empty pfl name !");
4765 if(_field_per_mesh.size()!=1)
4766 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : only single mesh supported !");
4767 MCAuto<MEDFileFieldPerMesh> fpm(_field_per_mesh[0]);
4769 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : only single not null mesh supported !");
4770 MEDFileFieldPerMeshPerTypePerDisc *disc(fpm->getLeafGivenTypeAndLocId(ct,0));
4771 if(disc->getType()!=tof)
4772 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : error !");
4773 int s(disc->getStart()),e(disc->getEnd()),nt(pfl->getNumberOfTuples());
4774 DataArray *arr(getUndergroundDataArray());
4775 int nt2(arr->getNumberOfTuples()),delta((e-s)-nt);
4777 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : internal error !");
4778 MCAuto<DataArray> arr0(arr->selectByTupleIdSafeSlice(0,s,1)),arr1(arr->selectByTupleIdSafeSlice(s,e,1)),arr2(arr->selectByTupleIdSafeSlice(e,nt2,1));
4779 MCAuto<DataArray> arr11(arr1->selectByTupleIdSafe(pfl->begin(),pfl->end()));
4780 MCAuto<DataArray> arrOut(arr->buildNewEmptyInstance());
4781 arrOut->alloc(nt2-delta,arr->getNumberOfComponents());
4782 arrOut->copyStringInfoFrom(*arr);
4783 arrOut->setContigPartOfSelectedValuesSlice(0,arr0,0,s,1);
4784 arrOut->setContigPartOfSelectedValuesSlice(s,arr11,0,nt,1);
4785 arrOut->setContigPartOfSelectedValuesSlice(e-delta,arr2,0,nt2-e,1);
4787 disc->setEnd(e-delta);
4788 disc->setProfile(name);
4792 * \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.
4793 * \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.
4794 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4795 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4797 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
4799 if(_field_per_mesh.empty())
4800 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId : This is empty !");
4801 return _field_per_mesh[0]->getLeafGivenTypeAndLocId(typ,locId);
4805 * \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.
4806 * \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.
4807 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4808 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4810 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
4812 if(_field_per_mesh.empty())
4813 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId : This is empty !");
4814 return _field_per_mesh[0]->getLeafGivenTypeAndLocId(typ,locId);
4818 * \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.
4820 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
4822 if(_field_per_mesh.empty())
4823 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4826 std::string mName2(mName);
4828 std::vector<std::string> msg;
4829 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4830 if(mName2==(*it)->getMeshName())
4833 msg.push_back((*it)->getMeshName());
4834 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4835 oss << "Possible meshes are : ";
4836 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4837 oss << "\"" << (*it2) << "\" ";
4838 throw INTERP_KERNEL::Exception(oss.str());
4841 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
4844 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4845 std::string tmp(mesh->getName());
4847 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4849 std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4851 for(;it!=_field_per_mesh.end();it++,i++)
4853 if((*it)->getMeshName()==tmp)
4856 int sz=_field_per_mesh.size();
4857 _field_per_mesh.resize(sz+1);
4858 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4862 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4863 MEDFileFieldGlobsReal& glob)
4866 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4868 MEDFileFieldPerMesh *fpm(*it);
4870 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4876 * This method splits \a this into several sub-parts so that each sub parts have exactly one spatial discretization. This method implements the minimal
4877 * splitting that leads to single spatial discretization of this.
4879 * \sa splitMultiDiscrPerGeoTypes
4881 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
4883 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4884 std::vector< std::vector<TypeOfField> > typesF;
4885 std::vector< std::vector<std::string> > pfls,locs;
4886 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4887 std::set<TypeOfField> allEnt;
4888 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4889 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4890 allEnt.insert(*it2);
4891 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4892 std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4893 for(std::size_t i=0;i<allEnt.size();i++,it3++)
4895 std::vector< std::pair<int,int> > its;
4896 ret[i]=shallowCpy();
4897 int newLgth(ret[i]->keepOnlySpatialDiscretization(*it3,its));
4898 ret[i]->updateData(newLgth,its);
4904 * This method performs a sub splitting as splitDiscretizations does but finer. This is the finest spliting level that can be done.
4905 * This method implements the minimal splitting so that each returned elements are mono Gauss discretization per geometric type.
4907 * \sa splitDiscretizations
4909 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes() const
4911 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4912 std::vector< std::vector<TypeOfField> > typesF;
4913 std::vector< std::vector<std::string> > pfls,locs;
4914 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4915 std::set<TypeOfField> allEnt;
4916 std::size_t nbOfMDPGT(0),ii(0);
4917 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++,ii++)
4919 nbOfMDPGT=std::max(nbOfMDPGT,locs[ii].size());
4920 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4921 allEnt.insert(*it2);
4923 if(allEnt.size()!=1)
4924 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : this field is expected to be defined only on one spatial discretization !");
4926 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
4929 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret0(1);
4930 ret0[0]=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(this); this->incrRef();
4933 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfMDPGT);
4934 for(std::size_t i=0;i<nbOfMDPGT;i++)
4936 std::vector< std::pair<int,int> > its;
4937 ret[i]=shallowCpy();
4938 int newLgth(ret[i]->keepOnlyGaussDiscretization(i,its));
4939 ret[i]->updateData(newLgth,its);
4944 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
4946 int globalCounter(0);
4947 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4948 (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4949 return globalCounter;
4952 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlyGaussDiscretization(std::size_t idOfDisc, std::vector< std::pair<int,int> >& its)
4954 int globalCounter(0);
4955 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4956 (*it)->keepOnlyGaussDiscretization(idOfDisc,globalCounter,its);
4957 return globalCounter;
4960 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
4962 if(_nb_of_tuples_to_be_allocated>=0)
4964 _nb_of_tuples_to_be_allocated=newLgth;
4965 const DataArray *oldArr(getUndergroundDataArray());
4968 MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4969 newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
4971 _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
4975 if(_nb_of_tuples_to_be_allocated==-1)
4977 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4979 const DataArray *oldArr(getUndergroundDataArray());
4980 if(!oldArr || !oldArr->isAllocated())
4981 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4982 MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4983 newArr->alloc(newLgth,getNumberOfComponents());
4985 newArr->copyStringInfoFrom(*oldArr);
4987 for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4989 if((*it).second<(*it).first)
4990 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4991 newArr->setContigPartOfSelectedValuesSlice(pos,oldArr,(*it).first,(*it).second,1);
4992 pos+=(*it).second-(*it).first;
4997 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
5000 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
5002 if(_field_per_mesh.empty())
5003 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
5004 if(_field_per_mesh.size()>1)
5005 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
5006 _field_per_mesh[0]->copyOptionsFrom(opts);
5007 _field_per_mesh[0]->writeLL(fid,nasc);
5011 * 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.
5012 * If false is returned the memory allocation is not required.
5014 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
5016 if(_nb_of_tuples_to_be_allocated>=0)
5018 getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
5019 _nb_of_tuples_to_be_allocated=-2;
5022 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
5024 if(_nb_of_tuples_to_be_allocated==-1)
5025 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
5026 if(_nb_of_tuples_to_be_allocated<-3)
5027 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
5028 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
5031 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
5033 med_int numdt,numit;
5035 med_int meshnumdt,meshnumit;
5036 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt));
5040 INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
5041 MEDFILESAFECALLERRD0(MEDfield23ComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit)); // to check with Adrien for legacy MED files
5043 //MEDFILESAFECALLERRD0(MEDfieldComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt,&meshnumdt,&meshnumit));
5044 if(_iteration!=numdt || _order!=numit)
5045 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
5046 _field_per_mesh.resize(1);
5051 mm=ms->getMeshWithName(getMeshName());
5054 _field_per_mesh[0]=MEDFileFieldPerMesh::NewOnRead(fid,this,0,meshnumdt,meshnumit,nasc,mm,entities);
5055 _nb_of_tuples_to_be_allocated=0;
5056 _field_per_mesh[0]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
5059 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
5061 allocIfNecessaryTheArrayToReceiveDataFromFile();
5062 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5063 (*it)->loadBigArraysRecursively(fid,nasc);
5066 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
5068 if(allocIfNecessaryTheArrayToReceiveDataFromFile())
5069 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5070 (*it)->loadBigArraysRecursively(fid,nasc);
5073 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
5075 loadOnlyStructureOfDataRecursively(fid,nasc,ms,entities);
5076 loadBigArraysRecursively(fid,nasc);
5079 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
5081 DataArray *thisArr(getUndergroundDataArray());
5082 if(thisArr && thisArr->isAllocated())
5084 _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
5085 thisArr->desallocate();
5089 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
5091 return _mesh_name.capacity()+_dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MCAuto< MEDFileFieldPerMesh >);
5094 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
5096 std::vector<const BigMemoryObject *> ret;
5097 if(getUndergroundDataArray())
5098 ret.push_back(getUndergroundDataArray());
5099 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5100 ret.push_back((const MEDFileFieldPerMesh *)*it);
5105 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
5106 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
5107 * "Sort By Type"), if not, an exception is thrown.
5108 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
5109 * \param [in] arr - the array of values.
5110 * \param [in,out] glob - the global data where profiles and localization present in
5111 * \a field, if any, are added.
5112 * \throw If the name of \a field is empty.
5113 * \throw If the data array of \a field is not set.
5114 * \throw If \a this->_arr is already allocated but has different number of components
5116 * \throw If the underlying mesh of \a field has no name.
5117 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
5119 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
5121 const MEDCouplingMesh *mesh(field->getMesh());
5123 TypeOfField type(field->getTypeOfField());
5124 std::vector<DataArrayInt *> dummy;
5126 setMeshName(mesh->getName());
5127 int start(copyTinyInfoFrom(th,field,arr));
5128 int pos(addNewEntryIfNecessary(mesh));
5131 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
5132 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
5135 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
5139 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
5140 * of a given mesh are used as the support of the given field (a real support is not used).
5141 * Elements of the given mesh must be sorted suitable for writing to MED file.
5142 * Order of underlying mesh entities of the given field specified by \a profile parameter
5143 * is not prescribed; this method permutes field values to have them sorted by element
5144 * type as required for writing to MED file. A new profile is added only if no equal
5145 * profile is missing.
5146 * \param [in] field - the field to add to \a this. The field double values are ignored.
5147 * \param [in] arrOfVals - the values of the field \a field used.
5148 * \param [in] mesh - the supporting mesh of \a field.
5149 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
5150 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
5151 * \param [in,out] glob - the global data where profiles and localization present in
5152 * \a field, if any, are added.
5153 * \throw If either \a field or \a mesh or \a profile has an empty name.
5154 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
5155 * \throw If the data array of \a field is not set.
5156 * \throw If \a this->_arr is already allocated but has different number of components
5158 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
5159 * \sa setFieldNoProfileSBT()
5161 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
5164 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
5165 if(!arrOfVals || !arrOfVals->isAllocated())
5166 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
5167 TypeOfField type=field->getTypeOfField();
5168 std::vector<DataArrayInt *> idsInPflPerType;
5169 std::vector<DataArrayInt *> idsPerType;
5170 std::vector<int> code,code2;
5171 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
5174 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
5175 std::vector< MCAuto<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
5176 std::vector< MCAuto<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin());
5177 std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
5179 MCAuto<MEDCouplingFieldTemplate> field2=field->clone(false);
5180 int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
5181 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
5183 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
5184 throw INTERP_KERNEL::Exception(oss.str());
5187 int start(copyTinyInfoFrom(th,field,arrOfVals));
5188 code2=m->getDistributionOfTypes();
5190 int pos=addNewEntryIfNecessary(m);
5191 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
5195 if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
5196 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
5197 std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
5198 std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
5199 int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
5200 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
5202 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
5203 throw INTERP_KERNEL::Exception(oss.str());
5205 int start(copyTinyInfoFrom(th,field,arrOfVals));
5206 int pos(addNewEntryIfNecessary(m));
5207 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
5212 * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
5214 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
5216 if(_nb_of_tuples_to_be_allocated>=0)
5217 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 !");
5218 DataArray *arr(getOrCreateAndGetArray());
5219 arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
5220 _nb_of_tuples_to_be_allocated=-3;
5224 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
5225 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
5226 * larger by the size of \a field. Returns an id of the first not filled
5227 * tuple of \a this->_arr.
5228 * \param [in] field - the field to copy the info on components and the name from.
5229 * \return int - the id of first not initialized tuple of \a this->_arr.
5230 * \throw If the name of \a field is empty.
5231 * \throw If the data array of \a field is not set.
5232 * \throw If \a this->_arr is already allocated but has different number of components
5235 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arr)
5238 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
5239 std::string name(field->getName());
5240 setName(name.c_str());
5241 if(field->getMesh())
5242 setMeshName(field->getMesh()->getName());
5243 setDtUnit(th->getTimeUnit());
5245 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
5247 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
5248 if(!arr->isAllocated())
5249 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
5250 _dt=th->getTime(_iteration,_order);
5251 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
5252 if(!getOrCreateAndGetArray()->isAllocated())
5254 allocNotFromFile(arr->getNumberOfTuples());
5259 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
5260 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
5261 getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
5262 _nb_of_tuples_to_be_allocated=-3;
5263 return oldNbOfTuples;
5268 * Returns number of components in \a this field
5269 * \return int - the number of components.
5271 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
5273 return getOrCreateAndGetArray()->getNumberOfComponents();
5277 * Change info on components in \a this.
5278 * \throw If size of \a infos is not equal to the number of components already in \a this.
5280 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
5282 DataArray *arr=getOrCreateAndGetArray();
5283 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
5287 * Returns info on components of \a this field.
5288 * \return const std::vector<std::string>& - a sequence of strings each being an
5289 * information on _i_-th component.
5291 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
5293 const DataArray *arr=getOrCreateAndGetArray();
5294 return arr->getInfoOnComponents();
5298 * Returns a mutable info on components of \a this field.
5299 * \return std::vector<std::string>& - a sequence of strings each being an
5300 * information on _i_-th component.
5302 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
5304 DataArray *arr=getOrCreateAndGetArray();
5305 return arr->getInfoOnComponents();
5308 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const
5310 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5312 const MEDFileFieldPerMesh *fpm(*it);
5315 if(fpm->presenceOfMultiDiscPerGeoType())
5321 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfStructureElements() const
5323 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5324 if((*it).isNotNull())
5325 if((*it)->presenceOfStructureElements())
5330 bool MEDFileAnyTypeField1TSWithoutSDA::onlyStructureElements() const
5332 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5333 if((*it).isNotNull())
5334 if(!(*it)->onlyStructureElements())
5339 void MEDFileAnyTypeField1TSWithoutSDA::killStructureElements()
5341 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5342 if((*it).isNotNull())
5343 (*it)->killStructureElements();
5346 void MEDFileAnyTypeField1TSWithoutSDA::keepOnlyStructureElements()
5348 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5349 if((*it).isNotNull())
5350 (*it)->keepOnlyStructureElements();
5353 void MEDFileAnyTypeField1TSWithoutSDA::keepOnlyOnSE(const std::string& seName)
5355 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5356 if((*it).isNotNull())
5357 (*it)->keepOnlyOnSE(seName);
5360 void MEDFileAnyTypeField1TSWithoutSDA::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
5362 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5363 if((*it).isNotNull())
5364 (*it)->getMeshSENames(ps);
5367 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh(const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5369 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 !";
5370 if(_field_per_mesh.empty())
5371 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is empty ! Nothing to extract !");
5372 if(_field_per_mesh.size()>1)
5373 throw INTERP_KERNEL::Exception(MSG0);
5374 if(_field_per_mesh[0].isNull())
5375 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is inconsistent !");
5376 const MEDFileFieldPerMesh *pm(_field_per_mesh[0]);
5377 std::set<TypeOfField> types;
5378 pm->fillTypesOfFieldAvailable(types);
5380 throw INTERP_KERNEL::Exception(MSG0);
5381 TypeOfField type(*types.begin());
5382 int meshDimRelToMax(0);
5387 int myDim(std::numeric_limits<int>::max());
5388 bool isUnique(pm->isUniqueLevel(myDim));
5390 throw INTERP_KERNEL::Exception(MSG0);
5391 meshDimRelToMax=myDim-mesh->getMeshDimension();
5392 if(meshDimRelToMax>0)
5393 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the mesh attached to field is not compatible with the field !");
5395 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,0/*renumPol*/,glob,mesh,arrOut,nasc);
5399 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5400 * \param [in] type - a spatial discretization of the new field.
5401 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5402 * \param [in] mName - a name of the supporting mesh.
5403 * \param [in] renumPol - specifies how to permute values of the result field according to
5404 * the optional numbers of cells and nodes, if any. The valid values are
5405 * - 0 - do not permute.
5406 * - 1 - permute cells.
5407 * - 2 - permute nodes.
5408 * - 3 - permute cells and nodes.
5410 * \param [in] glob - the global data storing profiles and localization.
5411 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5412 * caller is to delete this field using decrRef() as it is no more needed.
5413 * \throw If the MED file is not readable.
5414 * \throw If there is no mesh named \a mName in the MED file.
5415 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5416 * \throw If no field of \a this is lying on the mesh \a mName.
5417 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5419 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5421 MCAuto<MEDFileMesh> mm;
5423 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
5425 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
5426 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
5430 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5431 * \param [in] type - a spatial discretization of the new field.
5432 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5433 * \param [in] renumPol - specifies how to permute values of the result field according to
5434 * the optional numbers of cells and nodes, if any. The valid values are
5435 * - 0 - do not permute.
5436 * - 1 - permute cells.
5437 * - 2 - permute nodes.
5438 * - 3 - permute cells and nodes.
5440 * \param [in] glob - the global data storing profiles and localization.
5441 * \param [in] mesh - the supporting mesh.
5442 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5443 * caller is to delete this field using decrRef() as it is no more needed.
5444 * \throw If the MED file is not readable.
5445 * \throw If no field of \a this is lying on \a mesh.
5446 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5447 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5449 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5451 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax,false));
5452 const DataArrayInt *d(mesh->getNumberFieldAtLevel(meshDimRelToMax)),*e(mesh->getNumberFieldAtLevel(1));
5453 if(meshDimRelToMax==1)
5454 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
5455 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
5459 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
5461 * \param [in] type - a spatial discretization of the new field.
5462 * \param [in] mName - a name of the supporting mesh.
5463 * \param [in] renumPol - specifies how to permute values of the result field according to
5464 * the optional numbers of cells and nodes, if any. The valid values are
5465 * - 0 - do not permute.
5466 * - 1 - permute cells.
5467 * - 2 - permute nodes.
5468 * - 3 - permute cells and nodes.
5470 * \param [in] glob - the global data storing profiles and localization.
5471 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5472 * caller is to delete this field using decrRef() as it is no more needed.
5473 * \throw If the MED file is not readable.
5474 * \throw If there is no mesh named \a mName in the MED file.
5475 * \throw If there are no mesh entities in the mesh.
5476 * \throw If no field values of the given \a type are available.
5478 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5480 MCAuto<MEDFileMesh> mm;
5482 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
5484 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
5485 int absDim=getDimension();
5486 int meshDimRelToMax=absDim-mm->getMeshDimension();
5487 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
5491 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5492 * \param [in] type - a spatial discretization of the new field.
5493 * \param [in] renumPol - specifies how to permute values of the result field according to
5494 * the optional numbers of cells and nodes, if any. The valid values are
5495 * - 0 - do not permute.
5496 * - 1 - permute cells.
5497 * - 2 - permute nodes.
5498 * - 3 - permute cells and nodes.
5500 * \param [in] glob - the global data storing profiles and localization.
5501 * \param [in] mesh - the supporting mesh.
5502 * \param [in] cellRenum - the cell numbers array used for permutation of the result
5503 * field according to \a renumPol.
5504 * \param [in] nodeRenum - the node numbers array used for permutation of the result
5505 * field according to \a renumPol.
5506 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5507 * caller is to delete this field using decrRef() as it is no more needed.
5508 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5509 * \throw If no field of \a this is lying on \a mesh.
5510 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5512 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
5514 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
5516 MCAuto<MEDCouplingFieldDouble> ret=_field_per_mesh[0]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
5521 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5528 throw INTERP_KERNEL::Exception(msg1);
5529 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5532 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
5534 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5535 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
5536 throw INTERP_KERNEL::Exception(oss.str());
5538 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
5539 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
5540 std::vector<DataArray *> arrOut2(1,arrOut);
5541 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
5542 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
5543 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
5550 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5552 throw INTERP_KERNEL::Exception(msg1);
5555 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
5557 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5558 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
5559 throw INTERP_KERNEL::Exception(oss.str());
5561 MCAuto<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
5562 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
5563 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
5564 ret->renumberNodes(nodeRenumSafe->getConstPointer());
5569 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
5574 * Returns values and a profile of the field of a given type lying on a given support.
5575 * \param [in] type - a spatial discretization of the field.
5576 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5577 * \param [in] mesh - the supporting mesh.
5578 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
5579 * field of interest lies on. If the field lies on all entities of the given
5580 * dimension, all ids in \a pfl are zero. The caller is to delete this array
5581 * using decrRef() as it is no more needed.
5582 * \param [in] glob - the global data storing profiles and localization.
5583 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
5584 * field. The caller is to delete this array using decrRef() as it is no more needed.
5585 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
5586 * \throw If no field of \a this is lying on \a mesh.
5587 * \throw If no field values of the given \a type are available.
5589 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
5591 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
5592 MCAuto<DataArray> ret=_field_per_mesh[0]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
5593 ret->setName(nasc.getName().c_str());
5597 //= MEDFileField1TSWithoutSDA
5600 * Throws if a given value is not a valid (non-extended) relative dimension.
5601 * \param [in] meshDimRelToMax - the relative dimension value.
5602 * \throw If \a meshDimRelToMax > 0.
5604 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
5606 if(meshDimRelToMax>0)
5607 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
5611 * Checks if elements of a given mesh are in the order suitable for writing
5612 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
5613 * vector describing types of elements and their number.
5614 * \param [in] mesh - the mesh to check.
5615 * \return std::vector<int> - a vector holding for each element type (1) item of
5616 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
5617 * These values are in full-interlace mode.
5618 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
5620 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
5623 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
5624 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
5625 int nbOfTypes=geoTypes.size();
5626 std::vector<int> code(3*nbOfTypes);
5627 MCAuto<DataArrayInt> arr1=DataArrayInt::New();
5628 arr1->alloc(nbOfTypes,1);
5629 int *arrPtr=arr1->getPointer();
5630 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
5631 for(int i=0;i<nbOfTypes;i++,it++)
5632 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
5633 MCAuto<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
5634 const int *arrPtr2=arr2->getConstPointer();
5636 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
5639 int nbCells=mesh->getNumberOfCellsWithType(*it);
5640 code[3*pos]=(int)(*it);
5641 code[3*pos+1]=nbCells;
5642 code[3*pos+2]=-1;//no profiles
5644 std::vector<const DataArrayInt *> idsPerType;//no profiles
5645 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
5649 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
5654 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5656 return new MEDFileField1TSWithoutSDA(fieldName,meshName,csit,iteration,order,infos);
5660 * Returns all attributes and values of parts of \a this field lying on a given mesh.
5661 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
5662 * item of every of returned sequences refers to the _i_-th part of \a this field.
5663 * Thus all sequences returned by this method are of the same length equal to number
5664 * of different types of supporting entities.<br>
5665 * A field part can include sub-parts with several different spatial discretizations,
5666 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
5667 * for example. Hence, some of the returned sequences contains nested sequences, and an item
5668 * of a nested sequence corresponds to a type of spatial discretization.<br>
5669 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
5670 * The overhead is due to selecting values into new instances of DataArrayDouble.
5671 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
5672 * for the case with only one underlying mesh. (Actually, the number of meshes is
5673 * not checked if \a mname == \c NULL).
5674 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
5675 * a field part is returned.
5676 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
5677 * A field part can include sub-parts with several different spatial discretizations,
5678 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and
5679 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT" for example.
5680 * This sequence is of the same length as \a types.
5681 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
5682 * discretization. A profile name can be empty.
5683 * Length of this and of nested sequences is the same as that of \a typesF.
5684 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
5685 * discretization. A localization name can be empty.
5686 * Length of this and of nested sequences is the same as that of \a typesF.
5687 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
5688 * per each type of spatial discretization within one mesh entity type.
5689 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
5690 * Length of this and of nested sequences is the same as that of \a typesF.
5691 * \throw If no field is lying on \a mname.
5693 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
5696 if(_field_per_mesh.empty())
5697 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
5698 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[0]->getFieldSplitedByType(types,typesF,pfls,locs);
5699 int nbOfRet=ret0.size();
5700 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
5701 for(int i=0;i<nbOfRet;i++)
5703 const std::vector< std::pair<int,int> >& p=ret0[i];
5704 int nbOfRet1=p.size();
5705 ret[i].resize(nbOfRet1);
5706 for(int j=0;j<nbOfRet1;j++)
5708 DataArrayDouble *tmp=_arr->selectByTupleIdSafeSlice(p[j].first,p[j].second,1);
5715 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
5720 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
5722 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
5723 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5724 ret->deepCpyLeavesFrom(*this);
5725 const DataArrayDouble *arr(_arr);
5728 MCAuto<DataArrayInt> arr2(arr->convertToIntArr());
5729 ret->setArray(arr2);
5735 * Returns a pointer to the underground DataArrayDouble instance and a
5736 * sequence describing parameters of a support of each part of \a this field. The
5737 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5738 * direct access to the field values. This method is intended for the field lying on one
5740 * \param [in,out] entries - the sequence describing parameters of a support of each
5741 * part of \a this field. Each item of this sequence consists of two parts. The
5742 * first part describes a type of mesh entity and an id of discretization of a
5743 * current field part. The second part describes a range of values [begin,end)
5744 * within the returned array relating to the current field part.
5745 * \return DataArrayDouble * - the pointer to the field values array.
5746 * \throw If the number of underlying meshes is not equal to 1.
5747 * \throw If no field values are available.
5748 * \sa getUndergroundDataArray()
5750 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5752 return getUndergroundDataArrayTemplateExt(entries);
5755 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<double>(fieldName,meshName,csit,iteration,order)
5757 DataArrayDouble *arr(getOrCreateAndGetArrayTemplate());
5758 arr->setInfoAndChangeNbOfCompo(infos);
5761 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<double>()
5765 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
5767 MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
5768 ret->deepCpyLeavesFrom(*this);
5772 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCopy() const
5774 MCAuto<MEDFileField1TSWithoutSDA> ret(shallowCpy());
5775 if(_arr.isNotNull())
5776 ret->_arr=_arr->deepCopy();
5780 //= MEDFileIntField1TSWithoutSDA
5782 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5784 return new MEDFileIntField1TSWithoutSDA(fieldName,meshName,csit,iteration,order,infos);
5787 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA()
5791 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order,
5792 const std::vector<std::string>& infos):MEDFileField1TSNDTemplateWithoutSDA<int>(fieldName,meshName,csit,iteration,order,infos)
5794 DataArrayInt *arr(getOrCreateAndGetArrayTemplate());
5795 arr->setInfoAndChangeNbOfCompo(infos);
5798 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
5804 * Returns a pointer to the underground DataArrayInt instance and a
5805 * sequence describing parameters of a support of each part of \a this field. The
5806 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5807 * direct access to the field values. This method is intended for the field lying on one
5809 * \param [in,out] entries - the sequence describing parameters of a support of each
5810 * part of \a this field. Each item of this sequence consists of two parts. The
5811 * first part describes a type of mesh entity and an id of discretization of a
5812 * current field part. The second part describes a range of values [begin,end)
5813 * within the returned array relating to the current field part.
5814 * \return DataArrayInt * - the pointer to the field values array.
5815 * \throw If the number of underlying meshes is not equal to 1.
5816 * \throw If no field values are available.
5817 * \sa getUndergroundDataArray()
5819 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5821 return getUndergroundDataArrayIntExt(entries);
5825 * Returns a pointer to the underground DataArrayInt instance and a
5826 * sequence describing parameters of a support of each part of \a this field. The
5827 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5828 * direct access to the field values. This method is intended for the field lying on one
5830 * \param [in,out] entries - the sequence describing parameters of a support of each
5831 * part of \a this field. Each item of this sequence consists of two parts. The
5832 * first part describes a type of mesh entity and an id of discretization of a
5833 * current field part. The second part describes a range of values [begin,end)
5834 * within the returned array relating to the current field part.
5835 * \return DataArrayInt * - the pointer to the field values array.
5836 * \throw If the number of underlying meshes is not equal to 1.
5837 * \throw If no field values are available.
5838 * \sa getUndergroundDataArray()
5840 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5842 if(_field_per_mesh.size()!=1)
5843 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5844 if(_field_per_mesh[0]==0)
5845 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5846 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5847 return getUndergroundDataArrayTemplate();
5850 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5852 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5853 ret->deepCpyLeavesFrom(*this);
5857 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCopy() const
5859 MCAuto<MEDFileIntField1TSWithoutSDA> ret(shallowCpy());
5860 if(_arr.isNotNull())
5861 ret->_arr=_arr->deepCopy();
5865 //= MEDFileFloatField1TSWithoutSDA
5867 MEDFileFloatField1TSWithoutSDA *MEDFileFloatField1TSWithoutSDA::New(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5869 return new MEDFileFloatField1TSWithoutSDA(fieldName,meshName,csit,iteration,order,infos);
5872 MEDFileFloatField1TSWithoutSDA::MEDFileFloatField1TSWithoutSDA()
5876 MEDFileFloatField1TSWithoutSDA::MEDFileFloatField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order,
5877 const std::vector<std::string>& infos):MEDFileField1TSNDTemplateWithoutSDA<float>(fieldName,meshName,csit,iteration,order,infos)
5879 DataArrayFloat *arr(getOrCreateAndGetArrayTemplate());
5880 arr->setInfoAndChangeNbOfCompo(infos);
5883 const char *MEDFileFloatField1TSWithoutSDA::getTypeStr() const
5889 * Returns a pointer to the underground DataArrayFloat instance and a
5890 * sequence describing parameters of a support of each part of \a this field. The
5891 * caller should not decrRef() the returned DataArrayFloat. This method allows for a
5892 * direct access to the field values. This method is intended for the field lying on one
5894 * \param [in,out] entries - the sequence describing parameters of a support of each
5895 * part of \a this field. Each item of this sequence consists of two parts. The
5896 * first part describes a type of mesh entity and an id of discretization of a
5897 * current field part. The second part describes a range of values [begin,end)
5898 * within the returned array relating to the current field part.
5899 * \return DataArrayFloat * - the pointer to the field values array.
5900 * \throw If the number of underlying meshes is not equal to 1.
5901 * \throw If no field values are available.
5902 * \sa getUndergroundDataArray()
5904 DataArray *MEDFileFloatField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5906 return getUndergroundDataArrayFloatExt(entries);
5910 * Returns a pointer to the underground DataArrayFloat instance and a
5911 * sequence describing parameters of a support of each part of \a this field. The
5912 * caller should not decrRef() the returned DataArrayFloat. This method allows for a
5913 * direct access to the field values. This method is intended for the field lying on one
5915 * \param [in,out] entries - the sequence describing parameters of a support of each
5916 * part of \a this field. Each item of this sequence consists of two parts. The
5917 * first part describes a type of mesh entity and an id of discretization of a
5918 * current field part. The second part describes a range of values [begin,end)
5919 * within the returned array relating to the current field part.
5920 * \return DataArrayFloat * - the pointer to the field values array.
5921 * \throw If the number of underlying meshes is not equal to 1.
5922 * \throw If no field values are available.
5923 * \sa getUndergroundDataArray()
5925 DataArrayFloat *MEDFileFloatField1TSWithoutSDA::getUndergroundDataArrayFloatExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5927 if(_field_per_mesh.size()!=1)
5928 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5929 if(_field_per_mesh[0]==0)
5930 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5931 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5932 return getUndergroundDataArrayTemplate();
5935 MEDFileFloatField1TSWithoutSDA *MEDFileFloatField1TSWithoutSDA::shallowCpy() const
5937 MCAuto<MEDFileFloatField1TSWithoutSDA> ret(new MEDFileFloatField1TSWithoutSDA(*this));
5938 ret->deepCpyLeavesFrom(*this);
5942 MEDFileFloatField1TSWithoutSDA *MEDFileFloatField1TSWithoutSDA::deepCopy() const
5944 MCAuto<MEDFileFloatField1TSWithoutSDA> ret(shallowCpy());
5945 if(_arr.isNotNull())
5946 ret->_arr=_arr->deepCopy();
5950 //= MEDFileAnyTypeField1TS
5952 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5956 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
5958 med_field_type typcha;
5960 std::vector<std::string> infos;
5961 std::string dtunit,fieldName,meshName;
5962 LocateField2(fid,0,true,fieldName,typcha,infos,dtunit,meshName);
5963 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5968 ret=MEDFileField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5973 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5976 case MED_NODE://6432
5978 ret=MEDFileFloatField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5983 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] !";
5984 throw INTERP_KERNEL::Exception(oss.str());
5987 ret->setDtUnit(dtunit.c_str());
5988 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5990 med_int numdt,numit;
5992 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5993 ret->setTime(numdt,numit,dt);
5996 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
5998 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
6002 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
6003 try:MEDFileFieldGlobsReal(fid)
6005 _content=BuildContentFrom(fid,loadAll,ms,entities);
6008 catch(INTERP_KERNEL::Exception& e)
6013 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
6015 med_field_type typcha;
6016 std::vector<std::string> infos;
6017 std::string dtunit,meshName;
6021 nbSteps=LocateField(fid,fieldName,iii,typcha,infos,dtunit,meshName);
6023 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
6028 ret=MEDFileField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
6033 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
6036 case MED_NODE://6432
6038 ret=MEDFileFloatField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
6043 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, MED_FLOAT32] !";
6044 throw INTERP_KERNEL::Exception(oss.str());
6047 ret->setMeshName(meshName);
6048 ret->setDtUnit(dtunit.c_str());
6049 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
6053 std::ostringstream oss; oss << "MEDFileField1TS(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
6054 throw INTERP_KERNEL::Exception(oss.str());
6057 med_int numdt,numit;
6059 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
6060 ret->setTime(numdt,numit,dt);
6063 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
6065 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
6069 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
6070 try:MEDFileFieldGlobsReal(fid)
6072 _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
6075 catch(INTERP_KERNEL::Exception& e)
6080 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c)
6083 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
6084 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
6086 MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
6087 ret->_content=c; c->incrRef();
6090 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
6092 MCAuto<MEDFileIntField1TS> ret(MEDFileIntField1TS::New());
6093 ret->_content=c; c->incrRef();
6096 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
6099 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, med_idt fid)
6101 MEDFileAnyTypeField1TS *ret(BuildNewInstanceFromContent(c));
6102 ret->setFileName(FileNameFromFID(fid));
6106 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
6108 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6109 return New(fid,loadAll);
6112 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, bool loadAll)
6114 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,loadAll,0,0));
6115 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
6116 ret->loadGlobals(fid);
6120 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6122 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6123 return New(fid,fieldName,loadAll);
6126 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
6128 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
6129 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
6130 ret->loadGlobals(fid);
6134 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6136 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6137 return New(fid,fieldName,iteration,order,loadAll);
6140 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
6142 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0,0));
6143 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
6144 ret->loadGlobals(fid);
6148 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::NewAdv(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileEntities *entities)
6150 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6151 return NewAdv(fid,fieldName,iteration,order,loadAll,entities);
6154 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::NewAdv(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileEntities *entities)
6156 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0,entities));
6157 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
6158 ret->loadGlobals(fid);
6162 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
6164 med_field_type typcha;
6165 std::vector<std::string> infos;
6166 std::string dtunit,meshName;
6168 int nbOfStep2(LocateField(fid,fieldName,iii,typcha,infos,dtunit,meshName));
6169 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
6174 ret=MEDFileField1TSWithoutSDA::New(fieldName,meshName,-1,iteration,order,std::vector<std::string>());
6179 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,meshName,-1,iteration,order,std::vector<std::string>());
6182 case MED_NODE://6432
6184 ret=MEDFileFloatField1TSWithoutSDA::New(fieldName,meshName,-1,iteration,order,std::vector<std::string>());
6189 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, MED_FLOAT32] !";
6190 throw INTERP_KERNEL::Exception(oss.str());
6193 ret->setDtUnit(dtunit.c_str());
6194 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
6197 std::vector< std::pair<int,int> > dtits(nbOfStep2);
6198 for(int i=0;i<nbOfStep2 && !found;i++)
6200 med_int numdt,numit;
6202 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt));
6203 if(numdt==iteration && numit==order)
6209 dtits[i]=std::pair<int,int>(numdt,numit);
6213 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available iterations are : ";
6214 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
6215 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
6216 throw INTERP_KERNEL::Exception(oss.str());
6219 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
6221 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
6225 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
6226 try:MEDFileFieldGlobsReal(fid)
6228 _content=BuildContentFrom(fid,fieldName,iteration,order,loadAll,ms,entities);
6231 catch(INTERP_KERNEL::Exception& e)
6237 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6238 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6240 * \warning this is a shallow copy constructor
6242 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
6244 if(!shallowCopyOfContent)
6246 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
6247 otherPtr->incrRef();
6248 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
6252 _content=other.shallowCpy();
6256 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, std::string& meshName)
6260 int nbFields=MEDnField(fid);
6261 if(fieldIdCFormat>=nbFields)
6263 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << FileNameFromFID(fid) << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
6264 throw INTERP_KERNEL::Exception(oss.str());
6267 int ncomp(MEDfieldnComponent(fid,fieldIdCFormat+1));
6268 INTERP_KERNEL::AutoPtr<char> comp(MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE));
6269 INTERP_KERNEL::AutoPtr<char> unit(MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE));
6270 INTERP_KERNEL::AutoPtr<char> dtunit(MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE));
6271 INTERP_KERNEL::AutoPtr<char> nomcha(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
6272 INTERP_KERNEL::AutoPtr<char> nomMaa(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
6275 MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep));
6276 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
6277 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
6278 meshName=MEDLoaderBase::buildStringFromFortran(nomMaa,MED_NAME_SIZE);
6279 infos.clear(); infos.resize(ncomp);
6280 for(int j=0;j<ncomp;j++)
6281 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
6286 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
6289 * \return in case of success the number of time steps available for the field with name \a fieldName.
6291 int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const std::string& fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut, std::string& meshName)
6293 int nbFields=MEDnField(fid);
6295 std::vector<std::string> fns(nbFields);
6297 for(int i=0;i<nbFields && !found;i++)
6299 std::string tmp,tmp2;
6300 nbOfStep2=LocateField2(fid,i,false,tmp,typcha,infos,dtunitOut,tmp2);
6302 found=(tmp==fieldName);
6311 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available fields are : ";
6312 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
6313 oss << "\"" << *it << "\" ";
6314 throw INTERP_KERNEL::Exception(oss.str());
6320 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
6321 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
6322 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
6323 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
6324 * to keep a valid instance.
6325 * 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.
6326 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
6327 * 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.
6329 * \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.
6330 * \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.
6331 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
6332 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
6333 * \param [in] newLocName is the new localization name.
6334 * \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.
6335 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
6337 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
6339 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6340 std::string oldPflName=disc->getProfile();
6341 std::vector<std::string> vv=getPflsReallyUsedMulti();
6342 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
6343 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
6345 disc->setProfile(newPflName);
6346 DataArrayInt *pfl=getProfile(oldPflName.c_str());
6347 pfl->setName(newPflName);
6351 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
6352 throw INTERP_KERNEL::Exception(oss.str());
6357 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
6358 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
6359 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
6360 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
6361 * to keep a valid instance.
6362 * 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.
6363 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
6364 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
6365 * 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.
6367 * \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.
6368 * \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.
6369 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
6370 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
6371 * \param [in] newLocName is the new localization name.
6372 * \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.
6373 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
6375 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
6377 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6378 std::string oldLocName=disc->getLocalization();
6379 std::vector<std::string> vv=getLocsReallyUsedMulti();
6380 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
6381 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
6383 disc->setLocalization(newLocName);
6384 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
6385 loc.setName(newLocName);
6389 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
6390 throw INTERP_KERNEL::Exception(oss.str());
6394 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
6396 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
6398 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
6402 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
6404 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
6406 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
6411 * This method alloc the arrays and load potentially huge arrays contained in this field.
6412 * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
6413 * This method can be also called to refresh or reinit values from a file.
6415 * \throw If the fileName is not set or points to a non readable MED file.
6416 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
6418 void MEDFileAnyTypeField1TS::loadArrays()
6420 if(getFileName().empty())
6421 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
6422 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
6423 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
6427 * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
6428 * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
6429 * this method does not throw if \a this does not come from file read.
6431 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
6433 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
6435 if(!getFileName().empty())
6437 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
6438 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
6443 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
6444 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
6445 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
6447 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
6449 void MEDFileAnyTypeField1TS::unloadArrays()
6451 contentNotNullBase()->unloadArrays();
6455 * 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.
6456 * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
6457 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
6459 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
6461 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
6463 if(!getFileName().empty())
6464 contentNotNullBase()->unloadArrays();
6467 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
6469 int nbComp(getNumberOfComponents());
6470 INTERP_KERNEL::AutoPtr<char> comp(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
6471 INTERP_KERNEL::AutoPtr<char> unit(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
6472 for(int i=0;i<nbComp;i++)
6474 std::string info=getInfo()[i];
6476 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
6477 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
6478 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
6480 if(getName().empty())
6481 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
6482 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
6483 writeGlobals(fid,*this);
6484 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
6487 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
6489 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
6492 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
6494 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
6495 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
6500 * Returns a string describing \a this field. This string is outputted
6501 * by \c print Python command.
6503 std::string MEDFileAnyTypeField1TS::simpleRepr() const
6505 std::ostringstream oss;
6506 contentNotNullBase()->simpleRepr(0,oss,-1);
6507 simpleReprGlobs(oss);
6512 * This method returns all profiles whose name is non empty used.
6513 * \b WARNING If profile is used several times it will be reported \b only \b once.
6514 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
6516 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
6518 return contentNotNullBase()->getPflsReallyUsed2();
6522 * This method returns all localizations whose name is non empty used.
6523 * \b WARNING If localization is used several times it will be reported \b only \b once.
6525 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
6527 return contentNotNullBase()->getLocsReallyUsed2();
6531 * This method returns all profiles whose name is non empty used.
6532 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
6534 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
6536 return contentNotNullBase()->getPflsReallyUsedMulti2();
6540 * This method returns all localizations whose name is non empty used.
6541 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
6543 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
6545 return contentNotNullBase()->getLocsReallyUsedMulti2();
6548 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6550 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
6553 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6555 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
6558 int MEDFileAnyTypeField1TS::getDimension() const
6560 return contentNotNullBase()->getDimension();
6563 int MEDFileAnyTypeField1TS::getIteration() const
6565 return contentNotNullBase()->getIteration();
6568 int MEDFileAnyTypeField1TS::getOrder() const
6570 return contentNotNullBase()->getOrder();
6573 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
6575 return contentNotNullBase()->getTime(iteration,order);
6578 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
6580 contentNotNullBase()->setTime(iteration,order,val);
6583 std::string MEDFileAnyTypeField1TS::getName() const
6585 return contentNotNullBase()->getName();
6588 void MEDFileAnyTypeField1TS::setName(const std::string& name)
6590 contentNotNullBase()->setName(name);
6593 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
6595 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
6598 std::string MEDFileAnyTypeField1TS::getDtUnit() const
6600 return contentNotNullBase()->getDtUnit();
6603 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
6605 contentNotNullBase()->setDtUnit(dtUnit);
6608 std::string MEDFileAnyTypeField1TS::getMeshName() const
6610 return contentNotNullBase()->getMeshName();
6613 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
6615 contentNotNullBase()->setMeshName(newMeshName);
6618 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
6620 return contentNotNullBase()->changeMeshNames(modifTab);
6623 int MEDFileAnyTypeField1TS::getMeshIteration() const
6625 return contentNotNullBase()->getMeshIteration();
6628 int MEDFileAnyTypeField1TS::getMeshOrder() const
6630 return contentNotNullBase()->getMeshOrder();
6633 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
6635 return contentNotNullBase()->getNumberOfComponents();
6638 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
6640 return contentNotNullBase()->isDealingTS(iteration,order);
6643 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
6645 return contentNotNullBase()->getDtIt();
6648 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
6650 contentNotNullBase()->fillIteration(p);
6653 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
6655 contentNotNullBase()->fillTypesOfFieldAvailable(types);
6658 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
6660 contentNotNullBase()->setInfo(infos);
6663 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
6665 return contentNotNullBase()->getInfo();
6667 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
6669 return contentNotNullBase()->getInfo();
6672 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
6674 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
6677 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
6679 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6682 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
6684 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6687 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
6689 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
6692 void MEDFileAnyTypeField1TS::convertMedBallIntoClassic()
6694 return contentNotNullBase()->convertMedBallIntoClassic();
6697 void MEDFileAnyTypeField1TS::makeReduction(INTERP_KERNEL::NormalizedCellType ct, TypeOfField tof, const DataArrayInt *pfl)
6699 return contentNotNullBase()->makeReduction(ct,tof,pfl);
6702 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
6704 return contentNotNullBase()->getTypesOfFieldAvailable();
6707 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,
6708 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6710 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
6714 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
6715 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
6716 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
6718 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
6720 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6722 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
6723 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
6724 std::size_t sz(contentsSplit.size());
6725 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6726 for(std::size_t i=0;i<sz;i++)
6728 ret[i]=shallowCpy();
6729 ret[i]->_content=contentsSplit[i];
6735 * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
6736 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6738 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
6740 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6742 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
6743 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
6744 std::size_t sz(contentsSplit.size());
6745 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6746 for(std::size_t i=0;i<sz;i++)
6748 ret[i]=shallowCpy();
6749 ret[i]->_content=contentsSplit[i];
6755 * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this.
6756 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6758 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const
6760 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6762 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !");
6763 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
6764 std::size_t sz(contentsSplit.size());
6765 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6766 for(std::size_t i=0;i<sz;i++)
6768 ret[i]=shallowCpy();
6769 ret[i]->_content=contentsSplit[i];
6774 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCopy() const
6776 MCAuto<MEDFileAnyTypeField1TS> ret=shallowCpy();
6777 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
6778 ret->_content=_content->deepCopy();
6779 ret->deepCpyGlobs(*this);
6783 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
6785 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*field));
6786 return copyTinyInfoFrom(field->timeDiscrSafe(),ft,arr);
6789 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arr)
6791 return contentNotNullBase()->copyTinyInfoFrom(th,field,arr);
6797 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
6798 * following the given input policy.
6800 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6801 * By default (true) the globals are deeply copied.
6802 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
6804 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
6806 MCAuto<MEDFileIntField1TS> ret;
6807 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6810 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
6812 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
6813 MCAuto<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
6814 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc));
6817 ret=MEDFileIntField1TS::New();
6819 ret->deepCpyGlobs(*this);
6821 ret->shallowCpyGlobs(*this);
6825 MEDFileField1TS::MEDFileField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
6826 try:MEDFileTemplateField1TS<double>(fid,loadAll,ms)
6829 catch(INTERP_KERNEL::Exception& e)
6832 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6833 try:MEDFileTemplateField1TS<double>(fid,fieldName,loadAll,ms)
6836 catch(INTERP_KERNEL::Exception& e)
6839 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6840 try:MEDFileTemplateField1TS<double>(fid,fieldName,iteration,order,loadAll,ms)
6843 catch(INTERP_KERNEL::Exception& e)
6847 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6848 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6850 * \warning this is a shallow copy constructor
6852 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6853 try:MEDFileTemplateField1TS<double>(other,shallowCopyOfContent)
6856 catch(INTERP_KERNEL::Exception& e)
6859 MEDFileField1TS *MEDFileField1TS::shallowCpy() const
6861 return new MEDFileField1TS(*this);
6864 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6865 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6867 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6870 //= MEDFileIntField1TS
6872 MCAuto<MEDCouplingFieldDouble> MEDFileIntField1TS::ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f)
6875 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ConvertFieldIntToFieldDouble : null input field !");
6877 double t0(f->getTime(t1,t2));
6878 std::string tu(f->getTimeUnit());
6879 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
6880 MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(*ft));
6881 ret->setTime(t0,t1,t2); ret->setTimeUnit(tu);
6885 //= MEDFileFloatField1TS
6887 //= MEDFileFloatField1TS
6889 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
6891 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
6895 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName):MEDFileFieldNameScope(fieldName,meshName)
6900 * \param [in] fieldId field id in C mode
6902 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
6904 med_field_type typcha;
6905 std::string dtunitOut,meshName;
6906 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fieldId,false,_name,typcha,_infos,dtunitOut,meshName));
6907 setMeshName(meshName);
6908 setDtUnit(dtunitOut.c_str());
6909 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities);
6912 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
6913 try:MEDFileFieldNameScope(fieldName,meshName),_infos(infos)
6915 setDtUnit(dtunit.c_str());
6916 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities);
6918 catch(INTERP_KERNEL::Exception& e)
6923 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
6925 std::size_t ret(_mesh_name.capacity()+_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MCAuto<MEDFileField1TSWithoutSDA>));
6926 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
6927 ret+=(*it).capacity();
6931 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
6933 std::vector<const BigMemoryObject *> ret;
6934 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6935 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
6940 * 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
6943 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
6945 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6946 ret->setInfo(_infos);
6947 int sz=(int)_time_steps.size();
6948 for(const int *id=startIds;id!=endIds;id++)
6950 if(*id>=0 && *id<sz)
6952 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
6953 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6957 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6959 ret->pushBackTimeStep(tse2);
6963 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
6964 oss << " ! Should be in [0," << sz << ") !";
6965 throw INTERP_KERNEL::Exception(oss.str());
6968 if(ret->getNumberOfTS()>0)
6969 ret->synchronizeNameScope();
6970 ret->copyNameScope(*this);
6975 * 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
6978 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
6980 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
6981 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
6982 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6983 ret->setInfo(_infos);
6984 int sz=(int)_time_steps.size();
6986 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
6990 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
6991 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6995 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6997 ret->pushBackTimeStep(tse2);
7001 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
7002 oss << " ! Should be in [0," << sz << ") !";
7003 throw INTERP_KERNEL::Exception(oss.str());
7006 if(ret->getNumberOfTS()>0)
7007 ret->synchronizeNameScope();
7008 ret->copyNameScope(*this);
7012 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7015 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7016 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7018 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7021 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7022 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
7023 ids->pushBackSilent(id);
7025 return buildFromTimeStepIds(ids->begin(),ids->end());
7028 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7031 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7032 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7034 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7037 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7038 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
7039 ids->pushBackSilent(id);
7041 return buildFromTimeStepIds(ids->begin(),ids->end());
7044 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfStructureElements() const
7046 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7047 if((*it).isNotNull())
7048 if((*it)->presenceOfStructureElements())
7053 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::onlyStructureElements() const
7055 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7056 if((*it).isNotNull())
7057 if(!(*it)->onlyStructureElements())
7062 void MEDFileAnyTypeFieldMultiTSWithoutSDA::killStructureElements()
7064 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
7065 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7066 if((*it).isNotNull())
7068 if((*it)->presenceOfStructureElements())
7070 if(!(*it)->onlyStructureElements())
7072 (*it)->killStructureElements();
7084 void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyStructureElements()
7086 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
7087 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7088 if((*it).isNotNull())
7090 if((*it)->presenceOfStructureElements())
7092 if(!(*it)->onlyStructureElements())
7093 (*it)->keepOnlyStructureElements();
7100 void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyOnSE(const std::string& seName)
7102 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
7103 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7104 if((*it).isNotNull())
7105 (*it)->keepOnlyOnSE(seName);
7108 void MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
7110 std::vector< std::pair<std::string,std::string> > ps2;
7111 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7112 if((*it).isNotNull())
7114 (*it)->getMeshSENames(ps2);
7118 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames : this appears to not contain SE only !");
7119 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7120 if((*it).isNotNull())
7122 std::vector< std::pair<std::string,std::string> > ps3;
7123 (*it)->getMeshSENames(ps3);
7125 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames : For the moment only homogeneous SE def through time managed !");
7127 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=ps2.begin();it!=ps2.end();it++)
7129 std::vector< std::pair<std::string,std::string> >::iterator it2(std::find(ps.begin(),ps.end(),*it));
7135 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
7137 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7139 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7142 if(cur->presenceOfMultiDiscPerGeoType())
7148 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
7153 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
7158 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
7161 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7163 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
7164 if(pt->isDealingTS(iteration,order))
7167 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
7168 std::vector< std::pair<int,int> > vp=getIterations();
7169 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
7170 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
7171 throw INTERP_KERNEL::Exception(oss.str());
7174 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
7176 return *_time_steps[getTimeStepPos(iteration,order)];
7179 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
7181 return *_time_steps[getTimeStepPos(iteration,order)];
7184 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
7187 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
7189 if((*it).first==getMeshName())
7191 setMeshName((*it).second);
7195 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7197 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7199 ret=cur->changeMeshNames(modifTab) || ret;
7205 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
7207 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
7209 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
7213 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
7215 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7217 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
7220 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
7221 MEDFileFieldGlobsReal& glob)
7224 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7226 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
7228 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
7233 void MEDFileAnyTypeFieldMultiTSWithoutSDA::accept(MEDFileFieldVisitor& visitor) const
7235 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7236 if((*it).isNotNull())
7238 visitor.newTimeStepEntry(*it);
7239 (*it)->accept(visitor);
7240 visitor.endTimeStepEntry(*it);
7244 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7246 std::string startLine(bkOffset,' ');
7247 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
7249 oss << " (" << fmtsId << ")";
7250 oss << " has the following name: \"" << _name << "\"." << std::endl;
7251 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
7252 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7254 oss << startLine << " - \"" << *it << "\"" << std::endl;
7257 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7259 std::string chapter(17,'0'+i);
7260 oss << startLine << chapter << std::endl;
7261 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7263 cur->simpleRepr(bkOffset+2,oss,i);
7265 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
7266 oss << startLine << chapter << std::endl;
7270 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
7272 std::size_t sz=_time_steps.size();
7273 std::vector< std::pair<int,int> > ret(sz);
7275 for(std::size_t i=0;i<sz;i++)
7277 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
7280 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
7284 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
7285 throw INTERP_KERNEL::Exception(oss.str());
7291 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MCAuto<MEDFileAnyTypeField1TSWithoutSDA>& tse)
7293 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
7295 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
7296 checkCoherencyOfType(tse2);
7297 if(_time_steps.empty())
7299 setName(tse2->getName());
7300 setMeshName(tse2->getMeshName());
7301 setInfo(tse2->getInfo());
7303 checkThatComponentsMatch(tse2->getInfo());
7304 if(getDtUnit().empty() && !tse->getDtUnit().empty())
7305 setDtUnit(tse->getDtUnit());
7306 _time_steps.push_back(tse);
7309 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
7311 std::size_t nbOfCompo=_infos.size();
7312 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7314 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7317 if((cur->getInfo()).size()!=nbOfCompo)
7319 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
7320 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
7321 throw INTERP_KERNEL::Exception(oss.str());
7323 cur->copyNameScope(*this);
7328 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7330 _time_steps.resize(nbPdt);
7331 for(int i=0;i<nbPdt;i++)
7333 std::vector< std::pair<int,int> > ts;
7334 med_int numdt=0,numo=0;
7336 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt));
7341 _time_steps[i]=MEDFileField1TSWithoutSDA::New(getName(),getMeshName(),i+1,numdt,numo,_infos);
7346 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(getName(),getMeshName(),i+1,numdt,numo,_infos);
7349 case MED_NODE://6432
7351 _time_steps[i]=MEDFileFloatField1TSWithoutSDA::New(getName(),getMeshName(),i+1,numdt,numo,_infos);
7355 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32, FLOAT32 !");
7358 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities);
7360 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entities);
7361 synchronizeNameScope();
7365 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
7367 if(_time_steps.empty())
7368 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
7369 checkThatNbOfCompoOfTSMatchThis();
7370 std::vector<std::string> infos(getInfo());
7371 int nbComp=infos.size();
7372 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7373 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7374 for(int i=0;i<nbComp;i++)
7376 std::string info=infos[i];
7378 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7379 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7380 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7383 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7384 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
7385 int nbOfTS=_time_steps.size();
7386 for(int i=0;i<nbOfTS;i++)
7387 _time_steps[i]->writeLL(fid,opts,*this);
7390 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
7392 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7394 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7396 elt->loadBigArraysRecursively(fid,nasc);
7400 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
7402 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7404 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7406 elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7410 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
7412 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7414 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7416 elt->unloadArrays();
7420 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7422 return _time_steps.size();
7425 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
7427 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7428 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7430 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7432 newTS.push_back(*it);
7437 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
7439 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7440 int maxId=(int)_time_steps.size();
7442 std::set<int> idsToDel;
7443 for(const int *id=startIds;id!=endIds;id++,ii++)
7445 if(*id>=0 && *id<maxId)
7447 idsToDel.insert(*id);
7451 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7452 throw INTERP_KERNEL::Exception(oss.str());
7455 for(int iii=0;iii<maxId;iii++)
7456 if(idsToDel.find(iii)==idsToDel.end())
7457 newTS.push_back(_time_steps[iii]);
7461 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
7463 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7464 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7465 if(nbOfEntriesToKill==0)
7467 std::size_t sz=_time_steps.size();
7468 std::vector<bool> b(sz,true);
7470 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7472 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7473 for(std::size_t i=0;i<sz;i++)
7475 newTS.push_back(_time_steps[i]);
7479 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
7482 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
7483 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7485 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7489 tmp->getTime(it2,ord);
7490 if(it2==iteration && order==ord)
7493 oss << "(" << it2 << "," << ord << "), ";
7496 throw INTERP_KERNEL::Exception(oss.str());
7499 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
7502 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
7504 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7506 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7510 double ti=tmp->getTime(it2,ord);
7511 if(fabs(time-ti)<eps)
7517 throw INTERP_KERNEL::Exception(oss.str());
7520 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
7522 int lgth=_time_steps.size();
7523 std::vector< std::pair<int,int> > ret(lgth);
7524 for(int i=0;i<lgth;i++)
7525 _time_steps[i]->fillIteration(ret[i]);
7530 * 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'
7531 * This method returns two things.
7532 * - The absolute dimension of 'this' in first parameter.
7533 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7534 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
7536 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7537 * Only these 3 discretizations will be taken into account here.
7539 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7540 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7541 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7543 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7544 * 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'.
7546 * Let's consider the typical following case :
7547 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7548 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7549 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7551 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7553 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7555 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7556 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7557 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7558 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7560 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
7562 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7565 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
7567 if(pos<0 || pos>=(int)_time_steps.size())
7569 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7570 throw INTERP_KERNEL::Exception(oss.str());
7572 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7575 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7576 oss << "\nTry to use following method eraseEmptyTS !";
7577 throw INTERP_KERNEL::Exception(oss.str());
7582 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
7584 if(pos<0 || pos>=(int)_time_steps.size())
7586 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7587 throw INTERP_KERNEL::Exception(oss.str());
7589 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7592 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7593 oss << "\nTry to use following method eraseEmptyTS !";
7594 throw INTERP_KERNEL::Exception(oss.str());
7599 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
7601 std::vector<std::string> ret;
7602 std::set<std::string> ret2;
7603 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7605 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
7606 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7607 if(ret2.find(*it2)==ret2.end())
7609 ret.push_back(*it2);
7616 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
7618 std::vector<std::string> ret;
7619 std::set<std::string> ret2;
7620 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7622 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
7623 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7624 if(ret2.find(*it2)==ret2.end())
7626 ret.push_back(*it2);
7633 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
7635 std::vector<std::string> ret;
7636 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7638 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
7639 ret.insert(ret.end(),tmp.begin(),tmp.end());
7644 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
7646 std::vector<std::string> ret;
7647 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7649 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
7650 ret.insert(ret.end(),tmp.begin(),tmp.end());
7655 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7657 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7658 (*it)->changePflsRefsNamesGen2(mapOfModif);
7661 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7663 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7664 (*it)->changeLocsRefsNamesGen2(mapOfModif);
7667 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
7669 int lgth=_time_steps.size();
7670 std::vector< std::vector<TypeOfField> > ret(lgth);
7671 for(int i=0;i<lgth;i++)
7672 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
7677 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
7679 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
7681 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
7684 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCopy() const
7686 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
7688 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7690 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
7691 ret->_time_steps[i]=(*it)->deepCopy();
7696 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
7698 std::size_t sz(_infos.size()),sz2(_time_steps.size());
7699 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7700 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7701 for(std::size_t i=0;i<sz;i++)
7703 ret[i]=shallowCpy();
7704 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7706 for(std::size_t i=0;i<sz2;i++)
7708 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7711 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7712 throw INTERP_KERNEL::Exception(oss.str());
7716 for(std::size_t i=0;i<sz;i++)
7717 for(std::size_t j=0;j<sz2;j++)
7718 ret[i]->_time_steps[j]=ts[j][i];
7723 * This method splits into discretization each time steps in \a this.
7724 * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
7726 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
7728 std::size_t sz(_time_steps.size());
7729 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7730 for(std::size_t i=0;i<sz;i++)
7732 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7735 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
7736 throw INTERP_KERNEL::Exception(oss.str());
7738 items[i]=timeStep->splitDiscretizations();
7741 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
7742 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
7743 std::vector< TypeOfField > types;
7744 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7745 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7747 std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
7749 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
7750 std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
7751 if(it2==types.end())
7752 types.push_back(ts[0]);
7754 ret.resize(types.size()); ret2.resize(types.size());
7755 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7756 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7758 TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
7759 std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
7760 ret2[pos].push_back(*it1);
7762 for(std::size_t i=0;i<types.size();i++)
7764 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7765 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
7766 elt->pushBackTimeStep(*it1);//also updates infos in elt
7768 elt->MEDFileFieldNameScope::operator=(*this);
7774 * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
7776 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
7778 std::size_t sz(_time_steps.size());
7779 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7780 std::size_t szOut(std::numeric_limits<std::size_t>::max());
7781 for(std::size_t i=0;i<sz;i++)
7783 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7786 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
7787 throw INTERP_KERNEL::Exception(oss.str());
7789 items[i]=timeStep->splitMultiDiscrPerGeoTypes();
7790 if(szOut==std::numeric_limits<std::size_t>::max())
7791 szOut=items[i].size();
7793 if(items[i].size()!=szOut)
7794 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
7796 if(szOut==std::numeric_limits<std::size_t>::max())
7797 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
7798 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
7799 for(std::size_t i=0;i<szOut;i++)
7801 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7802 for(std::size_t j=0;j<sz;j++)
7803 elt->pushBackTimeStep(items[j][i]);
7805 elt->MEDFileFieldNameScope::operator=(*this);
7810 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
7812 setName(field->getName());
7813 if(field->getMesh())
7814 setMeshName(field->getMesh()->getName());
7816 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
7818 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
7819 _infos=arr->getInfoOnComponents();
7822 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
7824 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
7825 if(_name!=field->getName())
7827 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
7828 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
7829 throw INTERP_KERNEL::Exception(oss.str());
7832 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
7833 checkThatComponentsMatch(arr->getInfoOnComponents());
7836 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
7838 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
7839 if(getInfo().size()!=compos.size())
7841 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
7842 oss << " number of components of element to append (" << compos.size() << ") !";
7843 throw INTERP_KERNEL::Exception(oss.str());
7847 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
7848 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
7849 oss << " But compo in input fields are : ";
7850 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
7852 throw INTERP_KERNEL::Exception(oss.str());
7856 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
7858 std::size_t sz=_infos.size();
7860 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
7862 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7864 if(elt->getInfo().size()!=sz)
7866 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
7867 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
7868 throw INTERP_KERNEL::Exception(oss.str());
7873 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
7876 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7877 if(!_time_steps.empty())
7878 checkCoherencyOfTinyInfo(field,arr);
7879 MEDFileAnyTypeField1TSWithoutSDA *objC(createNew1TSWithoutSDAEmptyInstance());
7880 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7882 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*field));
7883 objC->setFieldNoProfileSBT(field->timeDiscrSafe(),ft,arr,glob,*this);
7885 copyTinyInfoFrom(field,arr);
7886 _time_steps.push_back(obj);
7889 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
7892 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7893 if(!_time_steps.empty())
7894 checkCoherencyOfTinyInfo(field,arr);
7895 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
7896 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7898 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::NewWithoutCheck(*field));
7899 objC->setFieldProfile(field->timeDiscrSafe(),ft,arr,mesh,meshDimRelToMax,profile,glob,*this);
7901 copyTinyInfoFrom(field,arr);
7902 setMeshName(objC->getMeshName());
7903 _time_steps.push_back(obj);
7906 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ts)
7908 int sz=(int)_time_steps.size();
7911 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
7912 throw INTERP_KERNEL::Exception(oss.str());
7914 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
7917 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
7919 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
7920 throw INTERP_KERNEL::Exception(oss.str());
7926 //= MEDFileFieldMultiTSWithoutSDA
7929 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
7930 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
7932 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
7934 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
7935 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
7937 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
7938 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
7941 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
7943 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
7944 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
7946 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7948 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
7951 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
7953 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
7954 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
7955 ret->setIteration(i,elt);
7961 //= MEDFileAnyTypeFieldMultiTS
7963 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
7967 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
7968 try:MEDFileFieldGlobsReal(fid)
7970 _content=BuildContentFrom(fid,loadAll,ms);
7973 catch(INTERP_KERNEL::Exception& e)
7978 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7980 med_field_type typcha;
7981 std::vector<std::string> infos;
7983 std::string meshName;
7985 MEDFileAnyTypeField1TS::LocateField(fid,fieldName,i,typcha,infos,dtunit,meshName);
7986 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7991 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
7996 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
7999 case MED_NODE://6432
8001 ret=new MEDFileFloatFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8006 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, MED_FLOAT32] !";
8007 throw INTERP_KERNEL::Exception(oss.str());
8010 ret->setMeshName(meshName);
8011 ret->setDtUnit(dtunit.c_str());
8015 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8017 med_field_type typcha;
8019 std::vector<std::string> infos;
8020 std::string dtunit,fieldName,meshName;
8021 MEDFileAnyTypeField1TS::LocateField2(fid,0,true,fieldName,typcha,infos,dtunit,meshName);
8022 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8027 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8032 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8035 case MED_NODE://6432
8037 ret=new MEDFileFloatFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8042 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, MED_FLOAT32] !";
8043 throw INTERP_KERNEL::Exception(oss.str());
8046 ret->setMeshName(meshName);
8047 ret->setDtUnit(dtunit.c_str());
8051 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c)
8054 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
8055 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
8057 MCAuto<MEDFileFieldMultiTS> ret(MEDFileFieldMultiTS::New());
8058 ret->_content=c; c->incrRef();
8061 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
8063 MCAuto<MEDFileIntFieldMultiTS> ret(MEDFileIntFieldMultiTS::New());
8064 ret->_content=c; c->incrRef();
8067 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
8070 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, med_idt fid)
8072 MEDFileAnyTypeFieldMultiTS *ret(BuildNewInstanceFromContent(c));
8073 std::string fileName(FileNameFromFID(fid));
8074 ret->setFileName(fileName);
8078 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8079 try:MEDFileFieldGlobsReal(fid)
8081 _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
8084 catch(INTERP_KERNEL::Exception& e)
8089 //= MEDFileAnyTypeFieldMultiTS
8092 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
8093 * that has been read from a specified MED file.
8094 * \param [in] fileName - the name of the MED file to read.
8095 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8096 * is to delete this field using decrRef() as it is no more needed.
8097 * \throw If reading the file fails.
8099 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
8101 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8102 return New(fid,loadAll);
8105 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, bool loadAll)
8107 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
8108 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8109 ret->loadGlobals(fid);
8114 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
8115 * that has been read from a specified MED file.
8116 * \param [in] fileName - the name of the MED file to read.
8117 * \param [in] fieldName - the name of the field to read.
8118 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8119 * is to delete this field using decrRef() as it is no more needed.
8120 * \throw If reading the file fails.
8121 * \throw If there is no field named \a fieldName in the file.
8123 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8125 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8126 return New(fid,fieldName,loadAll);
8129 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
8131 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
8132 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8133 ret->loadGlobals(fid);
8138 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8139 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8141 * \warning this is a shallow copy constructor
8143 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8145 if(!shallowCopyOfContent)
8147 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
8148 otherPtr->incrRef();
8149 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
8153 _content=other.shallowCpy();
8157 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
8159 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8161 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
8165 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
8167 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8169 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
8173 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
8175 return contentNotNullBase()->getPflsReallyUsed2();
8178 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
8180 return contentNotNullBase()->getLocsReallyUsed2();
8183 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
8185 return contentNotNullBase()->getPflsReallyUsedMulti2();
8188 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
8190 return contentNotNullBase()->getLocsReallyUsedMulti2();
8193 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8195 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
8198 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8200 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
8203 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
8205 return contentNotNullBase()->getNumberOfTS();
8208 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
8210 contentNotNullBase()->eraseEmptyTS();
8213 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
8215 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
8218 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
8220 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
8223 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
8225 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
8226 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8231 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
8233 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
8234 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8239 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
8241 return contentNotNullBase()->getIterations();
8244 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
8246 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
8247 pushBackTimeStep(*it);
8250 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
8253 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
8254 int nbOfTS(fmts->getNumberOfTS());
8255 for(int i=0;i<nbOfTS;i++)
8257 MCAuto<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
8258 pushBackTimeStep(elt);
8262 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
8265 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
8266 checkCoherencyOfType(f1ts);
8268 MCAuto<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
8269 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
8271 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
8272 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
8273 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
8274 _content->pushBackTimeStep(cSafe);
8275 appendGlobs(*f1ts,1e-12);
8278 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
8280 contentNotNullBase()->synchronizeNameScope();
8283 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
8285 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
8288 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
8290 return contentNotNullBase()->getPosGivenTime(time,eps);
8293 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8295 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
8298 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
8300 return contentNotNullBase()->getTypesOfFieldAvailable();
8303 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
8305 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
8308 std::string MEDFileAnyTypeFieldMultiTS::getName() const
8310 return contentNotNullBase()->getName();
8313 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
8315 contentNotNullBase()->setName(name);
8318 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
8320 return contentNotNullBase()->getDtUnit();
8323 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
8325 contentNotNullBase()->setDtUnit(dtUnit);
8328 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8330 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
8333 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
8335 return contentNotNullBase()->getTimeSteps(ret1);
8338 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
8340 return contentNotNullBase()->getMeshName();
8343 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
8345 contentNotNullBase()->setMeshName(newMeshName);
8348 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
8350 return contentNotNullBase()->changeMeshNames(modifTab);
8353 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
8355 return contentNotNullBase()->getInfo();
8358 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
8360 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
8363 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
8365 return contentNotNullBase()->setInfo(info);
8368 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
8370 const std::vector<std::string> ret=getInfo();
8371 return (int)ret.size();
8374 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
8376 writeGlobals(fid,*this);
8377 contentNotNullBase()->writeLL(fid,*this);
8381 * This method alloc the arrays and load potentially huge arrays contained in this field.
8382 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
8383 * This method can be also called to refresh or reinit values from a file.
8385 * \throw If the fileName is not set or points to a non readable MED file.
8387 void MEDFileAnyTypeFieldMultiTS::loadArrays()
8389 if(getFileName().empty())
8390 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
8391 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
8392 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
8396 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
8397 * But once data loaded once, this method does nothing.
8399 * \throw If the fileName is not set or points to a non readable MED file.
8400 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
8402 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
8404 if(!getFileName().empty())
8406 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
8407 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
8412 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
8413 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
8414 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
8416 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
8418 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
8420 contentNotNullBase()->unloadArrays();
8424 * 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.
8425 * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
8426 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
8428 * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
8430 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
8432 if(!getFileName().empty())
8433 contentNotNullBase()->unloadArrays();
8436 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
8438 std::ostringstream oss;
8439 contentNotNullBase()->simpleRepr(0,oss,-1);
8440 simpleReprGlobs(oss);
8444 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
8446 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
8449 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
8451 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
8452 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
8457 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
8458 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8459 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
8461 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
8463 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8465 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
8466 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
8467 std::size_t sz(contentsSplit.size());
8468 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8469 for(std::size_t i=0;i<sz;i++)
8471 ret[i]=shallowCpy();
8472 ret[i]->_content=contentsSplit[i];
8478 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
8479 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8481 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
8483 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8485 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
8486 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
8487 std::size_t sz(contentsSplit.size());
8488 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8489 for(std::size_t i=0;i<sz;i++)
8491 ret[i]=shallowCpy();
8492 ret[i]->_content=contentsSplit[i];
8498 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
8499 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8501 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
8503 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8505 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
8506 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
8507 std::size_t sz(contentsSplit.size());
8508 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8509 for(std::size_t i=0;i<sz;i++)
8511 ret[i]=shallowCpy();
8512 ret[i]->_content=contentsSplit[i];
8517 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCopy() const
8519 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8520 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
8521 ret->_content=_content->deepCopy();
8522 ret->deepCpyGlobs(*this);
8526 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
8532 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8533 * \param [in] iteration - the iteration number of a required time step.
8534 * \param [in] order - the iteration order number of required time step.
8535 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
8536 * delete this field using decrRef() as it is no more needed.
8537 * \throw If there is no required time step in \a this field.
8539 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
8541 int pos=getPosOfTimeStep(iteration,order);
8542 return getTimeStepAtPos(pos);
8546 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8547 * \param [in] time - the time of the time step of interest.
8548 * \param [in] eps - a precision used to compare time values.
8549 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8550 * delete this field using decrRef() as it is no more needed.
8551 * \throw If there is no required time step in \a this field.
8553 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
8555 int pos=getPosGivenTime(time,eps);
8556 return getTimeStepAtPos(pos);
8560 * 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.
8561 * The float64 value of time attached to the pair of integers are not considered here.
8562 * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
8564 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
8565 * \throw If there is a null pointer in \a vectFMTS.
8567 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
8569 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
8570 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8571 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8572 while(!lstFMTS.empty())
8574 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8575 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8577 throw INTERP_KERNEL::Exception(msg);
8578 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
8579 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8580 elt.push_back(curIt); it=lstFMTS.erase(it);
8581 while(it!=lstFMTS.end())
8585 throw INTERP_KERNEL::Exception(msg);
8586 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
8588 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8598 * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
8599 * All returned instances in a subvector can be safely loaded, rendered along time
8600 * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
8601 * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
8602 * 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).
8603 * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
8604 * 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.
8606 * \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().
8607 * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
8608 * \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.
8609 * \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.
8611 * \throw If an element in \a vectFMTS has not only one spatial discretization set.
8612 * \throw If an element in \a vectFMTS change of spatial discretization along time.
8613 * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
8614 * \thorw If some elements in \a vectFMTS do not have the same times steps.
8615 * \throw If mesh is null.
8616 * \throw If an element in \a vectFMTS is null.
8617 * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
8619 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& fsc)
8621 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
8623 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
8624 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8625 if(vectFMTS.empty())
8627 std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
8628 MEDFileAnyTypeFieldMultiTS *frstElt(*it);
8630 throw INTERP_KERNEL::Exception(msg);
8632 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
8633 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
8634 for(;it!=vectFMTS.end();it++,i++)
8637 throw INTERP_KERNEL::Exception(msg);
8638 TypeOfField tof0,tof1;
8639 if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
8642 vectFMTSNotNodes.push_back(*it);
8644 vectFMTSNodes.push_back(*it);
8647 vectFMTSNotNodes.push_back(*it);
8649 std::vector< MCAuto<MEDFileFastCellSupportComparator> > cmps;
8650 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
8652 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
8655 bool isFetched(false);
8656 for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
8659 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
8660 if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
8661 { ret[i].push_back(*it2); isFetched=true; }
8665 std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
8666 MCAuto<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
8667 ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
8675 * 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.
8676 * \param [out] cmps - same size than the returned vector.
8678 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& cmps)
8680 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8681 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8682 while(!lstFMTS.empty())
8684 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8685 MEDFileAnyTypeFieldMultiTS *ref(*it);
8686 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8687 elt.push_back(ref); it=lstFMTS.erase(it);
8688 MCAuto<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
8689 MCAuto<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
8690 while(it!=lstFMTS.end())
8692 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8693 if(cmp->isEqual(curIt))
8694 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8698 ret.push_back(elt); cmps.push_back(cmp);
8704 * 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.
8705 * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
8707 * \throw If \a f0 or \a f1 has not only one spatial discretization set.
8708 * \throw If \a f0 or \a f1 change of spatial discretization along time.
8709 * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
8710 * \thorw If \a f0 and \a f1 do not have the same times steps.
8711 * \throw If mesh is null.
8712 * \throw If \a f0 or \a f1 is null.
8713 * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
8715 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
8718 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
8720 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
8721 if(f0->getMeshName()!=mesh->getName())
8723 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8724 throw INTERP_KERNEL::Exception(oss.str());
8726 if(f1->getMeshName()!=mesh->getName())
8728 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8729 throw INTERP_KERNEL::Exception(oss.str());
8731 int nts=f0->getNumberOfTS();
8732 if(nts!=f1->getNumberOfTS())
8733 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
8736 for(int i=0;i<nts;i++)
8738 MCAuto<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
8739 MCAuto<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
8740 std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
8741 if(tofs0.size()!=1 || tofs1.size()!=1)
8742 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
8745 if(tof0!=tofs0[0] || tof1!=tofs1[0])
8746 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
8749 { tof0=tofs0[0]; tof1=tofs1[0]; }
8750 if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
8752 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() << ") !";
8753 throw INTERP_KERNEL::Exception(oss.str());
8755 if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
8757 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() << ") !";
8758 throw INTERP_KERNEL::Exception(oss.str());
8760 if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
8762 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() << ") !";
8763 throw INTERP_KERNEL::Exception(oss.str());
8770 MCAuto<MEDFileAnyTypeField1TS> AggregateHelperF1TS(const std::vector< typename MLFieldTraits<T>::F1TSType const *>& f1tss, const std::vector< std::vector< std::pair<int,int> > >& dts)
8772 MCAuto< typename MLFieldTraits<T>::F1TSType > ret(MLFieldTraits<T>::F1TSType::New());
8774 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : empty vector !");
8775 std::size_t sz(f1tss.size()),i(0);
8776 std::vector< typename MLFieldTraits<T>::F1TSWSDAType const *> f1tsw(sz);
8777 for(typename std::vector< typename MLFieldTraits<T>::F1TSType const *>::const_iterator it=f1tss.begin();it!=f1tss.end();it++,i++)
8779 typename MLFieldTraits<T>::F1TSType const *elt(*it);
8781 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : presence of a null pointer !");
8782 f1tsw[i]=dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType const *>(elt->contentNotNullBase());
8784 typename MLFieldTraits<T>::F1TSWSDAType *retc(dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType *>(ret->contentNotNullBase()));
8786 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : internal error 1 !");
8787 retc->aggregate(f1tsw,dts);
8788 ret->setDtUnit(f1tss[0]->getDtUnit());
8789 return DynamicCast<typename MLFieldTraits<T>::F1TSType , MEDFileAnyTypeField1TS>(ret);
8793 MCAuto< MEDFileAnyTypeFieldMultiTS > AggregateHelperFMTS(const std::vector< typename MLFieldTraits<T>::FMTSType const *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
8795 MCAuto< typename MLFieldTraits<T>::FMTSType > ret(MLFieldTraits<T>::FMTSType::New());
8797 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : empty vector !");
8798 std::size_t sz(fmtss.size());
8799 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
8801 typename MLFieldTraits<T>::FMTSType const *elt(*it);
8803 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : presence of null pointer !");
8805 int nbTS(fmtss[0]->getNumberOfTS());
8806 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
8807 if((*it)->getNumberOfTS()!=nbTS)
8808 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : all fields must have the same number of TS !");
8809 for(int iterTS=0;iterTS<nbTS;iterTS++)
8812 std::vector< typename MLFieldTraits<T>::F1TSType const *> f1tss(sz);
8813 std::vector< MCAuto<typename MLFieldTraits<T>::F1TSType> > f1tss2(sz);
8814 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++,i++)
8815 { f1tss2[i]=(*it)->getTimeStepAtPos(iterTS); f1tss[i]=f1tss2[i]; }
8816 MCAuto<MEDFileAnyTypeField1TS> f1ts(AggregateHelperF1TS<T>(f1tss,dts));
8817 ret->pushBackTimeStep(f1ts);
8818 ret->setDtUnit(f1ts->getDtUnit());
8820 return DynamicCast<typename MLFieldTraits<T>::FMTSType , MEDFileAnyTypeFieldMultiTS>(ret);
8824 * \a dts and \a ftmss are expected to have same size.
8826 MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileAnyTypeFieldMultiTS::Aggregate(const std::vector<const MEDFileAnyTypeFieldMultiTS *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
8829 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : input vector is empty !");
8830 std::size_t sz(fmtss.size());
8831 std::vector<const MEDFileFieldMultiTS *> fmtss1;
8832 std::vector<const MEDFileIntFieldMultiTS *> fmtss2;
8833 for(std::vector<const MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
8836 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : presence of null instance in input vector !");
8837 const MEDFileFieldMultiTS *elt1(dynamic_cast<const MEDFileFieldMultiTS *>(*it));
8840 fmtss1.push_back(elt1);
8843 const MEDFileIntFieldMultiTS *elt2(dynamic_cast<const MEDFileIntFieldMultiTS *>(*it));
8846 fmtss2.push_back(elt2);
8849 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not recognized type !");
8851 if(fmtss1.size()!=sz && fmtss2.size()!=sz)
8852 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : type of data is not homogeneous !");
8853 if(fmtss1.size()==sz)
8854 return AggregateHelperFMTS<double>(fmtss1,dts);
8855 if(fmtss2.size()!=sz)
8856 return AggregateHelperFMTS<int>(fmtss2,dts);
8857 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not implemented yet !");
8860 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
8862 return new MEDFileAnyTypeFieldMultiTSIterator(this);
8865 //= MEDFileFieldMultiTS
8867 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
8869 return new MEDFileFieldMultiTS(*this);
8873 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
8874 * following the given input policy.
8876 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
8877 * By default (true) the globals are deeply copied.
8878 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
8880 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
8882 MCAuto<MEDFileIntFieldMultiTS> ret;
8883 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8886 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
8888 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
8889 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
8890 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc));
8893 ret=MEDFileIntFieldMultiTS::New();
8895 ret->deepCpyGlobs(*this);
8897 ret->shallowCpyGlobs(*this);
8901 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8902 try:MEDFileTemplateFieldMultiTS<double>(fid,loadAll,ms)
8905 catch(INTERP_KERNEL::Exception& e)
8908 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8909 try:MEDFileTemplateFieldMultiTS<double>(fid,fieldName,loadAll,ms,entities)
8912 catch(INTERP_KERNEL::Exception& e)
8915 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileTemplateFieldMultiTS<double>(other,shallowCopyOfContent)
8919 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
8921 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
8924 //= MEDFileAnyTypeFieldMultiTSIterator
8926 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
8931 _nb_iter=fmts->getNumberOfTS();
8935 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
8939 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
8941 if(_iter_id<_nb_iter)
8943 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
8945 return fmts->getTimeStepAtPos(_iter_id++);
8953 //= MEDFileIntFieldMultiTS
8957 MEDFileFields *MEDFileFields::New()
8959 return new MEDFileFields;
8962 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
8964 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8965 return New(fid,loadAll);
8968 MEDFileFields *MEDFileFields::NewAdv(const std::string& fileName, bool loadAll, const MEDFileEntities *entities)
8970 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8971 return NewAdv(fid,loadAll,entities);
8974 MEDFileFields *MEDFileFields::NewAdv(med_idt fid, bool loadAll, const MEDFileEntities *entities)
8976 return new MEDFileFields(fid,loadAll,0,entities);
8979 MEDFileFields *MEDFileFields::NewWithDynGT(const std::string& fileName, const MEDFileStructureElements *se, bool loadAll)
8981 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8982 return NewWithDynGT(fid,se,loadAll);
8985 MEDFileFields *MEDFileFields::NewWithDynGT(med_idt fid, const MEDFileStructureElements *se, bool loadAll)
8988 throw INTERP_KERNEL::Exception("MEDFileFields::NewWithDynGT : null struct element pointer !");
8989 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> entities(MEDFileEntities::BuildFrom(*se));
8990 return new MEDFileFields(fid,loadAll,0,entities);
8993 MEDFileFields *MEDFileFields::New(med_idt fid, bool loadAll)
8995 return new MEDFileFields(fid,loadAll,0,0);
8998 MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9000 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9001 return new MEDFileFields(fid,loadAll,ms,0);
9004 MEDFileFields *MEDFileFields::LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9006 MEDFileUtilities::CheckFileForRead(fileName);
9007 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
9008 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9009 return new MEDFileFields(fid,loadAll,0,ent);
9012 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
9014 std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
9015 ret+=_fields.capacity()*sizeof(MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
9019 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
9021 std::vector<const BigMemoryObject *> ret;
9022 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9023 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
9027 MEDFileFields *MEDFileFields::deepCopy() const
9029 MCAuto<MEDFileFields> ret(shallowCpy());
9031 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9033 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9034 ret->_fields[i]=(*it)->deepCopy();
9036 ret->deepCpyGlobs(*this);
9040 MEDFileFields *MEDFileFields::shallowCpy() const
9042 return new MEDFileFields(*this);
9046 * 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
9047 * 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.
9048 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
9050 * \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.
9051 * \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.
9053 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9055 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
9057 std::set< std::pair<int,int> > s;
9058 bool firstShot=true;
9059 areThereSomeForgottenTS=false;
9060 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9062 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9064 std::vector< std::pair<int,int> > v=(*it)->getIterations();
9065 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
9067 { s=s1; firstShot=false; }
9070 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
9072 areThereSomeForgottenTS=true;
9076 std::vector< std::pair<int,int> > ret;
9077 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
9081 int MEDFileFields::getNumberOfFields() const
9083 return _fields.size();
9086 std::vector<std::string> MEDFileFields::getFieldsNames() const
9088 std::vector<std::string> ret(_fields.size());
9090 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9092 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
9095 ret[i]=f->getName();
9099 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
9100 throw INTERP_KERNEL::Exception(oss.str());
9106 std::vector<std::string> MEDFileFields::getMeshesNames() const
9108 std::vector<std::string> ret;
9109 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9111 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9113 ret.push_back(cur->getMeshName());
9118 std::string MEDFileFields::simpleRepr() const
9120 std::ostringstream oss;
9121 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
9126 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
9128 int nbOfFields(getNumberOfFields());
9129 std::string startLine(bkOffset,' ');
9130 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
9132 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9134 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9137 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
9141 oss << startLine << " - not defined !" << std::endl;
9145 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9147 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9148 std::string chapter(17,'0'+i);
9149 oss << startLine << chapter << std::endl;
9152 cur->simpleRepr(bkOffset+2,oss,i);
9156 oss << startLine << " - not defined !" << std::endl;
9158 oss << startLine << chapter << std::endl;
9160 simpleReprGlobs(oss);
9163 MEDFileFields::MEDFileFields()
9167 MEDFileFields::MEDFileFields(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
9168 try:MEDFileFieldGlobsReal(fid)
9170 int nbFields(MEDnField(fid));
9171 _fields.resize(nbFields);
9172 med_field_type typcha;
9173 for(int i=0;i<nbFields;i++)
9175 std::vector<std::string> infos;
9176 std::string fieldName,dtunit,meshName;
9177 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,i,false,fieldName,typcha,infos,dtunit,meshName));
9182 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName,meshName,typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
9187 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName,meshName,typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
9190 case MED_NODE://6432
9192 _fields[i]=MEDFileFloatFieldMultiTSWithoutSDA::New(fid,fieldName,meshName,typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
9197 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, MED_FLOAT32] !";
9198 throw INTERP_KERNEL::Exception(oss.str());
9202 loadAllGlobals(fid,entities);
9204 catch(INTERP_KERNEL::Exception& e)
9209 void MEDFileFields::writeLL(med_idt fid) const
9212 writeGlobals(fid,*this);
9213 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9215 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
9218 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
9219 throw INTERP_KERNEL::Exception(oss.str());
9221 elt->writeLL(fid,*this);
9226 * This method alloc the arrays and load potentially huge arrays contained in this field.
9227 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
9228 * This method can be also called to refresh or reinit values from a file.
9230 * \throw If the fileName is not set or points to a non readable MED file.
9232 void MEDFileFields::loadArrays()
9234 if(getFileName().empty())
9235 throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
9236 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
9237 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9239 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9241 elt->loadBigArraysRecursively(fid,*elt);
9246 * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
9247 * But once data loaded once, this method does nothing.
9249 * \throw If the fileName is not set or points to a non readable MED file.
9250 * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
9252 void MEDFileFields::loadArraysIfNecessary()
9254 if(!getFileName().empty())
9256 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
9257 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9259 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9261 elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
9267 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
9268 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
9269 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
9271 * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
9273 void MEDFileFields::unloadArrays()
9275 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9277 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9279 elt->unloadArrays();
9284 * 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.
9285 * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
9286 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
9288 * \sa MEDFileFields::loadArraysIfNecessary
9290 void MEDFileFields::unloadArraysWithoutDataLoss()
9292 if(!getFileName().empty())
9296 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
9298 std::vector<std::string> ret;
9299 std::set<std::string> ret2;
9300 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9302 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
9303 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
9304 if(ret2.find(*it2)==ret2.end())
9306 ret.push_back(*it2);
9313 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
9315 std::vector<std::string> ret;
9316 std::set<std::string> ret2;
9317 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9319 std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
9320 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
9321 if(ret2.find(*it2)==ret2.end())
9323 ret.push_back(*it2);
9330 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
9332 std::vector<std::string> ret;
9333 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9335 std::vector<std::string> tmp((*it)->getPflsReallyUsedMulti2());
9336 ret.insert(ret.end(),tmp.begin(),tmp.end());
9341 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
9343 std::vector<std::string> ret;
9344 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9346 std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
9347 ret.insert(ret.end(),tmp.begin(),tmp.end());
9352 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
9354 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
9355 (*it)->changePflsRefsNamesGen2(mapOfModif);
9358 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
9360 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
9361 (*it)->changeLocsRefsNamesGen2(mapOfModif);
9364 void MEDFileFields::resize(int newSize)
9366 _fields.resize(newSize);
9369 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
9371 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
9375 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
9378 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
9379 _fields.push_back(field->getContent());
9380 appendGlobs(*field,1e-12);
9383 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
9386 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
9387 if(i>=(int)_fields.size())
9388 _fields.resize(i+1);
9389 _fields[i]=field->getContent();
9390 appendGlobs(*field,1e-12);
9393 void MEDFileFields::destroyFieldAtPos(int i)
9395 destroyFieldsAtPos(&i,&i+1);
9398 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
9400 std::vector<bool> b(_fields.size(),true);
9401 for(const int *i=startIds;i!=endIds;i++)
9403 if(*i<0 || *i>=(int)_fields.size())
9405 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
9406 throw INTERP_KERNEL::Exception(oss.str());
9410 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
9412 for(std::size_t i=0;i<_fields.size();i++)
9414 fields[j++]=_fields[i];
9418 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
9420 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
9421 int nbOfEntriesToKill(DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg));
9422 std::vector<bool> b(_fields.size(),true);
9424 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
9426 if(k<0 || k>=(int)_fields.size())
9428 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
9429 throw INTERP_KERNEL::Exception(oss.str());
9433 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
9435 for(std::size_t i=0;i<_fields.size();i++)
9437 fields[j++]=_fields[i];
9441 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
9444 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9446 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9448 ret=cur->changeMeshNames(modifTab) || ret;
9454 * \param [in] meshName the name of the mesh that will be renumbered.
9455 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
9456 * This code corresponds to the distribution of types in the corresponding mesh.
9457 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
9458 * \param [in] renumO2N the old to new renumber array.
9459 * \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
9462 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
9465 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9467 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
9470 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
9477 * Return an extraction of \a this using \a extractDef map to specify the extraction.
9478 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
9480 * \return A new object that the caller is responsible to deallocate.
9482 MEDFileFields *MEDFileFields::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
9485 throw INTERP_KERNEL::Exception("MEDFileFields::extractPart : input mesh is NULL !");
9486 MCAuto<MEDFileFields> fsOut(MEDFileFields::New());
9487 int nbFields(getNumberOfFields());
9488 for(int i=0;i<nbFields;i++)
9490 MCAuto<MEDFileAnyTypeFieldMultiTS> fmts(getFieldAtPos(i));
9493 std::ostringstream oss; oss << "MEDFileFields::extractPart : at pos #" << i << " field is null !";
9494 throw INTERP_KERNEL::Exception(oss.str());
9496 MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(fmts->extractPart(extractDef,mm));
9497 fsOut->pushField(fmtsOut);
9499 return fsOut.retn();
9502 void MEDFileFields::accept(MEDFileFieldVisitor& visitor) const
9504 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9505 if((*it).isNotNull())
9507 visitor.newFieldEntry(*it);
9508 (*it)->accept(visitor);
9509 visitor.endFieldEntry(*it);
9513 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
9515 if(i<0 || i>=(int)_fields.size())
9517 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
9518 throw INTERP_KERNEL::Exception(oss.str());
9520 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
9523 MCAuto<MEDFileAnyTypeFieldMultiTS> ret;
9524 const MEDFileFieldMultiTSWithoutSDA *fmtsC(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts));
9525 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts));
9527 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
9529 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
9532 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
9533 throw INTERP_KERNEL::Exception(oss.str());
9535 ret->shallowCpyGlobs(*this);
9540 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
9541 * This method is accessible in python using __getitem__ with a list in input.
9542 * \return a new object that the caller should deal with.
9544 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
9546 MCAuto<MEDFileFields> ret=shallowCpy();
9547 std::size_t sz=std::distance(startIds,endIds);
9548 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
9550 for(const int *i=startIds;i!=endIds;i++,j++)
9552 if(*i<0 || *i>=(int)_fields.size())
9554 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
9555 throw INTERP_KERNEL::Exception(oss.str());
9557 fields[j]=_fields[*i];
9559 ret->_fields=fields;
9563 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
9565 return getFieldAtPos(getPosFromFieldName(fieldName));
9569 * This method removes, if any, fields in \a this having no time steps.
9570 * 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.
9572 * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
9574 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
9576 std::vector<MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
9577 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9579 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9582 if(elt->getNumberOfTS()>0)
9583 newFields.push_back(*it);
9586 if(_fields.size()==newFields.size())
9593 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
9594 * This method can be seen as a filter applied on \a this, that returns an object containing
9595 * 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
9596 * shallow copied from \a this.
9598 * \param [in] meshName - the name of the mesh on w
9599 * \return a new object that the caller should deal with.
9601 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
9603 MCAuto<MEDFileFields> ret(MEDFileFields::New());
9604 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9606 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9609 if(cur->getMeshName()==meshName)
9612 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
9613 ret->_fields.push_back(cur2);
9616 ret->shallowCpyOnlyUsedGlobs(*this);
9621 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
9622 * Input time steps are specified using a pair of integer (iteration, order).
9623 * 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,
9624 * but for each multitimestep only the time steps in \a timeSteps are kept.
9625 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
9627 * The returned object points to shallow copy of elements in \a this.
9629 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
9630 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
9631 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9633 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
9635 MCAuto<MEDFileFields> ret(MEDFileFields::New());
9636 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9638 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9641 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
9642 ret->_fields.push_back(elt);
9644 ret->shallowCpyOnlyUsedGlobs(*this);
9649 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
9651 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
9653 MCAuto<MEDFileFields> ret=MEDFileFields::New();
9654 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9656 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9659 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
9660 if(elt->getNumberOfTS()!=0)
9661 ret->_fields.push_back(elt);
9663 ret->shallowCpyOnlyUsedGlobs(*this);
9667 bool MEDFileFields::presenceOfStructureElements() const
9669 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9670 if((*it).isNotNull())
9671 if((*it)->presenceOfStructureElements())
9676 void MEDFileFields::killStructureElements()
9678 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
9679 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9680 if((*it).isNotNull())
9682 if((*it)->presenceOfStructureElements())
9684 if(!(*it)->onlyStructureElements())
9686 (*it)->killStructureElements();
9698 void MEDFileFields::keepOnlyStructureElements()
9700 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
9701 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9702 if((*it).isNotNull())
9704 if((*it)->presenceOfStructureElements())
9706 if(!(*it)->onlyStructureElements())
9707 (*it)->keepOnlyStructureElements();
9714 void MEDFileFields::keepOnlyOnMeshSE(const std::string& meshName, const std::string& seName)
9716 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
9717 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9718 if((*it).isNotNull())
9720 if((*it)->getMeshName()!=meshName)
9722 std::vector< std::pair<std::string,std::string> > ps;
9723 (*it)->getMeshSENames(ps);
9724 std::pair<std::string,std::string> p(meshName,seName);
9725 if(std::find(ps.begin(),ps.end(),p)!=ps.end())
9726 (*it)->keepOnlyOnSE(seName);
9732 void MEDFileFields::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
9734 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9735 if((*it).isNotNull())
9736 (*it)->getMeshSENames(ps);
9739 void MEDFileFields::blowUpSE(MEDFileMeshes *ms, const MEDFileStructureElements *ses)
9741 MEDFileBlowStrEltUp::DealWithSE(this,ms,ses);
9744 MCAuto<MEDFileFields> MEDFileFields::partOfThisOnStructureElements() const
9746 MCAuto<MEDFileFields> ret(deepCopy());
9747 ret->keepOnlyStructureElements();
9751 MCAuto<MEDFileFields> MEDFileFields::partOfThisLyingOnSpecifiedMeshSEName(const std::string& meshName, const std::string& seName) const
9753 MCAuto<MEDFileFields> ret(deepCopy());
9754 ret->keepOnlyOnMeshSE(meshName,seName);
9758 void MEDFileFields::aggregate(const MEDFileFields& other)
9760 int nbFieldsToAdd(other.getNumberOfFields());
9761 std::vector<std::string> fsn(getFieldsNames());
9762 for(int i=0;i<nbFieldsToAdd;i++)
9764 MCAuto<MEDFileAnyTypeFieldMultiTS> elt(other.getFieldAtPos(i));
9765 std::string name(elt->getName());
9766 if(std::find(fsn.begin(),fsn.end(),name)!=fsn.end())
9768 std::ostringstream oss; oss << "MEDFileFields::aggregate : name \"" << name << "\" already appears !";
9769 throw INTERP_KERNEL::Exception(oss.str());
9775 MEDFileFieldsIterator *MEDFileFields::iterator()
9777 return new MEDFileFieldsIterator(this);
9780 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
9782 std::string tmp(fieldName);
9783 std::vector<std::string> poss;
9784 for(std::size_t i=0;i<_fields.size();i++)
9786 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f(_fields[i]);
9789 std::string fname(f->getName());
9793 poss.push_back(fname);
9796 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
9797 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
9799 throw INTERP_KERNEL::Exception(oss.str());
9802 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
9807 _nb_iter=fs->getNumberOfFields();
9811 MEDFileFieldsIterator::~MEDFileFieldsIterator()
9815 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
9817 if(_iter_id<_nb_iter)
9819 MEDFileFields *fs(_fs);
9821 return fs->getFieldAtPos(_iter_id++);