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 DataArrayFloat *arrF(dynamic_cast<DataArrayFloat *>(arr));
729 float *startFeeding(arrF->getPointer()+_start*nbOfCompo);
730 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
733 throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 FLOAT32 or INT32 !");
737 * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
739 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart)
741 int delta=_end-_start;
742 _start=newValueOfStart;
746 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
748 return _father->getIteration();
751 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
753 return _father->getOrder();
756 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
758 return _father->getTime();
761 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
763 return _father->getMeshName();
766 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
768 const char startLine[]=" ## ";
769 std::string startLine2(bkOffset,' ');
770 startLine2+=startLine;
771 INTERP_KERNEL::AutoCppPtr<MEDCouplingFieldDiscretization> tmp(MEDCouplingFieldDiscretization::New(_type));
772 oss << startLine2 << "Localization #" << id << "." << std::endl;
773 oss << startLine2 << " Type=" << tmp->getRepr() << "." << std::endl;
774 oss << startLine2 << " This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
775 oss << startLine2 << " This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
776 oss << startLine2 << " This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
779 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
784 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
786 return _father->getGeoType();
789 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
794 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
799 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
801 return _father->getNumberOfComponents();
804 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
809 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray()
811 return _father->getOrCreateAndGetArray();
814 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const
816 const MEDFileFieldPerMeshPerTypeCommon *fath=_father;
817 return fath->getOrCreateAndGetArray();
820 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
822 return _father->getInfo();
825 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
830 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const std::string& newPflName)
835 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
837 return _localization;
840 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const std::string& newLocName)
842 _localization=newLocName;
845 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
847 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
849 if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
851 _profile=(*it2).second;
857 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
859 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
861 if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
863 _localization=(*it2).second;
869 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
873 dads.push_back(std::pair<int,int>(_start,_end));
874 geoTypes.push_back(getGeoType());
879 pfls.push_back(glob->getProfile(_profile.c_str()));
881 if(_localization.empty())
885 locs.push_back(glob->getLocalizationId(_localization.c_str()));
889 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
891 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));
895 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
897 TypeOfField type=getType();
898 INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
899 med_geometry_type mgeoti;
900 med_entity_type menti;
901 _father->entriesForMEDfile(getType(),mgeoti,menti);
902 const DataArray *arr(getOrCreateAndGetArray());
904 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
905 if(!arr->isAllocated())
906 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : the array to be written is not allocated !");
907 const DataArrayDouble *arrD(dynamic_cast<const DataArrayDouble *>(arr));
908 const DataArrayInt *arrI(dynamic_cast<const DataArrayInt *>(arr));
909 const DataArrayFloat *arrF(dynamic_cast<const DataArrayFloat *>(arr));
910 const unsigned char *locToWrite=0;
912 locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
914 locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
916 locToWrite=reinterpret_cast<const unsigned char *>(arrF->getConstPointer()+_start*arr->getNumberOfComponents());
918 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 FLOAT32 and INT32 !");
919 MEDFILESAFECALLERWR0(MEDfieldValueWithProfileWr,(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
920 MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
924 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const
929 dad.first=_start; dad.second=_end;
933 * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
934 * This code corresponds to the distribution of types in the corresponding mesh.
935 * \param [out] ptToFill memory zone where the output will be stored.
936 * \return the size of data pushed into output param \a ptToFill
938 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const
941 std::ostringstream oss;
942 std::size_t nbOfType=codeOfMesh.size()/3;
944 for(std::size_t i=0;i<nbOfType && found==-1;i++)
945 if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
949 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
950 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
951 throw INTERP_KERNEL::Exception(oss.str());
956 if(_nval!=codeOfMesh[3*found+1])
958 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
959 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
960 oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
961 throw INTERP_KERNEL::Exception(oss.str());
963 for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
968 const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
969 if(pfl->getNumberOfTuples()!=_nval)
971 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
972 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
974 oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
975 throw INTERP_KERNEL::Exception(oss.str());
977 int offset2=codeOfMesh[3*found+2];
978 for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
980 if(*pflId<codeOfMesh[3*found+1])
981 *work++=offset2+*pflId;
987 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const
989 for(int i=_start;i<_end;i++)
994 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId)
1005 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
1009 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
1012 std::map<std::pair<std::string,TypeOfField>,int> m;
1013 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
1014 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
1015 if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
1016 m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
1018 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
1019 ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
1024 * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
1026 * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
1027 * \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.
1028 * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
1029 * \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)
1030 * \param [in,out] glob if necessary by the method, new profiles can be added to it
1031 * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
1032 * \param [out] result All new entries will be appended on it.
1033 * \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 !)
1035 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
1036 const DataArrayInt *explicitIdsInMesh,
1037 const std::vector<int>& newCode,
1038 MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
1039 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >& result)
1041 if(entriesOnSameDisc.empty())
1043 TypeOfField type=entriesOnSameDisc[0]->getType();
1044 int szEntities=0,szTuples=0;
1045 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
1046 { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
1047 int nbi=szTuples/szEntities;
1048 if(szTuples%szEntities!=0)
1049 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
1050 MCAuto<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
1051 MCAuto<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
1052 std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
1053 std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
1054 std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
1055 std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
1056 MCAuto<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
1058 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
1060 int startOfEltIdOfChunk=(*it)->_start;
1061 MCAuto<DataArrayInt> newEltIds=explicitIdsInMesh->subArray(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
1062 MCAuto<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
1063 MCAuto<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
1065 MCAuto<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
1066 newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
1068 newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
1069 newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
1071 MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
1072 MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
1073 MCAuto<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
1074 MCAuto<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
1076 MCAuto<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
1078 MCAuto<DataArrayDouble> arrPart=arr->subArray(offset,offset+szTuples);
1079 arrPart->renumberInPlace(renumTupleIds->begin());
1080 arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
1082 const int *idIt=diffVals->begin();
1083 std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
1085 for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
1087 MCAuto<DataArrayInt> ids=newGeoTypesEltIdsAllGather->findIdsEqual(*idIt);
1088 MCAuto<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
1089 int nbEntityElts=subIds->getNumberOfTuples();
1091 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
1092 NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIota(newCode[3*(*idIt)+1]),nbi,
1096 result.push_back(eltToAdd);
1097 offset2+=nbEntityElts*nbi;
1099 ret=ret || li.empty();
1104 * \param [in] typeF type of field of new chunk
1105 * \param [in] geoType the geometric type of the chunk
1106 * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
1107 * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
1108 * \param [in] nbi number of integration points
1109 * \param [in] offset The offset in the **global array of data**.
1110 * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
1111 * to the new chunk to create.
1112 * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
1113 * \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
1114 * and corresponding entry erased from \a entriesOnSameDisc.
1115 * \return a newly allocated chunk
1117 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
1118 bool isPfl, int nbi, int offset,
1119 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
1120 MEDFileFieldGlobsReal& glob,
1121 bool ¬InExisting)
1123 int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
1124 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
1125 for(;it!=entriesOnSameDisc.end();it++)
1127 if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
1131 if((*it)->_profile.empty())
1134 if(!(*it)->_profile.empty())
1136 const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
1137 if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
1143 if(it==entriesOnSameDisc.end())
1146 MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
1148 ret->_loc_id=(int)geoType;
1149 ret->_nval=nbMeshEntities;
1151 ret->_end=ret->_start+ret->_nval*nbi;
1154 idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
1155 glob.appendProfile(idsOfMeshElt);
1156 ret->_profile=idsOfMeshElt->getName();
1158 //tony treatment of localization
1163 notInExisting=false;
1164 MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1165 ret->_loc_id=(int)geoType;
1166 ret->setNewStart(offset);
1167 entriesOnSameDisc.erase(it);
1173 ////////////////////////////////////
1175 MEDFileFieldPerMeshPerTypeCommon::~MEDFileFieldPerMeshPerTypeCommon()
1179 void MEDFileFieldPerMeshPerTypeCommon::setFather(MEDFileFieldPerMesh *father)
1184 void MEDFileFieldPerMeshPerTypeCommon::accept(MEDFileFieldVisitor& visitor) const
1186 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1187 if((*it).isNotNull())
1189 visitor.newPerMeshPerTypePerDisc(*it);
1193 void MEDFileFieldPerMeshPerTypeCommon::deepCopyElements()
1196 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1198 if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
1199 _field_pm_pt_pd[i]=(*it)->deepCopy(this);
1203 std::size_t MEDFileFieldPerMeshPerTypeCommon::getHeapMemorySizeWithoutChildren() const
1205 return _field_pm_pt_pd.capacity()*sizeof(MCAuto<MEDFileFieldPerMeshPerTypePerDisc>);
1208 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypeCommon::getDirectChildrenWithNull() const
1210 std::vector<const BigMemoryObject *> ret;
1211 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1212 ret.push_back((const MEDFileFieldPerMeshPerTypePerDisc *)*it);
1216 void MEDFileFieldPerMeshPerTypeCommon::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1218 std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
1219 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1220 _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1224 * This method is the most general one. No optimization is done here.
1225 * \param [in] multiTypePfl is the end user profile specified in high level API
1226 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1227 * \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.
1228 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1229 * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1230 * \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.
1232 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)
1234 std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1235 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1236 _field_pm_pt_pd[*it]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1239 void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
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]->assignNodeFieldNoProfile(start,field,arr,glob);
1246 void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1248 MCAuto<DataArrayInt> pfl2=pfl->deepCopy();
1249 if(!arr || !arr->isAllocated())
1250 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile : input array is null, or not allocated !");
1251 _field_pm_pt_pd.resize(1);
1252 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1253 _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.
1256 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldTemplate *field, int offset, int nbOfCells)
1258 TypeOfField type=field->getTypeOfField();
1259 if(type!=ON_GAUSS_PT)
1261 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1262 int sz=_field_pm_pt_pd.size();
1264 for(int j=0;j<sz && !found;j++)
1266 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1268 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1274 _field_pm_pt_pd.resize(sz+1);
1275 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1277 std::vector<int> ret(1,(int)sz);
1282 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1283 int sz2=ret2.size();
1284 std::vector<int> ret3(sz2);
1286 for(int i=0;i<sz2;i++)
1288 int sz=_field_pm_pt_pd.size();
1289 int locIdToFind=ret2[i];
1291 for(int j=0;j<sz && !found;j++)
1293 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1295 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1302 _field_pm_pt_pd.resize(sz+1);
1303 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1311 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldTemplate *field, int offset, int nbOfCells)
1313 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1314 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1316 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1317 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1319 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1320 MCAuto<DataArrayInt> da2=da->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1);
1321 MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1322 if(retTmp->presenceOfValue(-1))
1323 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1324 std::vector<int> ret(retTmp->begin(),retTmp->end());
1328 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldTemplate *field, const DataArrayInt *subCells)
1330 TypeOfField type=field->getTypeOfField();
1331 if(type!=ON_GAUSS_PT)
1333 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1334 int sz=_field_pm_pt_pd.size();
1336 for(int j=0;j<sz && !found;j++)
1338 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1340 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1346 _field_pm_pt_pd.resize(sz+1);
1347 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1349 std::vector<int> ret(1,0);
1354 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1355 int sz2=ret2.size();
1356 std::vector<int> ret3(sz2);
1358 for(int i=0;i<sz2;i++)
1360 int sz=_field_pm_pt_pd.size();
1361 int locIdToFind=ret2[i];
1363 for(int j=0;j<sz && !found;j++)
1365 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1367 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1374 _field_pm_pt_pd.resize(sz+1);
1375 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1383 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldTemplate *field, const DataArrayInt *subCells)
1385 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1386 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1388 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1389 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1391 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1392 MCAuto<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1393 MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1394 if(retTmp->presenceOfValue(-1))
1395 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1396 std::vector<int> ret(retTmp->begin(),retTmp->end());
1400 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerTypeCommon::getFather() const
1405 bool MEDFileFieldPerMeshPerTypeCommon::isUniqueLevel(int& dim) const
1407 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
1408 int curDim((int)cm.getDimension());
1409 if(dim!=std::numeric_limits<int>::max())
1419 void MEDFileFieldPerMeshPerTypeCommon::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1421 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1423 (*it)->fillTypesOfFieldAvailable(types);
1427 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
1429 int sz=_field_pm_pt_pd.size();
1430 dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1431 for(int i=0;i<sz;i++)
1433 _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1437 int MEDFileFieldPerMeshPerTypeCommon::getIteration() const
1439 return _father->getIteration();
1442 int MEDFileFieldPerMeshPerTypeCommon::getOrder() const
1444 return _father->getOrder();
1447 double MEDFileFieldPerMeshPerTypeCommon::getTime() const
1449 return _father->getTime();
1452 std::string MEDFileFieldPerMeshPerTypeCommon::getMeshName() const
1454 return _father->getMeshName();
1457 void MEDFileFieldPerMeshPerTypeCommon::getSizes(int& globalSz, int& nbOfEntries) const
1459 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1461 globalSz+=(*it)->getNumberOfTuples();
1463 nbOfEntries+=(int)_field_pm_pt_pd.size();
1466 int MEDFileFieldPerMeshPerTypeCommon::getNumberOfComponents() const
1468 return _father->getNumberOfComponents();
1471 bool MEDFileFieldPerMeshPerTypeCommon::presenceOfMultiDiscPerGeoType() const
1474 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1476 const MEDFileFieldPerMeshPerTypePerDisc *fmtd(*it);
1483 void MEDFileFieldPerMeshPerTypeCommon::pushDiscretization(MEDFileFieldPerMeshPerTypePerDisc *disc)
1485 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt;
1487 _field_pm_pt_pd.push_back(elt);
1490 DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray()
1492 return _father->getOrCreateAndGetArray();
1495 const DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray() const
1497 const MEDFileFieldPerMesh *fath=_father;
1498 return fath->getOrCreateAndGetArray();
1501 const std::vector<std::string>& MEDFileFieldPerMeshPerTypeCommon::getInfo() const
1503 return _father->getInfo();
1506 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsed() const
1508 std::vector<std::string> ret;
1509 std::set<std::string> ret2;
1510 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1512 std::string tmp=(*it1)->getProfile();
1514 if(ret2.find(tmp)==ret2.end())
1523 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsed() const
1525 std::vector<std::string> ret;
1526 std::set<std::string> ret2;
1527 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1529 std::string tmp=(*it1)->getLocalization();
1530 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1531 if(ret2.find(tmp)==ret2.end())
1540 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsedMulti() const
1542 std::vector<std::string> ret;
1543 std::set<std::string> ret2;
1544 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1546 std::string tmp=(*it1)->getProfile();
1553 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsedMulti() const
1555 std::vector<std::string> ret;
1556 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1558 std::string tmp=(*it1)->getLocalization();
1559 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1565 void MEDFileFieldPerMeshPerTypeCommon::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1567 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1568 (*it1)->changePflsRefsNamesGen(mapOfModif);
1571 void MEDFileFieldPerMeshPerTypeCommon::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1573 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1574 (*it1)->changeLocsRefsNamesGen(mapOfModif);
1577 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId)
1579 if(_field_pm_pt_pd.empty())
1581 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << getGeoTypeRepr() << "\" !";
1582 throw INTERP_KERNEL::Exception(oss.str());
1584 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1585 return _field_pm_pt_pd[locId];
1586 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
1587 oss2 << ") for geometric type \"" << getGeoTypeRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1588 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1589 return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1592 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId) const
1594 if(_field_pm_pt_pd.empty())
1596 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << getGeoTypeRepr() << "\" !";
1597 throw INTERP_KERNEL::Exception(oss.str());
1599 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1600 return _field_pm_pt_pd[locId];
1601 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
1602 oss2 << ") for geometric type \"" << getGeoTypeRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1603 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1604 return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1607 void MEDFileFieldPerMeshPerTypeCommon::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1610 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1612 (*it)->fillValues(i,startEntryId,entries);
1616 void MEDFileFieldPerMeshPerTypeCommon::setLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
1618 _field_pm_pt_pd=leaves;
1619 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1620 (*it)->setFather(this);
1624 * \param [in,out] globalNum a global numbering counter for the renumbering.
1625 * \param [out] its - list of pair (start,stop) kept
1626 * \return bool - false if the type of field \a tof is not contained in \a this.
1628 bool MEDFileFieldPerMeshPerTypeCommon::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
1631 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1632 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1633 if((*it)->getType()==tof)
1635 newPmPtPd.push_back(*it);
1636 std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1637 (*it)->setNewStart(globalNum);
1638 globalNum=(*it)->getEnd();
1639 its.push_back(bgEnd);
1643 _field_pm_pt_pd=newPmPtPd;
1648 * \param [in,out] globalNum a global numbering counter for the renumbering.
1649 * \param [out] its - list of pair (start,stop) kept
1650 * \return bool - false if the type of field \a tof is not contained in \a this.
1652 bool MEDFileFieldPerMeshPerTypeCommon::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
1654 if(_field_pm_pt_pd.size()<=idOfDisc)
1656 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt(_field_pm_pt_pd[idOfDisc]);
1657 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd(1,elt);
1658 std::pair<int,int> bgEnd; bgEnd.first=_field_pm_pt_pd[idOfDisc]->getStart(); bgEnd.second=_field_pm_pt_pd[idOfDisc]->getEnd();
1659 elt->setNewStart(globalNum);
1660 globalNum=elt->getEnd();
1661 its.push_back(bgEnd);
1662 _field_pm_pt_pd=newPmPtPd;
1666 void MEDFileFieldPerMeshPerTypeCommon::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
1668 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1669 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1672 void MEDFileFieldPerMeshPerTypeCommon::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1674 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1675 (*it)->loadBigArray(fid,nasc);
1678 void MEDFileFieldPerMeshPerTypeCommon::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1680 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1682 (*it)->copyOptionsFrom(*this);
1683 (*it)->writeLL(fid,nasc);
1687 med_entity_type MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1692 medfGeoType=typmai3[(int)ikGeoType];
1695 medfGeoType=MED_NONE;
1698 medfGeoType=typmai3[(int)ikGeoType];
1699 return MED_NODE_ELEMENT;
1701 medfGeoType=typmai3[(int)ikGeoType];
1704 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1706 return MED_UNDEF_ENTITY_TYPE;
1709 //////////////////////////////////////////////////
1711 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd)
1713 return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc,pd);
1716 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType)
1718 return new MEDFileFieldPerMeshPerType(fath,geoType);
1721 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCopy(MEDFileFieldPerMesh *father) const
1723 MCAuto<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
1724 ret->setFather(father);
1725 ret->deepCopyElements();
1729 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
1731 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1733 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1734 if(meshDim!=(int)cm.getDimension())
1737 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1738 (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1741 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1746 void MEDFileFieldPerMeshPerType::entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const
1748 ent=MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(mct,_geo_type,gt);
1751 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1753 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1754 int curDim((int)cm.getDimension());
1755 dim=std::max(dim,curDim);
1758 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1760 const char startLine[]=" ## ";
1761 std::string startLine2(bkOffset,' ');
1762 std::string startLine3(startLine2);
1763 startLine3+=startLine;
1764 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1766 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1767 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1770 oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1771 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1773 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1775 const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1777 cur->simpleRepr(bkOffset,oss,i);
1780 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1785 std::string MEDFileFieldPerMeshPerType::getGeoTypeRepr() const
1787 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1788 return std::string(cm.getRepr());
1791 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *father, INTERP_KERNEL::NormalizedCellType gt):MEDFileFieldPerMeshPerTypeCommon(father),_geo_type(gt)
1795 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):MEDFileFieldPerMeshPerTypeCommon(fath),_geo_type(geoType)
1797 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1798 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1799 med_geometry_type mgeoti;
1800 med_entity_type menti(ConvertIntoMEDFileType(type,geoType,mgeoti));
1801 int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName));
1802 _field_pm_pt_pd.resize(nbProfiles);
1803 for(int i=0;i<nbProfiles;i++)
1805 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i,pd);
1809 int nbProfiles2(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName));
1810 for(int i=0;i<nbProfiles2;i++)
1811 _field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i,pd));
1815 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)
1817 MCAuto<MEDFileFieldPerMeshPerType> ret(MEDFileFieldPerMeshPerType::New(father,gt));
1818 std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > > m;
1819 for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerType *> >::const_iterator it=pms.begin();it!=pms.end();it++)
1821 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it2=(*it).second->_field_pm_pt_pd.begin();it2!=(*it).second->_field_pm_pt_pd.end();it2++)
1822 m[(*it2)->getType()].push_back(std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * >((*it).first,*it2));
1824 for(std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > >::const_iterator it=m.begin();it!=m.end();it++)
1826 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> agg(MEDFileFieldPerMeshPerTypePerDisc::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
1827 ret->_field_pm_pt_pd.push_back(agg);
1832 //////////////////////////////////////////////////
1834 MEDFileFieldPerMeshPerTypeDyn *MEDFileFieldPerMeshPerTypeDyn::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileEntities *entities, int idGT, const MEDFileFieldNameScope& nasc)
1837 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeDyn::NewOnRead : null pointer !");
1838 const MEDFileAllStaticEntitiesPlusDyn *entities2(dynamic_cast<const MEDFileAllStaticEntitiesPlusDyn *>(entities));
1840 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeDyn::NewOnRead : invalid type of entities !");
1841 const MEDFileStructureElement *se(entities2->getWithGT(idGT));
1842 return new MEDFileFieldPerMeshPerTypeDyn(fid,fath,se,nasc);
1845 MEDFileFieldPerMeshPerTypeDyn::MEDFileFieldPerMeshPerTypeDyn(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileStructureElement *se, const MEDFileFieldNameScope& nasc):MEDFileFieldPerMeshPerTypeCommon(fath)
1848 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1849 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1850 int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,_se->getDynGT(),pflName,locName));
1851 _field_pm_pt_pd.resize(nbProfiles);
1852 for(int i=0;i<nbProfiles;i++)
1854 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,_se->getEntity(),i,NULL);
1858 int MEDFileFieldPerMeshPerTypeDyn::getDynGT() const
1860 return _se->getDynGT();
1863 std::string MEDFileFieldPerMeshPerTypeDyn::getModelName() const
1865 return _se->getName();
1868 void MEDFileFieldPerMeshPerTypeDyn::getDimension(int& dim) const
1870 throw INTERP_KERNEL::Exception("not implemented yet !");
1873 void MEDFileFieldPerMeshPerTypeDyn::entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const
1876 ent=MED_STRUCT_ELEMENT;
1879 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypeDyn::getGeoType() const
1881 throw INTERP_KERNEL::Exception("not implemented yet !");
1884 void MEDFileFieldPerMeshPerTypeDyn::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1886 const char startLine[]=" ## ";
1887 std::string startLine2(bkOffset,' ');
1888 std::string startLine3(startLine2);
1889 startLine3+=startLine;
1890 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry STRUCTURE_ELEMENT type " << getDynGT() << "." << std::endl;
1891 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1893 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1895 if((*it).isNotNull())
1896 (*it)->simpleRepr(bkOffset,oss,i);
1899 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1904 std::string MEDFileFieldPerMeshPerTypeDyn::getGeoTypeRepr() const
1906 throw INTERP_KERNEL::Exception("not implemented yet !");
1909 MEDFileFieldPerMeshPerTypeDyn *MEDFileFieldPerMeshPerTypeDyn::deepCopy(MEDFileFieldPerMesh *father) const
1911 MCAuto<MEDFileFieldPerMeshPerTypeDyn> ret(new MEDFileFieldPerMeshPerTypeDyn(*this));
1912 ret->setFather(father);
1913 ret->deepCopyElements();
1917 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
1919 throw INTERP_KERNEL::Exception("not implemented yet !");
1922 //////////////////////////////////////////////////
1924 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const MEDFileEntities *entities)
1926 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm,entities);
1929 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1931 return new MEDFileFieldPerMesh(fath,mesh);
1934 std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
1936 return _field_pm_pt.capacity()*sizeof(MCAuto< MEDFileFieldPerMeshPerType >);
1939 std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildrenWithNull() const
1941 std::vector<const BigMemoryObject *> ret;
1942 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1947 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCopy(MEDFileAnyTypeField1TSWithoutSDA *father) const
1949 MCAuto< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1950 ret->_father=father;
1952 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1954 if((*it).isNotNull())
1955 ret->_field_pm_pt[i]=(*it)->deepCopy((MEDFileFieldPerMesh *)(ret));
1960 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1962 std::string startLine(bkOffset,' ');
1963 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << getMeshName() << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1964 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1966 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1968 if((*it).isNotNull())
1969 (*it)->simpleRepr(bkOffset,oss,i);
1972 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1977 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh)
1979 mesh->getTime(_mesh_iteration,_mesh_order);
1982 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1984 int nbOfTypes=code.size()/3;
1986 for(int i=0;i<nbOfTypes;i++)
1988 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1989 int nbOfCells=code[3*i+1];
1990 int pos=addNewEntryIfNecessary(type);
1991 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1997 * This method is the most general one. No optimization is done here.
1998 * \param [in] multiTypePfl is the end user profile specified in high level API
1999 * \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].
2000 * \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.
2001 * \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.
2002 * \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.
2003 * \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.
2005 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)
2007 int nbOfTypes(code.size()/3);
2008 for(int i=0;i<nbOfTypes;i++)
2010 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
2011 int pos=addNewEntryIfNecessary(type);
2012 DataArrayInt *pfl=0;
2014 pfl=idsPerType[code[3*i+2]];
2015 int nbOfTupes2=code2.size()/3;
2017 for(;found<nbOfTupes2;found++)
2018 if(code[3*i]==code2[3*found])
2020 if(found==nbOfTupes2)
2021 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
2022 _field_pm_pt[pos]->assignFieldProfile(nbOfTypes==1,start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
2026 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
2028 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
2029 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
2032 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
2034 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
2035 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
2038 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
2040 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2041 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
2044 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
2046 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2047 (*it)->loadBigArraysRecursively(fid,nasc);
2050 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
2052 int nbOfTypes=_field_pm_pt.size();
2053 for(int i=0;i<nbOfTypes;i++)
2055 _field_pm_pt[i]->copyOptionsFrom(*this);
2056 _field_pm_pt[i]->writeLL(fid,nasc);
2060 void MEDFileFieldPerMesh::getDimension(int& dim) const
2062 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2063 (*it)->getDimension(dim);
2066 bool MEDFileFieldPerMesh::isUniqueLevel(int& dim) const
2068 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2069 if(!(*it)->isUniqueLevel(dim))
2074 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
2076 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2077 (*it)->fillTypesOfFieldAvailable(types);
2080 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
2082 int sz=_field_pm_pt.size();
2083 std::vector< std::vector<std::pair<int,int> > > ret(sz);
2084 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
2085 for(int i=0;i<sz;i++)
2087 types[i]=_field_pm_pt[i]->getGeoType();
2088 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
2093 double MEDFileFieldPerMesh::getTime() const
2096 return _father->getTime(tmp1,tmp2);
2099 int MEDFileFieldPerMesh::getIteration() const
2101 return _father->getIteration();
2104 int MEDFileFieldPerMesh::getOrder() const
2106 return _father->getOrder();
2109 int MEDFileFieldPerMesh::getNumberOfComponents() const
2111 return _father->getNumberOfComponents();
2114 std::string MEDFileFieldPerMesh::getMeshName() const
2116 return _father->getMeshName();
2119 void MEDFileFieldPerMesh::setMeshName(const std::string& meshName)
2121 _father->setMeshName(meshName);
2124 bool MEDFileFieldPerMesh::presenceOfMultiDiscPerGeoType() const
2126 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2130 if((*it)->presenceOfMultiDiscPerGeoType())
2136 bool MEDFileFieldPerMesh::presenceOfStructureElements() const
2138 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2139 if((*it).isNotNull())
2141 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2148 bool MEDFileFieldPerMesh::onlyStructureElements() const
2150 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2151 if((*it).isNotNull())
2153 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2160 void MEDFileFieldPerMesh::killStructureElements()
2162 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
2163 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2165 if((*it).isNotNull())
2167 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2175 void MEDFileFieldPerMesh::keepOnlyStructureElements()
2177 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
2178 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2180 if((*it).isNotNull())
2182 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2190 void MEDFileFieldPerMesh::keepOnlyOnSE(const std::string& seName)
2192 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
2193 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2195 if((*it).isNotNull())
2197 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2199 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::keepOnlyOnSE : presence of non SE !");
2200 if(pt->getModelName()==seName)
2207 void MEDFileFieldPerMesh::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
2209 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2211 if((*it).isNotNull())
2213 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2216 ps.push_back(std::pair<std::string,std::string>(getMeshName(),pt->getModelName()));
2219 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getMeshSENames : presence of a non structure element part !");
2224 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
2227 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
2228 return _father->getOrCreateAndGetArray();
2231 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
2234 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
2235 return _father->getOrCreateAndGetArray();
2238 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
2240 return _father->getInfo();
2244 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
2245 * 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.
2246 * It returns 2 output vectors :
2247 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
2248 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
2249 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
2251 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)
2253 int notNullPflsSz=0;
2254 int nbOfArrs=geoTypes.size();
2255 for(int i=0;i<nbOfArrs;i++)
2258 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
2259 int nbOfDiffGeoTypes=geoTypes3.size();
2260 code.resize(3*nbOfDiffGeoTypes);
2261 notNullPfls.resize(notNullPflsSz);
2264 for(int i=0;i<nbOfDiffGeoTypes;i++)
2267 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
2268 std::vector<const DataArrayInt *> notNullTmp;
2270 notNullTmp.push_back(pfls[j]);
2272 for(;j<nbOfArrs;j++)
2273 if(geoTypes[j]==refType)
2276 notNullTmp.push_back(pfls[j]);
2280 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
2281 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
2282 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
2283 code[3*i]=(int)refType;
2284 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
2285 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
2286 if(notNullTmp.empty())
2290 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
2291 code[3*i+2]=notNullPflsSz++;
2297 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
2299 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)
2303 for(int i=0;i<sz;i++)
2307 if(type!=ON_GAUSS_NE)
2308 ret+=dads[i].second-dads[i].first;
2311 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
2312 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
2317 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
2318 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
2324 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
2326 std::vector<std::string> ret;
2327 std::set<std::string> ret2;
2328 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2330 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
2331 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
2332 if(ret2.find(*it2)==ret2.end())
2334 ret.push_back(*it2);
2341 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
2343 std::vector<std::string> ret;
2344 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2346 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
2347 ret.insert(ret.end(),tmp.begin(),tmp.end());
2352 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
2354 std::vector<std::string> ret;
2355 std::set<std::string> ret2;
2356 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2358 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
2359 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
2360 if(ret2.find(*it2)==ret2.end())
2362 ret.push_back(*it2);
2369 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
2371 std::vector<std::string> ret;
2372 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2374 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
2375 ret.insert(ret.end(),tmp.begin(),tmp.end());
2380 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
2382 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
2384 if((*it).first==getMeshName())
2386 setMeshName((*it).second);
2393 void MEDFileFieldPerMesh::convertMedBallIntoClassic()
2395 if(_field_pm_pt.size()!=1)
2396 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : Only managed for single mesh !");
2397 if(_field_pm_pt[0].isNull())
2398 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : null pointer !");
2399 MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<MEDFileFieldPerMeshPerTypeDyn *>((MEDFileFieldPerMeshPerTypeCommon *)_field_pm_pt[0]));
2401 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : this is expected to be marked as structure element !");
2402 if(pt->getNumberOfLoc()!=1)
2403 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : only one loc managed !");
2404 const MEDFileFieldPerMeshPerTypePerDisc *disc(pt->getLeafGivenLocId(0));
2406 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : internal error !");
2407 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> disc2(MEDFileFieldPerMeshPerTypePerDisc::New(*disc));
2408 disc2->setType(ON_NODES);
2409 MCAuto<MEDFileFieldPerMeshPerType> pt2(MEDFileFieldPerMeshPerType::New(this,INTERP_KERNEL::NORM_ERROR));
2410 disc2->setFather(pt2);
2411 pt2->setFather(this);
2412 pt2->pushDiscretization(disc2);
2413 _field_pm_pt[0]=DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(pt2);
2416 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
2417 MEDFileFieldGlobsReal& glob)
2419 if(getMeshName()!=meshName)
2421 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
2422 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
2423 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
2424 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
2425 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
2426 getUndergroundDataArrayExt(entries);
2427 DataArray *arr0(getOrCreateAndGetArray());//tony
2429 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
2430 DataArrayDouble *arr(dynamic_cast<DataArrayDouble *>(arr0));//tony
2432 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
2435 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
2436 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
2438 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
2440 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2441 sz+=(*it).second.second-(*it).second.first;
2444 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2446 MCAuto<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
2447 ////////////////////
2448 MCAuto<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
2449 int *workI2=explicitIdsOldInMesh->getPointer();
2450 int sz1=0,sz2=0,sid=1;
2451 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
2452 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
2453 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
2455 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
2456 MCAuto<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
2457 int *workI=explicitIdsOldInArr->getPointer();
2458 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
2460 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
2461 (*itL2)->setLocId(sz2);
2462 (*itL2)->_tmp_work1=(*itL2)->getStart();
2463 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
2465 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
2467 explicitIdsOldInMesh->reAlloc(sz2);
2468 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
2469 ////////////////////
2470 MCAuto<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
2471 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
2472 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
2473 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
2475 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
2476 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
2477 otherEntriesNew.back()->setLocId((*it)->getGeoType());
2479 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
2480 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
2481 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
2483 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
2484 int newStart=elt->getLocId();
2485 elt->setLocId((*it)->getGeoType());
2486 elt->setNewStart(newStart);
2487 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
2488 entriesKeptNew.push_back(elt);
2489 entriesKeptNew2.push_back(elt);
2491 MCAuto<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
2492 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
2493 MCAuto<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
2494 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
2496 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
2499 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
2501 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
2502 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
2504 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
2505 glob,arr2,otherEntriesNew) || ret;
2509 // Assign new dispatching
2510 assignNewLeaves(otherEntriesNew);
2511 arr->deepCopyFrom(*arr2);
2516 * \param [in,out] globalNum a global numbering counter for the renumbering.
2517 * \param [out] its - list of pair (start,stop) kept
2519 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
2521 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > ret;
2522 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2524 std::vector< std::pair<int,int> > its2;
2525 if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
2528 its.insert(its.end(),its2.begin(),its2.end());
2535 * \param [in,out] globalNum a global numbering counter for the renumbering.
2536 * \param [out] its - list of pair (start,stop) kept
2538 void MEDFileFieldPerMesh::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
2540 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > ret;
2541 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2543 std::vector< std::pair<int,int> > its2;
2544 if((*it)->keepOnlyGaussDiscretization(idOfDisc,globalNum,its2))
2547 its.insert(its.end(),its2.begin(),its2.end());
2553 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
2555 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > > types;
2556 for( std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
2557 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
2559 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > fieldPmPt(types.size());
2560 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
2561 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it2=fieldPmPt.begin();
2562 for(;it1!=types.end();it1++,it2++)
2564 MCAuto<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
2565 elt->setLeaves((*it1).second);
2566 MCAuto<MEDFileFieldPerMeshPerTypeCommon> elt2(DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(elt));
2569 _field_pm_pt=fieldPmPt;
2572 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2574 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2575 (*it)->changePflsRefsNamesGen(mapOfModif);
2578 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2580 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2581 (*it)->changeLocsRefsNamesGen(mapOfModif);
2585 * \param [in] mesh is the whole mesh
2587 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2589 if(_field_pm_pt.empty())
2590 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2592 std::vector< std::pair<int,int> > dads;
2593 std::vector<const DataArrayInt *> pfls;
2594 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2595 std::vector<int> locs,code;
2596 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2597 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2598 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2600 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2603 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2604 throw INTERP_KERNEL::Exception(oss.str());
2607 std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2608 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2611 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2613 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2616 MCAuto<DataArrayInt> arr2(arr);
2617 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2623 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2627 if(nb!=mesh->getNumberOfNodes())
2629 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2630 oss << " nodes in mesh !";
2631 throw INTERP_KERNEL::Exception(oss.str());
2633 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2636 return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2640 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
2642 if(_field_pm_pt.empty())
2643 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2645 std::vector<std::pair<int,int> > dads;
2646 std::vector<const DataArrayInt *> pfls;
2647 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2648 std::vector<int> locs,code;
2649 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2650 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2651 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2653 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2656 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2657 throw INTERP_KERNEL::Exception(oss.str());
2659 std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2660 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2663 MCAuto<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2664 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2669 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2673 if(nb!=mesh->getNumberOfNodes())
2675 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2676 oss << " nodes in mesh !";
2677 throw INTERP_KERNEL::Exception(oss.str());
2680 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2686 void MEDFileFieldPerMesh::accept(MEDFileFieldVisitor& visitor) const
2688 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2689 if((*it).isNotNull())
2691 visitor.newPerMeshPerTypeEntry(*it);
2692 (*it)->accept(visitor);
2693 visitor.endPerMeshPerTypeEntry(*it);
2697 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
2701 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2703 (*it)->getSizes(globalSz,nbOfEntries);
2705 entries.resize(nbOfEntries);
2707 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2709 (*it)->fillValues(nbOfEntries,entries);
2713 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
2715 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2717 if((*it)->getGeoType()==typ)
2718 return (*it)->getLeafGivenLocId(locId);
2720 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2721 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2722 oss << "Possiblities are : ";
2723 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2725 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2726 oss << "\"" << cm2.getRepr() << "\", ";
2728 throw INTERP_KERNEL::Exception(oss.str());
2731 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
2733 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2735 if((*it)->getGeoType()==typ)
2736 return (*it)->getLeafGivenLocId(locId);
2738 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2739 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2740 oss << "Possiblities are : ";
2741 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2743 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2744 oss << "\"" << cm2.getRepr() << "\", ";
2746 throw INTERP_KERNEL::Exception(oss.str());
2750 * \param [in,out] start - Integer that gives the current position in the final aggregated array
2751 * \param [in] pms - list of elements to aggregate. integer gives the mesh id
2752 * \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.
2753 * \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.
2755 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)
2757 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret(new MEDFileFieldPerMeshPerTypePerDisc(father,tof));
2759 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : empty input vector !");
2760 for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it=pms.begin();it!=pms.end();it++)
2763 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : presence of null pointer !");
2764 if(!(*it).second->getProfile().empty())
2765 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for profiles !");
2766 if(!(*it).second->getLocalization().empty())
2767 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for gauss pts !");
2769 INTERP_KERNEL::NormalizedCellType gt(pms[0].second->getGeoType());
2771 std::vector< std::pair<int,int> > filteredDTS;
2772 for(std::vector< std::vector< std::pair<int,int> > >::const_iterator it=dts.begin();it!=dts.end();it++,i++)
2773 for(std::vector< std::pair<int,int> >::const_iterator it2=(*it).begin();it2!=(*it).end();it2++)
2774 if((*it2).first==gt)
2775 filteredDTS.push_back(std::pair<int,int>(i,(*it2).second));
2776 if(pms.size()!=filteredDTS.size())
2777 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles !");
2778 std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it1(pms.begin());
2779 std::vector< std::pair<int,int> >::const_iterator it2(filteredDTS.begin());
2780 int zeStart(start),nval(0);
2781 for(;it1!=pms.end();it1++,it2++)
2783 if((*it1).first!=(*it2).first)
2784 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles 2 !");
2785 int s1((*it1).second->getStart()),e1((*it1).second->getEnd());
2786 extractInfo.push_back(std::pair<int, std::pair<int,int> >((*it1).first,std::pair<int,int>(s1,e1)));
2788 nval+=((*it1).second)->getNumberOfVals();
2790 ret->_start=zeStart; ret->_end=start; ret->_nval=nval;
2794 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)
2796 MCAuto<MEDFileFieldPerMesh> ret(new MEDFileFieldPerMesh(father,pms[0]->getMeshName(),pms[0]->getMeshIteration(),pms[0]->getMeshOrder()));
2797 std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > > m;
2799 for(std::vector<const MEDFileFieldPerMesh *>::const_iterator it=pms.begin();it!=pms.end();it++,i++)
2801 const std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >& v((*it)->_field_pm_pt);
2802 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it2=v.begin();it2!=v.end();it2++)
2804 INTERP_KERNEL::NormalizedCellType gt((*it2)->getGeoType());
2805 const MEDFileFieldPerMeshPerType *elt(dynamic_cast<const MEDFileFieldPerMeshPerType *>((const MEDFileFieldPerMeshPerTypeCommon *)(*it2)));
2807 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::Aggregate : not managed for structelement !");
2808 m[gt].push_back(std::pair<int,const MEDFileFieldPerMeshPerType *>(i,elt));
2811 for(std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > >::const_iterator it=m.begin();it!=m.end();it++)
2813 MCAuto<MEDFileFieldPerMeshPerType> agg(MEDFileFieldPerMeshPerType::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
2814 MCAuto<MEDFileFieldPerMeshPerTypeCommon> agg2(DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(agg));
2815 ret->_field_pm_pt.push_back(agg2);
2820 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2823 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2824 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it2=_field_pm_pt.begin();
2825 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2827 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2832 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2837 int ret=std::distance(_field_pm_pt.begin(),it2);
2838 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2843 * 'dads' and 'locs' input parameters have the same number of elements
2844 * \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
2846 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2847 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2848 const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2851 MCAuto<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2852 ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2853 MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2854 const std::vector<std::string>& infos=getInfo();
2855 da->setInfoOnComponents(infos);
2857 if(type==ON_GAUSS_PT)
2860 int nbOfArrs=dads.size();
2861 for(int i=0;i<nbOfArrs;i++)
2863 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2864 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2865 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2866 MCAuto<DataArrayInt> di=DataArrayInt::New();
2867 di->alloc(nbOfElems,1);
2869 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2870 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2879 * 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.
2880 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2881 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2882 * The order of cells in the returned field is those imposed by the profile.
2883 * \param [in] mesh is the global mesh.
2885 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2886 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2887 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2888 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2890 if(da->isIota(mesh->getNumberOfCells()))
2891 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2892 MCAuto<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2893 m2->setName(mesh->getName().c_str());
2894 MCAuto<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2900 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2902 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2903 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2904 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2906 if(da->isIota(mesh->getNumberOfNodes()))
2907 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2908 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2909 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2912 if(meshu->getNodalConnectivity()==0)
2914 MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2915 int nb=da->getNbOfElems();
2916 const int *ptr=da->getConstPointer();
2917 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2918 meshuc->allocateCells(nb);
2919 for(int i=0;i<nb;i++)
2920 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2921 meshuc->finishInsertingCells();
2922 ret->setMesh(meshuc);
2923 const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2924 if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2925 disc->checkCoherencyBetween(meshuc,arrOut);
2930 MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2932 DataArrayInt *arr2=0;
2933 MCAuto<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2934 MCAuto<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2935 MCAuto<DataArrayInt> arr3(arr2);
2936 int nnodes=mesh2->getNumberOfNodes();
2937 if(nnodes==(int)da->getNbOfElems())
2939 MCAuto<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2940 arrOut->renumberInPlace(da3->getConstPointer());
2941 mesh2->setName(mesh->getName().c_str());
2942 ret->setMesh(mesh2);
2947 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 !!!";
2948 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2949 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2950 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2951 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2952 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2953 throw INTERP_KERNEL::Exception(oss.str());
2959 * This method is the most light method of field retrieving.
2961 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
2965 pflOut=DataArrayInt::New();
2966 pflOut->alloc(nbOfElems,1);
2971 pflOut=const_cast<DataArrayInt*>(pflIn);
2974 MCAuto<DataArrayInt> safePfl(pflOut);
2975 MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2976 const std::vector<std::string>& infos=getInfo();
2977 int nbOfComp=infos.size();
2978 for(int i=0;i<nbOfComp;i++)
2979 da->setInfoOnComponent(i,infos[i].c_str());
2990 static MFFPMIter *NewCell(const MEDFileEntities *entities);
2991 static bool IsPresenceOfNode(const MEDFileEntities *entities);
2992 virtual ~MFFPMIter() { }
2993 virtual void begin() = 0;
2994 virtual bool finished() const = 0;
2995 virtual void next() = 0;
2996 virtual int current() const = 0;
2999 class MFFPMIterSimple : public MFFPMIter
3002 MFFPMIterSimple():_pos(0) { }
3003 void begin() { _pos=0; }
3004 bool finished() const { return _pos>=MED_N_CELL_FIXED_GEO; }
3005 void next() { _pos++; }
3006 int current() const { return _pos; }
3011 class MFFPMIter2 : public MFFPMIter
3014 MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts);
3015 void begin() { _it=_ids.begin(); }
3016 bool finished() const { return _it==_ids.end(); }
3017 void next() { _it++; }
3018 int current() const { return *_it; }
3020 std::vector<int> _ids;
3021 std::vector<int>::const_iterator _it;
3024 MFFPMIter *MFFPMIter::NewCell(const MEDFileEntities *entities)
3027 return new MFFPMIterSimple;
3030 const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
3033 std::vector<INTERP_KERNEL::NormalizedCellType> tmp;
3034 const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
3035 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
3037 if((*it).first==ON_CELLS || (*it).first==ON_GAUSS_NE || (*it).first==ON_GAUSS_PT)
3038 tmp.push_back((*it).second);
3040 return new MFFPMIter2(tmp);
3042 return new MFFPMIterSimple;// for MEDFileAllStaticEntites and MEDFileAllStaticEntitiesPlusDyn cells are in
3046 bool MFFPMIter::IsPresenceOfNode(const MEDFileEntities *entities)
3052 const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
3055 const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
3056 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
3057 if((*it).first==ON_NODES)
3061 return true;// for MEDFileAllStaticEntites and MEDFileAllStaticEntitiesPlusDyn nodes are in
3065 MFFPMIter2::MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts)
3067 std::size_t sz(cts.size());
3069 for(std::size_t i=0;i<sz;i++)
3071 INTERP_KERNEL::NormalizedCellType *loc(std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,cts[i]));
3072 if(loc!=typmai2+MED_N_CELL_FIXED_GEO)
3073 _ids[i]=(int)std::distance(typmai2,loc);
3075 throw INTERP_KERNEL::Exception("MFFPMIter2 : The specified geo type does not exists !");
3081 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),
3084 INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
3085 INTERP_KERNEL::AutoPtr<char> pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
3086 INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
3087 const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
3088 INTERP_KERNEL::AutoCppPtr<MFFPMIter> iter0(MFFPMIter::NewCell(entities));
3089 for(iter0->begin();!iter0->finished();iter0->next())
3091 int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL ,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
3092 std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
3093 int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
3094 std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
3095 if(nbProfile>0 || nbProfile2>0)
3097 const PartDefinition *pd(0);
3099 pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[iter0->current()]),typmai2[iter0->current()]);
3100 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nasc,pd));
3107 if(MFFPMIter::IsPresenceOfNode(entities))
3109 int nbProfile(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName));
3112 const PartDefinition *pd(0);
3114 pd=mmu->getPartDefAtLevel(1,INTERP_KERNEL::NORM_ERROR);
3115 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd));
3116 setMeshName(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE));
3121 std::vector<int> dynGT(entities->getDynGTAvail());
3122 for(std::vector<int>::const_iterator it=dynGT.begin();it!=dynGT.end();it++)
3124 int nbPfl(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,*it,pflName,locName));
3127 _field_pm_pt.push_back(MEDFileFieldPerMeshPerTypeDyn::NewOnRead(fid,this,entities,*it,nasc));
3128 setMeshName(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE));
3133 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
3135 copyTinyInfoFrom(mesh);
3138 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3140 if(id>=(int)_pfls.size())
3142 _pfls[id]=DataArrayInt::New();
3143 int lgth(MEDprofileSizeByName(fid,pflName.c_str()));
3144 _pfls[id]->setName(pflName);
3145 _pfls[id]->alloc(lgth,1);
3146 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName.c_str(),_pfls[id]->getPointer()));
3147 _pfls[id]->applyLin(1,-1,0);//Converting into C format
3150 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
3152 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
3154 MEDFILESAFECALLERRD0(MEDprofileInfo,(fid,i+1,pflName,&sz));
3155 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
3156 if(i>=(int)_pfls.size())
3158 _pfls[i]=DataArrayInt::New();
3159 _pfls[i]->alloc(sz,1);
3160 _pfls[i]->setName(pflCpp.c_str());
3161 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName,_pfls[i]->getPointer()));
3162 _pfls[i]->applyLin(1,-1,0);//Converting into C format
3165 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3167 int nbOfPfls=_pfls.size();
3168 for(int i=0;i<nbOfPfls;i++)
3170 MCAuto<DataArrayInt> cpy=_pfls[i]->deepCopy();
3171 cpy->applyLin(1,1,0);
3172 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
3173 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
3174 MEDFILESAFECALLERWR0(MEDprofileWr,(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer()));
3177 int nbOfLocs=_locs.size();
3178 for(int i=0;i<nbOfLocs;i++)
3179 _locs[i]->writeLL(fid);
3182 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
3184 std::vector<std::string> pfls=getPfls();
3185 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
3187 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
3190 _pfls.push_back(*it);
3194 int id=std::distance(pfls.begin(),it2);
3195 if(!(*it)->isEqual(*_pfls[id]))
3197 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
3198 throw INTERP_KERNEL::Exception(oss.str());
3202 std::vector<std::string> locs=getLocs();
3203 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
3205 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
3208 _locs.push_back(*it);
3212 int id=std::distance(locs.begin(),it2);
3213 if(!(*it)->isEqual(*_locs[id],eps))
3215 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
3216 throw INTERP_KERNEL::Exception(oss.str());
3222 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
3224 for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
3225 getProfile((*it).c_str());
3228 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
3230 for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
3231 getLocalization((*it).c_str());
3234 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
3236 std::vector<std::string> profiles=real.getPflsReallyUsed();
3237 int sz=profiles.size();
3239 for(int i=0;i<sz;i++)
3240 loadProfileInFile(fid,i,profiles[i].c_str());
3242 std::vector<std::string> locs=real.getLocsReallyUsed();
3245 for(int i=0;i<sz;i++)
3246 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
3249 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid, const MEDFileEntities *entities)
3251 int nProfil=MEDnProfile(fid);
3252 for(int i=0;i<nProfil;i++)
3253 loadProfileInFile(fid,i);
3254 int sz=MEDnLocalization(fid);
3256 for(int i=0;i<sz;i++)
3258 _locs[i]=MEDFileFieldLoc::New(fid,i,entities);
3262 MEDFileFieldGlobs *MEDFileFieldGlobs::New(med_idt fid)
3264 return new MEDFileFieldGlobs(fid);
3267 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
3269 return new MEDFileFieldGlobs;
3272 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
3274 return _file_name.capacity()+_pfls.capacity()*sizeof(MCAuto<DataArrayInt>)+_locs.capacity()*sizeof(MCAuto<MEDFileFieldLoc>);
3277 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildrenWithNull() const
3279 std::vector<const BigMemoryObject *> ret;
3280 for(std::vector< MCAuto< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3281 ret.push_back((const DataArrayInt *)*it);
3282 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3283 ret.push_back((const MEDFileFieldLoc *)*it);
3287 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCopy() const
3289 MCAuto<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
3291 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3293 if((const DataArrayInt *)*it)
3294 ret->_pfls[i]=(*it)->deepCopy();
3297 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3299 if((const MEDFileFieldLoc*)*it)
3300 ret->_locs[i]=(*it)->deepCopy();
3306 * \throw if a profile in \a pfls in not in \a this.
3307 * \throw if a localization in \a locs in not in \a this.
3308 * \sa MEDFileFieldGlobs::deepCpyPart
3310 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
3312 MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
3313 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
3315 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
3317 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
3319 MCAuto<DataArrayInt> pfl2(pfl);
3320 ret->_pfls.push_back(pfl2);
3322 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
3324 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
3326 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
3328 MCAuto<MEDFileFieldLoc> loc2(loc);
3329 ret->_locs.push_back(loc2);
3331 ret->setFileName(getFileName());
3336 * \throw if a profile in \a pfls in not in \a this.
3337 * \throw if a localization in \a locs in not in \a this.
3338 * \sa MEDFileFieldGlobs::shallowCpyPart
3340 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
3342 MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
3343 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
3345 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
3347 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
3348 ret->_pfls.push_back(pfl->deepCopy());
3350 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
3352 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
3354 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
3355 ret->_locs.push_back(loc->deepCopy());
3357 ret->setFileName(getFileName());
3361 MEDFileFieldGlobs::MEDFileFieldGlobs(med_idt fid):_file_name(MEDFileWritable::FileNameFromFID(fid))
3365 MEDFileFieldGlobs::MEDFileFieldGlobs()
3369 MEDFileFieldGlobs::~MEDFileFieldGlobs()
3373 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
3375 oss << "Profiles :\n";
3376 std::size_t n=_pfls.size();
3377 for(std::size_t i=0;i<n;i++)
3379 oss << " - #" << i << " ";
3380 const DataArrayInt *pfl=_pfls[i];
3382 oss << "\"" << pfl->getName() << "\"\n";
3387 oss << "Localizations :\n";
3388 for(std::size_t i=0;i<n;i++)
3390 oss << " - #" << i << " ";
3391 const MEDFileFieldLoc *loc=_locs[i];
3393 loc->simpleRepr(oss);
3399 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3401 for(std::vector< MCAuto<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
3403 DataArrayInt *elt(*it);
3406 std::string name(elt->getName());
3407 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3409 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3411 elt->setName((*it2).second.c_str());
3419 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3421 for(std::vector< MCAuto<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
3423 MEDFileFieldLoc *elt(*it);
3426 std::string name(elt->getName());
3427 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3429 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3431 elt->setName((*it2).second.c_str());
3439 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
3441 if(locId<0 || locId>=(int)_locs.size())
3442 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
3443 return _locs[locId]->getNbOfGaussPtPerCell();
3446 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
3448 return getLocalizationFromId(getLocalizationId(locName));
3451 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
3453 if(locId<0 || locId>=(int)_locs.size())
3454 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3455 return *_locs[locId];
3459 namespace MEDCouplingImpl
3464 LocFinder(const std::string& loc):_loc(loc) { }
3465 bool operator() (const MCAuto<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
3467 const std::string &_loc;
3473 PflFinder(const std::string& pfl):_pfl(pfl) { }
3474 bool operator() (const MCAuto<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
3476 const std::string& _pfl;
3481 int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
3483 std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),MEDCouplingImpl::LocFinder(loc));
3486 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
3487 for(it=_locs.begin();it!=_locs.end();it++)
3488 oss << "\"" << (*it)->getName() << "\", ";
3489 throw INTERP_KERNEL::Exception(oss.str());
3491 return std::distance(_locs.begin(),it);
3495 * The returned value is never null.
3497 const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
3499 std::string pflNameCpp(pflName);
3500 std::vector< MCAuto<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3503 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3504 for(it=_pfls.begin();it!=_pfls.end();it++)
3505 oss << "\"" << (*it)->getName() << "\", ";
3506 throw INTERP_KERNEL::Exception(oss.str());
3511 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
3513 if(pflId<0 || pflId>=(int)_pfls.size())
3514 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3515 return _pfls[pflId];
3518 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
3520 if(locId<0 || locId>=(int)_locs.size())
3521 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3522 return *_locs[locId];
3525 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
3527 return getLocalizationFromId(getLocalizationId(locName));
3531 * The returned value is never null.
3533 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
3535 std::string pflNameCpp(pflName);
3536 std::vector< MCAuto<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3539 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3540 for(it=_pfls.begin();it!=_pfls.end();it++)
3541 oss << "\"" << (*it)->getName() << "\", ";
3542 throw INTERP_KERNEL::Exception(oss.str());
3547 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
3549 if(pflId<0 || pflId>=(int)_pfls.size())
3550 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3551 return _pfls[pflId];
3554 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
3556 std::vector< MCAuto<DataArrayInt> > newPfls;
3558 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3560 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
3561 newPfls.push_back(*it);
3566 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
3568 std::vector< MCAuto<MEDFileFieldLoc> > newLocs;
3570 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3572 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
3573 newLocs.push_back(*it);
3578 void MEDFileFieldGlobs::killStructureElementsInGlobs()
3580 std::vector< MCAuto<MEDFileFieldLoc> > newLocs;
3581 for(std::vector< MCAuto<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
3585 if(!(*it)->isOnStructureElement())
3586 newLocs.push_back(*it);
3591 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
3593 int sz=_pfls.size();
3594 std::vector<std::string> ret(sz);
3595 for(int i=0;i<sz;i++)
3596 ret[i]=_pfls[i]->getName();
3600 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
3602 int sz=_locs.size();
3603 std::vector<std::string> ret(sz);
3604 for(int i=0;i<sz;i++)
3605 ret[i]=_locs[i]->getName();
3609 bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
3611 std::vector<std::string> v=getPfls();
3612 std::string s(pflName);
3613 return std::find(v.begin(),v.end(),s)!=v.end();
3616 bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
3618 std::vector<std::string> v=getLocs();
3619 std::string s(locName);
3620 return std::find(v.begin(),v.end(),s)!=v.end();
3623 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
3625 std::map<int,std::vector<int> > m;
3627 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3629 const DataArrayInt *tmp=(*it);
3632 m[tmp->getHashCode()].push_back(i);
3635 std::vector< std::vector<int> > ret;
3636 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
3638 if((*it2).second.size()>1)
3640 std::vector<int> ret0;
3641 bool equalityOrNot=false;
3642 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
3644 std::vector<int>::const_iterator it4=it3; it4++;
3645 for(;it4!=(*it2).second.end();it4++)
3647 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
3650 ret0.push_back(*it3);
3651 ret0.push_back(*it4);
3657 ret.push_back(ret0);
3663 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
3665 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
3668 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
3670 std::string name(pfl->getName());
3672 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
3673 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3674 if(name==(*it)->getName())
3676 if(!pfl->isEqual(*(*it)))
3678 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
3679 throw INTERP_KERNEL::Exception(oss.str());
3683 _pfls.push_back(pfl);
3686 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)
3688 std::string name(locName);
3690 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
3691 MCAuto<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
3692 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3693 if((*it)->isName(locName))
3695 if(!(*it)->isEqual(*obj,1e-12))
3697 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
3698 throw INTERP_KERNEL::Exception(oss.str());
3701 _locs.push_back(obj);
3704 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
3706 std::vector<std::string> names=getPfls();
3707 return CreateNewNameNotIn("NewPfl_",names);
3710 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
3712 std::vector<std::string> names=getLocs();
3713 return CreateNewNameNotIn("NewLoc_",names);
3716 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
3718 for(std::size_t sz=0;sz<100000;sz++)
3720 std::ostringstream tryName;
3721 tryName << prefix << sz;
3722 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
3723 return tryName.str();
3725 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
3729 * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
3730 * \param [in] fname - the file name.
3732 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(med_idt fid):_globals(MEDFileFieldGlobs::New(fid))
3737 * Creates an empty MEDFileFieldGlobsReal.
3739 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
3743 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
3748 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildrenWithNull() const
3750 std::vector<const BigMemoryObject *> ret;
3751 ret.push_back((const MEDFileFieldGlobs *)_globals);
3756 * Returns a string describing profiles and Gauss points held in \a this.
3757 * \return std::string - the description string.
3759 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
3761 const MEDFileFieldGlobs *glob=_globals;
3762 std::ostringstream oss2; oss2 << glob;
3763 std::string stars(oss2.str().length(),'*');
3764 oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n";
3766 glob->simpleRepr(oss);
3768 oss << "NO GLOBAL INFORMATION !\n";
3771 void MEDFileFieldGlobsReal::resetContent()
3773 _globals=MEDFileFieldGlobs::New();
3776 void MEDFileFieldGlobsReal::killStructureElementsInGlobs()
3778 contentNotNull()->killStructureElementsInGlobs();
3781 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
3786 * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
3787 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3789 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3791 _globals=other._globals;
3795 * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3796 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3798 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3800 const MEDFileFieldGlobs *otherg(other._globals);
3803 _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3807 * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3808 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3810 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3812 const MEDFileFieldGlobs *otherg(other._globals);
3815 _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3818 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3820 _globals=other._globals;
3821 if((const MEDFileFieldGlobs *)_globals)
3822 _globals=other._globals->deepCopy();
3826 * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3827 * \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3828 * \param [in] eps - a precision used to compare Gauss points with same name held by
3829 * \a this and \a other MEDFileFieldGlobsReal.
3830 * \throw If \a this and \a other hold profiles with equal names but different ids.
3831 * \throw If \a this and \a other hold different Gauss points with equal names.
3833 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
3835 const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3836 if(thisGlobals==otherGlobals)
3840 _globals=other._globals;
3843 _globals->appendGlobs(*other._globals,eps);
3846 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
3848 checkGlobsPflsPartCoherency();
3849 checkGlobsLocsPartCoherency();
3852 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
3854 contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3857 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
3859 contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3862 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3864 contentNotNull()->loadProfileInFile(fid,id,pflName);
3867 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3869 contentNotNull()->loadProfileInFile(fid,id);
3872 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
3874 contentNotNull()->loadGlobals(fid,*this);
3877 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid, const MEDFileEntities *entities)
3879 contentNotNull()->loadAllGlobals(fid,entities);
3882 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3884 contentNotNull()->writeGlobals(fid,opt);
3888 * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3889 * or getPflsReallyUsedMulti().
3890 * \return std::vector<std::string> - a sequence of names of all profiles.
3892 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3894 return contentNotNull()->getPfls();
3898 * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3899 * or getLocsReallyUsedMulti().
3900 * \return std::vector<std::string> - a sequence of names of all localizations.
3902 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3904 return contentNotNull()->getLocs();
3908 * Checks if the profile with a given name exists.
3909 * \param [in] pflName - the profile name of interest.
3910 * \return bool - \c true if the profile named \a pflName exists.
3912 bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
3914 return contentNotNull()->existsPfl(pflName);
3918 * Checks if the localization with a given name exists.
3919 * \param [in] locName - the localization name of interest.
3920 * \return bool - \c true if the localization named \a locName exists.
3922 bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
3924 return contentNotNull()->existsLoc(locName);
3927 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
3929 return contentNotNull()->createNewNameOfPfl();
3932 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
3934 return contentNotNull()->createNewNameOfLoc();
3938 * Sets the name of a MED file.
3939 * \param [inout] fileName - the file name.
3941 void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
3943 contentNotNull()->setFileName(fileName);
3947 * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3948 * in the same order.
3949 * \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3950 * Each item of this sequence is a vector containing ids of equal profiles.
3952 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3954 return contentNotNull()->whichAreEqualProfiles();
3958 * Finds equal localizations.
3959 * \param [in] eps - a precision used to compare real values of the localizations.
3960 * \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3961 * Each item of this sequence is a vector containing ids of equal localizations.
3963 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3965 return contentNotNull()->whichAreEqualLocs(eps);
3969 * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3970 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3971 * this sequence is a pair whose
3972 * - the first item is a vector of profile names to replace by the second item,
3973 * - the second item is a profile name to replace every profile name of the first item.
3975 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3977 contentNotNull()->changePflsNamesInStruct(mapOfModif);
3981 * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3982 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3983 * this sequence is a pair whose
3984 * - the first item is a vector of localization names to replace by the second item,
3985 * - the second item is a localization name to replace every localization name of the first item.
3987 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3989 contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3993 * Replaces references to some profiles (a reference is a profile name) by references
3994 * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3995 * them-selves accordingly. <br>
3996 * This method is a generalization of changePflName().
3997 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3998 * this sequence is a pair whose
3999 * - the first item is a vector of profile names to replace by the second item,
4000 * - the second item is a profile name to replace every profile of the first item.
4001 * \sa changePflsRefsNamesGen()
4002 * \sa changePflName()
4004 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4006 changePflsRefsNamesGen(mapOfModif);
4007 changePflsNamesInStruct(mapOfModif);
4011 * Replaces references to some localizations (a reference is a localization name) by references
4012 * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
4013 * them-selves accordingly. <br>
4014 * This method is a generalization of changeLocName().
4015 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
4016 * this sequence is a pair whose
4017 * - the first item is a vector of localization names to replace by the second item,
4018 * - the second item is a localization name to replace every localization of the first item.
4019 * \sa changeLocsRefsNamesGen()
4020 * \sa changeLocName()
4022 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4024 changeLocsRefsNamesGen(mapOfModif);
4025 changeLocsNamesInStruct(mapOfModif);
4029 * Renames the profile having a given name and updates references to this profile.
4030 * \param [in] oldName - the name of the profile to rename.
4031 * \param [in] newName - a new name of the profile.
4032 * \sa changePflsNames().
4034 void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
4036 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
4037 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
4039 changePflsNames(mapOfModif);
4043 * Renames the localization having a given name and updates references to this localization.
4044 * \param [in] oldName - the name of the localization to rename.
4045 * \param [in] newName - a new name of the localization.
4046 * \sa changeLocsNames().
4048 void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
4050 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
4051 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
4053 changeLocsNames(mapOfModif);
4057 * Removes duplicated profiles. Returns a map used to update references to removed
4058 * profiles via changePflsRefsNamesGen().
4059 * Equal profiles are found using whichAreEqualProfiles().
4060 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
4061 * a sequence describing the performed replacements of profiles. Each element of
4062 * this sequence is a pair whose
4063 * - the first item is a vector of profile names replaced by the second item,
4064 * - the second item is a profile name replacing every profile of the first item.
4066 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
4068 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
4069 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
4071 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
4073 std::vector< std::string > tmp((*it).size());
4075 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
4076 tmp[j]=std::string(getProfileFromId(*it2)->getName());
4077 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
4079 std::vector<int> tmp2((*it).begin()+1,(*it).end());
4080 killProfileIds(tmp2);
4082 changePflsRefsNamesGen(ret);
4087 * Removes duplicated localizations. Returns a map used to update references to removed
4088 * localizations via changeLocsRefsNamesGen().
4089 * Equal localizations are found using whichAreEqualLocs().
4090 * \param [in] eps - a precision used to compare real values of the localizations.
4091 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
4092 * a sequence describing the performed replacements of localizations. Each element of
4093 * this sequence is a pair whose
4094 * - the first item is a vector of localization names replaced by the second item,
4095 * - the second item is a localization name replacing every localization of the first item.
4097 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
4099 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
4100 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
4102 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
4104 std::vector< std::string > tmp((*it).size());
4106 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
4107 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
4108 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
4110 std::vector<int> tmp2((*it).begin()+1,(*it).end());
4111 killLocalizationIds(tmp2);
4113 changeLocsRefsNamesGen(ret);
4118 * Returns number of Gauss points per cell in a given localization.
4119 * \param [in] locId - an id of the localization of interest.
4120 * \return int - the number of the Gauss points per cell.
4122 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
4124 return contentNotNull()->getNbOfGaussPtPerCell(locId);
4128 * Returns an id of a localization by its name.
4129 * \param [in] loc - the localization name of interest.
4130 * \return int - the id of the localization.
4131 * \throw If there is no a localization named \a loc.
4133 int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
4135 return contentNotNull()->getLocalizationId(loc);
4139 * Returns the name of the MED file.
4140 * \return const std::string& - the MED file name.
4142 std::string MEDFileFieldGlobsReal::getFileName() const
4144 return contentNotNull()->getFileName();
4148 * Returns a localization object by its name.
4149 * \param [in] locName - the name of the localization of interest.
4150 * \return const MEDFileFieldLoc& - the localization object having the name \a locName.
4151 * \throw If there is no a localization named \a locName.
4153 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
4155 return contentNotNull()->getLocalization(locName);
4159 * Returns a localization object by its id.
4160 * \param [in] locId - the id of the localization of interest.
4161 * \return const MEDFileFieldLoc& - the localization object having the id \a locId.
4162 * \throw If there is no a localization with id \a locId.
4164 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
4166 return contentNotNull()->getLocalizationFromId(locId);
4170 * Returns a profile array by its name.
4171 * \param [in] pflName - the name of the profile of interest.
4172 * \return const DataArrayInt * - the profile array having the name \a pflName.
4173 * \throw If there is no a profile named \a pflName.
4175 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
4177 return contentNotNull()->getProfile(pflName);
4181 * Returns a profile array by its id.
4182 * \param [in] pflId - the id of the profile of interest.
4183 * \return const DataArrayInt * - the profile array having the id \a pflId.
4184 * \throw If there is no a profile with id \a pflId.
4186 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
4188 return contentNotNull()->getProfileFromId(pflId);
4192 * Returns a localization object, apt for modification, by its id.
4193 * \param [in] locId - the id of the localization of interest.
4194 * \return MEDFileFieldLoc& - a non-const reference to the localization object
4195 * having the id \a locId.
4196 * \throw If there is no a localization with id \a locId.
4198 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
4200 return contentNotNull()->getLocalizationFromId(locId);
4204 * Returns a localization object, apt for modification, by its name.
4205 * \param [in] locName - the name of the localization of interest.
4206 * \return MEDFileFieldLoc& - a non-const reference to the localization object
4207 * having the name \a locName.
4208 * \throw If there is no a localization named \a locName.
4210 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
4212 return contentNotNull()->getLocalization(locName);
4216 * Returns a profile array, apt for modification, by its name.
4217 * \param [in] pflName - the name of the profile of interest.
4218 * \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
4219 * \throw If there is no a profile named \a pflName.
4221 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
4223 return contentNotNull()->getProfile(pflName);
4227 * Returns a profile array, apt for modification, by its id.
4228 * \param [in] pflId - the id of the profile of interest.
4229 * \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
4230 * \throw If there is no a profile with id \a pflId.
4232 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
4234 return contentNotNull()->getProfileFromId(pflId);
4238 * Removes profiles given by their ids. No data is updated to track this removal.
4239 * \param [in] pflIds - a sequence of ids of the profiles to remove.
4241 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
4243 contentNotNull()->killProfileIds(pflIds);
4247 * Removes localizations given by their ids. No data is updated to track this removal.
4248 * \param [in] locIds - a sequence of ids of the localizations to remove.
4250 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
4252 contentNotNull()->killLocalizationIds(locIds);
4256 * Stores a profile array.
4257 * \param [in] pfl - the profile array to store.
4258 * \throw If the name of \a pfl is empty.
4259 * \throw If a profile with the same name as that of \a pfl already exists but contains
4262 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
4264 contentNotNull()->appendProfile(pfl);
4268 * Adds a new localization of Gauss points.
4269 * \param [in] locName - the name of the new localization.
4270 * \param [in] geoType - a geometrical type of the reference cell.
4271 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
4272 * must be \c nbOfNodesPerCell * \c dimOfType.
4273 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
4274 * must be _wg_.size() * \c dimOfType.
4275 * \param [in] w - the weights of Gauss points.
4276 * \throw If \a locName is empty.
4277 * \throw If a localization with the name \a locName already exists but is
4278 * different form the new one.
4280 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)
4282 contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
4285 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
4287 MEDFileFieldGlobs *g(_globals);
4289 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
4293 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
4295 const MEDFileFieldGlobs *g(_globals);
4297 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
4301 //= MEDFileFieldNameScope
4303 MEDFileFieldNameScope::MEDFileFieldNameScope()
4307 MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName, const std::string& meshName):_name(fieldName),_mesh_name(meshName)
4312 * Returns the name of \a this field.
4313 * \return std::string - a string containing the field name.
4315 std::string MEDFileFieldNameScope::getName() const
4321 * Sets name of \a this field
4322 * \param [in] name - the new field name.
4324 void MEDFileFieldNameScope::setName(const std::string& fieldName)
4329 std::string MEDFileFieldNameScope::getDtUnit() const
4334 void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
4339 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
4342 _mesh_name=other._mesh_name;
4343 _dt_unit=other._dt_unit;
4347 * Returns the mesh name.
4348 * \return std::string - a string holding the mesh name.
4349 * \throw If \c _field_per_mesh.empty()
4351 std::string MEDFileFieldNameScope::getMeshName() const
4356 void MEDFileFieldNameScope::setMeshName(const std::string& meshName)
4358 _mesh_name=meshName;
4361 //= MEDFileAnyTypeField1TSWithoutSDA
4363 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
4365 _field_per_mesh.resize(other._field_per_mesh.size());
4367 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
4369 if((const MEDFileFieldPerMesh *)*it)
4370 _field_per_mesh[i]=(*it)->deepCopy(this);
4374 void MEDFileAnyTypeField1TSWithoutSDA::accept(MEDFileFieldVisitor& visitor) const
4376 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4377 if((*it).isNotNull())
4379 visitor.newMeshEntry(*it);
4380 (*it)->accept(visitor);
4381 visitor.endMeshEntry(*it);
4386 * Prints a string describing \a this field into a stream. This string is outputted
4387 * by \c print Python command.
4388 * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
4389 * \param [in,out] oss - the out stream.
4390 * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
4391 * info id printed, else, not.
4393 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
4395 std::string startOfLine(bkOffset,' ');
4396 oss << startOfLine << "Field ";
4398 oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
4399 oss << "on one time Step ";
4401 oss << "(" << f1tsId << ") ";
4402 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
4403 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
4404 const DataArray *arr=getUndergroundDataArray();
4407 const std::vector<std::string> &comps=arr->getInfoOnComponents();
4410 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
4411 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
4412 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
4414 if(arr->isAllocated())
4416 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
4419 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
4423 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
4425 oss << startOfLine << "----------------------" << std::endl;
4426 if(!_field_per_mesh.empty())
4429 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
4431 const MEDFileFieldPerMesh *cur=(*it2);
4433 cur->simpleRepr(bkOffset,oss,i);
4435 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
4440 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
4442 oss << startOfLine << "----------------------" << std::endl;
4445 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
4447 const DataArray *arr(getUndergroundDataArray());
4449 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
4450 int nbOfCompo=arr->getNumberOfComponents();
4451 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
4452 for(int i=0;i<nbOfCompo;i++)
4455 std::vector<int> v(1,i);
4456 MCAuto<DataArray> arr2=arr->keepSelectedComponents(v);
4457 ret[i]->setArray(arr2);
4462 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)
4466 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
4471 * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
4472 * empty. Returns -1 if this in on nodes.
4473 * \return int - the dimension of \a this.
4475 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
4478 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4479 (*it)->getDimension(ret);
4483 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
4486 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4488 MEDFileFieldPerMesh *cur(*it);
4490 ret=cur->changeMeshNames(modifTab) || ret;
4496 * Returns the number of iteration of the state of underlying mesh.
4497 * \return int - the iteration number.
4498 * \throw If \c _field_per_mesh.empty()
4500 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
4502 if(_field_per_mesh.empty())
4503 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
4504 return _field_per_mesh[0]->getMeshIteration();
4508 * Returns the order number of iteration of the state of underlying mesh.
4509 * \return int - the order number.
4510 * \throw If \c _field_per_mesh.empty()
4512 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
4514 if(_field_per_mesh.empty())
4515 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
4516 return _field_per_mesh[0]->getMeshOrder();
4520 * Checks if \a this field is tagged by a given iteration number and a given
4521 * iteration order number.
4522 * \param [in] iteration - the iteration number of interest.
4523 * \param [in] order - the iteration order number of interest.
4524 * \return bool - \c true if \a this->getIteration() == \a iteration &&
4525 * \a this->getOrder() == \a order.
4527 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
4529 return iteration==_iteration && order==_order;
4533 * Returns number of iteration and order number of iteration when
4534 * \a this field has been calculated.
4535 * \return std::pair<int,int> - a pair of the iteration number and the iteration
4538 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
4540 std::pair<int,int> p;
4546 * Returns number of iteration and order number of iteration when
4547 * \a this field has been calculated.
4548 * \param [in,out] p - a pair returning the iteration number and the iteration
4551 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
4558 * Returns all types of spatial discretization of \a this field.
4559 * \param [in,out] types - a sequence of types of \a this field.
4561 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
4563 std::set<TypeOfField> types2;
4564 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4566 (*it)->fillTypesOfFieldAvailable(types2);
4568 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
4569 std::copy(types2.begin(),types2.end(),bi);
4573 * Returns all types of spatial discretization of \a this field.
4574 * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
4577 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
4579 std::vector<TypeOfField> ret;
4580 fillTypesOfFieldAvailable(ret);
4584 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
4586 std::vector<std::string> ret;
4587 std::set<std::string> ret2;
4588 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4590 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
4591 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4592 if(ret2.find(*it2)==ret2.end())
4594 ret.push_back(*it2);
4601 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
4603 std::vector<std::string> ret;
4604 std::set<std::string> ret2;
4605 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4607 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
4608 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4609 if(ret2.find(*it2)==ret2.end())
4611 ret.push_back(*it2);
4618 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
4620 std::vector<std::string> ret;
4621 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4623 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
4624 ret.insert(ret.end(),tmp.begin(),tmp.end());
4629 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
4631 std::vector<std::string> ret;
4632 std::set<std::string> ret2;
4633 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4635 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
4636 ret.insert(ret.end(),tmp.begin(),tmp.end());
4641 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4643 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4644 (*it)->changePflsRefsNamesGen(mapOfModif);
4647 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4649 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4650 (*it)->changeLocsRefsNamesGen(mapOfModif);
4654 * Returns all attributes of parts of \a this field lying on a given mesh.
4655 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4656 * item of every of returned sequences refers to the _i_-th part of \a this field.
4657 * Thus all sequences returned by this method are of the same length equal to number
4658 * of different types of supporting entities.<br>
4659 * A field part can include sub-parts with several different spatial discretizations,
4660 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
4661 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4662 * of a nested sequence corresponds to a type of spatial discretization.<br>
4663 * This method allows for iteration over MEDFile DataStructure without any overhead.
4664 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4665 * for the case with only one underlying mesh. (Actually, the number of meshes is
4666 * not checked if \a mname == \c NULL).
4667 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4668 * a field part is returned.
4669 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4670 * This sequence is of the same length as \a types.
4671 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4672 * discretization. A profile name can be empty.
4673 * Length of this and of nested sequences is the same as that of \a typesF.
4674 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4675 * discretization. A localization name can be empty.
4676 * Length of this and of nested sequences is the same as that of \a typesF.
4677 * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
4678 * of ids of tuples within the data array, per each type of spatial
4679 * discretization within one mesh entity type.
4680 * Length of this and of nested sequences is the same as that of \a typesF.
4681 * \throw If no field is lying on \a mname.
4683 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
4685 if(_field_per_mesh.empty())
4686 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4687 return _field_per_mesh[0]->getFieldSplitedByType(types,typesF,pfls,locs);
4691 * Returns dimensions of mesh elements \a this field lies on. The returned value is a
4692 * maximal absolute dimension and values returned via the out parameter \a levs are
4693 * dimensions relative to the maximal absolute dimension. <br>
4694 * This method is designed for MEDFileField1TS instances that have a discretization
4695 * \ref MEDCoupling::ON_CELLS "ON_CELLS",
4696 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT",
4697 * \ref MEDCoupling::ON_GAUSS_NE "ON_GAUSS_NE".
4698 * Only these 3 discretizations will be taken into account here. If \a this is
4699 * \ref MEDCoupling::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
4700 * This method is useful to make the link between the dimension of the underlying mesh
4701 * and the levels of \a this, because it is possible that the highest dimension of \a this
4702 * field is not equal to the dimension of the underlying mesh.
4704 * Let's consider the following case:
4705 * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
4706 * TETRA4, HEXA8, TRI3 and SEG2.
4707 * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
4708 * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
4710 * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
4711 * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
4712 * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
4713 * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
4714 * parameter of getFieldAtLevel() is computed basing on the returned values as this:
4715 * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
4717 * to retrieve the highest level of
4718 * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br>
4719 * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
4720 * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
4721 * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
4722 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4723 * for the case with only one underlying mesh. (Actually, the number of meshes is
4724 * not checked if \a mname == \c NULL).
4725 * \param [in,out] levs - a sequence returning the dimensions relative to the maximal
4726 * absolute one. They are in decreasing order. This sequence is cleared before
4728 * \return int - the maximal absolute dimension of elements \a this fields lies on.
4729 * \throw If no field is lying on \a mname.
4731 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
4734 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4735 std::vector< std::vector<TypeOfField> > typesF;
4736 std::vector< std::vector<std::string> > pfls, locs;
4737 if(_field_per_mesh.empty())
4738 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels : This is empty !");
4739 _field_per_mesh[0]->getFieldSplitedByType(types,typesF,pfls,locs);
4741 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
4742 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
4743 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
4745 st.erase(INTERP_KERNEL::NORM_ERROR);
4747 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
4749 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
4750 ret1.insert((int)cm.getDimension());
4752 int ret=*std::max_element(ret1.begin(),ret1.end());
4753 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
4754 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
4758 void MEDFileAnyTypeField1TSWithoutSDA::convertMedBallIntoClassic()
4760 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it<_field_per_mesh.end();it++)
4761 if((*it).isNotNull())
4762 (*it)->convertMedBallIntoClassic();
4765 void MEDFileAnyTypeField1TSWithoutSDA::makeReduction(INTERP_KERNEL::NormalizedCellType ct, TypeOfField tof, const DataArrayInt *pfl)
4768 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : null pfl !");
4769 std::string name(pfl->getName());
4770 pfl->checkAllocated();
4771 if(pfl->getNumberOfComponents()!=1)
4772 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : non mono compo array !");
4774 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : empty pfl name !");
4775 if(_field_per_mesh.size()!=1)
4776 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : only single mesh supported !");
4777 MCAuto<MEDFileFieldPerMesh> fpm(_field_per_mesh[0]);
4779 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : only single not null mesh supported !");
4780 MEDFileFieldPerMeshPerTypePerDisc *disc(fpm->getLeafGivenTypeAndLocId(ct,0));
4781 if(disc->getType()!=tof)
4782 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : error !");
4783 int s(disc->getStart()),e(disc->getEnd()),nt(pfl->getNumberOfTuples());
4784 DataArray *arr(getUndergroundDataArray());
4785 int nt2(arr->getNumberOfTuples()),delta((e-s)-nt);
4787 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : internal error !");
4788 MCAuto<DataArray> arr0(arr->selectByTupleIdSafeSlice(0,s,1)),arr1(arr->selectByTupleIdSafeSlice(s,e,1)),arr2(arr->selectByTupleIdSafeSlice(e,nt2,1));
4789 MCAuto<DataArray> arr11(arr1->selectByTupleIdSafe(pfl->begin(),pfl->end()));
4790 MCAuto<DataArray> arrOut(arr->buildNewEmptyInstance());
4791 arrOut->alloc(nt2-delta,arr->getNumberOfComponents());
4792 arrOut->copyStringInfoFrom(*arr);
4793 arrOut->setContigPartOfSelectedValuesSlice(0,arr0,0,s,1);
4794 arrOut->setContigPartOfSelectedValuesSlice(s,arr11,0,nt,1);
4795 arrOut->setContigPartOfSelectedValuesSlice(e-delta,arr2,0,nt2-e,1);
4797 disc->setEnd(e-delta);
4798 disc->setProfile(name);
4802 * \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.
4803 * \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.
4804 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4805 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4807 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
4809 if(_field_per_mesh.empty())
4810 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId : This is empty !");
4811 return _field_per_mesh[0]->getLeafGivenTypeAndLocId(typ,locId);
4815 * \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.
4816 * \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.
4817 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4818 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4820 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
4822 if(_field_per_mesh.empty())
4823 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId : This is empty !");
4824 return _field_per_mesh[0]->getLeafGivenTypeAndLocId(typ,locId);
4828 * \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.
4830 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
4832 if(_field_per_mesh.empty())
4833 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4836 std::string mName2(mName);
4838 std::vector<std::string> msg;
4839 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4840 if(mName2==(*it)->getMeshName())
4843 msg.push_back((*it)->getMeshName());
4844 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4845 oss << "Possible meshes are : ";
4846 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4847 oss << "\"" << (*it2) << "\" ";
4848 throw INTERP_KERNEL::Exception(oss.str());
4851 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
4854 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4855 std::string tmp(mesh->getName());
4857 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4859 std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4861 for(;it!=_field_per_mesh.end();it++,i++)
4863 if((*it)->getMeshName()==tmp)
4866 int sz=_field_per_mesh.size();
4867 _field_per_mesh.resize(sz+1);
4868 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4872 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4873 MEDFileFieldGlobsReal& glob)
4876 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4878 MEDFileFieldPerMesh *fpm(*it);
4880 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4886 * This method splits \a this into several sub-parts so that each sub parts have exactly one spatial discretization. This method implements the minimal
4887 * splitting that leads to single spatial discretization of this.
4889 * \sa splitMultiDiscrPerGeoTypes
4891 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
4893 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4894 std::vector< std::vector<TypeOfField> > typesF;
4895 std::vector< std::vector<std::string> > pfls,locs;
4896 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4897 std::set<TypeOfField> allEnt;
4898 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4899 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4900 allEnt.insert(*it2);
4901 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4902 std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4903 for(std::size_t i=0;i<allEnt.size();i++,it3++)
4905 std::vector< std::pair<int,int> > its;
4906 ret[i]=shallowCpy();
4907 int newLgth(ret[i]->keepOnlySpatialDiscretization(*it3,its));
4908 ret[i]->updateData(newLgth,its);
4914 * This method performs a sub splitting as splitDiscretizations does but finer. This is the finest spliting level that can be done.
4915 * This method implements the minimal splitting so that each returned elements are mono Gauss discretization per geometric type.
4917 * \sa splitDiscretizations
4919 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes() const
4921 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4922 std::vector< std::vector<TypeOfField> > typesF;
4923 std::vector< std::vector<std::string> > pfls,locs;
4924 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4925 std::set<TypeOfField> allEnt;
4926 std::size_t nbOfMDPGT(0),ii(0);
4927 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++,ii++)
4929 nbOfMDPGT=std::max(nbOfMDPGT,locs[ii].size());
4930 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4931 allEnt.insert(*it2);
4933 if(allEnt.size()!=1)
4934 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : this field is expected to be defined only on one spatial discretization !");
4936 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
4939 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret0(1);
4940 ret0[0]=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(this); this->incrRef();
4943 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfMDPGT);
4944 for(std::size_t i=0;i<nbOfMDPGT;i++)
4946 std::vector< std::pair<int,int> > its;
4947 ret[i]=shallowCpy();
4948 int newLgth(ret[i]->keepOnlyGaussDiscretization(i,its));
4949 ret[i]->updateData(newLgth,its);
4954 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
4956 int globalCounter(0);
4957 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4958 (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4959 return globalCounter;
4962 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlyGaussDiscretization(std::size_t idOfDisc, std::vector< std::pair<int,int> >& its)
4964 int globalCounter(0);
4965 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4966 (*it)->keepOnlyGaussDiscretization(idOfDisc,globalCounter,its);
4967 return globalCounter;
4970 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
4972 if(_nb_of_tuples_to_be_allocated>=0)
4974 _nb_of_tuples_to_be_allocated=newLgth;
4975 const DataArray *oldArr(getUndergroundDataArray());
4978 MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4979 newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
4981 _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
4985 if(_nb_of_tuples_to_be_allocated==-1)
4987 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4989 const DataArray *oldArr(getUndergroundDataArray());
4990 if(!oldArr || !oldArr->isAllocated())
4991 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4992 MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4993 newArr->alloc(newLgth,getNumberOfComponents());
4995 newArr->copyStringInfoFrom(*oldArr);
4997 for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4999 if((*it).second<(*it).first)
5000 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
5001 newArr->setContigPartOfSelectedValuesSlice(pos,oldArr,(*it).first,(*it).second,1);
5002 pos+=(*it).second-(*it).first;
5007 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
5010 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
5012 if(_field_per_mesh.empty())
5013 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
5014 if(_field_per_mesh.size()>1)
5015 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
5016 _field_per_mesh[0]->copyOptionsFrom(opts);
5017 _field_per_mesh[0]->writeLL(fid,nasc);
5021 * 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.
5022 * If false is returned the memory allocation is not required.
5024 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
5026 if(_nb_of_tuples_to_be_allocated>=0)
5028 getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
5029 _nb_of_tuples_to_be_allocated=-2;
5032 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
5034 if(_nb_of_tuples_to_be_allocated==-1)
5035 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
5036 if(_nb_of_tuples_to_be_allocated<-3)
5037 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
5038 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
5041 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
5043 med_int numdt,numit;
5045 med_int meshnumdt,meshnumit;
5046 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt));
5050 INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
5051 MEDFILESAFECALLERRD0(MEDfield23ComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit)); // to check with Adrien for legacy MED files
5053 //MEDFILESAFECALLERRD0(MEDfieldComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt,&meshnumdt,&meshnumit));
5054 if(_iteration!=numdt || _order!=numit)
5055 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
5056 _field_per_mesh.resize(1);
5061 mm=ms->getMeshWithName(getMeshName());
5064 _field_per_mesh[0]=MEDFileFieldPerMesh::NewOnRead(fid,this,0,meshnumdt,meshnumit,nasc,mm,entities);
5065 _nb_of_tuples_to_be_allocated=0;
5066 _field_per_mesh[0]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
5069 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
5071 allocIfNecessaryTheArrayToReceiveDataFromFile();
5072 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5073 (*it)->loadBigArraysRecursively(fid,nasc);
5076 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
5078 if(allocIfNecessaryTheArrayToReceiveDataFromFile())
5079 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5080 (*it)->loadBigArraysRecursively(fid,nasc);
5083 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
5085 loadOnlyStructureOfDataRecursively(fid,nasc,ms,entities);
5086 loadBigArraysRecursively(fid,nasc);
5089 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
5091 DataArray *thisArr(getUndergroundDataArray());
5092 if(thisArr && thisArr->isAllocated())
5094 _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
5095 thisArr->desallocate();
5099 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
5101 return _mesh_name.capacity()+_dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MCAuto< MEDFileFieldPerMesh >);
5104 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
5106 std::vector<const BigMemoryObject *> ret;
5107 if(getUndergroundDataArray())
5108 ret.push_back(getUndergroundDataArray());
5109 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5110 ret.push_back((const MEDFileFieldPerMesh *)*it);
5115 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
5116 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
5117 * "Sort By Type"), if not, an exception is thrown.
5118 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
5119 * \param [in] arr - the array of values.
5120 * \param [in,out] glob - the global data where profiles and localization present in
5121 * \a field, if any, are added.
5122 * \throw If the name of \a field is empty.
5123 * \throw If the data array of \a field is not set.
5124 * \throw If \a this->_arr is already allocated but has different number of components
5126 * \throw If the underlying mesh of \a field has no name.
5127 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
5129 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
5131 const MEDCouplingMesh *mesh(field->getMesh());
5133 TypeOfField type(field->getTypeOfField());
5134 std::vector<DataArrayInt *> dummy;
5136 setMeshName(mesh->getName());
5137 int start(copyTinyInfoFrom(th,field,arr));
5138 int pos(addNewEntryIfNecessary(mesh));
5141 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
5142 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
5145 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
5149 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
5150 * of a given mesh are used as the support of the given field (a real support is not used).
5151 * Elements of the given mesh must be sorted suitable for writing to MED file.
5152 * Order of underlying mesh entities of the given field specified by \a profile parameter
5153 * is not prescribed; this method permutes field values to have them sorted by element
5154 * type as required for writing to MED file. A new profile is added only if no equal
5155 * profile is missing.
5156 * \param [in] field - the field to add to \a this. The field double values are ignored.
5157 * \param [in] arrOfVals - the values of the field \a field used.
5158 * \param [in] mesh - the supporting mesh of \a field.
5159 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
5160 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
5161 * \param [in,out] glob - the global data where profiles and localization present in
5162 * \a field, if any, are added.
5163 * \throw If either \a field or \a mesh or \a profile has an empty name.
5164 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
5165 * \throw If the data array of \a field is not set.
5166 * \throw If \a this->_arr is already allocated but has different number of components
5168 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
5169 * \sa setFieldNoProfileSBT()
5171 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)
5174 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
5175 if(!arrOfVals || !arrOfVals->isAllocated())
5176 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
5177 TypeOfField type=field->getTypeOfField();
5178 std::vector<DataArrayInt *> idsInPflPerType;
5179 std::vector<DataArrayInt *> idsPerType;
5180 std::vector<int> code,code2;
5181 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
5184 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
5185 std::vector< MCAuto<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
5186 std::vector< MCAuto<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin());
5187 std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
5189 MCAuto<MEDCouplingFieldTemplate> field2=field->clone(false);
5190 int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
5191 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
5193 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
5194 throw INTERP_KERNEL::Exception(oss.str());
5197 int start(copyTinyInfoFrom(th,field,arrOfVals));
5198 code2=m->getDistributionOfTypes();
5200 int pos=addNewEntryIfNecessary(m);
5201 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
5205 if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
5206 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
5207 std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
5208 std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
5209 int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
5210 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
5212 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
5213 throw INTERP_KERNEL::Exception(oss.str());
5215 int start(copyTinyInfoFrom(th,field,arrOfVals));
5216 int pos(addNewEntryIfNecessary(m));
5217 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
5222 * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
5224 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
5226 if(_nb_of_tuples_to_be_allocated>=0)
5227 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 !");
5228 DataArray *arr(getOrCreateAndGetArray());
5229 arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
5230 _nb_of_tuples_to_be_allocated=-3;
5234 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
5235 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
5236 * larger by the size of \a field. Returns an id of the first not filled
5237 * tuple of \a this->_arr.
5238 * \param [in] field - the field to copy the info on components and the name from.
5239 * \return int - the id of first not initialized tuple of \a this->_arr.
5240 * \throw If the name of \a field is empty.
5241 * \throw If the data array of \a field is not set.
5242 * \throw If \a this->_arr is already allocated but has different number of components
5245 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arr)
5248 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
5249 std::string name(field->getName());
5250 setName(name.c_str());
5251 if(field->getMesh())
5252 setMeshName(field->getMesh()->getName());
5253 setDtUnit(th->getTimeUnit());
5255 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
5257 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
5258 if(!arr->isAllocated())
5259 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
5260 _dt=th->getTime(_iteration,_order);
5261 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
5262 if(!getOrCreateAndGetArray()->isAllocated())
5264 allocNotFromFile(arr->getNumberOfTuples());
5269 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
5270 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
5271 getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
5272 _nb_of_tuples_to_be_allocated=-3;
5273 return oldNbOfTuples;
5278 * Returns number of components in \a this field
5279 * \return int - the number of components.
5281 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
5283 return getOrCreateAndGetArray()->getNumberOfComponents();
5287 * Change info on components in \a this.
5288 * \throw If size of \a infos is not equal to the number of components already in \a this.
5290 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
5292 DataArray *arr=getOrCreateAndGetArray();
5293 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
5297 * Returns info on components of \a this field.
5298 * \return const std::vector<std::string>& - a sequence of strings each being an
5299 * information on _i_-th component.
5301 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
5303 const DataArray *arr=getOrCreateAndGetArray();
5304 return arr->getInfoOnComponents();
5308 * Returns a mutable info on components of \a this field.
5309 * \return std::vector<std::string>& - a sequence of strings each being an
5310 * information on _i_-th component.
5312 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
5314 DataArray *arr=getOrCreateAndGetArray();
5315 return arr->getInfoOnComponents();
5318 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const
5320 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5322 const MEDFileFieldPerMesh *fpm(*it);
5325 if(fpm->presenceOfMultiDiscPerGeoType())
5331 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfStructureElements() const
5333 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5334 if((*it).isNotNull())
5335 if((*it)->presenceOfStructureElements())
5340 bool MEDFileAnyTypeField1TSWithoutSDA::onlyStructureElements() const
5342 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5343 if((*it).isNotNull())
5344 if(!(*it)->onlyStructureElements())
5349 void MEDFileAnyTypeField1TSWithoutSDA::killStructureElements()
5351 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5352 if((*it).isNotNull())
5353 (*it)->killStructureElements();
5356 void MEDFileAnyTypeField1TSWithoutSDA::keepOnlyStructureElements()
5358 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5359 if((*it).isNotNull())
5360 (*it)->keepOnlyStructureElements();
5363 void MEDFileAnyTypeField1TSWithoutSDA::keepOnlyOnSE(const std::string& seName)
5365 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5366 if((*it).isNotNull())
5367 (*it)->keepOnlyOnSE(seName);
5370 void MEDFileAnyTypeField1TSWithoutSDA::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
5372 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5373 if((*it).isNotNull())
5374 (*it)->getMeshSENames(ps);
5377 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh(const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5379 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 !";
5380 if(_field_per_mesh.empty())
5381 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is empty ! Nothing to extract !");
5382 if(_field_per_mesh.size()>1)
5383 throw INTERP_KERNEL::Exception(MSG0);
5384 if(_field_per_mesh[0].isNull())
5385 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is inconsistent !");
5386 const MEDFileFieldPerMesh *pm(_field_per_mesh[0]);
5387 std::set<TypeOfField> types;
5388 pm->fillTypesOfFieldAvailable(types);
5390 throw INTERP_KERNEL::Exception(MSG0);
5391 TypeOfField type(*types.begin());
5392 int meshDimRelToMax(0);
5397 int myDim(std::numeric_limits<int>::max());
5398 bool isUnique(pm->isUniqueLevel(myDim));
5400 throw INTERP_KERNEL::Exception(MSG0);
5401 meshDimRelToMax=myDim-mesh->getMeshDimension();
5402 if(meshDimRelToMax>0)
5403 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the mesh attached to field is not compatible with the field !");
5405 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,0/*renumPol*/,glob,mesh,arrOut,nasc);
5409 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5410 * \param [in] type - a spatial discretization of the new field.
5411 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5412 * \param [in] mName - a name of the supporting mesh.
5413 * \param [in] renumPol - specifies how to permute values of the result field according to
5414 * the optional numbers of cells and nodes, if any. The valid values are
5415 * - 0 - do not permute.
5416 * - 1 - permute cells.
5417 * - 2 - permute nodes.
5418 * - 3 - permute cells and nodes.
5420 * \param [in] glob - the global data storing profiles and localization.
5421 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5422 * caller is to delete this field using decrRef() as it is no more needed.
5423 * \throw If the MED file is not readable.
5424 * \throw If there is no mesh named \a mName in the MED file.
5425 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5426 * \throw If no field of \a this is lying on the mesh \a mName.
5427 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5429 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5431 MCAuto<MEDFileMesh> mm;
5433 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
5435 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
5436 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
5440 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5441 * \param [in] type - a spatial discretization of the new field.
5442 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5443 * \param [in] renumPol - specifies how to permute values of the result field according to
5444 * the optional numbers of cells and nodes, if any. The valid values are
5445 * - 0 - do not permute.
5446 * - 1 - permute cells.
5447 * - 2 - permute nodes.
5448 * - 3 - permute cells and nodes.
5450 * \param [in] glob - the global data storing profiles and localization.
5451 * \param [in] mesh - the supporting mesh.
5452 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5453 * caller is to delete this field using decrRef() as it is no more needed.
5454 * \throw If the MED file is not readable.
5455 * \throw If no field of \a this is lying on \a mesh.
5456 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5457 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5459 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5461 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax,false));
5462 const DataArrayInt *d(mesh->getNumberFieldAtLevel(meshDimRelToMax)),*e(mesh->getNumberFieldAtLevel(1));
5463 if(meshDimRelToMax==1)
5464 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
5465 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
5469 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
5471 * \param [in] type - a spatial discretization of the new field.
5472 * \param [in] mName - a name of the supporting mesh.
5473 * \param [in] renumPol - specifies how to permute values of the result field according to
5474 * the optional numbers of cells and nodes, if any. The valid values are
5475 * - 0 - do not permute.
5476 * - 1 - permute cells.
5477 * - 2 - permute nodes.
5478 * - 3 - permute cells and nodes.
5480 * \param [in] glob - the global data storing profiles and localization.
5481 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5482 * caller is to delete this field using decrRef() as it is no more needed.
5483 * \throw If the MED file is not readable.
5484 * \throw If there is no mesh named \a mName in the MED file.
5485 * \throw If there are no mesh entities in the mesh.
5486 * \throw If no field values of the given \a type are available.
5488 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5490 MCAuto<MEDFileMesh> mm;
5492 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
5494 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
5495 int absDim=getDimension();
5496 int meshDimRelToMax=absDim-mm->getMeshDimension();
5497 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
5501 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5502 * \param [in] type - a spatial discretization of the new field.
5503 * \param [in] renumPol - specifies how to permute values of the result field according to
5504 * the optional numbers of cells and nodes, if any. The valid values are
5505 * - 0 - do not permute.
5506 * - 1 - permute cells.
5507 * - 2 - permute nodes.
5508 * - 3 - permute cells and nodes.
5510 * \param [in] glob - the global data storing profiles and localization.
5511 * \param [in] mesh - the supporting mesh.
5512 * \param [in] cellRenum - the cell numbers array used for permutation of the result
5513 * field according to \a renumPol.
5514 * \param [in] nodeRenum - the node numbers array used for permutation of the result
5515 * field according to \a renumPol.
5516 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5517 * caller is to delete this field using decrRef() as it is no more needed.
5518 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5519 * \throw If no field of \a this is lying on \a mesh.
5520 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5522 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
5524 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
5526 MCAuto<MEDCouplingFieldDouble> ret=_field_per_mesh[0]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
5531 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5538 throw INTERP_KERNEL::Exception(msg1);
5539 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5542 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
5544 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5545 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
5546 throw INTERP_KERNEL::Exception(oss.str());
5548 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
5549 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
5550 std::vector<DataArray *> arrOut2(1,arrOut);
5551 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
5552 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
5553 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
5560 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5562 throw INTERP_KERNEL::Exception(msg1);
5565 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
5567 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5568 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
5569 throw INTERP_KERNEL::Exception(oss.str());
5571 MCAuto<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
5572 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
5573 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
5574 ret->renumberNodes(nodeRenumSafe->getConstPointer());
5579 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
5584 * Returns values and a profile of the field of a given type lying on a given support.
5585 * \param [in] type - a spatial discretization of the field.
5586 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5587 * \param [in] mesh - the supporting mesh.
5588 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
5589 * field of interest lies on. If the field lies on all entities of the given
5590 * dimension, all ids in \a pfl are zero. The caller is to delete this array
5591 * using decrRef() as it is no more needed.
5592 * \param [in] glob - the global data storing profiles and localization.
5593 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
5594 * field. The caller is to delete this array using decrRef() as it is no more needed.
5595 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
5596 * \throw If no field of \a this is lying on \a mesh.
5597 * \throw If no field values of the given \a type are available.
5599 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
5601 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
5602 MCAuto<DataArray> ret=_field_per_mesh[0]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
5603 ret->setName(nasc.getName().c_str());
5607 //= MEDFileField1TSWithoutSDA
5610 * Throws if a given value is not a valid (non-extended) relative dimension.
5611 * \param [in] meshDimRelToMax - the relative dimension value.
5612 * \throw If \a meshDimRelToMax > 0.
5614 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
5616 if(meshDimRelToMax>0)
5617 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
5621 * Checks if elements of a given mesh are in the order suitable for writing
5622 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
5623 * vector describing types of elements and their number.
5624 * \param [in] mesh - the mesh to check.
5625 * \return std::vector<int> - a vector holding for each element type (1) item of
5626 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
5627 * These values are in full-interlace mode.
5628 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
5630 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
5633 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
5634 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
5635 int nbOfTypes=geoTypes.size();
5636 std::vector<int> code(3*nbOfTypes);
5637 MCAuto<DataArrayInt> arr1=DataArrayInt::New();
5638 arr1->alloc(nbOfTypes,1);
5639 int *arrPtr=arr1->getPointer();
5640 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
5641 for(int i=0;i<nbOfTypes;i++,it++)
5642 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
5643 MCAuto<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
5644 const int *arrPtr2=arr2->getConstPointer();
5646 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
5649 int nbCells=mesh->getNumberOfCellsWithType(*it);
5650 code[3*pos]=(int)(*it);
5651 code[3*pos+1]=nbCells;
5652 code[3*pos+2]=-1;//no profiles
5654 std::vector<const DataArrayInt *> idsPerType;//no profiles
5655 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
5659 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
5664 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5666 return new MEDFileField1TSWithoutSDA(fieldName,meshName,csit,iteration,order,infos);
5670 * Returns all attributes and values of parts of \a this field lying on a given mesh.
5671 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
5672 * item of every of returned sequences refers to the _i_-th part of \a this field.
5673 * Thus all sequences returned by this method are of the same length equal to number
5674 * of different types of supporting entities.<br>
5675 * A field part can include sub-parts with several different spatial discretizations,
5676 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
5677 * for example. Hence, some of the returned sequences contains nested sequences, and an item
5678 * of a nested sequence corresponds to a type of spatial discretization.<br>
5679 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
5680 * The overhead is due to selecting values into new instances of DataArrayDouble.
5681 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
5682 * for the case with only one underlying mesh. (Actually, the number of meshes is
5683 * not checked if \a mname == \c NULL).
5684 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
5685 * a field part is returned.
5686 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
5687 * A field part can include sub-parts with several different spatial discretizations,
5688 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and
5689 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT" for example.
5690 * This sequence is of the same length as \a types.
5691 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
5692 * discretization. A profile name can be empty.
5693 * Length of this and of nested sequences is the same as that of \a typesF.
5694 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
5695 * discretization. A localization name can be empty.
5696 * Length of this and of nested sequences is the same as that of \a typesF.
5697 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
5698 * per each type of spatial discretization within one mesh entity type.
5699 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
5700 * Length of this and of nested sequences is the same as that of \a typesF.
5701 * \throw If no field is lying on \a mname.
5703 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
5706 if(_field_per_mesh.empty())
5707 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
5708 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[0]->getFieldSplitedByType(types,typesF,pfls,locs);
5709 int nbOfRet=ret0.size();
5710 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
5711 for(int i=0;i<nbOfRet;i++)
5713 const std::vector< std::pair<int,int> >& p=ret0[i];
5714 int nbOfRet1=p.size();
5715 ret[i].resize(nbOfRet1);
5716 for(int j=0;j<nbOfRet1;j++)
5718 DataArrayDouble *tmp=_arr->selectByTupleIdSafeSlice(p[j].first,p[j].second,1);
5725 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
5730 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
5732 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
5733 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5734 ret->deepCpyLeavesFrom(*this);
5735 const DataArrayDouble *arr(_arr);
5738 MCAuto<DataArrayInt> arr2(arr->convertToIntArr());
5739 ret->setArray(arr2);
5745 * Returns a pointer to the underground DataArrayDouble instance and a
5746 * sequence describing parameters of a support of each part of \a this field. The
5747 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5748 * direct access to the field values. This method is intended for the field lying on one
5750 * \param [in,out] entries - the sequence describing parameters of a support of each
5751 * part of \a this field. Each item of this sequence consists of two parts. The
5752 * first part describes a type of mesh entity and an id of discretization of a
5753 * current field part. The second part describes a range of values [begin,end)
5754 * within the returned array relating to the current field part.
5755 * \return DataArrayDouble * - the pointer to the field values array.
5756 * \throw If the number of underlying meshes is not equal to 1.
5757 * \throw If no field values are available.
5758 * \sa getUndergroundDataArray()
5760 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5762 return getUndergroundDataArrayTemplateExt(entries);
5765 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)
5767 DataArrayDouble *arr(getOrCreateAndGetArrayTemplate());
5768 arr->setInfoAndChangeNbOfCompo(infos);
5771 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<double>()
5775 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
5777 MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
5778 ret->deepCpyLeavesFrom(*this);
5782 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCopy() const
5784 MCAuto<MEDFileField1TSWithoutSDA> ret(shallowCpy());
5785 if(_arr.isNotNull())
5786 ret->_arr=_arr->deepCopy();
5790 //= MEDFileIntField1TSWithoutSDA
5792 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5794 return new MEDFileIntField1TSWithoutSDA(fieldName,meshName,csit,iteration,order,infos);
5797 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA()
5801 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order,
5802 const std::vector<std::string>& infos):MEDFileField1TSNDTemplateWithoutSDA<int>(fieldName,meshName,csit,iteration,order,infos)
5804 DataArrayInt *arr(getOrCreateAndGetArrayTemplate());
5805 arr->setInfoAndChangeNbOfCompo(infos);
5808 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
5814 * Returns a pointer to the underground DataArrayInt instance and a
5815 * sequence describing parameters of a support of each part of \a this field. The
5816 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5817 * direct access to the field values. This method is intended for the field lying on one
5819 * \param [in,out] entries - the sequence describing parameters of a support of each
5820 * part of \a this field. Each item of this sequence consists of two parts. The
5821 * first part describes a type of mesh entity and an id of discretization of a
5822 * current field part. The second part describes a range of values [begin,end)
5823 * within the returned array relating to the current field part.
5824 * \return DataArrayInt * - the pointer to the field values array.
5825 * \throw If the number of underlying meshes is not equal to 1.
5826 * \throw If no field values are available.
5827 * \sa getUndergroundDataArray()
5829 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5831 return getUndergroundDataArrayIntExt(entries);
5835 * Returns a pointer to the underground DataArrayInt instance and a
5836 * sequence describing parameters of a support of each part of \a this field. The
5837 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5838 * direct access to the field values. This method is intended for the field lying on one
5840 * \param [in,out] entries - the sequence describing parameters of a support of each
5841 * part of \a this field. Each item of this sequence consists of two parts. The
5842 * first part describes a type of mesh entity and an id of discretization of a
5843 * current field part. The second part describes a range of values [begin,end)
5844 * within the returned array relating to the current field part.
5845 * \return DataArrayInt * - the pointer to the field values array.
5846 * \throw If the number of underlying meshes is not equal to 1.
5847 * \throw If no field values are available.
5848 * \sa getUndergroundDataArray()
5850 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5852 if(_field_per_mesh.size()!=1)
5853 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5854 if(_field_per_mesh[0]==0)
5855 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5856 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5857 return getUndergroundDataArrayTemplate();
5860 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5862 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5863 ret->deepCpyLeavesFrom(*this);
5867 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCopy() const
5869 MCAuto<MEDFileIntField1TSWithoutSDA> ret(shallowCpy());
5870 if(_arr.isNotNull())
5871 ret->_arr=_arr->deepCopy();
5875 //= MEDFileFloatField1TSWithoutSDA
5877 MEDFileFloatField1TSWithoutSDA *MEDFileFloatField1TSWithoutSDA::New(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5879 return new MEDFileFloatField1TSWithoutSDA(fieldName,meshName,csit,iteration,order,infos);
5882 MEDFileFloatField1TSWithoutSDA::MEDFileFloatField1TSWithoutSDA()
5886 MEDFileFloatField1TSWithoutSDA::MEDFileFloatField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order,
5887 const std::vector<std::string>& infos):MEDFileField1TSNDTemplateWithoutSDA<float>(fieldName,meshName,csit,iteration,order,infos)
5889 DataArrayFloat *arr(getOrCreateAndGetArrayTemplate());
5890 arr->setInfoAndChangeNbOfCompo(infos);
5893 const char *MEDFileFloatField1TSWithoutSDA::getTypeStr() const
5899 * Returns a pointer to the underground DataArrayFloat instance and a
5900 * sequence describing parameters of a support of each part of \a this field. The
5901 * caller should not decrRef() the returned DataArrayFloat. This method allows for a
5902 * direct access to the field values. This method is intended for the field lying on one
5904 * \param [in,out] entries - the sequence describing parameters of a support of each
5905 * part of \a this field. Each item of this sequence consists of two parts. The
5906 * first part describes a type of mesh entity and an id of discretization of a
5907 * current field part. The second part describes a range of values [begin,end)
5908 * within the returned array relating to the current field part.
5909 * \return DataArrayFloat * - the pointer to the field values array.
5910 * \throw If the number of underlying meshes is not equal to 1.
5911 * \throw If no field values are available.
5912 * \sa getUndergroundDataArray()
5914 DataArray *MEDFileFloatField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5916 return getUndergroundDataArrayFloatExt(entries);
5920 * Returns a pointer to the underground DataArrayFloat instance and a
5921 * sequence describing parameters of a support of each part of \a this field. The
5922 * caller should not decrRef() the returned DataArrayFloat. This method allows for a
5923 * direct access to the field values. This method is intended for the field lying on one
5925 * \param [in,out] entries - the sequence describing parameters of a support of each
5926 * part of \a this field. Each item of this sequence consists of two parts. The
5927 * first part describes a type of mesh entity and an id of discretization of a
5928 * current field part. The second part describes a range of values [begin,end)
5929 * within the returned array relating to the current field part.
5930 * \return DataArrayFloat * - the pointer to the field values array.
5931 * \throw If the number of underlying meshes is not equal to 1.
5932 * \throw If no field values are available.
5933 * \sa getUndergroundDataArray()
5935 DataArrayFloat *MEDFileFloatField1TSWithoutSDA::getUndergroundDataArrayFloatExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5937 if(_field_per_mesh.size()!=1)
5938 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5939 if(_field_per_mesh[0]==0)
5940 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5941 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5942 return getUndergroundDataArrayTemplate();
5945 MEDFileFloatField1TSWithoutSDA *MEDFileFloatField1TSWithoutSDA::shallowCpy() const
5947 MCAuto<MEDFileFloatField1TSWithoutSDA> ret(new MEDFileFloatField1TSWithoutSDA(*this));
5948 ret->deepCpyLeavesFrom(*this);
5952 MEDFileFloatField1TSWithoutSDA *MEDFileFloatField1TSWithoutSDA::deepCopy() const
5954 MCAuto<MEDFileFloatField1TSWithoutSDA> ret(shallowCpy());
5955 if(_arr.isNotNull())
5956 ret->_arr=_arr->deepCopy();
5960 //= MEDFileAnyTypeField1TS
5962 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5966 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
5968 med_field_type typcha;
5970 std::vector<std::string> infos;
5971 std::string dtunit,fieldName,meshName;
5972 LocateField2(fid,0,true,fieldName,typcha,infos,dtunit,meshName);
5973 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5978 ret=MEDFileField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5983 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5988 ret=MEDFileFloatField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5993 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] !";
5994 throw INTERP_KERNEL::Exception(oss.str());
5997 ret->setDtUnit(dtunit.c_str());
5998 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
6000 med_int numdt,numit;
6002 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
6003 ret->setTime(numdt,numit,dt);
6006 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
6008 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
6012 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
6013 try:MEDFileFieldGlobsReal(fid)
6015 _content=BuildContentFrom(fid,loadAll,ms,entities);
6018 catch(INTERP_KERNEL::Exception& e)
6023 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
6025 med_field_type typcha;
6026 std::vector<std::string> infos;
6027 std::string dtunit,meshName;
6031 nbSteps=LocateField(fid,fieldName,iii,typcha,infos,dtunit,meshName);
6033 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
6038 ret=MEDFileField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
6043 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
6048 ret=MEDFileFloatField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
6053 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] !";
6054 throw INTERP_KERNEL::Exception(oss.str());
6057 ret->setMeshName(meshName);
6058 ret->setDtUnit(dtunit.c_str());
6059 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
6063 std::ostringstream oss; oss << "MEDFileField1TS(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
6064 throw INTERP_KERNEL::Exception(oss.str());
6067 med_int numdt,numit;
6069 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
6070 ret->setTime(numdt,numit,dt);
6073 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
6075 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
6079 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
6080 try:MEDFileFieldGlobsReal(fid)
6082 _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
6085 catch(INTERP_KERNEL::Exception& e)
6090 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c)
6093 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
6094 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
6096 MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
6097 ret->_content=c; c->incrRef();
6100 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
6102 MCAuto<MEDFileIntField1TS> ret(MEDFileIntField1TS::New());
6103 ret->_content=c; c->incrRef();
6106 if(dynamic_cast<const MEDFileFloatField1TSWithoutSDA *>(c))
6108 MCAuto<MEDFileFloatField1TS> ret(MEDFileFloatField1TS::New());
6109 ret->_content=c; c->incrRef();
6112 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 FLOAT32 and INT32 has been built but not intercepted !");
6115 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, med_idt fid)
6117 MEDFileAnyTypeField1TS *ret(BuildNewInstanceFromContent(c));
6118 ret->setFileName(FileNameFromFID(fid));
6122 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
6124 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6125 return New(fid,loadAll);
6128 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, bool loadAll)
6130 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,loadAll,0,0));
6131 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
6132 ret->loadGlobals(fid);
6136 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6138 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6139 return New(fid,fieldName,loadAll);
6142 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
6144 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
6145 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
6146 ret->loadGlobals(fid);
6150 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6152 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6153 return New(fid,fieldName,iteration,order,loadAll);
6156 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
6158 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0,0));
6159 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
6160 ret->loadGlobals(fid);
6164 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::NewAdv(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileEntities *entities)
6166 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6167 return NewAdv(fid,fieldName,iteration,order,loadAll,entities);
6170 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::NewAdv(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileEntities *entities)
6172 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0,entities));
6173 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
6174 ret->loadGlobals(fid);
6178 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
6180 med_field_type typcha;
6181 std::vector<std::string> infos;
6182 std::string dtunit,meshName;
6184 int nbOfStep2(LocateField(fid,fieldName,iii,typcha,infos,dtunit,meshName));
6185 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
6190 ret=MEDFileField1TSWithoutSDA::New(fieldName,meshName,-1,iteration,order,std::vector<std::string>());
6195 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,meshName,-1,iteration,order,std::vector<std::string>());
6200 ret=MEDFileFloatField1TSWithoutSDA::New(fieldName,meshName,-1,iteration,order,std::vector<std::string>());
6205 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] !";
6206 throw INTERP_KERNEL::Exception(oss.str());
6209 ret->setDtUnit(dtunit.c_str());
6210 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
6213 std::vector< std::pair<int,int> > dtits(nbOfStep2);
6214 for(int i=0;i<nbOfStep2 && !found;i++)
6216 med_int numdt,numit;
6218 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt));
6219 if(numdt==iteration && numit==order)
6225 dtits[i]=std::pair<int,int>(numdt,numit);
6229 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available iterations are : ";
6230 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
6231 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
6232 throw INTERP_KERNEL::Exception(oss.str());
6235 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
6237 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
6241 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
6242 try:MEDFileFieldGlobsReal(fid)
6244 _content=BuildContentFrom(fid,fieldName,iteration,order,loadAll,ms,entities);
6247 catch(INTERP_KERNEL::Exception& e)
6253 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6254 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6256 * \warning this is a shallow copy constructor
6258 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
6260 if(!shallowCopyOfContent)
6262 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
6263 otherPtr->incrRef();
6264 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
6268 _content=other.shallowCpy();
6272 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)
6276 int nbFields=MEDnField(fid);
6277 if(fieldIdCFormat>=nbFields)
6279 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << FileNameFromFID(fid) << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
6280 throw INTERP_KERNEL::Exception(oss.str());
6283 int ncomp(MEDfieldnComponent(fid,fieldIdCFormat+1));
6284 INTERP_KERNEL::AutoPtr<char> comp(MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE));
6285 INTERP_KERNEL::AutoPtr<char> unit(MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE));
6286 INTERP_KERNEL::AutoPtr<char> dtunit(MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE));
6287 INTERP_KERNEL::AutoPtr<char> nomcha(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
6288 INTERP_KERNEL::AutoPtr<char> nomMaa(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
6291 MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep));
6292 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
6293 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
6294 meshName=MEDLoaderBase::buildStringFromFortran(nomMaa,MED_NAME_SIZE);
6295 infos.clear(); infos.resize(ncomp);
6296 for(int j=0;j<ncomp;j++)
6297 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
6302 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
6305 * \return in case of success the number of time steps available for the field with name \a fieldName.
6307 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)
6309 int nbFields=MEDnField(fid);
6311 std::vector<std::string> fns(nbFields);
6313 for(int i=0;i<nbFields && !found;i++)
6315 std::string tmp,tmp2;
6316 nbOfStep2=LocateField2(fid,i,false,tmp,typcha,infos,dtunitOut,tmp2);
6318 found=(tmp==fieldName);
6327 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available fields are : ";
6328 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
6329 oss << "\"" << *it << "\" ";
6330 throw INTERP_KERNEL::Exception(oss.str());
6336 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
6337 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
6338 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
6339 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
6340 * to keep a valid instance.
6341 * 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.
6342 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
6343 * 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.
6345 * \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.
6346 * \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.
6347 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
6348 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
6349 * \param [in] newLocName is the new localization name.
6350 * \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.
6351 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
6353 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
6355 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6356 std::string oldPflName=disc->getProfile();
6357 std::vector<std::string> vv=getPflsReallyUsedMulti();
6358 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
6359 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
6361 disc->setProfile(newPflName);
6362 DataArrayInt *pfl=getProfile(oldPflName.c_str());
6363 pfl->setName(newPflName);
6367 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
6368 throw INTERP_KERNEL::Exception(oss.str());
6373 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
6374 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
6375 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
6376 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
6377 * to keep a valid instance.
6378 * 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.
6379 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
6380 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
6381 * 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.
6383 * \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.
6384 * \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.
6385 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
6386 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
6387 * \param [in] newLocName is the new localization name.
6388 * \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.
6389 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
6391 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
6393 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6394 std::string oldLocName=disc->getLocalization();
6395 std::vector<std::string> vv=getLocsReallyUsedMulti();
6396 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
6397 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
6399 disc->setLocalization(newLocName);
6400 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
6401 loc.setName(newLocName);
6405 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
6406 throw INTERP_KERNEL::Exception(oss.str());
6410 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
6412 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
6414 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
6418 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
6420 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
6422 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
6427 * This method alloc the arrays and load potentially huge arrays contained in this field.
6428 * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
6429 * This method can be also called to refresh or reinit values from a file.
6431 * \throw If the fileName is not set or points to a non readable MED file.
6432 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
6434 void MEDFileAnyTypeField1TS::loadArrays()
6436 if(getFileName().empty())
6437 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
6438 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
6439 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
6443 * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
6444 * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
6445 * this method does not throw if \a this does not come from file read.
6447 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
6449 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
6451 if(!getFileName().empty())
6453 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
6454 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
6459 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
6460 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
6461 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
6463 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
6465 void MEDFileAnyTypeField1TS::unloadArrays()
6467 contentNotNullBase()->unloadArrays();
6471 * 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.
6472 * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
6473 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
6475 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
6477 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
6479 if(!getFileName().empty())
6480 contentNotNullBase()->unloadArrays();
6483 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
6485 int nbComp(getNumberOfComponents());
6486 INTERP_KERNEL::AutoPtr<char> comp(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
6487 INTERP_KERNEL::AutoPtr<char> unit(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
6488 for(int i=0;i<nbComp;i++)
6490 std::string info=getInfo()[i];
6492 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
6493 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
6494 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
6496 if(getName().empty())
6497 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
6498 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
6499 writeGlobals(fid,*this);
6500 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
6503 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
6505 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
6508 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
6510 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
6511 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
6516 * Returns a string describing \a this field. This string is outputted
6517 * by \c print Python command.
6519 std::string MEDFileAnyTypeField1TS::simpleRepr() const
6521 std::ostringstream oss;
6522 contentNotNullBase()->simpleRepr(0,oss,-1);
6523 simpleReprGlobs(oss);
6528 * This method returns all profiles whose name is non empty used.
6529 * \b WARNING If profile is used several times it will be reported \b only \b once.
6530 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
6532 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
6534 return contentNotNullBase()->getPflsReallyUsed2();
6538 * This method returns all localizations whose name is non empty used.
6539 * \b WARNING If localization is used several times it will be reported \b only \b once.
6541 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
6543 return contentNotNullBase()->getLocsReallyUsed2();
6547 * This method returns all profiles whose name is non empty used.
6548 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
6550 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
6552 return contentNotNullBase()->getPflsReallyUsedMulti2();
6556 * This method returns all localizations whose name is non empty used.
6557 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
6559 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
6561 return contentNotNullBase()->getLocsReallyUsedMulti2();
6564 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6566 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
6569 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6571 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
6574 int MEDFileAnyTypeField1TS::getDimension() const
6576 return contentNotNullBase()->getDimension();
6579 int MEDFileAnyTypeField1TS::getIteration() const
6581 return contentNotNullBase()->getIteration();
6584 int MEDFileAnyTypeField1TS::getOrder() const
6586 return contentNotNullBase()->getOrder();
6589 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
6591 return contentNotNullBase()->getTime(iteration,order);
6594 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
6596 contentNotNullBase()->setTime(iteration,order,val);
6599 std::string MEDFileAnyTypeField1TS::getName() const
6601 return contentNotNullBase()->getName();
6604 void MEDFileAnyTypeField1TS::setName(const std::string& name)
6606 contentNotNullBase()->setName(name);
6609 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
6611 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
6614 std::string MEDFileAnyTypeField1TS::getDtUnit() const
6616 return contentNotNullBase()->getDtUnit();
6619 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
6621 contentNotNullBase()->setDtUnit(dtUnit);
6624 std::string MEDFileAnyTypeField1TS::getMeshName() const
6626 return contentNotNullBase()->getMeshName();
6629 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
6631 contentNotNullBase()->setMeshName(newMeshName);
6634 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
6636 return contentNotNullBase()->changeMeshNames(modifTab);
6639 int MEDFileAnyTypeField1TS::getMeshIteration() const
6641 return contentNotNullBase()->getMeshIteration();
6644 int MEDFileAnyTypeField1TS::getMeshOrder() const
6646 return contentNotNullBase()->getMeshOrder();
6649 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
6651 return contentNotNullBase()->getNumberOfComponents();
6654 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
6656 return contentNotNullBase()->isDealingTS(iteration,order);
6659 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
6661 return contentNotNullBase()->getDtIt();
6664 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
6666 contentNotNullBase()->fillIteration(p);
6669 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
6671 contentNotNullBase()->fillTypesOfFieldAvailable(types);
6674 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
6676 contentNotNullBase()->setInfo(infos);
6679 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
6681 return contentNotNullBase()->getInfo();
6683 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
6685 return contentNotNullBase()->getInfo();
6688 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
6690 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
6693 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
6695 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6698 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
6700 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6703 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
6705 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
6708 void MEDFileAnyTypeField1TS::convertMedBallIntoClassic()
6710 return contentNotNullBase()->convertMedBallIntoClassic();
6713 void MEDFileAnyTypeField1TS::makeReduction(INTERP_KERNEL::NormalizedCellType ct, TypeOfField tof, const DataArrayInt *pfl)
6715 return contentNotNullBase()->makeReduction(ct,tof,pfl);
6718 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
6720 return contentNotNullBase()->getTypesOfFieldAvailable();
6723 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,
6724 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6726 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
6730 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
6731 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
6732 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
6734 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
6736 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6738 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
6739 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
6740 std::size_t sz(contentsSplit.size());
6741 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6742 for(std::size_t i=0;i<sz;i++)
6744 ret[i]=shallowCpy();
6745 ret[i]->_content=contentsSplit[i];
6751 * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
6752 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6754 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
6756 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6758 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
6759 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
6760 std::size_t sz(contentsSplit.size());
6761 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6762 for(std::size_t i=0;i<sz;i++)
6764 ret[i]=shallowCpy();
6765 ret[i]->_content=contentsSplit[i];
6771 * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this.
6772 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6774 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const
6776 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6778 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !");
6779 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
6780 std::size_t sz(contentsSplit.size());
6781 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6782 for(std::size_t i=0;i<sz;i++)
6784 ret[i]=shallowCpy();
6785 ret[i]->_content=contentsSplit[i];
6790 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCopy() const
6792 MCAuto<MEDFileAnyTypeField1TS> ret=shallowCpy();
6793 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
6794 ret->_content=_content->deepCopy();
6795 ret->deepCpyGlobs(*this);
6799 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
6801 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*field));
6802 return copyTinyInfoFrom(field->timeDiscrSafe(),ft,arr);
6805 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arr)
6807 return contentNotNullBase()->copyTinyInfoFrom(th,field,arr);
6813 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
6814 * following the given input policy.
6816 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6817 * By default (true) the globals are deeply copied.
6818 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
6820 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
6822 MCAuto<MEDFileIntField1TS> ret;
6823 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6826 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
6828 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
6829 MCAuto<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
6830 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc));
6833 ret=MEDFileIntField1TS::New();
6835 ret->deepCpyGlobs(*this);
6837 ret->shallowCpyGlobs(*this);
6841 MEDFileField1TS::MEDFileField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
6842 try:MEDFileTemplateField1TS<double>(fid,loadAll,ms)
6845 catch(INTERP_KERNEL::Exception& e)
6848 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6849 try:MEDFileTemplateField1TS<double>(fid,fieldName,loadAll,ms)
6852 catch(INTERP_KERNEL::Exception& e)
6855 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6856 try:MEDFileTemplateField1TS<double>(fid,fieldName,iteration,order,loadAll,ms)
6859 catch(INTERP_KERNEL::Exception& e)
6863 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6864 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6866 * \warning this is a shallow copy constructor
6868 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6869 try:MEDFileTemplateField1TS<double>(other,shallowCopyOfContent)
6872 catch(INTERP_KERNEL::Exception& e)
6875 MEDFileField1TS *MEDFileField1TS::shallowCpy() const
6877 return new MEDFileField1TS(*this);
6880 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6881 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6883 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6886 //= MEDFileIntField1TS
6888 MCAuto<MEDCouplingFieldDouble> MEDFileIntField1TS::ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f)
6891 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ConvertFieldIntToFieldDouble : null input field !");
6893 double t0(f->getTime(t1,t2));
6894 std::string tu(f->getTimeUnit());
6895 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
6896 MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(*ft));
6897 ret->setTime(t0,t1,t2); ret->setTimeUnit(tu);
6901 //= MEDFileFloatField1TS
6903 //= MEDFileFloatField1TS
6905 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
6907 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
6911 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName):MEDFileFieldNameScope(fieldName,meshName)
6916 * \param [in] fieldId field id in C mode
6918 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
6920 med_field_type typcha;
6921 std::string dtunitOut,meshName;
6922 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fieldId,false,_name,typcha,_infos,dtunitOut,meshName));
6923 setMeshName(meshName);
6924 setDtUnit(dtunitOut.c_str());
6925 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities);
6928 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)
6929 try:MEDFileFieldNameScope(fieldName,meshName),_infos(infos)
6931 setDtUnit(dtunit.c_str());
6932 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities);
6934 catch(INTERP_KERNEL::Exception& e)
6939 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
6941 std::size_t ret(_mesh_name.capacity()+_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MCAuto<MEDFileField1TSWithoutSDA>));
6942 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
6943 ret+=(*it).capacity();
6947 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
6949 std::vector<const BigMemoryObject *> ret;
6950 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6951 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
6956 * 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
6959 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
6961 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6962 ret->setInfo(_infos);
6963 int sz=(int)_time_steps.size();
6964 for(const int *id=startIds;id!=endIds;id++)
6966 if(*id>=0 && *id<sz)
6968 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
6969 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6973 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6975 ret->pushBackTimeStep(tse2);
6979 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
6980 oss << " ! Should be in [0," << sz << ") !";
6981 throw INTERP_KERNEL::Exception(oss.str());
6984 if(ret->getNumberOfTS()>0)
6985 ret->synchronizeNameScope();
6986 ret->copyNameScope(*this);
6991 * 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
6994 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
6996 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
6997 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
6998 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6999 ret->setInfo(_infos);
7000 int sz=(int)_time_steps.size();
7002 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
7006 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
7007 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7011 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7013 ret->pushBackTimeStep(tse2);
7017 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
7018 oss << " ! Should be in [0," << sz << ") !";
7019 throw INTERP_KERNEL::Exception(oss.str());
7022 if(ret->getNumberOfTS()>0)
7023 ret->synchronizeNameScope();
7024 ret->copyNameScope(*this);
7028 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(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 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7047 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7048 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7050 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7053 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7054 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
7055 ids->pushBackSilent(id);
7057 return buildFromTimeStepIds(ids->begin(),ids->end());
7060 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfStructureElements() const
7062 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7063 if((*it).isNotNull())
7064 if((*it)->presenceOfStructureElements())
7069 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::onlyStructureElements() const
7071 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7072 if((*it).isNotNull())
7073 if(!(*it)->onlyStructureElements())
7078 void MEDFileAnyTypeFieldMultiTSWithoutSDA::killStructureElements()
7080 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
7081 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7082 if((*it).isNotNull())
7084 if((*it)->presenceOfStructureElements())
7086 if(!(*it)->onlyStructureElements())
7088 (*it)->killStructureElements();
7100 void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyStructureElements()
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())
7106 if((*it)->presenceOfStructureElements())
7108 if(!(*it)->onlyStructureElements())
7109 (*it)->keepOnlyStructureElements();
7116 void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyOnSE(const std::string& seName)
7118 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
7119 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7120 if((*it).isNotNull())
7121 (*it)->keepOnlyOnSE(seName);
7124 void MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
7126 std::vector< std::pair<std::string,std::string> > ps2;
7127 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7128 if((*it).isNotNull())
7130 (*it)->getMeshSENames(ps2);
7134 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames : this appears to not contain SE only !");
7135 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7136 if((*it).isNotNull())
7138 std::vector< std::pair<std::string,std::string> > ps3;
7139 (*it)->getMeshSENames(ps3);
7141 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames : For the moment only homogeneous SE def through time managed !");
7143 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=ps2.begin();it!=ps2.end();it++)
7145 std::vector< std::pair<std::string,std::string> >::iterator it2(std::find(ps.begin(),ps.end(),*it));
7151 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
7153 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7155 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7158 if(cur->presenceOfMultiDiscPerGeoType())
7164 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
7169 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
7174 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
7177 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7179 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
7180 if(pt->isDealingTS(iteration,order))
7183 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
7184 std::vector< std::pair<int,int> > vp=getIterations();
7185 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
7186 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
7187 throw INTERP_KERNEL::Exception(oss.str());
7190 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
7192 return *_time_steps[getTimeStepPos(iteration,order)];
7195 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
7197 return *_time_steps[getTimeStepPos(iteration,order)];
7200 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
7203 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
7205 if((*it).first==getMeshName())
7207 setMeshName((*it).second);
7211 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7213 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7215 ret=cur->changeMeshNames(modifTab) || ret;
7221 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
7223 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
7225 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
7229 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
7231 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7233 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
7236 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
7237 MEDFileFieldGlobsReal& glob)
7240 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7242 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
7244 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
7249 void MEDFileAnyTypeFieldMultiTSWithoutSDA::accept(MEDFileFieldVisitor& visitor) const
7251 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7252 if((*it).isNotNull())
7254 visitor.newTimeStepEntry(*it);
7255 (*it)->accept(visitor);
7256 visitor.endTimeStepEntry(*it);
7260 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7262 std::string startLine(bkOffset,' ');
7263 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
7265 oss << " (" << fmtsId << ")";
7266 oss << " has the following name: \"" << _name << "\"." << std::endl;
7267 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
7268 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7270 oss << startLine << " - \"" << *it << "\"" << std::endl;
7273 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7275 std::string chapter(17,'0'+i);
7276 oss << startLine << chapter << std::endl;
7277 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7279 cur->simpleRepr(bkOffset+2,oss,i);
7281 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
7282 oss << startLine << chapter << std::endl;
7286 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
7288 std::size_t sz=_time_steps.size();
7289 std::vector< std::pair<int,int> > ret(sz);
7291 for(std::size_t i=0;i<sz;i++)
7293 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
7296 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
7300 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
7301 throw INTERP_KERNEL::Exception(oss.str());
7307 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MCAuto<MEDFileAnyTypeField1TSWithoutSDA>& tse)
7309 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
7311 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
7312 checkCoherencyOfType(tse2);
7313 if(_time_steps.empty())
7315 setName(tse2->getName());
7316 setMeshName(tse2->getMeshName());
7317 setInfo(tse2->getInfo());
7319 checkThatComponentsMatch(tse2->getInfo());
7320 if(getDtUnit().empty() && !tse->getDtUnit().empty())
7321 setDtUnit(tse->getDtUnit());
7322 _time_steps.push_back(tse);
7325 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
7327 std::size_t nbOfCompo=_infos.size();
7328 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7330 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7333 if((cur->getInfo()).size()!=nbOfCompo)
7335 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
7336 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
7337 throw INTERP_KERNEL::Exception(oss.str());
7339 cur->copyNameScope(*this);
7344 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7346 _time_steps.resize(nbPdt);
7347 for(int i=0;i<nbPdt;i++)
7349 std::vector< std::pair<int,int> > ts;
7350 med_int numdt=0,numo=0;
7352 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt));
7357 _time_steps[i]=MEDFileField1TSWithoutSDA::New(getName(),getMeshName(),i+1,numdt,numo,_infos);
7362 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(getName(),getMeshName(),i+1,numdt,numo,_infos);
7367 _time_steps[i]=MEDFileFloatField1TSWithoutSDA::New(getName(),getMeshName(),i+1,numdt,numo,_infos);
7371 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32, FLOAT32 !");
7374 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities);
7376 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entities);
7377 synchronizeNameScope();
7381 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
7383 if(_time_steps.empty())
7384 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
7385 checkThatNbOfCompoOfTSMatchThis();
7386 std::vector<std::string> infos(getInfo());
7387 int nbComp=infos.size();
7388 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7389 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7390 for(int i=0;i<nbComp;i++)
7392 std::string info=infos[i];
7394 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7395 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7396 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7399 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7400 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
7401 int nbOfTS=_time_steps.size();
7402 for(int i=0;i<nbOfTS;i++)
7403 _time_steps[i]->writeLL(fid,opts,*this);
7406 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
7408 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7410 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7412 elt->loadBigArraysRecursively(fid,nasc);
7416 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
7418 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7420 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7422 elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7426 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
7428 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7430 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7432 elt->unloadArrays();
7436 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7438 return _time_steps.size();
7441 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
7443 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7444 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7446 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7448 newTS.push_back(*it);
7453 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
7455 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7456 int maxId=(int)_time_steps.size();
7458 std::set<int> idsToDel;
7459 for(const int *id=startIds;id!=endIds;id++,ii++)
7461 if(*id>=0 && *id<maxId)
7463 idsToDel.insert(*id);
7467 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7468 throw INTERP_KERNEL::Exception(oss.str());
7471 for(int iii=0;iii<maxId;iii++)
7472 if(idsToDel.find(iii)==idsToDel.end())
7473 newTS.push_back(_time_steps[iii]);
7477 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
7479 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7480 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7481 if(nbOfEntriesToKill==0)
7483 std::size_t sz=_time_steps.size();
7484 std::vector<bool> b(sz,true);
7486 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7488 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7489 for(std::size_t i=0;i<sz;i++)
7491 newTS.push_back(_time_steps[i]);
7495 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
7498 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
7499 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7501 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7505 tmp->getTime(it2,ord);
7506 if(it2==iteration && order==ord)
7509 oss << "(" << it2 << "," << ord << "), ";
7512 throw INTERP_KERNEL::Exception(oss.str());
7515 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
7518 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
7520 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7522 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7526 double ti=tmp->getTime(it2,ord);
7527 if(fabs(time-ti)<eps)
7533 throw INTERP_KERNEL::Exception(oss.str());
7536 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
7538 int lgth=_time_steps.size();
7539 std::vector< std::pair<int,int> > ret(lgth);
7540 for(int i=0;i<lgth;i++)
7541 _time_steps[i]->fillIteration(ret[i]);
7546 * 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'
7547 * This method returns two things.
7548 * - The absolute dimension of 'this' in first parameter.
7549 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7550 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
7552 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7553 * Only these 3 discretizations will be taken into account here.
7555 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7556 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7557 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7559 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7560 * 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'.
7562 * Let's consider the typical following case :
7563 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7564 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7565 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7567 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7569 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7571 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7572 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7573 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7574 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7576 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
7578 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7581 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
7583 if(pos<0 || pos>=(int)_time_steps.size())
7585 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7586 throw INTERP_KERNEL::Exception(oss.str());
7588 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7591 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7592 oss << "\nTry to use following method eraseEmptyTS !";
7593 throw INTERP_KERNEL::Exception(oss.str());
7598 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
7600 if(pos<0 || pos>=(int)_time_steps.size())
7602 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7603 throw INTERP_KERNEL::Exception(oss.str());
7605 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7608 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7609 oss << "\nTry to use following method eraseEmptyTS !";
7610 throw INTERP_KERNEL::Exception(oss.str());
7615 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
7617 std::vector<std::string> ret;
7618 std::set<std::string> ret2;
7619 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7621 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
7622 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7623 if(ret2.find(*it2)==ret2.end())
7625 ret.push_back(*it2);
7632 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
7634 std::vector<std::string> ret;
7635 std::set<std::string> ret2;
7636 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7638 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
7639 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7640 if(ret2.find(*it2)==ret2.end())
7642 ret.push_back(*it2);
7649 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
7651 std::vector<std::string> ret;
7652 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7654 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
7655 ret.insert(ret.end(),tmp.begin(),tmp.end());
7660 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
7662 std::vector<std::string> ret;
7663 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7665 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
7666 ret.insert(ret.end(),tmp.begin(),tmp.end());
7671 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7673 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7674 (*it)->changePflsRefsNamesGen2(mapOfModif);
7677 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7679 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7680 (*it)->changeLocsRefsNamesGen2(mapOfModif);
7683 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
7685 int lgth=_time_steps.size();
7686 std::vector< std::vector<TypeOfField> > ret(lgth);
7687 for(int i=0;i<lgth;i++)
7688 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
7693 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
7695 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
7697 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
7700 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCopy() const
7702 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
7704 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7706 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
7707 ret->_time_steps[i]=(*it)->deepCopy();
7712 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
7714 std::size_t sz(_infos.size()),sz2(_time_steps.size());
7715 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7716 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7717 for(std::size_t i=0;i<sz;i++)
7719 ret[i]=shallowCpy();
7720 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7722 for(std::size_t i=0;i<sz2;i++)
7724 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7727 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7728 throw INTERP_KERNEL::Exception(oss.str());
7732 for(std::size_t i=0;i<sz;i++)
7733 for(std::size_t j=0;j<sz2;j++)
7734 ret[i]->_time_steps[j]=ts[j][i];
7739 * This method splits into discretization each time steps in \a this.
7740 * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
7742 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
7744 std::size_t sz(_time_steps.size());
7745 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7746 for(std::size_t i=0;i<sz;i++)
7748 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7751 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
7752 throw INTERP_KERNEL::Exception(oss.str());
7754 items[i]=timeStep->splitDiscretizations();
7757 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
7758 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
7759 std::vector< TypeOfField > types;
7760 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7761 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7763 std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
7765 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
7766 std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
7767 if(it2==types.end())
7768 types.push_back(ts[0]);
7770 ret.resize(types.size()); ret2.resize(types.size());
7771 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7772 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7774 TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
7775 std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
7776 ret2[pos].push_back(*it1);
7778 for(std::size_t i=0;i<types.size();i++)
7780 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7781 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
7782 elt->pushBackTimeStep(*it1);//also updates infos in elt
7784 elt->MEDFileFieldNameScope::operator=(*this);
7790 * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
7792 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
7794 std::size_t sz(_time_steps.size());
7795 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7796 std::size_t szOut(std::numeric_limits<std::size_t>::max());
7797 for(std::size_t i=0;i<sz;i++)
7799 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7802 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
7803 throw INTERP_KERNEL::Exception(oss.str());
7805 items[i]=timeStep->splitMultiDiscrPerGeoTypes();
7806 if(szOut==std::numeric_limits<std::size_t>::max())
7807 szOut=items[i].size();
7809 if(items[i].size()!=szOut)
7810 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
7812 if(szOut==std::numeric_limits<std::size_t>::max())
7813 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
7814 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
7815 for(std::size_t i=0;i<szOut;i++)
7817 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7818 for(std::size_t j=0;j<sz;j++)
7819 elt->pushBackTimeStep(items[j][i]);
7821 elt->MEDFileFieldNameScope::operator=(*this);
7826 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
7828 setName(field->getName());
7829 if(field->getMesh())
7830 setMeshName(field->getMesh()->getName());
7832 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
7834 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
7835 _infos=arr->getInfoOnComponents();
7838 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
7840 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
7841 if(_name!=field->getName())
7843 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
7844 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
7845 throw INTERP_KERNEL::Exception(oss.str());
7848 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
7849 checkThatComponentsMatch(arr->getInfoOnComponents());
7852 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
7854 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
7855 if(getInfo().size()!=compos.size())
7857 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
7858 oss << " number of components of element to append (" << compos.size() << ") !";
7859 throw INTERP_KERNEL::Exception(oss.str());
7863 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
7864 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
7865 oss << " But compo in input fields are : ";
7866 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
7868 throw INTERP_KERNEL::Exception(oss.str());
7872 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
7874 std::size_t sz=_infos.size();
7876 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
7878 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7880 if(elt->getInfo().size()!=sz)
7882 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
7883 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
7884 throw INTERP_KERNEL::Exception(oss.str());
7889 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
7892 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::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::New(*field));
7899 objC->setFieldNoProfileSBT(field->timeDiscrSafe(),ft,arr,glob,*this);
7901 copyTinyInfoFrom(field,arr);
7902 _time_steps.push_back(obj);
7905 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
7908 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7909 if(!_time_steps.empty())
7910 checkCoherencyOfTinyInfo(field,arr);
7911 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
7912 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7914 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::NewWithoutCheck(*field));
7915 objC->setFieldProfile(field->timeDiscrSafe(),ft,arr,mesh,meshDimRelToMax,profile,glob,*this);
7917 copyTinyInfoFrom(field,arr);
7918 setMeshName(objC->getMeshName());
7919 _time_steps.push_back(obj);
7922 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ts)
7924 int sz=(int)_time_steps.size();
7927 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
7928 throw INTERP_KERNEL::Exception(oss.str());
7930 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
7933 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
7935 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
7936 throw INTERP_KERNEL::Exception(oss.str());
7942 //= MEDFileFieldMultiTSWithoutSDA
7945 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
7946 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
7948 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
7950 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
7951 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
7953 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
7954 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
7957 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
7959 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
7960 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
7962 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7964 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
7967 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
7969 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
7970 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
7971 ret->setIteration(i,elt);
7977 //= MEDFileAnyTypeFieldMultiTS
7979 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
7983 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
7984 try:MEDFileFieldGlobsReal(fid)
7986 _content=BuildContentFrom(fid,loadAll,ms);
7989 catch(INTERP_KERNEL::Exception& e)
7994 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7996 med_field_type typcha;
7997 std::vector<std::string> infos;
7999 std::string meshName;
8001 MEDFileAnyTypeField1TS::LocateField(fid,fieldName,i,typcha,infos,dtunit,meshName);
8002 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8007 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8012 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8017 ret=new MEDFileFloatFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8022 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] !";
8023 throw INTERP_KERNEL::Exception(oss.str());
8026 ret->setMeshName(meshName);
8027 ret->setDtUnit(dtunit.c_str());
8031 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8033 med_field_type typcha;
8035 std::vector<std::string> infos;
8036 std::string dtunit,fieldName,meshName;
8037 MEDFileAnyTypeField1TS::LocateField2(fid,0,true,fieldName,typcha,infos,dtunit,meshName);
8038 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8043 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8048 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8053 ret=new MEDFileFloatFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8058 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] !";
8059 throw INTERP_KERNEL::Exception(oss.str());
8062 ret->setMeshName(meshName);
8063 ret->setDtUnit(dtunit.c_str());
8067 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c)
8070 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
8071 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
8073 MCAuto<MEDFileFieldMultiTS> ret(MEDFileFieldMultiTS::New());
8074 ret->_content=c; c->incrRef();
8077 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
8079 MCAuto<MEDFileIntFieldMultiTS> ret(MEDFileIntFieldMultiTS::New());
8080 ret->_content=c; c->incrRef();
8083 if(dynamic_cast<const MEDFileFloatFieldMultiTSWithoutSDA *>(c))
8085 MCAuto<MEDFileFloatFieldMultiTS> ret(MEDFileFloatFieldMultiTS::New());
8086 ret->_content=c; c->incrRef();
8089 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 FLOAT32 and INT32 has been built but not intercepted !");
8092 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, med_idt fid)
8094 MEDFileAnyTypeFieldMultiTS *ret(BuildNewInstanceFromContent(c));
8095 std::string fileName(FileNameFromFID(fid));
8096 ret->setFileName(fileName);
8100 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8101 try:MEDFileFieldGlobsReal(fid)
8103 _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
8106 catch(INTERP_KERNEL::Exception& e)
8111 //= MEDFileAnyTypeFieldMultiTS
8114 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
8115 * that has been read from a specified MED file.
8116 * \param [in] fileName - the name of the MED file to read.
8117 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8118 * is to delete this field using decrRef() as it is no more needed.
8119 * \throw If reading the file fails.
8121 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
8123 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8124 return New(fid,loadAll);
8127 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, bool loadAll)
8129 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
8130 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8131 ret->loadGlobals(fid);
8136 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
8137 * that has been read from a specified MED file.
8138 * \param [in] fileName - the name of the MED file to read.
8139 * \param [in] fieldName - the name of the field to read.
8140 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8141 * is to delete this field using decrRef() as it is no more needed.
8142 * \throw If reading the file fails.
8143 * \throw If there is no field named \a fieldName in the file.
8145 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8147 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8148 return New(fid,fieldName,loadAll);
8151 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
8153 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
8154 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8155 ret->loadGlobals(fid);
8160 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8161 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8163 * \warning this is a shallow copy constructor
8165 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8167 if(!shallowCopyOfContent)
8169 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
8170 otherPtr->incrRef();
8171 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
8175 _content=other.shallowCpy();
8179 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
8181 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8183 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
8187 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
8189 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8191 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
8195 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
8197 return contentNotNullBase()->getPflsReallyUsed2();
8200 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
8202 return contentNotNullBase()->getLocsReallyUsed2();
8205 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
8207 return contentNotNullBase()->getPflsReallyUsedMulti2();
8210 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
8212 return contentNotNullBase()->getLocsReallyUsedMulti2();
8215 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8217 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
8220 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8222 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
8225 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
8227 return contentNotNullBase()->getNumberOfTS();
8230 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
8232 contentNotNullBase()->eraseEmptyTS();
8235 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
8237 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
8240 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
8242 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
8245 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
8247 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
8248 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8253 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
8255 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
8256 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8261 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
8263 return contentNotNullBase()->getIterations();
8266 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
8268 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
8269 pushBackTimeStep(*it);
8272 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
8275 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
8276 int nbOfTS(fmts->getNumberOfTS());
8277 for(int i=0;i<nbOfTS;i++)
8279 MCAuto<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
8280 pushBackTimeStep(elt);
8284 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
8287 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
8288 checkCoherencyOfType(f1ts);
8290 MCAuto<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
8291 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
8293 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
8294 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
8295 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
8296 _content->pushBackTimeStep(cSafe);
8297 appendGlobs(*f1ts,1e-12);
8300 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
8302 contentNotNullBase()->synchronizeNameScope();
8305 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
8307 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
8310 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
8312 return contentNotNullBase()->getPosGivenTime(time,eps);
8315 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8317 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
8320 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
8322 return contentNotNullBase()->getTypesOfFieldAvailable();
8325 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
8327 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
8330 std::string MEDFileAnyTypeFieldMultiTS::getName() const
8332 return contentNotNullBase()->getName();
8335 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
8337 contentNotNullBase()->setName(name);
8340 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
8342 return contentNotNullBase()->getDtUnit();
8345 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
8347 contentNotNullBase()->setDtUnit(dtUnit);
8350 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8352 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
8355 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
8357 return contentNotNullBase()->getTimeSteps(ret1);
8360 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
8362 return contentNotNullBase()->getMeshName();
8365 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
8367 contentNotNullBase()->setMeshName(newMeshName);
8370 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
8372 return contentNotNullBase()->changeMeshNames(modifTab);
8375 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
8377 return contentNotNullBase()->getInfo();
8380 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
8382 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
8385 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
8387 return contentNotNullBase()->setInfo(info);
8390 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
8392 const std::vector<std::string> ret=getInfo();
8393 return (int)ret.size();
8396 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
8398 writeGlobals(fid,*this);
8399 contentNotNullBase()->writeLL(fid,*this);
8403 * This method alloc the arrays and load potentially huge arrays contained in this field.
8404 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
8405 * This method can be also called to refresh or reinit values from a file.
8407 * \throw If the fileName is not set or points to a non readable MED file.
8409 void MEDFileAnyTypeFieldMultiTS::loadArrays()
8411 if(getFileName().empty())
8412 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
8413 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
8414 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
8418 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
8419 * But once data loaded once, this method does nothing.
8421 * \throw If the fileName is not set or points to a non readable MED file.
8422 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
8424 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
8426 if(!getFileName().empty())
8428 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
8429 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
8434 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
8435 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
8436 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
8438 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
8440 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
8442 contentNotNullBase()->unloadArrays();
8446 * 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.
8447 * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
8448 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
8450 * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
8452 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
8454 if(!getFileName().empty())
8455 contentNotNullBase()->unloadArrays();
8458 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
8460 std::ostringstream oss;
8461 contentNotNullBase()->simpleRepr(0,oss,-1);
8462 simpleReprGlobs(oss);
8466 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
8468 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
8471 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
8473 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
8474 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
8479 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
8480 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8481 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
8483 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
8485 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8487 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
8488 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
8489 std::size_t sz(contentsSplit.size());
8490 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8491 for(std::size_t i=0;i<sz;i++)
8493 ret[i]=shallowCpy();
8494 ret[i]->_content=contentsSplit[i];
8500 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
8501 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8503 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
8505 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8507 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
8508 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
8509 std::size_t sz(contentsSplit.size());
8510 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8511 for(std::size_t i=0;i<sz;i++)
8513 ret[i]=shallowCpy();
8514 ret[i]->_content=contentsSplit[i];
8520 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
8521 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8523 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
8525 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8527 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
8528 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
8529 std::size_t sz(contentsSplit.size());
8530 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8531 for(std::size_t i=0;i<sz;i++)
8533 ret[i]=shallowCpy();
8534 ret[i]->_content=contentsSplit[i];
8539 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCopy() const
8541 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8542 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
8543 ret->_content=_content->deepCopy();
8544 ret->deepCpyGlobs(*this);
8548 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
8554 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8555 * \param [in] iteration - the iteration number of a required time step.
8556 * \param [in] order - the iteration order number of required time step.
8557 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
8558 * delete this field using decrRef() as it is no more needed.
8559 * \throw If there is no required time step in \a this field.
8561 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
8563 int pos=getPosOfTimeStep(iteration,order);
8564 return getTimeStepAtPos(pos);
8568 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8569 * \param [in] time - the time of the time step of interest.
8570 * \param [in] eps - a precision used to compare time values.
8571 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8572 * delete this field using decrRef() as it is no more needed.
8573 * \throw If there is no required time step in \a this field.
8575 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
8577 int pos=getPosGivenTime(time,eps);
8578 return getTimeStepAtPos(pos);
8582 * 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.
8583 * The float64 value of time attached to the pair of integers are not considered here.
8584 * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
8586 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
8587 * \throw If there is a null pointer in \a vectFMTS.
8589 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
8591 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
8592 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8593 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8594 while(!lstFMTS.empty())
8596 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8597 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8599 throw INTERP_KERNEL::Exception(msg);
8600 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
8601 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8602 elt.push_back(curIt); it=lstFMTS.erase(it);
8603 while(it!=lstFMTS.end())
8607 throw INTERP_KERNEL::Exception(msg);
8608 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
8610 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8620 * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
8621 * All returned instances in a subvector can be safely loaded, rendered along time
8622 * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
8623 * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
8624 * 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).
8625 * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
8626 * 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.
8628 * \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().
8629 * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
8630 * \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.
8631 * \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.
8633 * \throw If an element in \a vectFMTS has not only one spatial discretization set.
8634 * \throw If an element in \a vectFMTS change of spatial discretization along time.
8635 * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
8636 * \thorw If some elements in \a vectFMTS do not have the same times steps.
8637 * \throw If mesh is null.
8638 * \throw If an element in \a vectFMTS is null.
8639 * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
8641 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& fsc)
8643 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
8645 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
8646 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8647 if(vectFMTS.empty())
8649 std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
8650 MEDFileAnyTypeFieldMultiTS *frstElt(*it);
8652 throw INTERP_KERNEL::Exception(msg);
8654 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
8655 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
8656 for(;it!=vectFMTS.end();it++,i++)
8659 throw INTERP_KERNEL::Exception(msg);
8660 TypeOfField tof0,tof1;
8661 if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
8664 vectFMTSNotNodes.push_back(*it);
8666 vectFMTSNodes.push_back(*it);
8669 vectFMTSNotNodes.push_back(*it);
8671 std::vector< MCAuto<MEDFileFastCellSupportComparator> > cmps;
8672 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
8674 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
8677 bool isFetched(false);
8678 for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
8681 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
8682 if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
8683 { ret[i].push_back(*it2); isFetched=true; }
8687 std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
8688 MCAuto<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
8689 ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
8697 * 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.
8698 * \param [out] cmps - same size than the returned vector.
8700 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& cmps)
8702 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8703 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8704 while(!lstFMTS.empty())
8706 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8707 MEDFileAnyTypeFieldMultiTS *ref(*it);
8708 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8709 elt.push_back(ref); it=lstFMTS.erase(it);
8710 MCAuto<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
8711 MCAuto<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
8712 while(it!=lstFMTS.end())
8714 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8715 if(cmp->isEqual(curIt))
8716 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8720 ret.push_back(elt); cmps.push_back(cmp);
8726 * 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.
8727 * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
8729 * \throw If \a f0 or \a f1 has not only one spatial discretization set.
8730 * \throw If \a f0 or \a f1 change of spatial discretization along time.
8731 * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
8732 * \thorw If \a f0 and \a f1 do not have the same times steps.
8733 * \throw If mesh is null.
8734 * \throw If \a f0 or \a f1 is null.
8735 * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
8737 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
8740 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
8742 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
8743 if(f0->getMeshName()!=mesh->getName())
8745 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8746 throw INTERP_KERNEL::Exception(oss.str());
8748 if(f1->getMeshName()!=mesh->getName())
8750 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8751 throw INTERP_KERNEL::Exception(oss.str());
8753 int nts=f0->getNumberOfTS();
8754 if(nts!=f1->getNumberOfTS())
8755 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
8758 for(int i=0;i<nts;i++)
8760 MCAuto<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
8761 MCAuto<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
8762 std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
8763 if(tofs0.size()!=1 || tofs1.size()!=1)
8764 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
8767 if(tof0!=tofs0[0] || tof1!=tofs1[0])
8768 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
8771 { tof0=tofs0[0]; tof1=tofs1[0]; }
8772 if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
8774 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() << ") !";
8775 throw INTERP_KERNEL::Exception(oss.str());
8777 if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
8779 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() << ") !";
8780 throw INTERP_KERNEL::Exception(oss.str());
8782 if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
8784 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() << ") !";
8785 throw INTERP_KERNEL::Exception(oss.str());
8792 MCAuto<MEDFileAnyTypeField1TS> AggregateHelperF1TS(const std::vector< typename MLFieldTraits<T>::F1TSType const *>& f1tss, const std::vector< std::vector< std::pair<int,int> > >& dts)
8794 MCAuto< typename MLFieldTraits<T>::F1TSType > ret(MLFieldTraits<T>::F1TSType::New());
8796 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : empty vector !");
8797 std::size_t sz(f1tss.size()),i(0);
8798 std::vector< typename MLFieldTraits<T>::F1TSWSDAType const *> f1tsw(sz);
8799 for(typename std::vector< typename MLFieldTraits<T>::F1TSType const *>::const_iterator it=f1tss.begin();it!=f1tss.end();it++,i++)
8801 typename MLFieldTraits<T>::F1TSType const *elt(*it);
8803 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : presence of a null pointer !");
8804 f1tsw[i]=dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType const *>(elt->contentNotNullBase());
8806 typename MLFieldTraits<T>::F1TSWSDAType *retc(dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType *>(ret->contentNotNullBase()));
8808 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : internal error 1 !");
8809 retc->aggregate(f1tsw,dts);
8810 ret->setDtUnit(f1tss[0]->getDtUnit());
8811 return DynamicCast<typename MLFieldTraits<T>::F1TSType , MEDFileAnyTypeField1TS>(ret);
8815 MCAuto< MEDFileAnyTypeFieldMultiTS > AggregateHelperFMTS(const std::vector< typename MLFieldTraits<T>::FMTSType const *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
8817 MCAuto< typename MLFieldTraits<T>::FMTSType > ret(MLFieldTraits<T>::FMTSType::New());
8819 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : empty vector !");
8820 std::size_t sz(fmtss.size());
8821 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
8823 typename MLFieldTraits<T>::FMTSType const *elt(*it);
8825 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : presence of null pointer !");
8827 int nbTS(fmtss[0]->getNumberOfTS());
8828 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
8829 if((*it)->getNumberOfTS()!=nbTS)
8830 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : all fields must have the same number of TS !");
8831 for(int iterTS=0;iterTS<nbTS;iterTS++)
8834 std::vector< typename MLFieldTraits<T>::F1TSType const *> f1tss(sz);
8835 std::vector< MCAuto<typename MLFieldTraits<T>::F1TSType> > f1tss2(sz);
8836 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++,i++)
8837 { f1tss2[i]=(*it)->getTimeStepAtPos(iterTS); f1tss[i]=f1tss2[i]; }
8838 MCAuto<MEDFileAnyTypeField1TS> f1ts(AggregateHelperF1TS<T>(f1tss,dts));
8839 ret->pushBackTimeStep(f1ts);
8840 ret->setDtUnit(f1ts->getDtUnit());
8842 return DynamicCast<typename MLFieldTraits<T>::FMTSType , MEDFileAnyTypeFieldMultiTS>(ret);
8846 * \a dts and \a ftmss are expected to have same size.
8848 MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileAnyTypeFieldMultiTS::Aggregate(const std::vector<const MEDFileAnyTypeFieldMultiTS *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
8851 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : input vector is empty !");
8852 std::size_t sz(fmtss.size());
8853 std::vector<const MEDFileFieldMultiTS *> fmtss1;
8854 std::vector<const MEDFileIntFieldMultiTS *> fmtss2;
8855 for(std::vector<const MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
8858 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : presence of null instance in input vector !");
8859 const MEDFileFieldMultiTS *elt1(dynamic_cast<const MEDFileFieldMultiTS *>(*it));
8862 fmtss1.push_back(elt1);
8865 const MEDFileIntFieldMultiTS *elt2(dynamic_cast<const MEDFileIntFieldMultiTS *>(*it));
8868 fmtss2.push_back(elt2);
8871 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not recognized type !");
8873 if(fmtss1.size()!=sz && fmtss2.size()!=sz)
8874 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : type of data is not homogeneous !");
8875 if(fmtss1.size()==sz)
8876 return AggregateHelperFMTS<double>(fmtss1,dts);
8877 if(fmtss2.size()!=sz)
8878 return AggregateHelperFMTS<int>(fmtss2,dts);
8879 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not implemented yet !");
8882 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
8884 return new MEDFileAnyTypeFieldMultiTSIterator(this);
8887 //= MEDFileFieldMultiTS
8889 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
8891 return new MEDFileFieldMultiTS(*this);
8895 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
8896 * following the given input policy.
8898 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
8899 * By default (true) the globals are deeply copied.
8900 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
8902 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
8904 MCAuto<MEDFileIntFieldMultiTS> ret;
8905 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8908 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
8910 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
8911 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
8912 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc));
8915 ret=MEDFileIntFieldMultiTS::New();
8917 ret->deepCpyGlobs(*this);
8919 ret->shallowCpyGlobs(*this);
8923 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8924 try:MEDFileTemplateFieldMultiTS<double>(fid,loadAll,ms)
8927 catch(INTERP_KERNEL::Exception& e)
8930 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8931 try:MEDFileTemplateFieldMultiTS<double>(fid,fieldName,loadAll,ms,entities)
8934 catch(INTERP_KERNEL::Exception& e)
8937 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileTemplateFieldMultiTS<double>(other,shallowCopyOfContent)
8941 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
8943 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
8946 //= MEDFileAnyTypeFieldMultiTSIterator
8948 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
8953 _nb_iter=fmts->getNumberOfTS();
8957 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
8961 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
8963 if(_iter_id<_nb_iter)
8965 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
8967 return fmts->getTimeStepAtPos(_iter_id++);
8975 //= MEDFileIntFieldMultiTS
8979 MEDFileFields *MEDFileFields::New()
8981 return new MEDFileFields;
8984 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
8986 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8987 return New(fid,loadAll);
8990 MEDFileFields *MEDFileFields::NewAdv(const std::string& fileName, bool loadAll, const MEDFileEntities *entities)
8992 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8993 return NewAdv(fid,loadAll,entities);
8996 MEDFileFields *MEDFileFields::NewAdv(med_idt fid, bool loadAll, const MEDFileEntities *entities)
8998 return new MEDFileFields(fid,loadAll,0,entities);
9001 MEDFileFields *MEDFileFields::NewWithDynGT(const std::string& fileName, const MEDFileStructureElements *se, bool loadAll)
9003 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9004 return NewWithDynGT(fid,se,loadAll);
9007 MEDFileFields *MEDFileFields::NewWithDynGT(med_idt fid, const MEDFileStructureElements *se, bool loadAll)
9010 throw INTERP_KERNEL::Exception("MEDFileFields::NewWithDynGT : null struct element pointer !");
9011 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> entities(MEDFileEntities::BuildFrom(*se));
9012 return new MEDFileFields(fid,loadAll,0,entities);
9015 MEDFileFields *MEDFileFields::New(med_idt fid, bool loadAll)
9017 return new MEDFileFields(fid,loadAll,0,0);
9020 MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9022 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9023 return new MEDFileFields(fid,loadAll,ms,0);
9026 MEDFileFields *MEDFileFields::LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9028 MEDFileUtilities::CheckFileForRead(fileName);
9029 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
9030 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9031 return new MEDFileFields(fid,loadAll,0,ent);
9034 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
9036 std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
9037 ret+=_fields.capacity()*sizeof(MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
9041 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
9043 std::vector<const BigMemoryObject *> ret;
9044 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9045 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
9049 MEDFileFields *MEDFileFields::deepCopy() const
9051 MCAuto<MEDFileFields> ret(shallowCpy());
9053 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9055 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9056 ret->_fields[i]=(*it)->deepCopy();
9058 ret->deepCpyGlobs(*this);
9062 MEDFileFields *MEDFileFields::shallowCpy() const
9064 return new MEDFileFields(*this);
9068 * 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
9069 * 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.
9070 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
9072 * \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.
9073 * \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.
9075 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9077 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
9079 std::set< std::pair<int,int> > s;
9080 bool firstShot=true;
9081 areThereSomeForgottenTS=false;
9082 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9084 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9086 std::vector< std::pair<int,int> > v=(*it)->getIterations();
9087 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
9089 { s=s1; firstShot=false; }
9092 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
9094 areThereSomeForgottenTS=true;
9098 std::vector< std::pair<int,int> > ret;
9099 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
9103 int MEDFileFields::getNumberOfFields() const
9105 return _fields.size();
9108 std::vector<std::string> MEDFileFields::getFieldsNames() const
9110 std::vector<std::string> ret(_fields.size());
9112 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9114 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
9117 ret[i]=f->getName();
9121 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
9122 throw INTERP_KERNEL::Exception(oss.str());
9128 std::vector<std::string> MEDFileFields::getMeshesNames() const
9130 std::vector<std::string> ret;
9131 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9133 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9135 ret.push_back(cur->getMeshName());
9140 std::string MEDFileFields::simpleRepr() const
9142 std::ostringstream oss;
9143 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
9148 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
9150 int nbOfFields(getNumberOfFields());
9151 std::string startLine(bkOffset,' ');
9152 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
9154 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9156 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9159 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
9163 oss << startLine << " - not defined !" << std::endl;
9167 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9169 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9170 std::string chapter(17,'0'+i);
9171 oss << startLine << chapter << std::endl;
9174 cur->simpleRepr(bkOffset+2,oss,i);
9178 oss << startLine << " - not defined !" << std::endl;
9180 oss << startLine << chapter << std::endl;
9182 simpleReprGlobs(oss);
9185 MEDFileFields::MEDFileFields()
9189 MEDFileFields::MEDFileFields(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
9190 try:MEDFileFieldGlobsReal(fid)
9192 int nbFields(MEDnField(fid));
9193 _fields.resize(nbFields);
9194 med_field_type typcha;
9195 for(int i=0;i<nbFields;i++)
9197 std::vector<std::string> infos;
9198 std::string fieldName,dtunit,meshName;
9199 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,i,false,fieldName,typcha,infos,dtunit,meshName));
9204 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName,meshName,typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
9209 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName,meshName,typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
9214 _fields[i]=MEDFileFloatFieldMultiTSWithoutSDA::New(fid,fieldName,meshName,typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
9219 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] !";
9220 throw INTERP_KERNEL::Exception(oss.str());
9224 loadAllGlobals(fid,entities);
9226 catch(INTERP_KERNEL::Exception& e)
9231 void MEDFileFields::writeLL(med_idt fid) const
9234 writeGlobals(fid,*this);
9235 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9237 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
9240 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
9241 throw INTERP_KERNEL::Exception(oss.str());
9243 elt->writeLL(fid,*this);
9248 * This method alloc the arrays and load potentially huge arrays contained in this field.
9249 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
9250 * This method can be also called to refresh or reinit values from a file.
9252 * \throw If the fileName is not set or points to a non readable MED file.
9254 void MEDFileFields::loadArrays()
9256 if(getFileName().empty())
9257 throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
9258 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
9259 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9261 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9263 elt->loadBigArraysRecursively(fid,*elt);
9268 * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
9269 * But once data loaded once, this method does nothing.
9271 * \throw If the fileName is not set or points to a non readable MED file.
9272 * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
9274 void MEDFileFields::loadArraysIfNecessary()
9276 if(!getFileName().empty())
9278 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
9279 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9281 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9283 elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
9289 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
9290 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
9291 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
9293 * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
9295 void MEDFileFields::unloadArrays()
9297 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9299 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9301 elt->unloadArrays();
9306 * 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.
9307 * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
9308 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
9310 * \sa MEDFileFields::loadArraysIfNecessary
9312 void MEDFileFields::unloadArraysWithoutDataLoss()
9314 if(!getFileName().empty())
9318 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
9320 std::vector<std::string> ret;
9321 std::set<std::string> ret2;
9322 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9324 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
9325 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
9326 if(ret2.find(*it2)==ret2.end())
9328 ret.push_back(*it2);
9335 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
9337 std::vector<std::string> ret;
9338 std::set<std::string> ret2;
9339 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9341 std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
9342 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
9343 if(ret2.find(*it2)==ret2.end())
9345 ret.push_back(*it2);
9352 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
9354 std::vector<std::string> ret;
9355 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9357 std::vector<std::string> tmp((*it)->getPflsReallyUsedMulti2());
9358 ret.insert(ret.end(),tmp.begin(),tmp.end());
9363 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
9365 std::vector<std::string> ret;
9366 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9368 std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
9369 ret.insert(ret.end(),tmp.begin(),tmp.end());
9374 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
9376 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
9377 (*it)->changePflsRefsNamesGen2(mapOfModif);
9380 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
9382 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
9383 (*it)->changeLocsRefsNamesGen2(mapOfModif);
9386 void MEDFileFields::resize(int newSize)
9388 _fields.resize(newSize);
9391 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
9393 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
9397 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
9400 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
9401 _fields.push_back(field->getContent());
9402 appendGlobs(*field,1e-12);
9405 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
9408 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
9409 if(i>=(int)_fields.size())
9410 _fields.resize(i+1);
9411 _fields[i]=field->getContent();
9412 appendGlobs(*field,1e-12);
9415 void MEDFileFields::destroyFieldAtPos(int i)
9417 destroyFieldsAtPos(&i,&i+1);
9420 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
9422 std::vector<bool> b(_fields.size(),true);
9423 for(const int *i=startIds;i!=endIds;i++)
9425 if(*i<0 || *i>=(int)_fields.size())
9427 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
9428 throw INTERP_KERNEL::Exception(oss.str());
9432 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
9434 for(std::size_t i=0;i<_fields.size();i++)
9436 fields[j++]=_fields[i];
9440 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
9442 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
9443 int nbOfEntriesToKill(DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg));
9444 std::vector<bool> b(_fields.size(),true);
9446 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
9448 if(k<0 || k>=(int)_fields.size())
9450 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
9451 throw INTERP_KERNEL::Exception(oss.str());
9455 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
9457 for(std::size_t i=0;i<_fields.size();i++)
9459 fields[j++]=_fields[i];
9463 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
9466 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9468 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9470 ret=cur->changeMeshNames(modifTab) || ret;
9476 * \param [in] meshName the name of the mesh that will be renumbered.
9477 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
9478 * This code corresponds to the distribution of types in the corresponding mesh.
9479 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
9480 * \param [in] renumO2N the old to new renumber array.
9481 * \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
9484 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
9487 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9489 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
9492 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
9499 * Return an extraction of \a this using \a extractDef map to specify the extraction.
9500 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
9502 * \return A new object that the caller is responsible to deallocate.
9504 MEDFileFields *MEDFileFields::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
9507 throw INTERP_KERNEL::Exception("MEDFileFields::extractPart : input mesh is NULL !");
9508 MCAuto<MEDFileFields> fsOut(MEDFileFields::New());
9509 int nbFields(getNumberOfFields());
9510 for(int i=0;i<nbFields;i++)
9512 MCAuto<MEDFileAnyTypeFieldMultiTS> fmts(getFieldAtPos(i));
9515 std::ostringstream oss; oss << "MEDFileFields::extractPart : at pos #" << i << " field is null !";
9516 throw INTERP_KERNEL::Exception(oss.str());
9518 MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(fmts->extractPart(extractDef,mm));
9519 fsOut->pushField(fmtsOut);
9521 return fsOut.retn();
9524 void MEDFileFields::accept(MEDFileFieldVisitor& visitor) const
9526 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9527 if((*it).isNotNull())
9529 visitor.newFieldEntry(*it);
9530 (*it)->accept(visitor);
9531 visitor.endFieldEntry(*it);
9535 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
9537 if(i<0 || i>=(int)_fields.size())
9539 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
9540 throw INTERP_KERNEL::Exception(oss.str());
9542 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
9545 MCAuto<MEDFileAnyTypeFieldMultiTS> ret;
9546 const MEDFileFieldMultiTSWithoutSDA *fmtsC(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts));
9547 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts));
9548 const MEDFileFloatFieldMultiTSWithoutSDA *fmtsC3(dynamic_cast<const MEDFileFloatFieldMultiTSWithoutSDA *>(fmts));
9550 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
9552 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
9554 ret=MEDFileFloatFieldMultiTS::New(*fmtsC3,false);
9557 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor float (FLOAT32) nor integer (INT32) !";
9558 throw INTERP_KERNEL::Exception(oss.str());
9560 ret->shallowCpyGlobs(*this);
9565 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
9566 * This method is accessible in python using __getitem__ with a list in input.
9567 * \return a new object that the caller should deal with.
9569 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
9571 MCAuto<MEDFileFields> ret=shallowCpy();
9572 std::size_t sz=std::distance(startIds,endIds);
9573 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
9575 for(const int *i=startIds;i!=endIds;i++,j++)
9577 if(*i<0 || *i>=(int)_fields.size())
9579 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
9580 throw INTERP_KERNEL::Exception(oss.str());
9582 fields[j]=_fields[*i];
9584 ret->_fields=fields;
9588 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
9590 return getFieldAtPos(getPosFromFieldName(fieldName));
9594 * This method removes, if any, fields in \a this having no time steps.
9595 * 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.
9597 * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
9599 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
9601 std::vector<MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
9602 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9604 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9607 if(elt->getNumberOfTS()>0)
9608 newFields.push_back(*it);
9611 if(_fields.size()==newFields.size())
9618 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
9619 * This method can be seen as a filter applied on \a this, that returns an object containing
9620 * 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
9621 * shallow copied from \a this.
9623 * \param [in] meshName - the name of the mesh on w
9624 * \return a new object that the caller should deal with.
9626 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
9628 MCAuto<MEDFileFields> ret(MEDFileFields::New());
9629 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9631 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9634 if(cur->getMeshName()==meshName)
9637 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
9638 ret->_fields.push_back(cur2);
9641 ret->shallowCpyOnlyUsedGlobs(*this);
9646 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
9647 * Input time steps are specified using a pair of integer (iteration, order).
9648 * 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,
9649 * but for each multitimestep only the time steps in \a timeSteps are kept.
9650 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
9652 * The returned object points to shallow copy of elements in \a this.
9654 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
9655 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
9656 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9658 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
9660 MCAuto<MEDFileFields> ret(MEDFileFields::New());
9661 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9663 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9666 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
9667 ret->_fields.push_back(elt);
9669 ret->shallowCpyOnlyUsedGlobs(*this);
9674 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
9676 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
9678 MCAuto<MEDFileFields> ret=MEDFileFields::New();
9679 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9681 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9684 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
9685 if(elt->getNumberOfTS()!=0)
9686 ret->_fields.push_back(elt);
9688 ret->shallowCpyOnlyUsedGlobs(*this);
9692 bool MEDFileFields::presenceOfStructureElements() const
9694 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9695 if((*it).isNotNull())
9696 if((*it)->presenceOfStructureElements())
9701 void MEDFileFields::killStructureElements()
9703 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
9704 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9705 if((*it).isNotNull())
9707 if((*it)->presenceOfStructureElements())
9709 if(!(*it)->onlyStructureElements())
9711 (*it)->killStructureElements();
9723 void MEDFileFields::keepOnlyStructureElements()
9725 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
9726 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9727 if((*it).isNotNull())
9729 if((*it)->presenceOfStructureElements())
9731 if(!(*it)->onlyStructureElements())
9732 (*it)->keepOnlyStructureElements();
9739 void MEDFileFields::keepOnlyOnMeshSE(const std::string& meshName, const std::string& seName)
9741 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
9742 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9743 if((*it).isNotNull())
9745 if((*it)->getMeshName()!=meshName)
9747 std::vector< std::pair<std::string,std::string> > ps;
9748 (*it)->getMeshSENames(ps);
9749 std::pair<std::string,std::string> p(meshName,seName);
9750 if(std::find(ps.begin(),ps.end(),p)!=ps.end())
9751 (*it)->keepOnlyOnSE(seName);
9757 void MEDFileFields::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
9759 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9760 if((*it).isNotNull())
9761 (*it)->getMeshSENames(ps);
9764 void MEDFileFields::blowUpSE(MEDFileMeshes *ms, const MEDFileStructureElements *ses)
9766 MEDFileBlowStrEltUp::DealWithSE(this,ms,ses);
9769 MCAuto<MEDFileFields> MEDFileFields::partOfThisOnStructureElements() const
9771 MCAuto<MEDFileFields> ret(deepCopy());
9772 ret->keepOnlyStructureElements();
9776 MCAuto<MEDFileFields> MEDFileFields::partOfThisLyingOnSpecifiedMeshSEName(const std::string& meshName, const std::string& seName) const
9778 MCAuto<MEDFileFields> ret(deepCopy());
9779 ret->keepOnlyOnMeshSE(meshName,seName);
9783 void MEDFileFields::aggregate(const MEDFileFields& other)
9785 int nbFieldsToAdd(other.getNumberOfFields());
9786 std::vector<std::string> fsn(getFieldsNames());
9787 for(int i=0;i<nbFieldsToAdd;i++)
9789 MCAuto<MEDFileAnyTypeFieldMultiTS> elt(other.getFieldAtPos(i));
9790 std::string name(elt->getName());
9791 if(std::find(fsn.begin(),fsn.end(),name)!=fsn.end())
9793 std::ostringstream oss; oss << "MEDFileFields::aggregate : name \"" << name << "\" already appears !";
9794 throw INTERP_KERNEL::Exception(oss.str());
9800 MEDFileFieldsIterator *MEDFileFields::iterator()
9802 return new MEDFileFieldsIterator(this);
9805 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
9807 std::string tmp(fieldName);
9808 std::vector<std::string> poss;
9809 for(std::size_t i=0;i<_fields.size();i++)
9811 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f(_fields[i]);
9814 std::string fname(f->getName());
9818 poss.push_back(fname);
9821 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
9822 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
9824 throw INTERP_KERNEL::Exception(oss.str());
9827 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
9832 _nb_iter=fs->getNumberOfFields();
9836 MEDFileFieldsIterator::~MEDFileFieldsIterator()
9840 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
9842 if(_iter_id<_nb_iter)
9844 MEDFileFields *fs(_fs);
9846 return fs->getFieldAtPos(_iter_id++);