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 med_entity_type mentiCpy(menti);
584 INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
586 med_int nbValsInFile(MEDfieldnValueWithProfileByName(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile.c_str(),MED_COMPACT_PFLMODE,&tmp1,locname,&nbi));
587 if(nbValsInFile==0 && menti==MED_CELL)
589 nbValsInFile=MEDfieldnValueWithProfileByName(fid,fieldName.c_str(),iteration,order,MED_DESCENDING_FACE,mgeoti,_profile.c_str(),MED_COMPACT_PFLMODE,&tmp1,locname,&nbi);
592 nbValsInFile=MEDfieldnValueWithProfileByName(fid,fieldName.c_str(),iteration,order,MED_DESCENDING_EDGE,mgeoti,_profile.c_str(),MED_COMPACT_PFLMODE,&tmp1,locname,&nbi);
594 { mentiCpy=MED_DESCENDING_EDGE; }
597 { mentiCpy=MED_DESCENDING_FACE; }
599 if(_end-_start!=nbValsInFile*nbi)
601 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 !";
602 throw INTERP_KERNEL::Exception(oss.str());
604 MEDFILESAFECALLERRD0(MEDfieldValueWithProfileRd,(fid,fieldName.c_str(),iteration,order,mentiCpy,mgeoti,MED_COMPACT_PFLMODE,_profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,startFeedingPtr));
608 if(!_profile.empty())
609 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : not implemented !");
610 INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)),locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
612 int overallNval(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
613 const SlicePartDefinition *spd(dynamic_cast<const SlicePartDefinition *>(pd));
617 spd->getSlice(start,stop,step);
618 int nbOfEltsToLoad(DataArray::GetNumberOfItemGivenBES(start,stop,step,"MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile"));
619 med_filter filter=MED_FILTER_INIT;
620 MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
621 MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
622 /*start*/start+1,/*stride*/step,/*count*/1,/*blocksize*/nbOfEltsToLoad,
623 /*lastblocksize=useless because count=1*/0,&filter);
624 MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,startFeedingPtr));
625 MEDfilterClose(&filter);
628 const DataArrayPartDefinition *dpd(dynamic_cast<const DataArrayPartDefinition *>(pd));
631 dpd->checkConsistencyLight();
632 MCAuto<DataArrayInt> myIds(dpd->toDAI());
633 int a(myIds->getMinValueInArray()),b(myIds->getMaxValueInArray());
634 myIds=myIds->deepCopy();// WARNING deep copy here because _pd is modified by applyLin !!!
635 myIds->applyLin(1,-a);
636 int nbOfEltsToLoad(b-a+1);
637 med_filter filter=MED_FILTER_INIT;
638 {//TODO : manage int32 !
639 MCAuto<DataArrayDouble> tmp(DataArrayDouble::New());
640 tmp->alloc(nbOfEltsToLoad,nbOfCompo);
641 MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
642 MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
643 /*start*/a+1,/*stride*/1,/*count*/1,/*blocksize*/nbOfEltsToLoad,
644 /*lastblocksize=useless because count=1*/0,&filter);
645 MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,reinterpret_cast<unsigned char *>(tmp->getPointer())));
646 MCAuto<DataArrayDouble> feeder(DataArrayDouble::New());
647 feeder->useExternalArrayWithRWAccess(reinterpret_cast<double *>(startFeedingPtr),_nval,nbOfCompo);
648 feeder->setContigPartOfSelectedValues(0,tmp,myIds);
650 MEDfilterClose(&filter);
653 throw INTERP_KERNEL::Exception("Not implemented yet for not slices!");
657 const MEDFileFieldPerMeshPerTypeCommon *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
662 void MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
664 INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
665 INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
666 std::string fieldName(nasc.getName()),meshName(getMeshName());
667 int iteration(getIteration()),order(getOrder()),profilesize,nbi;
668 TypeOfField type(getType());
669 med_geometry_type mgeoti;
670 med_entity_type menti;
671 _father->entriesForMEDfile(type,mgeoti,menti);
672 int zeNVal(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
673 if(zeNVal==0 && type==ON_CELLS)
674 {//eheh maybe there's a surprise :)
675 int zeNVal1(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,MED_DESCENDING_FACE,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
678 int zeNVal2(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,MED_DESCENDING_EDGE,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
687 _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
688 _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
689 const PartDefinition *pd(_pd);
696 if(!_profile.empty())
697 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively : profiles are not managed yet with part of def !");
698 _nval=pd->getNumberOfElems();
701 _end=start+_nval*nbi;
703 if(type==ON_CELLS && !_localization.empty())
705 if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
706 setType(ON_GAUSS_PT);
709 setType(ON_GAUSS_NE);
710 _localization.clear();
715 void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, const MEDFileFieldNameScope& nasc)
717 std::string fieldName(nasc.getName()),meshName(getMeshName());
718 int iteration(getIteration()),order(getOrder());
719 TypeOfField type(getType());
720 med_geometry_type mgeoti;
721 med_entity_type menti;
722 _father->entriesForMEDfile(type,mgeoti,menti);
724 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !");
727 DataArray *arr(getOrCreateAndGetArray());//arr is not null due to the spec of getOrCreateAndGetArray
728 if(_start<0 || _start>=arr->getNumberOfTuples())
730 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << ") !";
731 throw INTERP_KERNEL::Exception(oss.str());
733 if(_end<0 || _end>arr->getNumberOfTuples())
735 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !";
736 throw INTERP_KERNEL::Exception(oss.str());
738 int nbOfCompo(arr->getNumberOfComponents());
739 DataArrayDouble *arrD(dynamic_cast<DataArrayDouble *>(arr));
742 double *startFeeding(arrD->getPointer()+_start*nbOfCompo);
743 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
746 DataArrayInt *arrI(dynamic_cast<DataArrayInt *>(arr));
749 int *startFeeding(arrI->getPointer()+_start*nbOfCompo);
750 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
753 DataArrayFloat *arrF(dynamic_cast<DataArrayFloat *>(arr));
756 float *startFeeding(arrF->getPointer()+_start*nbOfCompo);
757 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
760 throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 FLOAT32 or INT32 !");
764 * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
766 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart)
768 int delta=_end-_start;
769 _start=newValueOfStart;
773 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
775 return _father->getIteration();
778 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
780 return _father->getOrder();
783 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
785 return _father->getTime();
788 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
790 return _father->getMeshName();
793 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
795 const char startLine[]=" ## ";
796 std::string startLine2(bkOffset,' ');
797 startLine2+=startLine;
798 INTERP_KERNEL::AutoCppPtr<MEDCouplingFieldDiscretization> tmp(MEDCouplingFieldDiscretization::New(_type));
799 oss << startLine2 << "Localization #" << id << "." << std::endl;
800 oss << startLine2 << " Type=" << tmp->getRepr() << "." << std::endl;
801 oss << startLine2 << " This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
802 oss << startLine2 << " This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
803 oss << startLine2 << " This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
806 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
811 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
813 return _father->getGeoType();
816 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
821 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
826 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
828 return _father->getNumberOfComponents();
831 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
836 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray()
838 return _father->getOrCreateAndGetArray();
841 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const
843 const MEDFileFieldPerMeshPerTypeCommon *fath=_father;
844 return fath->getOrCreateAndGetArray();
847 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
849 return _father->getInfo();
852 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
857 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const std::string& newPflName)
862 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
864 return _localization;
867 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const std::string& newLocName)
869 _localization=newLocName;
872 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
874 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
876 if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
878 _profile=(*it2).second;
884 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
886 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
888 if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
890 _localization=(*it2).second;
896 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
900 dads.push_back(std::pair<int,int>(_start,_end));
901 geoTypes.push_back(getGeoType());
906 pfls.push_back(glob->getProfile(_profile.c_str()));
908 if(_localization.empty())
912 locs.push_back(glob->getLocalizationId(_localization.c_str()));
916 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
918 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));
922 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
924 TypeOfField type=getType();
925 INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
926 med_geometry_type mgeoti;
927 med_entity_type menti;
928 _father->entriesForMEDfile(getType(),mgeoti,menti);
929 const DataArray *arr(getOrCreateAndGetArray());
931 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
932 if(!arr->isAllocated())
933 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : the array to be written is not allocated !");
934 const DataArrayDouble *arrD(dynamic_cast<const DataArrayDouble *>(arr));
935 const DataArrayInt *arrI(dynamic_cast<const DataArrayInt *>(arr));
936 const DataArrayFloat *arrF(dynamic_cast<const DataArrayFloat *>(arr));
937 const unsigned char *locToWrite=0;
939 locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
941 locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
943 locToWrite=reinterpret_cast<const unsigned char *>(arrF->getConstPointer()+_start*arr->getNumberOfComponents());
945 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 FLOAT32 and INT32 !");
946 MEDFILESAFECALLERWR0(MEDfieldValueWithProfileWr,(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
947 MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
951 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const
956 dad.first=_start; dad.second=_end;
960 * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
961 * This code corresponds to the distribution of types in the corresponding mesh.
962 * \param [out] ptToFill memory zone where the output will be stored.
963 * \return the size of data pushed into output param \a ptToFill
965 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const
968 std::ostringstream oss;
969 std::size_t nbOfType=codeOfMesh.size()/3;
971 for(std::size_t i=0;i<nbOfType && found==-1;i++)
972 if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
976 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
977 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
978 throw INTERP_KERNEL::Exception(oss.str());
983 if(_nval!=codeOfMesh[3*found+1])
985 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
986 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
987 oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
988 throw INTERP_KERNEL::Exception(oss.str());
990 for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
995 const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
996 if(pfl->getNumberOfTuples()!=_nval)
998 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
999 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
1001 oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
1002 throw INTERP_KERNEL::Exception(oss.str());
1004 int offset2=codeOfMesh[3*found+2];
1005 for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
1007 if(*pflId<codeOfMesh[3*found+1])
1008 *work++=offset2+*pflId;
1014 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const
1016 for(int i=_start;i<_end;i++)
1021 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId)
1032 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
1036 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
1039 std::map<std::pair<std::string,TypeOfField>,int> m;
1040 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
1041 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
1042 if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
1043 m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
1045 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
1046 ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
1051 * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
1053 * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
1054 * \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.
1055 * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
1056 * \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)
1057 * \param [in,out] glob if necessary by the method, new profiles can be added to it
1058 * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
1059 * \param [out] result All new entries will be appended on it.
1060 * \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 !)
1062 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
1063 const DataArrayInt *explicitIdsInMesh,
1064 const std::vector<int>& newCode,
1065 MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
1066 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >& result)
1068 if(entriesOnSameDisc.empty())
1070 TypeOfField type=entriesOnSameDisc[0]->getType();
1071 int szEntities=0,szTuples=0;
1072 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
1073 { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
1074 int nbi=szTuples/szEntities;
1075 if(szTuples%szEntities!=0)
1076 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
1077 MCAuto<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
1078 MCAuto<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
1079 std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
1080 std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
1081 std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
1082 std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
1083 MCAuto<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
1085 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
1087 int startOfEltIdOfChunk=(*it)->_start;
1088 MCAuto<DataArrayInt> newEltIds=explicitIdsInMesh->subArray(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
1089 MCAuto<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
1090 MCAuto<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
1092 MCAuto<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
1093 newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
1095 newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
1096 newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
1098 MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
1099 MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
1100 MCAuto<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
1101 MCAuto<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
1103 MCAuto<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
1105 MCAuto<DataArrayDouble> arrPart=arr->subArray(offset,offset+szTuples);
1106 arrPart->renumberInPlace(renumTupleIds->begin());
1107 arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
1109 const int *idIt=diffVals->begin();
1110 std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
1112 for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
1114 MCAuto<DataArrayInt> ids=newGeoTypesEltIdsAllGather->findIdsEqual(*idIt);
1115 MCAuto<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
1116 int nbEntityElts=subIds->getNumberOfTuples();
1118 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
1119 NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIota(newCode[3*(*idIt)+1]),nbi,
1123 result.push_back(eltToAdd);
1124 offset2+=nbEntityElts*nbi;
1126 ret=ret || li.empty();
1131 * \param [in] typeF type of field of new chunk
1132 * \param [in] geoType the geometric type of the chunk
1133 * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
1134 * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
1135 * \param [in] nbi number of integration points
1136 * \param [in] offset The offset in the **global array of data**.
1137 * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
1138 * to the new chunk to create.
1139 * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
1140 * \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
1141 * and corresponding entry erased from \a entriesOnSameDisc.
1142 * \return a newly allocated chunk
1144 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
1145 bool isPfl, int nbi, int offset,
1146 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
1147 MEDFileFieldGlobsReal& glob,
1148 bool ¬InExisting)
1150 int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
1151 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
1152 for(;it!=entriesOnSameDisc.end();it++)
1154 if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
1158 if((*it)->_profile.empty())
1161 if(!(*it)->_profile.empty())
1163 const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
1164 if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
1170 if(it==entriesOnSameDisc.end())
1173 MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
1175 ret->_loc_id=(int)geoType;
1176 ret->_nval=nbMeshEntities;
1178 ret->_end=ret->_start+ret->_nval*nbi;
1181 idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
1182 glob.appendProfile(idsOfMeshElt);
1183 ret->_profile=idsOfMeshElt->getName();
1185 //tony treatment of localization
1190 notInExisting=false;
1191 MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1192 ret->_loc_id=(int)geoType;
1193 ret->setNewStart(offset);
1194 entriesOnSameDisc.erase(it);
1200 ////////////////////////////////////
1202 MEDFileFieldPerMeshPerTypeCommon::~MEDFileFieldPerMeshPerTypeCommon()
1206 void MEDFileFieldPerMeshPerTypeCommon::setFather(MEDFileFieldPerMesh *father)
1211 void MEDFileFieldPerMeshPerTypeCommon::accept(MEDFileFieldVisitor& visitor) const
1213 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1214 if((*it).isNotNull())
1216 visitor.newPerMeshPerTypePerDisc(*it);
1220 void MEDFileFieldPerMeshPerTypeCommon::deepCopyElements()
1223 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1225 if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
1226 _field_pm_pt_pd[i]=(*it)->deepCopy(this);
1230 std::size_t MEDFileFieldPerMeshPerTypeCommon::getHeapMemorySizeWithoutChildren() const
1232 return _field_pm_pt_pd.capacity()*sizeof(MCAuto<MEDFileFieldPerMeshPerTypePerDisc>);
1235 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypeCommon::getDirectChildrenWithNull() const
1237 std::vector<const BigMemoryObject *> ret;
1238 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1239 ret.push_back((const MEDFileFieldPerMeshPerTypePerDisc *)*it);
1243 void MEDFileFieldPerMeshPerTypeCommon::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1245 std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
1246 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1247 _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1251 * This method is the most general one. No optimization is done here.
1252 * \param [in] multiTypePfl is the end user profile specified in high level API
1253 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1254 * \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.
1255 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1256 * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1257 * \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.
1259 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)
1261 std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1262 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1263 _field_pm_pt_pd[*it]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1266 void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1268 _field_pm_pt_pd.resize(1);
1269 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1270 _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1273 void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1275 MCAuto<DataArrayInt> pfl2=pfl->deepCopy();
1276 if(!arr || !arr->isAllocated())
1277 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile : input array is null, or not allocated !");
1278 _field_pm_pt_pd.resize(1);
1279 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1280 _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.
1283 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldTemplate *field, int offset, int nbOfCells)
1285 TypeOfField type=field->getTypeOfField();
1286 if(type!=ON_GAUSS_PT)
1288 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1289 int sz=_field_pm_pt_pd.size();
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);
1301 _field_pm_pt_pd.resize(sz+1);
1302 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1304 std::vector<int> ret(1,(int)sz);
1309 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1310 int sz2=ret2.size();
1311 std::vector<int> ret3(sz2);
1313 for(int i=0;i<sz2;i++)
1315 int sz=_field_pm_pt_pd.size();
1316 int locIdToFind=ret2[i];
1318 for(int j=0;j<sz && !found;j++)
1320 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1322 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1329 _field_pm_pt_pd.resize(sz+1);
1330 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1338 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldTemplate *field, int offset, int nbOfCells)
1340 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1341 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1343 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1344 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1346 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1347 MCAuto<DataArrayInt> da2=da->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1);
1348 MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1349 if(retTmp->presenceOfValue(-1))
1350 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1351 std::vector<int> ret(retTmp->begin(),retTmp->end());
1355 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldTemplate *field, const DataArrayInt *subCells)
1357 TypeOfField type=field->getTypeOfField();
1358 if(type!=ON_GAUSS_PT)
1360 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1361 int sz=_field_pm_pt_pd.size();
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);
1373 _field_pm_pt_pd.resize(sz+1);
1374 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1376 std::vector<int> ret(1,0);
1381 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1382 int sz2=ret2.size();
1383 std::vector<int> ret3(sz2);
1385 for(int i=0;i<sz2;i++)
1387 int sz=_field_pm_pt_pd.size();
1388 int locIdToFind=ret2[i];
1390 for(int j=0;j<sz && !found;j++)
1392 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1394 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1401 _field_pm_pt_pd.resize(sz+1);
1402 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1410 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldTemplate *field, const DataArrayInt *subCells)
1412 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1413 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1415 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1416 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1418 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1419 MCAuto<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1420 MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1421 if(retTmp->presenceOfValue(-1))
1422 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1423 std::vector<int> ret(retTmp->begin(),retTmp->end());
1427 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerTypeCommon::getFather() const
1432 bool MEDFileFieldPerMeshPerTypeCommon::isUniqueLevel(int& dim) const
1434 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
1435 int curDim((int)cm.getDimension());
1436 if(dim!=std::numeric_limits<int>::max())
1446 void MEDFileFieldPerMeshPerTypeCommon::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1448 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1450 (*it)->fillTypesOfFieldAvailable(types);
1454 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
1456 int sz=_field_pm_pt_pd.size();
1457 dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1458 for(int i=0;i<sz;i++)
1460 _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1464 int MEDFileFieldPerMeshPerTypeCommon::getIteration() const
1466 return _father->getIteration();
1469 int MEDFileFieldPerMeshPerTypeCommon::getOrder() const
1471 return _father->getOrder();
1474 double MEDFileFieldPerMeshPerTypeCommon::getTime() const
1476 return _father->getTime();
1479 std::string MEDFileFieldPerMeshPerTypeCommon::getMeshName() const
1481 return _father->getMeshName();
1484 void MEDFileFieldPerMeshPerTypeCommon::getSizes(int& globalSz, int& nbOfEntries) const
1486 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1488 globalSz+=(*it)->getNumberOfTuples();
1490 nbOfEntries+=(int)_field_pm_pt_pd.size();
1493 int MEDFileFieldPerMeshPerTypeCommon::getNumberOfComponents() const
1495 return _father->getNumberOfComponents();
1498 bool MEDFileFieldPerMeshPerTypeCommon::presenceOfMultiDiscPerGeoType() const
1501 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1503 const MEDFileFieldPerMeshPerTypePerDisc *fmtd(*it);
1510 void MEDFileFieldPerMeshPerTypeCommon::pushDiscretization(MEDFileFieldPerMeshPerTypePerDisc *disc)
1512 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt;
1514 _field_pm_pt_pd.push_back(elt);
1517 DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray()
1519 return _father->getOrCreateAndGetArray();
1522 const DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray() const
1524 const MEDFileFieldPerMesh *fath=_father;
1525 return fath->getOrCreateAndGetArray();
1528 const std::vector<std::string>& MEDFileFieldPerMeshPerTypeCommon::getInfo() const
1530 return _father->getInfo();
1533 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsed() const
1535 std::vector<std::string> ret;
1536 std::set<std::string> ret2;
1537 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1539 std::string tmp=(*it1)->getProfile();
1541 if(ret2.find(tmp)==ret2.end())
1550 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsed() const
1552 std::vector<std::string> ret;
1553 std::set<std::string> ret2;
1554 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1556 std::string tmp=(*it1)->getLocalization();
1557 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1558 if(ret2.find(tmp)==ret2.end())
1567 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsedMulti() const
1569 std::vector<std::string> ret;
1570 std::set<std::string> ret2;
1571 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1573 std::string tmp=(*it1)->getProfile();
1580 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsedMulti() const
1582 std::vector<std::string> ret;
1583 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1585 std::string tmp=(*it1)->getLocalization();
1586 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1592 void MEDFileFieldPerMeshPerTypeCommon::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1594 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1595 (*it1)->changePflsRefsNamesGen(mapOfModif);
1598 void MEDFileFieldPerMeshPerTypeCommon::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1600 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1601 (*it1)->changeLocsRefsNamesGen(mapOfModif);
1604 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId)
1606 if(_field_pm_pt_pd.empty())
1608 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << getGeoTypeRepr() << "\" !";
1609 throw INTERP_KERNEL::Exception(oss.str());
1611 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1612 return _field_pm_pt_pd[locId];
1613 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
1614 oss2 << ") for geometric type \"" << getGeoTypeRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1615 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1616 return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1619 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId) const
1621 if(_field_pm_pt_pd.empty())
1623 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << getGeoTypeRepr() << "\" !";
1624 throw INTERP_KERNEL::Exception(oss.str());
1626 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1627 return _field_pm_pt_pd[locId];
1628 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
1629 oss2 << ") for geometric type \"" << getGeoTypeRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1630 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1631 return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1634 void MEDFileFieldPerMeshPerTypeCommon::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1637 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1639 (*it)->fillValues(i,startEntryId,entries);
1643 void MEDFileFieldPerMeshPerTypeCommon::setLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
1645 _field_pm_pt_pd=leaves;
1646 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1647 (*it)->setFather(this);
1651 * \param [in,out] globalNum a global numbering counter for the renumbering.
1652 * \param [out] its - list of pair (start,stop) kept
1653 * \return bool - false if the type of field \a tof is not contained in \a this.
1655 bool MEDFileFieldPerMeshPerTypeCommon::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
1658 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1659 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1660 if((*it)->getType()==tof)
1662 newPmPtPd.push_back(*it);
1663 std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1664 (*it)->setNewStart(globalNum);
1665 globalNum=(*it)->getEnd();
1666 its.push_back(bgEnd);
1670 _field_pm_pt_pd=newPmPtPd;
1675 * \param [in,out] globalNum a global numbering counter for the renumbering.
1676 * \param [out] its - list of pair (start,stop) kept
1677 * \return bool - false if the type of field \a tof is not contained in \a this.
1679 bool MEDFileFieldPerMeshPerTypeCommon::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
1681 if(_field_pm_pt_pd.size()<=idOfDisc)
1683 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt(_field_pm_pt_pd[idOfDisc]);
1684 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd(1,elt);
1685 std::pair<int,int> bgEnd; bgEnd.first=_field_pm_pt_pd[idOfDisc]->getStart(); bgEnd.second=_field_pm_pt_pd[idOfDisc]->getEnd();
1686 elt->setNewStart(globalNum);
1687 globalNum=elt->getEnd();
1688 its.push_back(bgEnd);
1689 _field_pm_pt_pd=newPmPtPd;
1693 void MEDFileFieldPerMeshPerTypeCommon::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
1695 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1696 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1699 void MEDFileFieldPerMeshPerTypeCommon::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1701 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1702 (*it)->loadBigArray(fid,nasc);
1705 void MEDFileFieldPerMeshPerTypeCommon::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1707 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1709 (*it)->copyOptionsFrom(*this);
1710 (*it)->writeLL(fid,nasc);
1714 med_entity_type MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1719 medfGeoType=typmai3[(int)ikGeoType];
1722 medfGeoType=MED_NONE;
1725 medfGeoType=typmai3[(int)ikGeoType];
1726 return MED_NODE_ELEMENT;
1728 medfGeoType=typmai3[(int)ikGeoType];
1731 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1733 return MED_UNDEF_ENTITY_TYPE;
1736 //////////////////////////////////////////////////
1738 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd)
1740 return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc,pd);
1743 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType)
1745 return new MEDFileFieldPerMeshPerType(fath,geoType);
1748 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCopy(MEDFileFieldPerMesh *father) const
1750 MCAuto<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
1751 ret->setFather(father);
1752 ret->deepCopyElements();
1756 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
1758 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1760 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1761 if(meshDim!=(int)cm.getDimension())
1764 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1765 (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1768 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1773 void MEDFileFieldPerMeshPerType::entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const
1775 ent=MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(mct,_geo_type,gt);
1778 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1780 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1781 int curDim((int)cm.getDimension());
1782 dim=std::max(dim,curDim);
1785 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1787 const char startLine[]=" ## ";
1788 std::string startLine2(bkOffset,' ');
1789 std::string startLine3(startLine2);
1790 startLine3+=startLine;
1791 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1793 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1794 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1797 oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1798 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1800 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1802 const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1804 cur->simpleRepr(bkOffset,oss,i);
1807 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1812 std::string MEDFileFieldPerMeshPerType::getGeoTypeRepr() const
1814 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1815 return std::string(cm.getRepr());
1818 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *father, INTERP_KERNEL::NormalizedCellType gt):MEDFileFieldPerMeshPerTypeCommon(father),_geo_type(gt)
1822 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):MEDFileFieldPerMeshPerTypeCommon(fath),_geo_type(geoType)
1824 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1825 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1826 med_geometry_type mgeoti;
1827 med_entity_type menti(ConvertIntoMEDFileType(type,geoType,mgeoti));
1828 int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName));
1829 _field_pm_pt_pd.resize(nbProfiles);
1830 for(int i=0;i<nbProfiles;i++)
1832 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i,pd);
1836 int nbProfiles2(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName));
1837 for(int i=0;i<nbProfiles2;i++)
1838 _field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i,pd));
1840 if(!_field_pm_pt_pd.empty() || type!=ON_CELLS)
1842 // dark side of the force.
1844 int nbProfiles1(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_DESCENDING_FACE,mgeoti,pflName,locName));
1845 int nbProfiles2(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_DESCENDING_EDGE,mgeoti,pflName,locName));
1846 if(nbProfiles1==0 && nbProfiles2==0)
1847 return ;// OK definitely nothing in field
1848 menti=nbProfiles1>=nbProfiles2?MED_DESCENDING_FACE:MED_DESCENDING_EDGE;//not enough words to describe the beauty
1849 nbProfiles=std::max(nbProfiles1,nbProfiles2);
1850 _field_pm_pt_pd.resize(nbProfiles);
1851 for(int i=0;i<nbProfiles;i++)
1852 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_CELLS,i,pd);
1856 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)
1858 MCAuto<MEDFileFieldPerMeshPerType> ret(MEDFileFieldPerMeshPerType::New(father,gt));
1859 std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > > m;
1860 for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerType *> >::const_iterator it=pms.begin();it!=pms.end();it++)
1862 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it2=(*it).second->_field_pm_pt_pd.begin();it2!=(*it).second->_field_pm_pt_pd.end();it2++)
1863 m[(*it2)->getType()].push_back(std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * >((*it).first,*it2));
1865 for(std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > >::const_iterator it=m.begin();it!=m.end();it++)
1867 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> agg(MEDFileFieldPerMeshPerTypePerDisc::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
1868 ret->_field_pm_pt_pd.push_back(agg);
1873 //////////////////////////////////////////////////
1875 MEDFileFieldPerMeshPerTypeDyn *MEDFileFieldPerMeshPerTypeDyn::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileEntities *entities, int idGT, const MEDFileFieldNameScope& nasc)
1878 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeDyn::NewOnRead : null pointer !");
1879 const MEDFileAllStaticEntitiesPlusDyn *entities2(dynamic_cast<const MEDFileAllStaticEntitiesPlusDyn *>(entities));
1881 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeDyn::NewOnRead : invalid type of entities !");
1882 const MEDFileStructureElement *se(entities2->getWithGT(idGT));
1883 return new MEDFileFieldPerMeshPerTypeDyn(fid,fath,se,nasc);
1886 MEDFileFieldPerMeshPerTypeDyn::MEDFileFieldPerMeshPerTypeDyn(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileStructureElement *se, const MEDFileFieldNameScope& nasc):MEDFileFieldPerMeshPerTypeCommon(fath)
1889 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1890 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1891 int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,_se->getDynGT(),pflName,locName));
1892 _field_pm_pt_pd.resize(nbProfiles);
1893 for(int i=0;i<nbProfiles;i++)
1895 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,_se->getEntity(),i,NULL);
1899 int MEDFileFieldPerMeshPerTypeDyn::getDynGT() const
1901 return _se->getDynGT();
1904 std::string MEDFileFieldPerMeshPerTypeDyn::getModelName() const
1906 return _se->getName();
1909 void MEDFileFieldPerMeshPerTypeDyn::getDimension(int& dim) const
1911 throw INTERP_KERNEL::Exception("not implemented yet !");
1914 void MEDFileFieldPerMeshPerTypeDyn::entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const
1917 ent=MED_STRUCT_ELEMENT;
1920 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypeDyn::getGeoType() const
1922 throw INTERP_KERNEL::Exception("not implemented yet !");
1925 void MEDFileFieldPerMeshPerTypeDyn::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1927 const char startLine[]=" ## ";
1928 std::string startLine2(bkOffset,' ');
1929 std::string startLine3(startLine2);
1930 startLine3+=startLine;
1931 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry STRUCTURE_ELEMENT type " << getDynGT() << "." << std::endl;
1932 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1934 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1936 if((*it).isNotNull())
1937 (*it)->simpleRepr(bkOffset,oss,i);
1940 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1945 std::string MEDFileFieldPerMeshPerTypeDyn::getGeoTypeRepr() const
1947 throw INTERP_KERNEL::Exception("not implemented yet !");
1950 MEDFileFieldPerMeshPerTypeDyn *MEDFileFieldPerMeshPerTypeDyn::deepCopy(MEDFileFieldPerMesh *father) const
1952 MCAuto<MEDFileFieldPerMeshPerTypeDyn> ret(new MEDFileFieldPerMeshPerTypeDyn(*this));
1953 ret->setFather(father);
1954 ret->deepCopyElements();
1958 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
1960 throw INTERP_KERNEL::Exception("not implemented yet !");
1963 //////////////////////////////////////////////////
1965 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const MEDFileEntities *entities)
1967 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm,entities);
1970 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1972 return new MEDFileFieldPerMesh(fath,mesh);
1975 std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
1977 return _field_pm_pt.capacity()*sizeof(MCAuto< MEDFileFieldPerMeshPerType >);
1980 std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildrenWithNull() const
1982 std::vector<const BigMemoryObject *> ret;
1983 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1988 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCopy(MEDFileAnyTypeField1TSWithoutSDA *father) const
1990 MCAuto< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1991 ret->_father=father;
1993 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1995 if((*it).isNotNull())
1996 ret->_field_pm_pt[i]=(*it)->deepCopy((MEDFileFieldPerMesh *)(ret));
2001 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
2003 std::string startLine(bkOffset,' ');
2004 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << getMeshName() << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
2005 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
2007 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2009 if((*it).isNotNull())
2010 (*it)->simpleRepr(bkOffset,oss,i);
2013 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
2018 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh)
2020 mesh->getTime(_mesh_iteration,_mesh_order);
2023 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
2025 int nbOfTypes=code.size()/3;
2027 for(int i=0;i<nbOfTypes;i++)
2029 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
2030 int nbOfCells=code[3*i+1];
2031 int pos=addNewEntryIfNecessary(type);
2032 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
2038 * This method is the most general one. No optimization is done here.
2039 * \param [in] multiTypePfl is the end user profile specified in high level API
2040 * \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].
2041 * \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.
2042 * \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.
2043 * \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.
2044 * \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.
2046 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)
2048 int nbOfTypes(code.size()/3);
2049 for(int i=0;i<nbOfTypes;i++)
2051 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
2052 int pos=addNewEntryIfNecessary(type);
2053 DataArrayInt *pfl=0;
2055 pfl=idsPerType[code[3*i+2]];
2056 int nbOfTupes2=code2.size()/3;
2058 for(;found<nbOfTupes2;found++)
2059 if(code[3*i]==code2[3*found])
2061 if(found==nbOfTupes2)
2062 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
2063 _field_pm_pt[pos]->assignFieldProfile(nbOfTypes==1,start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
2067 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
2069 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
2070 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
2073 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
2075 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
2076 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
2079 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
2081 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2082 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
2085 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
2087 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2088 (*it)->loadBigArraysRecursively(fid,nasc);
2091 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
2093 int nbOfTypes=_field_pm_pt.size();
2094 for(int i=0;i<nbOfTypes;i++)
2096 _field_pm_pt[i]->copyOptionsFrom(*this);
2097 _field_pm_pt[i]->writeLL(fid,nasc);
2101 void MEDFileFieldPerMesh::getDimension(int& dim) const
2103 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2104 (*it)->getDimension(dim);
2107 bool MEDFileFieldPerMesh::isUniqueLevel(int& dim) const
2109 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2110 if(!(*it)->isUniqueLevel(dim))
2115 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
2117 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2118 (*it)->fillTypesOfFieldAvailable(types);
2121 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
2123 int sz=_field_pm_pt.size();
2124 std::vector< std::vector<std::pair<int,int> > > ret(sz);
2125 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
2126 for(int i=0;i<sz;i++)
2128 types[i]=_field_pm_pt[i]->getGeoType();
2129 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
2134 double MEDFileFieldPerMesh::getTime() const
2137 return _father->getTime(tmp1,tmp2);
2140 int MEDFileFieldPerMesh::getIteration() const
2142 return _father->getIteration();
2145 int MEDFileFieldPerMesh::getOrder() const
2147 return _father->getOrder();
2150 int MEDFileFieldPerMesh::getNumberOfComponents() const
2152 return _father->getNumberOfComponents();
2155 std::string MEDFileFieldPerMesh::getMeshName() const
2157 return _father->getMeshName();
2160 void MEDFileFieldPerMesh::setMeshName(const std::string& meshName)
2162 _father->setMeshName(meshName);
2165 bool MEDFileFieldPerMesh::presenceOfMultiDiscPerGeoType() const
2167 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2171 if((*it)->presenceOfMultiDiscPerGeoType())
2177 bool MEDFileFieldPerMesh::presenceOfStructureElements() const
2179 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_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));
2189 bool MEDFileFieldPerMesh::onlyStructureElements() const
2191 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2192 if((*it).isNotNull())
2194 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2201 void MEDFileFieldPerMesh::killStructureElements()
2203 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
2204 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2206 if((*it).isNotNull())
2208 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2216 void MEDFileFieldPerMesh::keepOnlyStructureElements()
2218 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
2219 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2221 if((*it).isNotNull())
2223 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2231 void MEDFileFieldPerMesh::keepOnlyOnSE(const std::string& seName)
2233 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
2234 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2236 if((*it).isNotNull())
2238 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2240 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::keepOnlyOnSE : presence of non SE !");
2241 if(pt->getModelName()==seName)
2248 void MEDFileFieldPerMesh::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
2250 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2252 if((*it).isNotNull())
2254 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2257 ps.push_back(std::pair<std::string,std::string>(getMeshName(),pt->getModelName()));
2260 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getMeshSENames : presence of a non structure element part !");
2265 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
2268 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
2269 return _father->getOrCreateAndGetArray();
2272 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
2275 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
2276 return _father->getOrCreateAndGetArray();
2279 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
2281 return _father->getInfo();
2285 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
2286 * 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.
2287 * It returns 2 output vectors :
2288 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
2289 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
2290 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
2292 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)
2294 int notNullPflsSz=0;
2295 int nbOfArrs=geoTypes.size();
2296 for(int i=0;i<nbOfArrs;i++)
2299 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
2300 int nbOfDiffGeoTypes=geoTypes3.size();
2301 code.resize(3*nbOfDiffGeoTypes);
2302 notNullPfls.resize(notNullPflsSz);
2305 for(int i=0;i<nbOfDiffGeoTypes;i++)
2308 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
2309 std::vector<const DataArrayInt *> notNullTmp;
2311 notNullTmp.push_back(pfls[j]);
2313 for(;j<nbOfArrs;j++)
2314 if(geoTypes[j]==refType)
2317 notNullTmp.push_back(pfls[j]);
2321 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
2322 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
2323 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
2324 code[3*i]=(int)refType;
2325 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
2326 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
2327 if(notNullTmp.empty())
2331 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
2332 code[3*i+2]=notNullPflsSz++;
2338 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
2340 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)
2344 for(int i=0;i<sz;i++)
2348 if(type!=ON_GAUSS_NE)
2349 ret+=dads[i].second-dads[i].first;
2352 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
2353 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
2358 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
2359 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
2365 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
2367 std::vector<std::string> ret;
2368 std::set<std::string> ret2;
2369 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2371 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
2372 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
2373 if(ret2.find(*it2)==ret2.end())
2375 ret.push_back(*it2);
2382 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
2384 std::vector<std::string> ret;
2385 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2387 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
2388 ret.insert(ret.end(),tmp.begin(),tmp.end());
2393 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
2395 std::vector<std::string> ret;
2396 std::set<std::string> ret2;
2397 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2399 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
2400 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
2401 if(ret2.find(*it2)==ret2.end())
2403 ret.push_back(*it2);
2410 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
2412 std::vector<std::string> ret;
2413 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2415 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
2416 ret.insert(ret.end(),tmp.begin(),tmp.end());
2421 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
2423 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
2425 if((*it).first==getMeshName())
2427 setMeshName((*it).second);
2434 void MEDFileFieldPerMesh::convertMedBallIntoClassic()
2436 if(_field_pm_pt.size()!=1)
2437 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : Only managed for single mesh !");
2438 if(_field_pm_pt[0].isNull())
2439 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : null pointer !");
2440 MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<MEDFileFieldPerMeshPerTypeDyn *>((MEDFileFieldPerMeshPerTypeCommon *)_field_pm_pt[0]));
2442 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : this is expected to be marked as structure element !");
2443 if(pt->getNumberOfLoc()!=1)
2444 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : only one loc managed !");
2445 const MEDFileFieldPerMeshPerTypePerDisc *disc(pt->getLeafGivenLocId(0));
2447 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : internal error !");
2448 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> disc2(MEDFileFieldPerMeshPerTypePerDisc::New(*disc));
2449 disc2->setType(ON_NODES);
2450 MCAuto<MEDFileFieldPerMeshPerType> pt2(MEDFileFieldPerMeshPerType::New(this,INTERP_KERNEL::NORM_ERROR));
2451 disc2->setFather(pt2);
2452 pt2->setFather(this);
2453 pt2->pushDiscretization(disc2);
2454 _field_pm_pt[0]=DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(pt2);
2457 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
2458 MEDFileFieldGlobsReal& glob)
2460 if(getMeshName()!=meshName)
2462 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
2463 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
2464 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
2465 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
2466 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
2467 getUndergroundDataArrayExt(entries);
2468 DataArray *arr0(getOrCreateAndGetArray());//tony
2470 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
2471 DataArrayDouble *arr(dynamic_cast<DataArrayDouble *>(arr0));//tony
2473 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
2476 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
2477 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
2479 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
2481 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2482 sz+=(*it).second.second-(*it).second.first;
2485 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2487 MCAuto<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
2488 ////////////////////
2489 MCAuto<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
2490 int *workI2=explicitIdsOldInMesh->getPointer();
2491 int sz1=0,sz2=0,sid=1;
2492 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
2493 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
2494 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
2496 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
2497 MCAuto<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
2498 int *workI=explicitIdsOldInArr->getPointer();
2499 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
2501 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
2502 (*itL2)->setLocId(sz2);
2503 (*itL2)->_tmp_work1=(*itL2)->getStart();
2504 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
2506 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
2508 explicitIdsOldInMesh->reAlloc(sz2);
2509 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
2510 ////////////////////
2511 MCAuto<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
2512 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
2513 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
2514 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
2516 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
2517 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
2518 otherEntriesNew.back()->setLocId((*it)->getGeoType());
2520 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
2521 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
2522 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
2524 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
2525 int newStart=elt->getLocId();
2526 elt->setLocId((*it)->getGeoType());
2527 elt->setNewStart(newStart);
2528 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
2529 entriesKeptNew.push_back(elt);
2530 entriesKeptNew2.push_back(elt);
2532 MCAuto<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
2533 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
2534 MCAuto<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
2535 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
2537 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
2540 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
2542 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
2543 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
2545 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
2546 glob,arr2,otherEntriesNew) || ret;
2550 // Assign new dispatching
2551 assignNewLeaves(otherEntriesNew);
2552 arr->deepCopyFrom(*arr2);
2557 * \param [in,out] globalNum a global numbering counter for the renumbering.
2558 * \param [out] its - list of pair (start,stop) kept
2560 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
2562 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > ret;
2563 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2565 std::vector< std::pair<int,int> > its2;
2566 if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
2569 its.insert(its.end(),its2.begin(),its2.end());
2576 * \param [in,out] globalNum a global numbering counter for the renumbering.
2577 * \param [out] its - list of pair (start,stop) kept
2579 void MEDFileFieldPerMesh::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
2581 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > ret;
2582 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2584 std::vector< std::pair<int,int> > its2;
2585 if((*it)->keepOnlyGaussDiscretization(idOfDisc,globalNum,its2))
2588 its.insert(its.end(),its2.begin(),its2.end());
2594 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
2596 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > > types;
2597 for( std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
2598 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
2600 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > fieldPmPt(types.size());
2601 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
2602 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it2=fieldPmPt.begin();
2603 for(;it1!=types.end();it1++,it2++)
2605 MCAuto<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
2606 elt->setLeaves((*it1).second);
2607 MCAuto<MEDFileFieldPerMeshPerTypeCommon> elt2(DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(elt));
2610 _field_pm_pt=fieldPmPt;
2613 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2615 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2616 (*it)->changePflsRefsNamesGen(mapOfModif);
2619 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2621 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2622 (*it)->changeLocsRefsNamesGen(mapOfModif);
2626 * \param [in] mesh is the whole mesh
2628 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2630 if(_field_pm_pt.empty())
2631 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2633 std::vector< std::pair<int,int> > dads;
2634 std::vector<const DataArrayInt *> pfls;
2635 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2636 std::vector<int> locs,code;
2637 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2638 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2639 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2641 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2644 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2645 throw INTERP_KERNEL::Exception(oss.str());
2648 std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2649 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2652 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2654 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2657 MCAuto<DataArrayInt> arr2(arr);
2658 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2664 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2668 if(nb!=mesh->getNumberOfNodes())
2670 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2671 oss << " nodes in mesh !";
2672 throw INTERP_KERNEL::Exception(oss.str());
2674 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2677 return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2681 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
2683 if(_field_pm_pt.empty())
2684 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2686 std::vector<std::pair<int,int> > dads;
2687 std::vector<const DataArrayInt *> pfls;
2688 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2689 std::vector<int> locs,code;
2690 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2691 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2692 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2694 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2697 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2698 throw INTERP_KERNEL::Exception(oss.str());
2700 std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2701 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2704 MCAuto<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2705 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2710 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2714 if(nb!=mesh->getNumberOfNodes())
2716 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2717 oss << " nodes in mesh !";
2718 throw INTERP_KERNEL::Exception(oss.str());
2721 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2727 void MEDFileFieldPerMesh::accept(MEDFileFieldVisitor& visitor) const
2729 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2730 if((*it).isNotNull())
2732 visitor.newPerMeshPerTypeEntry(*it);
2733 (*it)->accept(visitor);
2734 visitor.endPerMeshPerTypeEntry(*it);
2738 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
2742 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2744 (*it)->getSizes(globalSz,nbOfEntries);
2746 entries.resize(nbOfEntries);
2748 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2750 (*it)->fillValues(nbOfEntries,entries);
2754 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
2756 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2758 if((*it)->getGeoType()==typ)
2759 return (*it)->getLeafGivenLocId(locId);
2761 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2762 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2763 oss << "Possiblities are : ";
2764 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2766 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2767 oss << "\"" << cm2.getRepr() << "\", ";
2769 throw INTERP_KERNEL::Exception(oss.str());
2772 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
2774 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2776 if((*it)->getGeoType()==typ)
2777 return (*it)->getLeafGivenLocId(locId);
2779 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2780 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2781 oss << "Possiblities are : ";
2782 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2784 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2785 oss << "\"" << cm2.getRepr() << "\", ";
2787 throw INTERP_KERNEL::Exception(oss.str());
2791 * \param [in,out] start - Integer that gives the current position in the final aggregated array
2792 * \param [in] pms - list of elements to aggregate. integer gives the mesh id
2793 * \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.
2794 * \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.
2796 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)
2798 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret(new MEDFileFieldPerMeshPerTypePerDisc(father,tof));
2800 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : empty input vector !");
2801 for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it=pms.begin();it!=pms.end();it++)
2804 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : presence of null pointer !");
2805 if(!(*it).second->getProfile().empty())
2806 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for profiles !");
2807 if(!(*it).second->getLocalization().empty())
2808 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for gauss pts !");
2810 INTERP_KERNEL::NormalizedCellType gt(pms[0].second->getGeoType());
2812 std::vector< std::pair<int,int> > filteredDTS;
2813 for(std::vector< std::vector< std::pair<int,int> > >::const_iterator it=dts.begin();it!=dts.end();it++,i++)
2814 for(std::vector< std::pair<int,int> >::const_iterator it2=(*it).begin();it2!=(*it).end();it2++)
2815 if((*it2).first==gt)
2816 filteredDTS.push_back(std::pair<int,int>(i,(*it2).second));
2817 if(pms.size()!=filteredDTS.size())
2818 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles !");
2819 std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it1(pms.begin());
2820 std::vector< std::pair<int,int> >::const_iterator it2(filteredDTS.begin());
2821 int zeStart(start),nval(0);
2822 for(;it1!=pms.end();it1++,it2++)
2824 if((*it1).first!=(*it2).first)
2825 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles 2 !");
2826 int s1((*it1).second->getStart()),e1((*it1).second->getEnd());
2827 extractInfo.push_back(std::pair<int, std::pair<int,int> >((*it1).first,std::pair<int,int>(s1,e1)));
2829 nval+=((*it1).second)->getNumberOfVals();
2831 ret->_start=zeStart; ret->_end=start; ret->_nval=nval;
2835 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)
2837 MCAuto<MEDFileFieldPerMesh> ret(new MEDFileFieldPerMesh(father,pms[0]->getMeshName(),pms[0]->getMeshIteration(),pms[0]->getMeshOrder()));
2838 std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > > m;
2840 for(std::vector<const MEDFileFieldPerMesh *>::const_iterator it=pms.begin();it!=pms.end();it++,i++)
2842 const std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >& v((*it)->_field_pm_pt);
2843 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it2=v.begin();it2!=v.end();it2++)
2845 INTERP_KERNEL::NormalizedCellType gt((*it2)->getGeoType());
2846 const MEDFileFieldPerMeshPerType *elt(dynamic_cast<const MEDFileFieldPerMeshPerType *>((const MEDFileFieldPerMeshPerTypeCommon *)(*it2)));
2848 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::Aggregate : not managed for structelement !");
2849 m[gt].push_back(std::pair<int,const MEDFileFieldPerMeshPerType *>(i,elt));
2852 for(std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > >::const_iterator it=m.begin();it!=m.end();it++)
2854 MCAuto<MEDFileFieldPerMeshPerType> agg(MEDFileFieldPerMeshPerType::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
2855 MCAuto<MEDFileFieldPerMeshPerTypeCommon> agg2(DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(agg));
2856 ret->_field_pm_pt.push_back(agg2);
2861 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2864 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2865 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it2=_field_pm_pt.begin();
2866 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2868 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2873 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2878 int ret=std::distance(_field_pm_pt.begin(),it2);
2879 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2884 * 'dads' and 'locs' input parameters have the same number of elements
2885 * \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
2887 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2888 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2889 const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2892 MCAuto<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2893 ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2894 MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2895 const std::vector<std::string>& infos=getInfo();
2896 da->setInfoOnComponents(infos);
2898 if(type==ON_GAUSS_PT)
2901 int nbOfArrs=dads.size();
2902 for(int i=0;i<nbOfArrs;i++)
2904 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2905 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2906 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2907 MCAuto<DataArrayInt> di=DataArrayInt::New();
2908 di->alloc(nbOfElems,1);
2910 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2911 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2920 * 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.
2921 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2922 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2923 * The order of cells in the returned field is those imposed by the profile.
2924 * \param [in] mesh is the global mesh.
2926 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2927 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2928 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2929 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2931 if(da->isIota(mesh->getNumberOfCells()))
2932 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2933 MCAuto<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2934 m2->setName(mesh->getName().c_str());
2935 MCAuto<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2941 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2943 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2944 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2945 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2947 if(da->isIota(mesh->getNumberOfNodes()))
2948 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2949 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2950 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2953 if(meshu->getNodalConnectivity()==0)
2955 MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2956 int nb=da->getNbOfElems();
2957 const int *ptr=da->getConstPointer();
2958 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2959 meshuc->allocateCells(nb);
2960 for(int i=0;i<nb;i++)
2961 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2962 meshuc->finishInsertingCells();
2963 ret->setMesh(meshuc);
2964 const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2965 if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2966 disc->checkCoherencyBetween(meshuc,arrOut);
2971 MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2973 DataArrayInt *arr2=0;
2974 MCAuto<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2975 MCAuto<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2976 MCAuto<DataArrayInt> arr3(arr2);
2977 int nnodes=mesh2->getNumberOfNodes();
2978 if(nnodes==(int)da->getNbOfElems())
2980 MCAuto<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2981 arrOut->renumberInPlace(da3->getConstPointer());
2982 mesh2->setName(mesh->getName().c_str());
2983 ret->setMesh(mesh2);
2988 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 !!!";
2989 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2990 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2991 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2992 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2993 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2994 throw INTERP_KERNEL::Exception(oss.str());
3000 * This method is the most light method of field retrieving.
3002 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
3006 pflOut=DataArrayInt::New();
3007 pflOut->alloc(nbOfElems,1);
3012 pflOut=const_cast<DataArrayInt*>(pflIn);
3015 MCAuto<DataArrayInt> safePfl(pflOut);
3016 MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
3017 const std::vector<std::string>& infos=getInfo();
3018 int nbOfComp=infos.size();
3019 for(int i=0;i<nbOfComp;i++)
3020 da->setInfoOnComponent(i,infos[i].c_str());
3031 static MFFPMIter *NewCell(const MEDFileEntities *entities);
3032 static bool IsPresenceOfNode(const MEDFileEntities *entities);
3033 virtual ~MFFPMIter() { }
3034 virtual void begin() = 0;
3035 virtual bool finished() const = 0;
3036 virtual void next() = 0;
3037 virtual int current() const = 0;
3040 class MFFPMIterSimple : public MFFPMIter
3043 MFFPMIterSimple():_pos(0) { }
3044 void begin() { _pos=0; }
3045 bool finished() const { return _pos>=MED_N_CELL_FIXED_GEO; }
3046 void next() { _pos++; }
3047 int current() const { return _pos; }
3052 class MFFPMIter2 : public MFFPMIter
3055 MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts);
3056 void begin() { _it=_ids.begin(); }
3057 bool finished() const { return _it==_ids.end(); }
3058 void next() { _it++; }
3059 int current() const { return *_it; }
3061 std::vector<int> _ids;
3062 std::vector<int>::const_iterator _it;
3065 MFFPMIter *MFFPMIter::NewCell(const MEDFileEntities *entities)
3068 return new MFFPMIterSimple;
3071 const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
3074 std::vector<INTERP_KERNEL::NormalizedCellType> tmp;
3075 const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
3076 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
3078 if((*it).first==ON_CELLS || (*it).first==ON_GAUSS_NE || (*it).first==ON_GAUSS_PT)
3079 tmp.push_back((*it).second);
3081 return new MFFPMIter2(tmp);
3083 return new MFFPMIterSimple;// for MEDFileAllStaticEntites and MEDFileAllStaticEntitiesPlusDyn cells are in
3087 bool MFFPMIter::IsPresenceOfNode(const MEDFileEntities *entities)
3093 const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
3096 const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
3097 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
3098 if((*it).first==ON_NODES)
3102 return true;// for MEDFileAllStaticEntites and MEDFileAllStaticEntitiesPlusDyn nodes are in
3106 MFFPMIter2::MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts)
3108 std::size_t sz(cts.size());
3110 for(std::size_t i=0;i<sz;i++)
3112 INTERP_KERNEL::NormalizedCellType *loc(std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,cts[i]));
3113 if(loc!=typmai2+MED_N_CELL_FIXED_GEO)
3114 _ids[i]=(int)std::distance(typmai2,loc);
3116 throw INTERP_KERNEL::Exception("MFFPMIter2 : The specified geo type does not exists !");
3122 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),
3125 INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
3126 INTERP_KERNEL::AutoPtr<char> pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
3127 INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
3128 const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
3129 INTERP_KERNEL::AutoCppPtr<MFFPMIter> iter0(MFFPMIter::NewCell(entities));
3130 for(iter0->begin();!iter0->finished();iter0->next())
3132 int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL ,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
3133 std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
3134 int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
3135 std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
3136 if(nbProfile>0 || nbProfile2>0)
3138 const PartDefinition *pd(0);
3140 pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[iter0->current()]),typmai2[iter0->current()]);
3141 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nasc,pd));
3148 if(MFFPMIter::IsPresenceOfNode(entities))
3150 int nbProfile(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName));
3153 const PartDefinition *pd(0);
3155 pd=mmu->getPartDefAtLevel(1,INTERP_KERNEL::NORM_ERROR);
3156 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd));
3157 setMeshName(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE));
3162 std::vector<int> dynGT(entities->getDynGTAvail());
3163 for(std::vector<int>::const_iterator it=dynGT.begin();it!=dynGT.end();it++)
3165 int nbPfl(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,*it,pflName,locName));
3168 _field_pm_pt.push_back(MEDFileFieldPerMeshPerTypeDyn::NewOnRead(fid,this,entities,*it,nasc));
3169 setMeshName(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE));
3172 if(!_field_pm_pt.empty())
3174 //for vicious users using MED_ARETE MED_FACE in fields. the last try. For Others not overhead to pay.
3175 iter0=MFFPMIter::NewCell(entities);
3176 for(iter0->begin();!iter0->finished();iter0->next())
3178 int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_DESCENDING_FACE,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
3179 std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
3180 int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_DESCENDING_EDGE,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
3181 std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
3182 if(nbProfile>0 || nbProfile2>0)
3184 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nasc,NULL));
3193 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
3195 copyTinyInfoFrom(mesh);
3198 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3200 if(id>=(int)_pfls.size())
3202 _pfls[id]=DataArrayInt::New();
3203 int lgth(MEDprofileSizeByName(fid,pflName.c_str()));
3204 _pfls[id]->setName(pflName);
3205 _pfls[id]->alloc(lgth,1);
3206 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName.c_str(),_pfls[id]->getPointer()));
3207 _pfls[id]->applyLin(1,-1,0);//Converting into C format
3210 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
3212 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
3214 MEDFILESAFECALLERRD0(MEDprofileInfo,(fid,i+1,pflName,&sz));
3215 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
3216 if(i>=(int)_pfls.size())
3218 _pfls[i]=DataArrayInt::New();
3219 _pfls[i]->alloc(sz,1);
3220 _pfls[i]->setName(pflCpp.c_str());
3221 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName,_pfls[i]->getPointer()));
3222 _pfls[i]->applyLin(1,-1,0);//Converting into C format
3225 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3227 int nbOfPfls=_pfls.size();
3228 for(int i=0;i<nbOfPfls;i++)
3230 MCAuto<DataArrayInt> cpy=_pfls[i]->deepCopy();
3231 cpy->applyLin(1,1,0);
3232 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
3233 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
3234 MEDFILESAFECALLERWR0(MEDprofileWr,(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer()));
3237 int nbOfLocs=_locs.size();
3238 for(int i=0;i<nbOfLocs;i++)
3239 _locs[i]->writeLL(fid);
3242 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
3244 std::vector<std::string> pfls=getPfls();
3245 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
3247 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
3250 _pfls.push_back(*it);
3254 int id=std::distance(pfls.begin(),it2);
3255 if(!(*it)->isEqual(*_pfls[id]))
3257 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
3258 throw INTERP_KERNEL::Exception(oss.str());
3262 std::vector<std::string> locs=getLocs();
3263 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
3265 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
3268 _locs.push_back(*it);
3272 int id=std::distance(locs.begin(),it2);
3273 if(!(*it)->isEqual(*_locs[id],eps))
3275 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
3276 throw INTERP_KERNEL::Exception(oss.str());
3282 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
3284 for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
3285 getProfile((*it).c_str());
3288 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
3290 for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
3291 getLocalization((*it).c_str());
3294 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
3296 std::vector<std::string> profiles=real.getPflsReallyUsed();
3297 int sz=profiles.size();
3299 for(int i=0;i<sz;i++)
3300 loadProfileInFile(fid,i,profiles[i].c_str());
3302 std::vector<std::string> locs=real.getLocsReallyUsed();
3305 for(int i=0;i<sz;i++)
3306 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
3309 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid, const MEDFileEntities *entities)
3311 int nProfil=MEDnProfile(fid);
3312 for(int i=0;i<nProfil;i++)
3313 loadProfileInFile(fid,i);
3314 int sz=MEDnLocalization(fid);
3316 for(int i=0;i<sz;i++)
3318 _locs[i]=MEDFileFieldLoc::New(fid,i,entities);
3322 MEDFileFieldGlobs *MEDFileFieldGlobs::New(med_idt fid)
3324 return new MEDFileFieldGlobs(fid);
3327 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
3329 return new MEDFileFieldGlobs;
3332 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
3334 return _file_name.capacity()+_pfls.capacity()*sizeof(MCAuto<DataArrayInt>)+_locs.capacity()*sizeof(MCAuto<MEDFileFieldLoc>);
3337 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildrenWithNull() const
3339 std::vector<const BigMemoryObject *> ret;
3340 for(std::vector< MCAuto< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3341 ret.push_back((const DataArrayInt *)*it);
3342 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3343 ret.push_back((const MEDFileFieldLoc *)*it);
3347 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCopy() const
3349 MCAuto<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
3351 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3353 if((const DataArrayInt *)*it)
3354 ret->_pfls[i]=(*it)->deepCopy();
3357 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3359 if((const MEDFileFieldLoc*)*it)
3360 ret->_locs[i]=(*it)->deepCopy();
3366 * \throw if a profile in \a pfls in not in \a this.
3367 * \throw if a localization in \a locs in not in \a this.
3368 * \sa MEDFileFieldGlobs::deepCpyPart
3370 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
3372 MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
3373 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
3375 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
3377 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
3379 MCAuto<DataArrayInt> pfl2(pfl);
3380 ret->_pfls.push_back(pfl2);
3382 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
3384 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
3386 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
3388 MCAuto<MEDFileFieldLoc> loc2(loc);
3389 ret->_locs.push_back(loc2);
3391 ret->setFileName(getFileName());
3396 * \throw if a profile in \a pfls in not in \a this.
3397 * \throw if a localization in \a locs in not in \a this.
3398 * \sa MEDFileFieldGlobs::shallowCpyPart
3400 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
3402 MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
3403 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
3405 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
3407 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
3408 ret->_pfls.push_back(pfl->deepCopy());
3410 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
3412 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
3414 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
3415 ret->_locs.push_back(loc->deepCopy());
3417 ret->setFileName(getFileName());
3421 MEDFileFieldGlobs::MEDFileFieldGlobs(med_idt fid):_file_name(MEDFileWritable::FileNameFromFID(fid))
3425 MEDFileFieldGlobs::MEDFileFieldGlobs()
3429 MEDFileFieldGlobs::~MEDFileFieldGlobs()
3433 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
3435 oss << "Profiles :\n";
3436 std::size_t n=_pfls.size();
3437 for(std::size_t i=0;i<n;i++)
3439 oss << " - #" << i << " ";
3440 const DataArrayInt *pfl=_pfls[i];
3442 oss << "\"" << pfl->getName() << "\"\n";
3447 oss << "Localizations :\n";
3448 for(std::size_t i=0;i<n;i++)
3450 oss << " - #" << i << " ";
3451 const MEDFileFieldLoc *loc=_locs[i];
3453 loc->simpleRepr(oss);
3459 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3461 for(std::vector< MCAuto<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
3463 DataArrayInt *elt(*it);
3466 std::string name(elt->getName());
3467 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3469 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3471 elt->setName((*it2).second.c_str());
3479 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3481 for(std::vector< MCAuto<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
3483 MEDFileFieldLoc *elt(*it);
3486 std::string name(elt->getName());
3487 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3489 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3491 elt->setName((*it2).second.c_str());
3499 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
3501 if(locId<0 || locId>=(int)_locs.size())
3502 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
3503 return _locs[locId]->getNbOfGaussPtPerCell();
3506 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
3508 return getLocalizationFromId(getLocalizationId(locName));
3511 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
3513 if(locId<0 || locId>=(int)_locs.size())
3514 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3515 return *_locs[locId];
3519 namespace MEDCouplingImpl
3524 LocFinder(const std::string& loc):_loc(loc) { }
3525 bool operator() (const MCAuto<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
3527 const std::string &_loc;
3533 PflFinder(const std::string& pfl):_pfl(pfl) { }
3534 bool operator() (const MCAuto<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
3536 const std::string& _pfl;
3541 int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
3543 std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),MEDCouplingImpl::LocFinder(loc));
3546 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
3547 for(it=_locs.begin();it!=_locs.end();it++)
3548 oss << "\"" << (*it)->getName() << "\", ";
3549 throw INTERP_KERNEL::Exception(oss.str());
3551 return std::distance(_locs.begin(),it);
3555 * The returned value is never null.
3557 const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
3559 std::string pflNameCpp(pflName);
3560 std::vector< MCAuto<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3563 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3564 for(it=_pfls.begin();it!=_pfls.end();it++)
3565 oss << "\"" << (*it)->getName() << "\", ";
3566 throw INTERP_KERNEL::Exception(oss.str());
3571 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
3573 if(pflId<0 || pflId>=(int)_pfls.size())
3574 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3575 return _pfls[pflId];
3578 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
3580 if(locId<0 || locId>=(int)_locs.size())
3581 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3582 return *_locs[locId];
3585 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
3587 return getLocalizationFromId(getLocalizationId(locName));
3591 * The returned value is never null.
3593 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
3595 std::string pflNameCpp(pflName);
3596 std::vector< MCAuto<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3599 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3600 for(it=_pfls.begin();it!=_pfls.end();it++)
3601 oss << "\"" << (*it)->getName() << "\", ";
3602 throw INTERP_KERNEL::Exception(oss.str());
3607 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
3609 if(pflId<0 || pflId>=(int)_pfls.size())
3610 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3611 return _pfls[pflId];
3614 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
3616 std::vector< MCAuto<DataArrayInt> > newPfls;
3618 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3620 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
3621 newPfls.push_back(*it);
3626 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
3628 std::vector< MCAuto<MEDFileFieldLoc> > newLocs;
3630 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3632 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
3633 newLocs.push_back(*it);
3638 void MEDFileFieldGlobs::killStructureElementsInGlobs()
3640 std::vector< MCAuto<MEDFileFieldLoc> > newLocs;
3641 for(std::vector< MCAuto<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
3645 if(!(*it)->isOnStructureElement())
3646 newLocs.push_back(*it);
3651 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
3653 int sz=_pfls.size();
3654 std::vector<std::string> ret(sz);
3655 for(int i=0;i<sz;i++)
3656 ret[i]=_pfls[i]->getName();
3660 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
3662 int sz=_locs.size();
3663 std::vector<std::string> ret(sz);
3664 for(int i=0;i<sz;i++)
3665 ret[i]=_locs[i]->getName();
3669 bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
3671 std::vector<std::string> v=getPfls();
3672 std::string s(pflName);
3673 return std::find(v.begin(),v.end(),s)!=v.end();
3676 bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
3678 std::vector<std::string> v=getLocs();
3679 std::string s(locName);
3680 return std::find(v.begin(),v.end(),s)!=v.end();
3683 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
3685 std::map<int,std::vector<int> > m;
3687 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3689 const DataArrayInt *tmp=(*it);
3692 m[tmp->getHashCode()].push_back(i);
3695 std::vector< std::vector<int> > ret;
3696 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
3698 if((*it2).second.size()>1)
3700 std::vector<int> ret0;
3701 bool equalityOrNot=false;
3702 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
3704 std::vector<int>::const_iterator it4=it3; it4++;
3705 for(;it4!=(*it2).second.end();it4++)
3707 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
3710 ret0.push_back(*it3);
3711 ret0.push_back(*it4);
3717 ret.push_back(ret0);
3723 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
3725 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
3728 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
3730 std::string name(pfl->getName());
3732 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
3733 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3734 if(name==(*it)->getName())
3736 if(!pfl->isEqual(*(*it)))
3738 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
3739 throw INTERP_KERNEL::Exception(oss.str());
3743 _pfls.push_back(pfl);
3746 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)
3748 std::string name(locName);
3750 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
3751 MCAuto<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
3752 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3753 if((*it)->isName(locName))
3755 if(!(*it)->isEqual(*obj,1e-12))
3757 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
3758 throw INTERP_KERNEL::Exception(oss.str());
3761 _locs.push_back(obj);
3764 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
3766 std::vector<std::string> names=getPfls();
3767 return CreateNewNameNotIn("NewPfl_",names);
3770 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
3772 std::vector<std::string> names=getLocs();
3773 return CreateNewNameNotIn("NewLoc_",names);
3776 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
3778 for(std::size_t sz=0;sz<100000;sz++)
3780 std::ostringstream tryName;
3781 tryName << prefix << sz;
3782 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
3783 return tryName.str();
3785 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
3789 * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
3790 * \param [in] fname - the file name.
3792 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(med_idt fid):_globals(MEDFileFieldGlobs::New(fid))
3797 * Creates an empty MEDFileFieldGlobsReal.
3799 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
3803 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
3808 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildrenWithNull() const
3810 std::vector<const BigMemoryObject *> ret;
3811 ret.push_back((const MEDFileFieldGlobs *)_globals);
3816 * Returns a string describing profiles and Gauss points held in \a this.
3817 * \return std::string - the description string.
3819 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
3821 const MEDFileFieldGlobs *glob=_globals;
3822 std::ostringstream oss2; oss2 << glob;
3823 std::string stars(oss2.str().length(),'*');
3824 oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n";
3826 glob->simpleRepr(oss);
3828 oss << "NO GLOBAL INFORMATION !\n";
3831 void MEDFileFieldGlobsReal::resetContent()
3833 _globals=MEDFileFieldGlobs::New();
3836 void MEDFileFieldGlobsReal::killStructureElementsInGlobs()
3838 contentNotNull()->killStructureElementsInGlobs();
3841 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
3846 * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
3847 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3849 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3851 _globals=other._globals;
3855 * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3856 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3858 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3860 const MEDFileFieldGlobs *otherg(other._globals);
3863 _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3867 * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3868 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3870 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3872 const MEDFileFieldGlobs *otherg(other._globals);
3875 _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3878 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3880 _globals=other._globals;
3881 if((const MEDFileFieldGlobs *)_globals)
3882 _globals=other._globals->deepCopy();
3886 * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3887 * \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3888 * \param [in] eps - a precision used to compare Gauss points with same name held by
3889 * \a this and \a other MEDFileFieldGlobsReal.
3890 * \throw If \a this and \a other hold profiles with equal names but different ids.
3891 * \throw If \a this and \a other hold different Gauss points with equal names.
3893 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
3895 const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3896 if(thisGlobals==otherGlobals)
3900 _globals=other._globals;
3903 _globals->appendGlobs(*other._globals,eps);
3906 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
3908 checkGlobsPflsPartCoherency();
3909 checkGlobsLocsPartCoherency();
3912 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
3914 contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3917 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
3919 contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3922 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3924 contentNotNull()->loadProfileInFile(fid,id,pflName);
3927 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3929 contentNotNull()->loadProfileInFile(fid,id);
3932 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
3934 contentNotNull()->loadGlobals(fid,*this);
3937 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid, const MEDFileEntities *entities)
3939 contentNotNull()->loadAllGlobals(fid,entities);
3942 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3944 contentNotNull()->writeGlobals(fid,opt);
3948 * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3949 * or getPflsReallyUsedMulti().
3950 * \return std::vector<std::string> - a sequence of names of all profiles.
3952 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3954 return contentNotNull()->getPfls();
3958 * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3959 * or getLocsReallyUsedMulti().
3960 * \return std::vector<std::string> - a sequence of names of all localizations.
3962 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3964 return contentNotNull()->getLocs();
3968 * Checks if the profile with a given name exists.
3969 * \param [in] pflName - the profile name of interest.
3970 * \return bool - \c true if the profile named \a pflName exists.
3972 bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
3974 return contentNotNull()->existsPfl(pflName);
3978 * Checks if the localization with a given name exists.
3979 * \param [in] locName - the localization name of interest.
3980 * \return bool - \c true if the localization named \a locName exists.
3982 bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
3984 return contentNotNull()->existsLoc(locName);
3987 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
3989 return contentNotNull()->createNewNameOfPfl();
3992 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
3994 return contentNotNull()->createNewNameOfLoc();
3998 * Sets the name of a MED file.
3999 * \param [inout] fileName - the file name.
4001 void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
4003 contentNotNull()->setFileName(fileName);
4007 * Finds equal profiles. Two profiles are considered equal if they contain the same ids
4008 * in the same order.
4009 * \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
4010 * Each item of this sequence is a vector containing ids of equal profiles.
4012 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
4014 return contentNotNull()->whichAreEqualProfiles();
4018 * Finds equal localizations.
4019 * \param [in] eps - a precision used to compare real values of the localizations.
4020 * \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
4021 * Each item of this sequence is a vector containing ids of equal localizations.
4023 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
4025 return contentNotNull()->whichAreEqualLocs(eps);
4029 * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
4030 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
4031 * this sequence is a pair whose
4032 * - the first item is a vector of profile names to replace by the second item,
4033 * - the second item is a profile name to replace every profile name of the first item.
4035 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4037 contentNotNull()->changePflsNamesInStruct(mapOfModif);
4041 * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
4042 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
4043 * this sequence is a pair whose
4044 * - the first item is a vector of localization names to replace by the second item,
4045 * - the second item is a localization name to replace every localization name of the first item.
4047 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4049 contentNotNull()->changeLocsNamesInStruct(mapOfModif);
4053 * Replaces references to some profiles (a reference is a profile name) by references
4054 * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
4055 * them-selves accordingly. <br>
4056 * This method is a generalization of changePflName().
4057 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
4058 * this sequence is a pair whose
4059 * - the first item is a vector of profile names to replace by the second item,
4060 * - the second item is a profile name to replace every profile of the first item.
4061 * \sa changePflsRefsNamesGen()
4062 * \sa changePflName()
4064 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4066 changePflsRefsNamesGen(mapOfModif);
4067 changePflsNamesInStruct(mapOfModif);
4071 * Replaces references to some localizations (a reference is a localization name) by references
4072 * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
4073 * them-selves accordingly. <br>
4074 * This method is a generalization of changeLocName().
4075 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
4076 * this sequence is a pair whose
4077 * - the first item is a vector of localization names to replace by the second item,
4078 * - the second item is a localization name to replace every localization of the first item.
4079 * \sa changeLocsRefsNamesGen()
4080 * \sa changeLocName()
4082 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4084 changeLocsRefsNamesGen(mapOfModif);
4085 changeLocsNamesInStruct(mapOfModif);
4089 * Renames the profile having a given name and updates references to this profile.
4090 * \param [in] oldName - the name of the profile to rename.
4091 * \param [in] newName - a new name of the profile.
4092 * \sa changePflsNames().
4094 void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
4096 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
4097 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
4099 changePflsNames(mapOfModif);
4103 * Renames the localization having a given name and updates references to this localization.
4104 * \param [in] oldName - the name of the localization to rename.
4105 * \param [in] newName - a new name of the localization.
4106 * \sa changeLocsNames().
4108 void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
4110 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
4111 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
4113 changeLocsNames(mapOfModif);
4117 * Removes duplicated profiles. Returns a map used to update references to removed
4118 * profiles via changePflsRefsNamesGen().
4119 * Equal profiles are found using whichAreEqualProfiles().
4120 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
4121 * a sequence describing the performed replacements of profiles. Each element of
4122 * this sequence is a pair whose
4123 * - the first item is a vector of profile names replaced by the second item,
4124 * - the second item is a profile name replacing every profile of the first item.
4126 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
4128 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
4129 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
4131 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
4133 std::vector< std::string > tmp((*it).size());
4135 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
4136 tmp[j]=std::string(getProfileFromId(*it2)->getName());
4137 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
4139 std::vector<int> tmp2((*it).begin()+1,(*it).end());
4140 killProfileIds(tmp2);
4142 changePflsRefsNamesGen(ret);
4147 * Removes duplicated localizations. Returns a map used to update references to removed
4148 * localizations via changeLocsRefsNamesGen().
4149 * Equal localizations are found using whichAreEqualLocs().
4150 * \param [in] eps - a precision used to compare real values of the localizations.
4151 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
4152 * a sequence describing the performed replacements of localizations. Each element of
4153 * this sequence is a pair whose
4154 * - the first item is a vector of localization names replaced by the second item,
4155 * - the second item is a localization name replacing every localization of the first item.
4157 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
4159 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
4160 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
4162 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
4164 std::vector< std::string > tmp((*it).size());
4166 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
4167 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
4168 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
4170 std::vector<int> tmp2((*it).begin()+1,(*it).end());
4171 killLocalizationIds(tmp2);
4173 changeLocsRefsNamesGen(ret);
4178 * Returns number of Gauss points per cell in a given localization.
4179 * \param [in] locId - an id of the localization of interest.
4180 * \return int - the number of the Gauss points per cell.
4182 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
4184 return contentNotNull()->getNbOfGaussPtPerCell(locId);
4188 * Returns an id of a localization by its name.
4189 * \param [in] loc - the localization name of interest.
4190 * \return int - the id of the localization.
4191 * \throw If there is no a localization named \a loc.
4193 int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
4195 return contentNotNull()->getLocalizationId(loc);
4199 * Returns the name of the MED file.
4200 * \return const std::string& - the MED file name.
4202 std::string MEDFileFieldGlobsReal::getFileName() const
4204 return contentNotNull()->getFileName();
4208 * Returns a localization object by its name.
4209 * \param [in] locName - the name of the localization of interest.
4210 * \return const MEDFileFieldLoc& - the localization object having the name \a locName.
4211 * \throw If there is no a localization named \a locName.
4213 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
4215 return contentNotNull()->getLocalization(locName);
4219 * Returns a localization object by its id.
4220 * \param [in] locId - the id of the localization of interest.
4221 * \return const MEDFileFieldLoc& - the localization object having the id \a locId.
4222 * \throw If there is no a localization with id \a locId.
4224 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
4226 return contentNotNull()->getLocalizationFromId(locId);
4230 * Returns a profile array by its name.
4231 * \param [in] pflName - the name of the profile of interest.
4232 * \return const DataArrayInt * - the profile array having the name \a pflName.
4233 * \throw If there is no a profile named \a pflName.
4235 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
4237 return contentNotNull()->getProfile(pflName);
4241 * Returns a profile array by its id.
4242 * \param [in] pflId - the id of the profile of interest.
4243 * \return const DataArrayInt * - the profile array having the id \a pflId.
4244 * \throw If there is no a profile with id \a pflId.
4246 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
4248 return contentNotNull()->getProfileFromId(pflId);
4252 * Returns a localization object, apt for modification, by its id.
4253 * \param [in] locId - the id of the localization of interest.
4254 * \return MEDFileFieldLoc& - a non-const reference to the localization object
4255 * having the id \a locId.
4256 * \throw If there is no a localization with id \a locId.
4258 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
4260 return contentNotNull()->getLocalizationFromId(locId);
4264 * Returns a localization object, apt for modification, by its name.
4265 * \param [in] locName - the name of the localization of interest.
4266 * \return MEDFileFieldLoc& - a non-const reference to the localization object
4267 * having the name \a locName.
4268 * \throw If there is no a localization named \a locName.
4270 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
4272 return contentNotNull()->getLocalization(locName);
4276 * Returns a profile array, apt for modification, by its name.
4277 * \param [in] pflName - the name of the profile of interest.
4278 * \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
4279 * \throw If there is no a profile named \a pflName.
4281 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
4283 return contentNotNull()->getProfile(pflName);
4287 * Returns a profile array, apt for modification, by its id.
4288 * \param [in] pflId - the id of the profile of interest.
4289 * \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
4290 * \throw If there is no a profile with id \a pflId.
4292 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
4294 return contentNotNull()->getProfileFromId(pflId);
4298 * Removes profiles given by their ids. No data is updated to track this removal.
4299 * \param [in] pflIds - a sequence of ids of the profiles to remove.
4301 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
4303 contentNotNull()->killProfileIds(pflIds);
4307 * Removes localizations given by their ids. No data is updated to track this removal.
4308 * \param [in] locIds - a sequence of ids of the localizations to remove.
4310 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
4312 contentNotNull()->killLocalizationIds(locIds);
4316 * Stores a profile array.
4317 * \param [in] pfl - the profile array to store.
4318 * \throw If the name of \a pfl is empty.
4319 * \throw If a profile with the same name as that of \a pfl already exists but contains
4322 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
4324 contentNotNull()->appendProfile(pfl);
4328 * Adds a new localization of Gauss points.
4329 * \param [in] locName - the name of the new localization.
4330 * \param [in] geoType - a geometrical type of the reference cell.
4331 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
4332 * must be \c nbOfNodesPerCell * \c dimOfType.
4333 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
4334 * must be _wg_.size() * \c dimOfType.
4335 * \param [in] w - the weights of Gauss points.
4336 * \throw If \a locName is empty.
4337 * \throw If a localization with the name \a locName already exists but is
4338 * different form the new one.
4340 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)
4342 contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
4345 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
4347 MEDFileFieldGlobs *g(_globals);
4349 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
4353 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
4355 const MEDFileFieldGlobs *g(_globals);
4357 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
4361 //= MEDFileFieldNameScope
4363 MEDFileFieldNameScope::MEDFileFieldNameScope()
4367 MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName, const std::string& meshName):_name(fieldName),_mesh_name(meshName)
4372 * Returns the name of \a this field.
4373 * \return std::string - a string containing the field name.
4375 std::string MEDFileFieldNameScope::getName() const
4381 * Sets name of \a this field
4382 * \param [in] name - the new field name.
4384 void MEDFileFieldNameScope::setName(const std::string& fieldName)
4389 std::string MEDFileFieldNameScope::getDtUnit() const
4394 void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
4399 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
4402 _mesh_name=other._mesh_name;
4403 _dt_unit=other._dt_unit;
4407 * Returns the mesh name.
4408 * \return std::string - a string holding the mesh name.
4409 * \throw If \c _field_per_mesh.empty()
4411 std::string MEDFileFieldNameScope::getMeshName() const
4416 void MEDFileFieldNameScope::setMeshName(const std::string& meshName)
4418 _mesh_name=meshName;
4421 //= MEDFileAnyTypeField1TSWithoutSDA
4423 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
4425 _field_per_mesh.resize(other._field_per_mesh.size());
4427 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
4429 if((const MEDFileFieldPerMesh *)*it)
4430 _field_per_mesh[i]=(*it)->deepCopy(this);
4434 void MEDFileAnyTypeField1TSWithoutSDA::accept(MEDFileFieldVisitor& visitor) const
4436 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4437 if((*it).isNotNull())
4439 visitor.newMeshEntry(*it);
4440 (*it)->accept(visitor);
4441 visitor.endMeshEntry(*it);
4446 * Prints a string describing \a this field into a stream. This string is outputted
4447 * by \c print Python command.
4448 * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
4449 * \param [in,out] oss - the out stream.
4450 * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
4451 * info id printed, else, not.
4453 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
4455 std::string startOfLine(bkOffset,' ');
4456 oss << startOfLine << "Field ";
4458 oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
4459 oss << "on one time Step ";
4461 oss << "(" << f1tsId << ") ";
4462 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
4463 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
4464 const DataArray *arr=getUndergroundDataArray();
4467 const std::vector<std::string> &comps=arr->getInfoOnComponents();
4470 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
4471 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
4472 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
4474 if(arr->isAllocated())
4476 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
4479 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
4483 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
4485 oss << startOfLine << "----------------------" << std::endl;
4486 if(!_field_per_mesh.empty())
4489 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
4491 const MEDFileFieldPerMesh *cur=(*it2);
4493 cur->simpleRepr(bkOffset,oss,i);
4495 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
4500 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
4502 oss << startOfLine << "----------------------" << std::endl;
4505 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
4507 const DataArray *arr(getUndergroundDataArray());
4509 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
4510 int nbOfCompo=arr->getNumberOfComponents();
4511 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
4512 for(int i=0;i<nbOfCompo;i++)
4515 std::vector<int> v(1,i);
4516 MCAuto<DataArray> arr2=arr->keepSelectedComponents(v);
4517 ret[i]->setArray(arr2);
4522 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)
4526 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
4531 * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
4532 * empty. Returns -1 if this in on nodes.
4533 * \return int - the dimension of \a this.
4535 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
4538 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4539 (*it)->getDimension(ret);
4543 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
4546 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4548 MEDFileFieldPerMesh *cur(*it);
4550 ret=cur->changeMeshNames(modifTab) || ret;
4556 * Returns the number of iteration of the state of underlying mesh.
4557 * \return int - the iteration number.
4558 * \throw If \c _field_per_mesh.empty()
4560 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
4562 if(_field_per_mesh.empty())
4563 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
4564 return _field_per_mesh[0]->getMeshIteration();
4568 * Returns the order number of iteration of the state of underlying mesh.
4569 * \return int - the order number.
4570 * \throw If \c _field_per_mesh.empty()
4572 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
4574 if(_field_per_mesh.empty())
4575 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
4576 return _field_per_mesh[0]->getMeshOrder();
4580 * Checks if \a this field is tagged by a given iteration number and a given
4581 * iteration order number.
4582 * \param [in] iteration - the iteration number of interest.
4583 * \param [in] order - the iteration order number of interest.
4584 * \return bool - \c true if \a this->getIteration() == \a iteration &&
4585 * \a this->getOrder() == \a order.
4587 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
4589 return iteration==_iteration && order==_order;
4593 * Returns number of iteration and order number of iteration when
4594 * \a this field has been calculated.
4595 * \return std::pair<int,int> - a pair of the iteration number and the iteration
4598 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
4600 std::pair<int,int> p;
4606 * Returns number of iteration and order number of iteration when
4607 * \a this field has been calculated.
4608 * \param [in,out] p - a pair returning the iteration number and the iteration
4611 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
4618 * Returns all types of spatial discretization of \a this field.
4619 * \param [in,out] types - a sequence of types of \a this field.
4621 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
4623 std::set<TypeOfField> types2;
4624 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4626 (*it)->fillTypesOfFieldAvailable(types2);
4628 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
4629 std::copy(types2.begin(),types2.end(),bi);
4633 * Returns all types of spatial discretization of \a this field.
4634 * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
4637 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
4639 std::vector<TypeOfField> ret;
4640 fillTypesOfFieldAvailable(ret);
4644 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
4646 std::vector<std::string> ret;
4647 std::set<std::string> ret2;
4648 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4650 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
4651 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4652 if(ret2.find(*it2)==ret2.end())
4654 ret.push_back(*it2);
4661 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
4663 std::vector<std::string> ret;
4664 std::set<std::string> ret2;
4665 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4667 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
4668 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4669 if(ret2.find(*it2)==ret2.end())
4671 ret.push_back(*it2);
4678 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
4680 std::vector<std::string> ret;
4681 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4683 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
4684 ret.insert(ret.end(),tmp.begin(),tmp.end());
4689 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
4691 std::vector<std::string> ret;
4692 std::set<std::string> ret2;
4693 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4695 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
4696 ret.insert(ret.end(),tmp.begin(),tmp.end());
4701 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4703 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4704 (*it)->changePflsRefsNamesGen(mapOfModif);
4707 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4709 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4710 (*it)->changeLocsRefsNamesGen(mapOfModif);
4714 * Returns all attributes of parts of \a this field lying on a given mesh.
4715 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4716 * item of every of returned sequences refers to the _i_-th part of \a this field.
4717 * Thus all sequences returned by this method are of the same length equal to number
4718 * of different types of supporting entities.<br>
4719 * A field part can include sub-parts with several different spatial discretizations,
4720 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
4721 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4722 * of a nested sequence corresponds to a type of spatial discretization.<br>
4723 * This method allows for iteration over MEDFile DataStructure without any overhead.
4724 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4725 * for the case with only one underlying mesh. (Actually, the number of meshes is
4726 * not checked if \a mname == \c NULL).
4727 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4728 * a field part is returned.
4729 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4730 * This sequence is of the same length as \a types.
4731 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4732 * discretization. A profile name can be empty.
4733 * Length of this and of nested sequences is the same as that of \a typesF.
4734 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4735 * discretization. A localization name can be empty.
4736 * Length of this and of nested sequences is the same as that of \a typesF.
4737 * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
4738 * of ids of tuples within the data array, per each type of spatial
4739 * discretization within one mesh entity type.
4740 * Length of this and of nested sequences is the same as that of \a typesF.
4741 * \throw If no field is lying on \a mname.
4743 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
4745 if(_field_per_mesh.empty())
4746 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4747 return _field_per_mesh[0]->getFieldSplitedByType(types,typesF,pfls,locs);
4751 * Returns dimensions of mesh elements \a this field lies on. The returned value is a
4752 * maximal absolute dimension and values returned via the out parameter \a levs are
4753 * dimensions relative to the maximal absolute dimension. <br>
4754 * This method is designed for MEDFileField1TS instances that have a discretization
4755 * \ref MEDCoupling::ON_CELLS "ON_CELLS",
4756 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT",
4757 * \ref MEDCoupling::ON_GAUSS_NE "ON_GAUSS_NE".
4758 * Only these 3 discretizations will be taken into account here. If \a this is
4759 * \ref MEDCoupling::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
4760 * This method is useful to make the link between the dimension of the underlying mesh
4761 * and the levels of \a this, because it is possible that the highest dimension of \a this
4762 * field is not equal to the dimension of the underlying mesh.
4764 * Let's consider the following case:
4765 * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
4766 * TETRA4, HEXA8, TRI3 and SEG2.
4767 * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
4768 * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
4770 * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
4771 * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
4772 * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
4773 * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
4774 * parameter of getFieldAtLevel() is computed basing on the returned values as this:
4775 * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
4777 * to retrieve the highest level of
4778 * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br>
4779 * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
4780 * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
4781 * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
4782 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4783 * for the case with only one underlying mesh. (Actually, the number of meshes is
4784 * not checked if \a mname == \c NULL).
4785 * \param [in,out] levs - a sequence returning the dimensions relative to the maximal
4786 * absolute one. They are in decreasing order. This sequence is cleared before
4788 * \return int - the maximal absolute dimension of elements \a this fields lies on.
4789 * \throw If no field is lying on \a mname.
4791 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
4794 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4795 std::vector< std::vector<TypeOfField> > typesF;
4796 std::vector< std::vector<std::string> > pfls, locs;
4797 if(_field_per_mesh.empty())
4798 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels : This is empty !");
4799 _field_per_mesh[0]->getFieldSplitedByType(types,typesF,pfls,locs);
4801 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
4802 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
4803 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
4805 st.erase(INTERP_KERNEL::NORM_ERROR);
4807 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
4809 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
4810 ret1.insert((int)cm.getDimension());
4812 int ret=*std::max_element(ret1.begin(),ret1.end());
4813 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
4814 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
4818 void MEDFileAnyTypeField1TSWithoutSDA::convertMedBallIntoClassic()
4820 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it<_field_per_mesh.end();it++)
4821 if((*it).isNotNull())
4822 (*it)->convertMedBallIntoClassic();
4825 void MEDFileAnyTypeField1TSWithoutSDA::makeReduction(INTERP_KERNEL::NormalizedCellType ct, TypeOfField tof, const DataArrayInt *pfl)
4828 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : null pfl !");
4829 std::string name(pfl->getName());
4830 pfl->checkAllocated();
4831 if(pfl->getNumberOfComponents()!=1)
4832 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : non mono compo array !");
4834 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : empty pfl name !");
4835 if(_field_per_mesh.size()!=1)
4836 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : only single mesh supported !");
4837 MCAuto<MEDFileFieldPerMesh> fpm(_field_per_mesh[0]);
4839 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : only single not null mesh supported !");
4840 MEDFileFieldPerMeshPerTypePerDisc *disc(fpm->getLeafGivenTypeAndLocId(ct,0));
4841 if(disc->getType()!=tof)
4842 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : error !");
4843 int s(disc->getStart()),e(disc->getEnd()),nt(pfl->getNumberOfTuples());
4844 DataArray *arr(getUndergroundDataArray());
4845 int nt2(arr->getNumberOfTuples()),delta((e-s)-nt);
4847 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : internal error !");
4848 MCAuto<DataArray> arr0(arr->selectByTupleIdSafeSlice(0,s,1)),arr1(arr->selectByTupleIdSafeSlice(s,e,1)),arr2(arr->selectByTupleIdSafeSlice(e,nt2,1));
4849 MCAuto<DataArray> arr11(arr1->selectByTupleIdSafe(pfl->begin(),pfl->end()));
4850 MCAuto<DataArray> arrOut(arr->buildNewEmptyInstance());
4851 arrOut->alloc(nt2-delta,arr->getNumberOfComponents());
4852 arrOut->copyStringInfoFrom(*arr);
4853 arrOut->setContigPartOfSelectedValuesSlice(0,arr0,0,s,1);
4854 arrOut->setContigPartOfSelectedValuesSlice(s,arr11,0,nt,1);
4855 arrOut->setContigPartOfSelectedValuesSlice(e-delta,arr2,0,nt2-e,1);
4857 disc->setEnd(e-delta);
4858 disc->setProfile(name);
4862 * \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.
4863 * \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.
4864 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4865 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4867 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
4869 if(_field_per_mesh.empty())
4870 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId : This is empty !");
4871 return _field_per_mesh[0]->getLeafGivenTypeAndLocId(typ,locId);
4875 * \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.
4876 * \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.
4877 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4878 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4880 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
4882 if(_field_per_mesh.empty())
4883 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId : This is empty !");
4884 return _field_per_mesh[0]->getLeafGivenTypeAndLocId(typ,locId);
4888 * \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.
4890 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
4892 if(_field_per_mesh.empty())
4893 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4896 std::string mName2(mName);
4898 std::vector<std::string> msg;
4899 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4900 if(mName2==(*it)->getMeshName())
4903 msg.push_back((*it)->getMeshName());
4904 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4905 oss << "Possible meshes are : ";
4906 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4907 oss << "\"" << (*it2) << "\" ";
4908 throw INTERP_KERNEL::Exception(oss.str());
4911 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
4914 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4915 std::string tmp(mesh->getName());
4917 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4919 std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4921 for(;it!=_field_per_mesh.end();it++,i++)
4923 if((*it)->getMeshName()==tmp)
4926 int sz=_field_per_mesh.size();
4927 _field_per_mesh.resize(sz+1);
4928 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4932 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4933 MEDFileFieldGlobsReal& glob)
4936 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4938 MEDFileFieldPerMesh *fpm(*it);
4940 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4946 * This method splits \a this into several sub-parts so that each sub parts have exactly one spatial discretization. This method implements the minimal
4947 * splitting that leads to single spatial discretization of this.
4949 * \sa splitMultiDiscrPerGeoTypes
4951 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
4953 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4954 std::vector< std::vector<TypeOfField> > typesF;
4955 std::vector< std::vector<std::string> > pfls,locs;
4956 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4957 std::set<TypeOfField> allEnt;
4958 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4959 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4960 allEnt.insert(*it2);
4961 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4962 std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4963 for(std::size_t i=0;i<allEnt.size();i++,it3++)
4965 std::vector< std::pair<int,int> > its;
4966 ret[i]=shallowCpy();
4967 int newLgth(ret[i]->keepOnlySpatialDiscretization(*it3,its));
4968 ret[i]->updateData(newLgth,its);
4974 * This method performs a sub splitting as splitDiscretizations does but finer. This is the finest spliting level that can be done.
4975 * This method implements the minimal splitting so that each returned elements are mono Gauss discretization per geometric type.
4977 * \sa splitDiscretizations
4979 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes() const
4981 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4982 std::vector< std::vector<TypeOfField> > typesF;
4983 std::vector< std::vector<std::string> > pfls,locs;
4984 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4985 std::set<TypeOfField> allEnt;
4986 std::size_t nbOfMDPGT(0),ii(0);
4987 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++,ii++)
4989 nbOfMDPGT=std::max(nbOfMDPGT,locs[ii].size());
4990 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4991 allEnt.insert(*it2);
4993 if(allEnt.size()!=1)
4994 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : this field is expected to be defined only on one spatial discretization !");
4996 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
4999 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret0(1);
5000 ret0[0]=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(this); this->incrRef();
5003 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfMDPGT);
5004 for(std::size_t i=0;i<nbOfMDPGT;i++)
5006 std::vector< std::pair<int,int> > its;
5007 ret[i]=shallowCpy();
5008 int newLgth(ret[i]->keepOnlyGaussDiscretization(i,its));
5009 ret[i]->updateData(newLgth,its);
5014 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
5016 int globalCounter(0);
5017 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5018 (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
5019 return globalCounter;
5022 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlyGaussDiscretization(std::size_t idOfDisc, std::vector< std::pair<int,int> >& its)
5024 int globalCounter(0);
5025 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5026 (*it)->keepOnlyGaussDiscretization(idOfDisc,globalCounter,its);
5027 return globalCounter;
5030 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
5032 if(_nb_of_tuples_to_be_allocated>=0)
5034 _nb_of_tuples_to_be_allocated=newLgth;
5035 const DataArray *oldArr(getUndergroundDataArray());
5038 MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
5039 newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
5041 _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
5045 if(_nb_of_tuples_to_be_allocated==-1)
5047 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
5049 const DataArray *oldArr(getUndergroundDataArray());
5050 if(!oldArr || !oldArr->isAllocated())
5051 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
5052 MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
5053 newArr->alloc(newLgth,getNumberOfComponents());
5055 newArr->copyStringInfoFrom(*oldArr);
5057 for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
5059 if((*it).second<(*it).first)
5060 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
5061 newArr->setContigPartOfSelectedValuesSlice(pos,oldArr,(*it).first,(*it).second,1);
5062 pos+=(*it).second-(*it).first;
5067 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
5070 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
5072 if(_field_per_mesh.empty())
5073 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
5074 if(_field_per_mesh.size()>1)
5075 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
5076 _field_per_mesh[0]->copyOptionsFrom(opts);
5077 _field_per_mesh[0]->writeLL(fid,nasc);
5081 * 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.
5082 * If false is returned the memory allocation is not required.
5084 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
5086 if(_nb_of_tuples_to_be_allocated>=0)
5088 getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
5089 _nb_of_tuples_to_be_allocated=-2;
5092 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
5094 if(_nb_of_tuples_to_be_allocated==-1)
5095 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
5096 if(_nb_of_tuples_to_be_allocated<-3)
5097 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
5098 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
5101 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
5103 med_int numdt,numit;
5105 med_int meshnumdt,meshnumit;
5106 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt));
5110 INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
5111 MEDFILESAFECALLERRD0(MEDfield23ComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit)); // to check with Adrien for legacy MED files
5113 //MEDFILESAFECALLERRD0(MEDfieldComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt,&meshnumdt,&meshnumit));
5114 if(_iteration!=numdt || _order!=numit)
5115 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
5116 _field_per_mesh.resize(1);
5121 mm=ms->getMeshWithName(getMeshName());
5124 _field_per_mesh[0]=MEDFileFieldPerMesh::NewOnRead(fid,this,0,meshnumdt,meshnumit,nasc,mm,entities);
5125 _nb_of_tuples_to_be_allocated=0;
5126 _field_per_mesh[0]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
5129 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
5131 allocIfNecessaryTheArrayToReceiveDataFromFile();
5132 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5133 (*it)->loadBigArraysRecursively(fid,nasc);
5136 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
5138 if(allocIfNecessaryTheArrayToReceiveDataFromFile())
5139 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5140 (*it)->loadBigArraysRecursively(fid,nasc);
5143 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
5145 loadOnlyStructureOfDataRecursively(fid,nasc,ms,entities);
5146 loadBigArraysRecursively(fid,nasc);
5149 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
5151 DataArray *thisArr(getUndergroundDataArray());
5152 if(thisArr && thisArr->isAllocated())
5154 _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
5155 thisArr->desallocate();
5159 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
5161 return _mesh_name.capacity()+_dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MCAuto< MEDFileFieldPerMesh >);
5164 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
5166 std::vector<const BigMemoryObject *> ret;
5167 if(getUndergroundDataArray())
5168 ret.push_back(getUndergroundDataArray());
5169 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5170 ret.push_back((const MEDFileFieldPerMesh *)*it);
5175 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
5176 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
5177 * "Sort By Type"), if not, an exception is thrown.
5178 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
5179 * \param [in] arr - the array of values.
5180 * \param [in,out] glob - the global data where profiles and localization present in
5181 * \a field, if any, are added.
5182 * \throw If the name of \a field is empty.
5183 * \throw If the data array of \a field is not set.
5184 * \throw If \a this->_arr is already allocated but has different number of components
5186 * \throw If the underlying mesh of \a field has no name.
5187 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
5189 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
5191 const MEDCouplingMesh *mesh(field->getMesh());
5193 TypeOfField type(field->getTypeOfField());
5194 std::vector<DataArrayInt *> dummy;
5196 setMeshName(mesh->getName());
5197 int start(copyTinyInfoFrom(th,field,arr));
5198 int pos(addNewEntryIfNecessary(mesh));
5201 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
5202 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
5205 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
5209 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
5210 * of a given mesh are used as the support of the given field (a real support is not used).
5211 * Elements of the given mesh must be sorted suitable for writing to MED file.
5212 * Order of underlying mesh entities of the given field specified by \a profile parameter
5213 * is not prescribed; this method permutes field values to have them sorted by element
5214 * type as required for writing to MED file. A new profile is added only if no equal
5215 * profile is missing.
5216 * \param [in] field - the field to add to \a this. The field double values are ignored.
5217 * \param [in] arrOfVals - the values of the field \a field used.
5218 * \param [in] mesh - the supporting mesh of \a field.
5219 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
5220 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
5221 * \param [in,out] glob - the global data where profiles and localization present in
5222 * \a field, if any, are added.
5223 * \throw If either \a field or \a mesh or \a profile has an empty name.
5224 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
5225 * \throw If the data array of \a field is not set.
5226 * \throw If \a this->_arr is already allocated but has different number of components
5228 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
5229 * \sa setFieldNoProfileSBT()
5231 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)
5234 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
5235 if(!arrOfVals || !arrOfVals->isAllocated())
5236 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
5237 TypeOfField type=field->getTypeOfField();
5238 std::vector<DataArrayInt *> idsInPflPerType;
5239 std::vector<DataArrayInt *> idsPerType;
5240 std::vector<int> code,code2;
5241 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
5244 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
5245 std::vector< MCAuto<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
5246 std::vector< MCAuto<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin());
5247 std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
5249 MCAuto<MEDCouplingFieldTemplate> field2=field->clone(false);
5250 int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
5251 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
5253 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
5254 throw INTERP_KERNEL::Exception(oss.str());
5257 int start(copyTinyInfoFrom(th,field,arrOfVals));
5258 code2=m->getDistributionOfTypes();
5260 int pos=addNewEntryIfNecessary(m);
5261 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
5265 if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
5266 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
5267 std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
5268 std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
5269 int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
5270 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
5272 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
5273 throw INTERP_KERNEL::Exception(oss.str());
5275 int start(copyTinyInfoFrom(th,field,arrOfVals));
5276 int pos(addNewEntryIfNecessary(m));
5277 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
5282 * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
5284 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
5286 if(_nb_of_tuples_to_be_allocated>=0)
5287 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 !");
5288 DataArray *arr(getOrCreateAndGetArray());
5289 arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
5290 _nb_of_tuples_to_be_allocated=-3;
5294 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
5295 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
5296 * larger by the size of \a field. Returns an id of the first not filled
5297 * tuple of \a this->_arr.
5298 * \param [in] field - the field to copy the info on components and the name from.
5299 * \return int - the id of first not initialized tuple of \a this->_arr.
5300 * \throw If the name of \a field is empty.
5301 * \throw If the data array of \a field is not set.
5302 * \throw If \a this->_arr is already allocated but has different number of components
5305 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arr)
5308 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
5309 std::string name(field->getName());
5310 setName(name.c_str());
5311 if(field->getMesh())
5312 setMeshName(field->getMesh()->getName());
5313 setDtUnit(th->getTimeUnit());
5315 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
5317 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
5318 if(!arr->isAllocated())
5319 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
5320 _dt=th->getTime(_iteration,_order);
5321 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
5322 if(!getOrCreateAndGetArray()->isAllocated())
5324 allocNotFromFile(arr->getNumberOfTuples());
5329 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
5330 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
5331 getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
5332 _nb_of_tuples_to_be_allocated=-3;
5333 return oldNbOfTuples;
5338 * Returns number of components in \a this field
5339 * \return int - the number of components.
5341 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
5343 return getOrCreateAndGetArray()->getNumberOfComponents();
5347 * Change info on components in \a this.
5348 * \throw If size of \a infos is not equal to the number of components already in \a this.
5350 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
5352 DataArray *arr=getOrCreateAndGetArray();
5353 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
5357 * Returns info on components of \a this field.
5358 * \return const std::vector<std::string>& - a sequence of strings each being an
5359 * information on _i_-th component.
5361 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
5363 const DataArray *arr=getOrCreateAndGetArray();
5364 return arr->getInfoOnComponents();
5368 * Returns a mutable info on components of \a this field.
5369 * \return std::vector<std::string>& - a sequence of strings each being an
5370 * information on _i_-th component.
5372 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
5374 DataArray *arr=getOrCreateAndGetArray();
5375 return arr->getInfoOnComponents();
5378 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const
5380 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5382 const MEDFileFieldPerMesh *fpm(*it);
5385 if(fpm->presenceOfMultiDiscPerGeoType())
5391 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfStructureElements() const
5393 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5394 if((*it).isNotNull())
5395 if((*it)->presenceOfStructureElements())
5400 bool MEDFileAnyTypeField1TSWithoutSDA::onlyStructureElements() const
5402 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5403 if((*it).isNotNull())
5404 if(!(*it)->onlyStructureElements())
5409 void MEDFileAnyTypeField1TSWithoutSDA::killStructureElements()
5411 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5412 if((*it).isNotNull())
5413 (*it)->killStructureElements();
5416 void MEDFileAnyTypeField1TSWithoutSDA::keepOnlyStructureElements()
5418 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5419 if((*it).isNotNull())
5420 (*it)->keepOnlyStructureElements();
5423 void MEDFileAnyTypeField1TSWithoutSDA::keepOnlyOnSE(const std::string& seName)
5425 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5426 if((*it).isNotNull())
5427 (*it)->keepOnlyOnSE(seName);
5430 void MEDFileAnyTypeField1TSWithoutSDA::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
5432 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5433 if((*it).isNotNull())
5434 (*it)->getMeshSENames(ps);
5437 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh(const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5439 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 !";
5440 if(_field_per_mesh.empty())
5441 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is empty ! Nothing to extract !");
5442 if(_field_per_mesh.size()>1)
5443 throw INTERP_KERNEL::Exception(MSG0);
5444 if(_field_per_mesh[0].isNull())
5445 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is inconsistent !");
5446 const MEDFileFieldPerMesh *pm(_field_per_mesh[0]);
5447 std::set<TypeOfField> types;
5448 pm->fillTypesOfFieldAvailable(types);
5450 throw INTERP_KERNEL::Exception(MSG0);
5451 TypeOfField type(*types.begin());
5452 int meshDimRelToMax(0);
5457 int myDim(std::numeric_limits<int>::max());
5458 bool isUnique(pm->isUniqueLevel(myDim));
5460 throw INTERP_KERNEL::Exception(MSG0);
5461 meshDimRelToMax=myDim-mesh->getMeshDimension();
5462 if(meshDimRelToMax>0)
5463 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the mesh attached to field is not compatible with the field !");
5465 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,0/*renumPol*/,glob,mesh,arrOut,nasc);
5469 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5470 * \param [in] type - a spatial discretization of the new field.
5471 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
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 of \a meshDimRelToMax dimension in the mesh.
5486 * \throw If no field of \a this is lying on the mesh \a mName.
5487 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5489 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5491 MCAuto<MEDFileMesh> mm;
5493 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
5495 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
5496 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
5500 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5501 * \param [in] type - a spatial discretization of the new field.
5502 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
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 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5513 * caller is to delete this field using decrRef() as it is no more needed.
5514 * \throw If the MED file is not readable.
5515 * \throw If no field of \a this is lying on \a mesh.
5516 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5517 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5519 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5521 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax,false));
5522 const DataArrayInt *d(mesh->getNumberFieldAtLevel(meshDimRelToMax)),*e(mesh->getNumberFieldAtLevel(1));
5523 if(meshDimRelToMax==1)
5524 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
5525 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
5529 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
5531 * \param [in] type - a spatial discretization of the new field.
5532 * \param [in] mName - a name of the supporting mesh.
5533 * \param [in] renumPol - specifies how to permute values of the result field according to
5534 * the optional numbers of cells and nodes, if any. The valid values are
5535 * - 0 - do not permute.
5536 * - 1 - permute cells.
5537 * - 2 - permute nodes.
5538 * - 3 - permute cells and nodes.
5540 * \param [in] glob - the global data storing profiles and localization.
5541 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5542 * caller is to delete this field using decrRef() as it is no more needed.
5543 * \throw If the MED file is not readable.
5544 * \throw If there is no mesh named \a mName in the MED file.
5545 * \throw If there are no mesh entities in the mesh.
5546 * \throw If no field values of the given \a type are available.
5548 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5550 MCAuto<MEDFileMesh> mm;
5552 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
5554 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
5555 int absDim=getDimension();
5556 int meshDimRelToMax=absDim-mm->getMeshDimension();
5557 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
5561 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5562 * \param [in] type - a spatial discretization of the new field.
5563 * \param [in] renumPol - specifies how to permute values of the result field according to
5564 * the optional numbers of cells and nodes, if any. The valid values are
5565 * - 0 - do not permute.
5566 * - 1 - permute cells.
5567 * - 2 - permute nodes.
5568 * - 3 - permute cells and nodes.
5570 * \param [in] glob - the global data storing profiles and localization.
5571 * \param [in] mesh - the supporting mesh.
5572 * \param [in] cellRenum - the cell numbers array used for permutation of the result
5573 * field according to \a renumPol.
5574 * \param [in] nodeRenum - the node numbers array used for permutation of the result
5575 * field according to \a renumPol.
5576 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5577 * caller is to delete this field using decrRef() as it is no more needed.
5578 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5579 * \throw If no field of \a this is lying on \a mesh.
5580 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5582 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
5584 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
5586 MCAuto<MEDCouplingFieldDouble> ret=_field_per_mesh[0]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
5591 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5598 throw INTERP_KERNEL::Exception(msg1);
5599 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5602 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
5604 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5605 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
5606 throw INTERP_KERNEL::Exception(oss.str());
5608 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
5609 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
5610 std::vector<DataArray *> arrOut2(1,arrOut);
5611 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
5612 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
5613 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
5620 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5622 throw INTERP_KERNEL::Exception(msg1);
5625 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
5627 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5628 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
5629 throw INTERP_KERNEL::Exception(oss.str());
5631 MCAuto<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
5632 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
5633 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
5634 ret->renumberNodes(nodeRenumSafe->getConstPointer());
5639 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
5644 * Returns values and a profile of the field of a given type lying on a given support.
5645 * \param [in] type - a spatial discretization of the field.
5646 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5647 * \param [in] mesh - the supporting mesh.
5648 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
5649 * field of interest lies on. If the field lies on all entities of the given
5650 * dimension, all ids in \a pfl are zero. The caller is to delete this array
5651 * using decrRef() as it is no more needed.
5652 * \param [in] glob - the global data storing profiles and localization.
5653 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
5654 * field. The caller is to delete this array using decrRef() as it is no more needed.
5655 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
5656 * \throw If no field of \a this is lying on \a mesh.
5657 * \throw If no field values of the given \a type are available.
5659 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
5661 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
5662 MCAuto<DataArray> ret=_field_per_mesh[0]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
5663 ret->setName(nasc.getName().c_str());
5667 //= MEDFileField1TSWithoutSDA
5670 * Throws if a given value is not a valid (non-extended) relative dimension.
5671 * \param [in] meshDimRelToMax - the relative dimension value.
5672 * \throw If \a meshDimRelToMax > 0.
5674 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
5676 if(meshDimRelToMax>0)
5677 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
5681 * Checks if elements of a given mesh are in the order suitable for writing
5682 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
5683 * vector describing types of elements and their number.
5684 * \param [in] mesh - the mesh to check.
5685 * \return std::vector<int> - a vector holding for each element type (1) item of
5686 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
5687 * These values are in full-interlace mode.
5688 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
5690 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
5693 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
5694 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
5695 int nbOfTypes=geoTypes.size();
5696 std::vector<int> code(3*nbOfTypes);
5697 MCAuto<DataArrayInt> arr1=DataArrayInt::New();
5698 arr1->alloc(nbOfTypes,1);
5699 int *arrPtr=arr1->getPointer();
5700 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
5701 for(int i=0;i<nbOfTypes;i++,it++)
5702 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
5703 MCAuto<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
5704 const int *arrPtr2=arr2->getConstPointer();
5706 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
5709 int nbCells=mesh->getNumberOfCellsWithType(*it);
5710 code[3*pos]=(int)(*it);
5711 code[3*pos+1]=nbCells;
5712 code[3*pos+2]=-1;//no profiles
5714 std::vector<const DataArrayInt *> idsPerType;//no profiles
5715 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
5719 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
5724 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5726 return new MEDFileField1TSWithoutSDA(fieldName,meshName,csit,iteration,order,infos);
5730 * Returns all attributes and values of parts of \a this field lying on a given mesh.
5731 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
5732 * item of every of returned sequences refers to the _i_-th part of \a this field.
5733 * Thus all sequences returned by this method are of the same length equal to number
5734 * of different types of supporting entities.<br>
5735 * A field part can include sub-parts with several different spatial discretizations,
5736 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
5737 * for example. Hence, some of the returned sequences contains nested sequences, and an item
5738 * of a nested sequence corresponds to a type of spatial discretization.<br>
5739 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
5740 * The overhead is due to selecting values into new instances of DataArrayDouble.
5741 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
5742 * for the case with only one underlying mesh. (Actually, the number of meshes is
5743 * not checked if \a mname == \c NULL).
5744 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
5745 * a field part is returned.
5746 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
5747 * A field part can include sub-parts with several different spatial discretizations,
5748 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and
5749 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT" for example.
5750 * This sequence is of the same length as \a types.
5751 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
5752 * discretization. A profile name can be empty.
5753 * Length of this and of nested sequences is the same as that of \a typesF.
5754 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
5755 * discretization. A localization name can be empty.
5756 * Length of this and of nested sequences is the same as that of \a typesF.
5757 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
5758 * per each type of spatial discretization within one mesh entity type.
5759 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
5760 * Length of this and of nested sequences is the same as that of \a typesF.
5761 * \throw If no field is lying on \a mname.
5763 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
5766 if(_field_per_mesh.empty())
5767 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
5768 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[0]->getFieldSplitedByType(types,typesF,pfls,locs);
5769 int nbOfRet=ret0.size();
5770 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
5771 for(int i=0;i<nbOfRet;i++)
5773 const std::vector< std::pair<int,int> >& p=ret0[i];
5774 int nbOfRet1=p.size();
5775 ret[i].resize(nbOfRet1);
5776 for(int j=0;j<nbOfRet1;j++)
5778 DataArrayDouble *tmp=_arr->selectByTupleIdSafeSlice(p[j].first,p[j].second,1);
5785 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
5790 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
5792 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
5793 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5794 ret->deepCpyLeavesFrom(*this);
5795 const DataArrayDouble *arr(_arr);
5798 MCAuto<DataArrayInt> arr2(arr->convertToIntArr());
5799 ret->setArray(arr2);
5805 * Returns a pointer to the underground DataArrayDouble instance and a
5806 * sequence describing parameters of a support of each part of \a this field. The
5807 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5808 * direct access to the field values. This method is intended for the field lying on one
5810 * \param [in,out] entries - the sequence describing parameters of a support of each
5811 * part of \a this field. Each item of this sequence consists of two parts. The
5812 * first part describes a type of mesh entity and an id of discretization of a
5813 * current field part. The second part describes a range of values [begin,end)
5814 * within the returned array relating to the current field part.
5815 * \return DataArrayDouble * - the pointer to the field values array.
5816 * \throw If the number of underlying meshes is not equal to 1.
5817 * \throw If no field values are available.
5818 * \sa getUndergroundDataArray()
5820 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5822 return getUndergroundDataArrayTemplateExt(entries);
5825 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)
5827 DataArrayDouble *arr(getOrCreateAndGetArrayTemplate());
5828 arr->setInfoAndChangeNbOfCompo(infos);
5831 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<double>()
5835 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
5837 MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
5838 ret->deepCpyLeavesFrom(*this);
5842 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCopy() const
5844 MCAuto<MEDFileField1TSWithoutSDA> ret(shallowCpy());
5845 if(_arr.isNotNull())
5846 ret->_arr=_arr->deepCopy();
5850 //= MEDFileIntField1TSWithoutSDA
5852 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5854 return new MEDFileIntField1TSWithoutSDA(fieldName,meshName,csit,iteration,order,infos);
5857 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA()
5861 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order,
5862 const std::vector<std::string>& infos):MEDFileField1TSNDTemplateWithoutSDA<int>(fieldName,meshName,csit,iteration,order,infos)
5864 DataArrayInt *arr(getOrCreateAndGetArrayTemplate());
5865 arr->setInfoAndChangeNbOfCompo(infos);
5868 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
5874 * Returns a pointer to the underground DataArrayInt instance and a
5875 * sequence describing parameters of a support of each part of \a this field. The
5876 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5877 * direct access to the field values. This method is intended for the field lying on one
5879 * \param [in,out] entries - the sequence describing parameters of a support of each
5880 * part of \a this field. Each item of this sequence consists of two parts. The
5881 * first part describes a type of mesh entity and an id of discretization of a
5882 * current field part. The second part describes a range of values [begin,end)
5883 * within the returned array relating to the current field part.
5884 * \return DataArrayInt * - the pointer to the field values array.
5885 * \throw If the number of underlying meshes is not equal to 1.
5886 * \throw If no field values are available.
5887 * \sa getUndergroundDataArray()
5889 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5891 return getUndergroundDataArrayIntExt(entries);
5895 * Returns a pointer to the underground DataArrayInt instance and a
5896 * sequence describing parameters of a support of each part of \a this field. The
5897 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5898 * direct access to the field values. This method is intended for the field lying on one
5900 * \param [in,out] entries - the sequence describing parameters of a support of each
5901 * part of \a this field. Each item of this sequence consists of two parts. The
5902 * first part describes a type of mesh entity and an id of discretization of a
5903 * current field part. The second part describes a range of values [begin,end)
5904 * within the returned array relating to the current field part.
5905 * \return DataArrayInt * - the pointer to the field values array.
5906 * \throw If the number of underlying meshes is not equal to 1.
5907 * \throw If no field values are available.
5908 * \sa getUndergroundDataArray()
5910 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5912 if(_field_per_mesh.size()!=1)
5913 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5914 if(_field_per_mesh[0]==0)
5915 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5916 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5917 return getUndergroundDataArrayTemplate();
5920 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5922 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5923 ret->deepCpyLeavesFrom(*this);
5927 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCopy() const
5929 MCAuto<MEDFileIntField1TSWithoutSDA> ret(shallowCpy());
5930 if(_arr.isNotNull())
5931 ret->_arr=_arr->deepCopy();
5935 //= MEDFileFloatField1TSWithoutSDA
5937 MEDFileFloatField1TSWithoutSDA *MEDFileFloatField1TSWithoutSDA::New(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5939 return new MEDFileFloatField1TSWithoutSDA(fieldName,meshName,csit,iteration,order,infos);
5942 MEDFileFloatField1TSWithoutSDA::MEDFileFloatField1TSWithoutSDA()
5946 MEDFileFloatField1TSWithoutSDA::MEDFileFloatField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order,
5947 const std::vector<std::string>& infos):MEDFileField1TSNDTemplateWithoutSDA<float>(fieldName,meshName,csit,iteration,order,infos)
5949 DataArrayFloat *arr(getOrCreateAndGetArrayTemplate());
5950 arr->setInfoAndChangeNbOfCompo(infos);
5953 const char *MEDFileFloatField1TSWithoutSDA::getTypeStr() const
5959 * Returns a pointer to the underground DataArrayFloat instance and a
5960 * sequence describing parameters of a support of each part of \a this field. The
5961 * caller should not decrRef() the returned DataArrayFloat. This method allows for a
5962 * direct access to the field values. This method is intended for the field lying on one
5964 * \param [in,out] entries - the sequence describing parameters of a support of each
5965 * part of \a this field. Each item of this sequence consists of two parts. The
5966 * first part describes a type of mesh entity and an id of discretization of a
5967 * current field part. The second part describes a range of values [begin,end)
5968 * within the returned array relating to the current field part.
5969 * \return DataArrayFloat * - the pointer to the field values array.
5970 * \throw If the number of underlying meshes is not equal to 1.
5971 * \throw If no field values are available.
5972 * \sa getUndergroundDataArray()
5974 DataArray *MEDFileFloatField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5976 return getUndergroundDataArrayFloatExt(entries);
5980 * Returns a pointer to the underground DataArrayFloat instance and a
5981 * sequence describing parameters of a support of each part of \a this field. The
5982 * caller should not decrRef() the returned DataArrayFloat. This method allows for a
5983 * direct access to the field values. This method is intended for the field lying on one
5985 * \param [in,out] entries - the sequence describing parameters of a support of each
5986 * part of \a this field. Each item of this sequence consists of two parts. The
5987 * first part describes a type of mesh entity and an id of discretization of a
5988 * current field part. The second part describes a range of values [begin,end)
5989 * within the returned array relating to the current field part.
5990 * \return DataArrayFloat * - the pointer to the field values array.
5991 * \throw If the number of underlying meshes is not equal to 1.
5992 * \throw If no field values are available.
5993 * \sa getUndergroundDataArray()
5995 DataArrayFloat *MEDFileFloatField1TSWithoutSDA::getUndergroundDataArrayFloatExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5997 if(_field_per_mesh.size()!=1)
5998 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5999 if(_field_per_mesh[0]==0)
6000 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
6001 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
6002 return getUndergroundDataArrayTemplate();
6005 MEDFileFloatField1TSWithoutSDA *MEDFileFloatField1TSWithoutSDA::shallowCpy() const
6007 MCAuto<MEDFileFloatField1TSWithoutSDA> ret(new MEDFileFloatField1TSWithoutSDA(*this));
6008 ret->deepCpyLeavesFrom(*this);
6012 MEDFileFloatField1TSWithoutSDA *MEDFileFloatField1TSWithoutSDA::deepCopy() const
6014 MCAuto<MEDFileFloatField1TSWithoutSDA> ret(shallowCpy());
6015 if(_arr.isNotNull())
6016 ret->_arr=_arr->deepCopy();
6020 //= MEDFileAnyTypeField1TS
6022 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
6026 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
6028 med_field_type typcha;
6030 std::vector<std::string> infos;
6031 std::string dtunit,fieldName,meshName;
6032 LocateField2(fid,0,true,fieldName,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) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of the first field is not in [MED_FLOAT64, MED_INT32] !";
6054 throw INTERP_KERNEL::Exception(oss.str());
6057 ret->setDtUnit(dtunit.c_str());
6058 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
6060 med_int numdt,numit;
6062 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
6063 ret->setTime(numdt,numit,dt);
6066 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
6068 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
6072 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
6073 try:MEDFileFieldGlobsReal(fid)
6075 _content=BuildContentFrom(fid,loadAll,ms,entities);
6078 catch(INTERP_KERNEL::Exception& e)
6083 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
6085 med_field_type typcha;
6086 std::vector<std::string> infos;
6087 std::string dtunit,meshName;
6091 nbSteps=LocateField(fid,fieldName,iii,typcha,infos,dtunit,meshName);
6093 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
6098 ret=MEDFileField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
6103 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
6108 ret=MEDFileFloatField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
6113 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] !";
6114 throw INTERP_KERNEL::Exception(oss.str());
6117 ret->setMeshName(meshName);
6118 ret->setDtUnit(dtunit.c_str());
6119 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
6123 std::ostringstream oss; oss << "MEDFileField1TS(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
6124 throw INTERP_KERNEL::Exception(oss.str());
6127 med_int numdt,numit;
6129 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
6130 ret->setTime(numdt,numit,dt);
6133 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
6135 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
6139 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
6140 try:MEDFileFieldGlobsReal(fid)
6142 _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
6145 catch(INTERP_KERNEL::Exception& e)
6150 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c)
6153 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
6154 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
6156 MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
6157 ret->_content=c; c->incrRef();
6160 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
6162 MCAuto<MEDFileIntField1TS> ret(MEDFileIntField1TS::New());
6163 ret->_content=c; c->incrRef();
6166 if(dynamic_cast<const MEDFileFloatField1TSWithoutSDA *>(c))
6168 MCAuto<MEDFileFloatField1TS> ret(MEDFileFloatField1TS::New());
6169 ret->_content=c; c->incrRef();
6172 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 FLOAT32 and INT32 has been built but not intercepted !");
6175 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, med_idt fid)
6177 MEDFileAnyTypeField1TS *ret(BuildNewInstanceFromContent(c));
6178 ret->setFileName(FileNameFromFID(fid));
6182 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
6184 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6185 return New(fid,loadAll);
6188 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, bool loadAll)
6190 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,loadAll,0,0));
6191 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
6192 ret->loadGlobals(fid);
6196 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6198 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6199 return New(fid,fieldName,loadAll);
6202 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
6204 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
6205 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
6206 ret->loadGlobals(fid);
6210 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6212 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6213 return New(fid,fieldName,iteration,order,loadAll);
6216 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
6218 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0,0));
6219 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
6220 ret->loadGlobals(fid);
6224 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::NewAdv(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileEntities *entities)
6226 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6227 return NewAdv(fid,fieldName,iteration,order,loadAll,entities);
6230 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::NewAdv(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileEntities *entities)
6232 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0,entities));
6233 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
6234 ret->loadGlobals(fid);
6238 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
6240 med_field_type typcha;
6241 std::vector<std::string> infos;
6242 std::string dtunit,meshName;
6244 int nbOfStep2(LocateField(fid,fieldName,iii,typcha,infos,dtunit,meshName));
6245 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
6250 ret=MEDFileField1TSWithoutSDA::New(fieldName,meshName,-1,iteration,order,std::vector<std::string>());
6255 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,meshName,-1,iteration,order,std::vector<std::string>());
6260 ret=MEDFileFloatField1TSWithoutSDA::New(fieldName,meshName,-1,iteration,order,std::vector<std::string>());
6265 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] !";
6266 throw INTERP_KERNEL::Exception(oss.str());
6269 ret->setDtUnit(dtunit.c_str());
6270 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
6273 std::vector< std::pair<int,int> > dtits(nbOfStep2);
6274 for(int i=0;i<nbOfStep2 && !found;i++)
6276 med_int numdt,numit;
6278 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt));
6279 if(numdt==iteration && numit==order)
6285 dtits[i]=std::pair<int,int>(numdt,numit);
6289 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available iterations are : ";
6290 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
6291 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
6292 throw INTERP_KERNEL::Exception(oss.str());
6295 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
6297 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
6301 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
6302 try:MEDFileFieldGlobsReal(fid)
6304 _content=BuildContentFrom(fid,fieldName,iteration,order,loadAll,ms,entities);
6307 catch(INTERP_KERNEL::Exception& e)
6313 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6314 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6316 * \warning this is a shallow copy constructor
6318 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
6320 if(!shallowCopyOfContent)
6322 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
6323 otherPtr->incrRef();
6324 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
6328 _content=other.shallowCpy();
6332 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)
6336 int nbFields=MEDnField(fid);
6337 if(fieldIdCFormat>=nbFields)
6339 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << FileNameFromFID(fid) << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
6340 throw INTERP_KERNEL::Exception(oss.str());
6343 int ncomp(MEDfieldnComponent(fid,fieldIdCFormat+1));
6344 INTERP_KERNEL::AutoPtr<char> comp(MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE));
6345 INTERP_KERNEL::AutoPtr<char> unit(MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE));
6346 INTERP_KERNEL::AutoPtr<char> dtunit(MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE));
6347 INTERP_KERNEL::AutoPtr<char> nomcha(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
6348 INTERP_KERNEL::AutoPtr<char> nomMaa(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
6351 MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep));
6352 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
6353 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
6354 meshName=MEDLoaderBase::buildStringFromFortran(nomMaa,MED_NAME_SIZE);
6355 infos.clear(); infos.resize(ncomp);
6356 for(int j=0;j<ncomp;j++)
6357 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
6362 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
6365 * \return in case of success the number of time steps available for the field with name \a fieldName.
6367 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)
6369 int nbFields=MEDnField(fid);
6371 std::vector<std::string> fns(nbFields);
6373 for(int i=0;i<nbFields && !found;i++)
6375 std::string tmp,tmp2;
6376 nbOfStep2=LocateField2(fid,i,false,tmp,typcha,infos,dtunitOut,tmp2);
6378 found=(tmp==fieldName);
6387 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available fields are : ";
6388 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
6389 oss << "\"" << *it << "\" ";
6390 throw INTERP_KERNEL::Exception(oss.str());
6396 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
6397 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
6398 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
6399 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
6400 * to keep a valid instance.
6401 * 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.
6402 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
6403 * 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.
6405 * \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.
6406 * \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.
6407 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
6408 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
6409 * \param [in] newLocName is the new localization name.
6410 * \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.
6411 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
6413 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
6415 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6416 std::string oldPflName=disc->getProfile();
6417 std::vector<std::string> vv=getPflsReallyUsedMulti();
6418 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
6419 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
6421 disc->setProfile(newPflName);
6422 DataArrayInt *pfl=getProfile(oldPflName.c_str());
6423 pfl->setName(newPflName);
6427 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
6428 throw INTERP_KERNEL::Exception(oss.str());
6433 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
6434 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
6435 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
6436 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
6437 * to keep a valid instance.
6438 * 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.
6439 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
6440 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
6441 * 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.
6443 * \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.
6444 * \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.
6445 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
6446 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
6447 * \param [in] newLocName is the new localization name.
6448 * \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.
6449 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
6451 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
6453 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6454 std::string oldLocName=disc->getLocalization();
6455 std::vector<std::string> vv=getLocsReallyUsedMulti();
6456 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
6457 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
6459 disc->setLocalization(newLocName);
6460 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
6461 loc.setName(newLocName);
6465 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
6466 throw INTERP_KERNEL::Exception(oss.str());
6470 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
6472 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
6474 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
6478 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
6480 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
6482 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
6487 * This method alloc the arrays and load potentially huge arrays contained in this field.
6488 * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
6489 * This method can be also called to refresh or reinit values from a file.
6491 * \throw If the fileName is not set or points to a non readable MED file.
6492 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
6494 void MEDFileAnyTypeField1TS::loadArrays()
6496 if(getFileName().empty())
6497 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
6498 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
6499 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
6503 * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
6504 * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
6505 * this method does not throw if \a this does not come from file read.
6507 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
6509 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
6511 if(!getFileName().empty())
6513 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
6514 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
6519 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
6520 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
6521 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
6523 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
6525 void MEDFileAnyTypeField1TS::unloadArrays()
6527 contentNotNullBase()->unloadArrays();
6531 * 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.
6532 * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
6533 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
6535 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
6537 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
6539 if(!getFileName().empty())
6540 contentNotNullBase()->unloadArrays();
6543 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
6545 int nbComp(getNumberOfComponents());
6546 INTERP_KERNEL::AutoPtr<char> comp(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
6547 INTERP_KERNEL::AutoPtr<char> unit(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
6548 for(int i=0;i<nbComp;i++)
6550 std::string info=getInfo()[i];
6552 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
6553 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
6554 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
6556 if(getName().empty())
6557 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
6558 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
6559 writeGlobals(fid,*this);
6560 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
6563 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
6565 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
6568 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
6570 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
6571 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
6576 * Returns a string describing \a this field. This string is outputted
6577 * by \c print Python command.
6579 std::string MEDFileAnyTypeField1TS::simpleRepr() const
6581 std::ostringstream oss;
6582 contentNotNullBase()->simpleRepr(0,oss,-1);
6583 simpleReprGlobs(oss);
6588 * This method returns all profiles whose name is non empty used.
6589 * \b WARNING If profile is used several times it will be reported \b only \b once.
6590 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
6592 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
6594 return contentNotNullBase()->getPflsReallyUsed2();
6598 * This method returns all localizations whose name is non empty used.
6599 * \b WARNING If localization is used several times it will be reported \b only \b once.
6601 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
6603 return contentNotNullBase()->getLocsReallyUsed2();
6607 * This method returns all profiles whose name is non empty used.
6608 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
6610 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
6612 return contentNotNullBase()->getPflsReallyUsedMulti2();
6616 * This method returns all localizations whose name is non empty used.
6617 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
6619 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
6621 return contentNotNullBase()->getLocsReallyUsedMulti2();
6624 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6626 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
6629 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6631 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
6634 int MEDFileAnyTypeField1TS::getDimension() const
6636 return contentNotNullBase()->getDimension();
6639 int MEDFileAnyTypeField1TS::getIteration() const
6641 return contentNotNullBase()->getIteration();
6644 int MEDFileAnyTypeField1TS::getOrder() const
6646 return contentNotNullBase()->getOrder();
6649 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
6651 return contentNotNullBase()->getTime(iteration,order);
6654 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
6656 contentNotNullBase()->setTime(iteration,order,val);
6659 std::string MEDFileAnyTypeField1TS::getName() const
6661 return contentNotNullBase()->getName();
6664 void MEDFileAnyTypeField1TS::setName(const std::string& name)
6666 contentNotNullBase()->setName(name);
6669 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
6671 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
6674 std::string MEDFileAnyTypeField1TS::getDtUnit() const
6676 return contentNotNullBase()->getDtUnit();
6679 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
6681 contentNotNullBase()->setDtUnit(dtUnit);
6684 std::string MEDFileAnyTypeField1TS::getMeshName() const
6686 return contentNotNullBase()->getMeshName();
6689 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
6691 contentNotNullBase()->setMeshName(newMeshName);
6694 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
6696 return contentNotNullBase()->changeMeshNames(modifTab);
6699 int MEDFileAnyTypeField1TS::getMeshIteration() const
6701 return contentNotNullBase()->getMeshIteration();
6704 int MEDFileAnyTypeField1TS::getMeshOrder() const
6706 return contentNotNullBase()->getMeshOrder();
6709 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
6711 return contentNotNullBase()->getNumberOfComponents();
6714 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
6716 return contentNotNullBase()->isDealingTS(iteration,order);
6719 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
6721 return contentNotNullBase()->getDtIt();
6724 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
6726 contentNotNullBase()->fillIteration(p);
6729 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
6731 contentNotNullBase()->fillTypesOfFieldAvailable(types);
6734 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
6736 contentNotNullBase()->setInfo(infos);
6739 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
6741 return contentNotNullBase()->getInfo();
6743 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
6745 return contentNotNullBase()->getInfo();
6748 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
6750 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
6753 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
6755 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6758 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
6760 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6763 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
6765 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
6768 void MEDFileAnyTypeField1TS::convertMedBallIntoClassic()
6770 return contentNotNullBase()->convertMedBallIntoClassic();
6773 void MEDFileAnyTypeField1TS::makeReduction(INTERP_KERNEL::NormalizedCellType ct, TypeOfField tof, const DataArrayInt *pfl)
6775 return contentNotNullBase()->makeReduction(ct,tof,pfl);
6778 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
6780 return contentNotNullBase()->getTypesOfFieldAvailable();
6783 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,
6784 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6786 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
6790 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
6791 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
6792 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
6794 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
6796 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6798 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
6799 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
6800 std::size_t sz(contentsSplit.size());
6801 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6802 for(std::size_t i=0;i<sz;i++)
6804 ret[i]=shallowCpy();
6805 ret[i]->_content=contentsSplit[i];
6811 * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
6812 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6814 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
6816 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6818 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
6819 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
6820 std::size_t sz(contentsSplit.size());
6821 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6822 for(std::size_t i=0;i<sz;i++)
6824 ret[i]=shallowCpy();
6825 ret[i]->_content=contentsSplit[i];
6831 * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this.
6832 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6834 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const
6836 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6838 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !");
6839 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
6840 std::size_t sz(contentsSplit.size());
6841 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6842 for(std::size_t i=0;i<sz;i++)
6844 ret[i]=shallowCpy();
6845 ret[i]->_content=contentsSplit[i];
6850 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCopy() const
6852 MCAuto<MEDFileAnyTypeField1TS> ret=shallowCpy();
6853 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
6854 ret->_content=_content->deepCopy();
6855 ret->deepCpyGlobs(*this);
6859 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
6861 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*field));
6862 return copyTinyInfoFrom(field->timeDiscrSafe(),ft,arr);
6865 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arr)
6867 return contentNotNullBase()->copyTinyInfoFrom(th,field,arr);
6873 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
6874 * following the given input policy.
6876 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6877 * By default (true) the globals are deeply copied.
6878 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
6880 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
6882 MCAuto<MEDFileIntField1TS> ret;
6883 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6886 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
6888 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
6889 MCAuto<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
6890 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc));
6893 ret=MEDFileIntField1TS::New();
6895 ret->deepCpyGlobs(*this);
6897 ret->shallowCpyGlobs(*this);
6901 MEDFileField1TS::MEDFileField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
6902 try:MEDFileTemplateField1TS<double>(fid,loadAll,ms)
6905 catch(INTERP_KERNEL::Exception& e)
6908 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6909 try:MEDFileTemplateField1TS<double>(fid,fieldName,loadAll,ms)
6912 catch(INTERP_KERNEL::Exception& e)
6915 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6916 try:MEDFileTemplateField1TS<double>(fid,fieldName,iteration,order,loadAll,ms)
6919 catch(INTERP_KERNEL::Exception& e)
6923 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6924 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6926 * \warning this is a shallow copy constructor
6928 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6929 try:MEDFileTemplateField1TS<double>(other,shallowCopyOfContent)
6932 catch(INTERP_KERNEL::Exception& e)
6935 MEDFileField1TS *MEDFileField1TS::shallowCpy() const
6937 return new MEDFileField1TS(*this);
6940 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6941 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6943 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6946 //= MEDFileIntField1TS
6948 MCAuto<MEDCouplingFieldDouble> MEDFileIntField1TS::ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f)
6951 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ConvertFieldIntToFieldDouble : null input field !");
6953 double t0(f->getTime(t1,t2));
6954 std::string tu(f->getTimeUnit());
6955 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
6956 MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(*ft));
6957 ret->setTime(t0,t1,t2); ret->setTimeUnit(tu);
6961 //= MEDFileFloatField1TS
6963 //= MEDFileFloatField1TS
6965 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
6967 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
6971 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName):MEDFileFieldNameScope(fieldName,meshName)
6976 * \param [in] fieldId field id in C mode
6978 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
6980 med_field_type typcha;
6981 std::string dtunitOut,meshName;
6982 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fieldId,false,_name,typcha,_infos,dtunitOut,meshName));
6983 setMeshName(meshName);
6984 setDtUnit(dtunitOut.c_str());
6985 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities);
6988 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)
6989 try:MEDFileFieldNameScope(fieldName,meshName),_infos(infos)
6991 setDtUnit(dtunit.c_str());
6992 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities);
6994 catch(INTERP_KERNEL::Exception& e)
6999 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
7001 std::size_t ret(_mesh_name.capacity()+_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MCAuto<MEDFileField1TSWithoutSDA>));
7002 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7003 ret+=(*it).capacity();
7007 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
7009 std::vector<const BigMemoryObject *> ret;
7010 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7011 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
7016 * 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
7019 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
7021 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7022 ret->setInfo(_infos);
7023 int sz=(int)_time_steps.size();
7024 for(const int *id=startIds;id!=endIds;id++)
7026 if(*id>=0 && *id<sz)
7028 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
7029 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7033 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7035 ret->pushBackTimeStep(tse2);
7039 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
7040 oss << " ! Should be in [0," << sz << ") !";
7041 throw INTERP_KERNEL::Exception(oss.str());
7044 if(ret->getNumberOfTS()>0)
7045 ret->synchronizeNameScope();
7046 ret->copyNameScope(*this);
7051 * 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
7054 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
7056 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
7057 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7058 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7059 ret->setInfo(_infos);
7060 int sz=(int)_time_steps.size();
7062 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
7066 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
7067 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7071 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7073 ret->pushBackTimeStep(tse2);
7077 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
7078 oss << " ! Should be in [0," << sz << ") !";
7079 throw INTERP_KERNEL::Exception(oss.str());
7082 if(ret->getNumberOfTS()>0)
7083 ret->synchronizeNameScope();
7084 ret->copyNameScope(*this);
7088 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7091 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7092 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7094 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7097 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7098 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
7099 ids->pushBackSilent(id);
7101 return buildFromTimeStepIds(ids->begin(),ids->end());
7104 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7107 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7108 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7110 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7113 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7114 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
7115 ids->pushBackSilent(id);
7117 return buildFromTimeStepIds(ids->begin(),ids->end());
7120 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfStructureElements() const
7122 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7123 if((*it).isNotNull())
7124 if((*it)->presenceOfStructureElements())
7129 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::onlyStructureElements() const
7131 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7132 if((*it).isNotNull())
7133 if(!(*it)->onlyStructureElements())
7138 void MEDFileAnyTypeFieldMultiTSWithoutSDA::killStructureElements()
7140 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
7141 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7142 if((*it).isNotNull())
7144 if((*it)->presenceOfStructureElements())
7146 if(!(*it)->onlyStructureElements())
7148 (*it)->killStructureElements();
7160 void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyStructureElements()
7162 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
7163 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7164 if((*it).isNotNull())
7166 if((*it)->presenceOfStructureElements())
7168 if(!(*it)->onlyStructureElements())
7169 (*it)->keepOnlyStructureElements();
7176 void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyOnSE(const std::string& seName)
7178 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
7179 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7180 if((*it).isNotNull())
7181 (*it)->keepOnlyOnSE(seName);
7184 void MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
7186 std::vector< std::pair<std::string,std::string> > ps2;
7187 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7188 if((*it).isNotNull())
7190 (*it)->getMeshSENames(ps2);
7194 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames : this appears to not contain SE only !");
7195 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7196 if((*it).isNotNull())
7198 std::vector< std::pair<std::string,std::string> > ps3;
7199 (*it)->getMeshSENames(ps3);
7201 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames : For the moment only homogeneous SE def through time managed !");
7203 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=ps2.begin();it!=ps2.end();it++)
7205 std::vector< std::pair<std::string,std::string> >::iterator it2(std::find(ps.begin(),ps.end(),*it));
7211 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
7213 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7215 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7218 if(cur->presenceOfMultiDiscPerGeoType())
7224 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
7229 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
7234 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
7237 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7239 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
7240 if(pt->isDealingTS(iteration,order))
7243 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
7244 std::vector< std::pair<int,int> > vp=getIterations();
7245 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
7246 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
7247 throw INTERP_KERNEL::Exception(oss.str());
7250 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
7252 return *_time_steps[getTimeStepPos(iteration,order)];
7255 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
7257 return *_time_steps[getTimeStepPos(iteration,order)];
7260 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
7263 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
7265 if((*it).first==getMeshName())
7267 setMeshName((*it).second);
7271 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7273 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7275 ret=cur->changeMeshNames(modifTab) || ret;
7281 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
7283 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
7285 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
7289 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
7291 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7293 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
7296 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
7297 MEDFileFieldGlobsReal& glob)
7300 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7302 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
7304 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
7309 void MEDFileAnyTypeFieldMultiTSWithoutSDA::accept(MEDFileFieldVisitor& visitor) const
7311 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7312 if((*it).isNotNull())
7314 visitor.newTimeStepEntry(*it);
7315 (*it)->accept(visitor);
7316 visitor.endTimeStepEntry(*it);
7320 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7322 std::string startLine(bkOffset,' ');
7323 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
7325 oss << " (" << fmtsId << ")";
7326 oss << " has the following name: \"" << _name << "\"." << std::endl;
7327 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
7328 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7330 oss << startLine << " - \"" << *it << "\"" << std::endl;
7333 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7335 std::string chapter(17,'0'+i);
7336 oss << startLine << chapter << std::endl;
7337 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7339 cur->simpleRepr(bkOffset+2,oss,i);
7341 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
7342 oss << startLine << chapter << std::endl;
7346 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
7348 std::size_t sz=_time_steps.size();
7349 std::vector< std::pair<int,int> > ret(sz);
7351 for(std::size_t i=0;i<sz;i++)
7353 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
7356 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
7360 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
7361 throw INTERP_KERNEL::Exception(oss.str());
7367 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MCAuto<MEDFileAnyTypeField1TSWithoutSDA>& tse)
7369 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
7371 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
7372 checkCoherencyOfType(tse2);
7373 if(_time_steps.empty())
7375 setName(tse2->getName());
7376 setMeshName(tse2->getMeshName());
7377 setInfo(tse2->getInfo());
7379 checkThatComponentsMatch(tse2->getInfo());
7380 if(getDtUnit().empty() && !tse->getDtUnit().empty())
7381 setDtUnit(tse->getDtUnit());
7382 _time_steps.push_back(tse);
7385 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
7387 std::size_t nbOfCompo=_infos.size();
7388 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7390 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7393 if((cur->getInfo()).size()!=nbOfCompo)
7395 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
7396 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
7397 throw INTERP_KERNEL::Exception(oss.str());
7399 cur->copyNameScope(*this);
7404 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7406 _time_steps.resize(nbPdt);
7407 for(int i=0;i<nbPdt;i++)
7409 std::vector< std::pair<int,int> > ts;
7410 med_int numdt=0,numo=0;
7412 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt));
7417 _time_steps[i]=MEDFileField1TSWithoutSDA::New(getName(),getMeshName(),i+1,numdt,numo,_infos);
7422 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(getName(),getMeshName(),i+1,numdt,numo,_infos);
7427 _time_steps[i]=MEDFileFloatField1TSWithoutSDA::New(getName(),getMeshName(),i+1,numdt,numo,_infos);
7431 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32, FLOAT32 !");
7434 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities);
7436 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entities);
7437 synchronizeNameScope();
7441 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
7443 if(_time_steps.empty())
7444 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
7445 checkThatNbOfCompoOfTSMatchThis();
7446 std::vector<std::string> infos(getInfo());
7447 int nbComp=infos.size();
7448 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7449 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7450 for(int i=0;i<nbComp;i++)
7452 std::string info=infos[i];
7454 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7455 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7456 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7459 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7460 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
7461 int nbOfTS=_time_steps.size();
7462 for(int i=0;i<nbOfTS;i++)
7463 _time_steps[i]->writeLL(fid,opts,*this);
7466 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
7468 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7470 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7472 elt->loadBigArraysRecursively(fid,nasc);
7476 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
7478 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7480 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7482 elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7486 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
7488 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7490 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7492 elt->unloadArrays();
7496 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7498 return _time_steps.size();
7501 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
7503 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7504 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7506 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7508 newTS.push_back(*it);
7513 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
7515 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7516 int maxId=(int)_time_steps.size();
7518 std::set<int> idsToDel;
7519 for(const int *id=startIds;id!=endIds;id++,ii++)
7521 if(*id>=0 && *id<maxId)
7523 idsToDel.insert(*id);
7527 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7528 throw INTERP_KERNEL::Exception(oss.str());
7531 for(int iii=0;iii<maxId;iii++)
7532 if(idsToDel.find(iii)==idsToDel.end())
7533 newTS.push_back(_time_steps[iii]);
7537 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
7539 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7540 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7541 if(nbOfEntriesToKill==0)
7543 std::size_t sz=_time_steps.size();
7544 std::vector<bool> b(sz,true);
7546 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7548 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7549 for(std::size_t i=0;i<sz;i++)
7551 newTS.push_back(_time_steps[i]);
7555 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
7558 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
7559 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7561 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7565 tmp->getTime(it2,ord);
7566 if(it2==iteration && order==ord)
7569 oss << "(" << it2 << "," << ord << "), ";
7572 throw INTERP_KERNEL::Exception(oss.str());
7575 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
7578 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
7580 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7582 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7586 double ti=tmp->getTime(it2,ord);
7587 if(fabs(time-ti)<eps)
7593 throw INTERP_KERNEL::Exception(oss.str());
7596 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
7598 int lgth=_time_steps.size();
7599 std::vector< std::pair<int,int> > ret(lgth);
7600 for(int i=0;i<lgth;i++)
7601 _time_steps[i]->fillIteration(ret[i]);
7606 * 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'
7607 * This method returns two things.
7608 * - The absolute dimension of 'this' in first parameter.
7609 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7610 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
7612 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7613 * Only these 3 discretizations will be taken into account here.
7615 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7616 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7617 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7619 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7620 * 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'.
7622 * Let's consider the typical following case :
7623 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7624 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7625 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7627 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7629 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7631 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7632 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7633 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7634 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7636 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
7638 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7641 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
7643 if(pos<0 || pos>=(int)_time_steps.size())
7645 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7646 throw INTERP_KERNEL::Exception(oss.str());
7648 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7651 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7652 oss << "\nTry to use following method eraseEmptyTS !";
7653 throw INTERP_KERNEL::Exception(oss.str());
7658 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
7660 if(pos<0 || pos>=(int)_time_steps.size())
7662 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7663 throw INTERP_KERNEL::Exception(oss.str());
7665 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7668 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7669 oss << "\nTry to use following method eraseEmptyTS !";
7670 throw INTERP_KERNEL::Exception(oss.str());
7675 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
7677 std::vector<std::string> ret;
7678 std::set<std::string> ret2;
7679 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7681 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
7682 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7683 if(ret2.find(*it2)==ret2.end())
7685 ret.push_back(*it2);
7692 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
7694 std::vector<std::string> ret;
7695 std::set<std::string> ret2;
7696 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7698 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
7699 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7700 if(ret2.find(*it2)==ret2.end())
7702 ret.push_back(*it2);
7709 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
7711 std::vector<std::string> ret;
7712 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7714 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
7715 ret.insert(ret.end(),tmp.begin(),tmp.end());
7720 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
7722 std::vector<std::string> ret;
7723 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7725 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
7726 ret.insert(ret.end(),tmp.begin(),tmp.end());
7731 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7733 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7734 (*it)->changePflsRefsNamesGen2(mapOfModif);
7737 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7739 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7740 (*it)->changeLocsRefsNamesGen2(mapOfModif);
7743 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
7745 int lgth=_time_steps.size();
7746 std::vector< std::vector<TypeOfField> > ret(lgth);
7747 for(int i=0;i<lgth;i++)
7748 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
7753 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
7755 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
7757 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
7760 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCopy() const
7762 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
7764 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7766 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
7767 ret->_time_steps[i]=(*it)->deepCopy();
7772 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
7774 std::size_t sz(_infos.size()),sz2(_time_steps.size());
7775 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7776 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7777 for(std::size_t i=0;i<sz;i++)
7779 ret[i]=shallowCpy();
7780 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7782 for(std::size_t i=0;i<sz2;i++)
7784 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7787 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7788 throw INTERP_KERNEL::Exception(oss.str());
7792 for(std::size_t i=0;i<sz;i++)
7793 for(std::size_t j=0;j<sz2;j++)
7794 ret[i]->_time_steps[j]=ts[j][i];
7799 * This method splits into discretization each time steps in \a this.
7800 * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
7802 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
7804 std::size_t sz(_time_steps.size());
7805 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7806 for(std::size_t i=0;i<sz;i++)
7808 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7811 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
7812 throw INTERP_KERNEL::Exception(oss.str());
7814 items[i]=timeStep->splitDiscretizations();
7817 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
7818 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
7819 std::vector< TypeOfField > types;
7820 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7821 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7823 std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
7825 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
7826 std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
7827 if(it2==types.end())
7828 types.push_back(ts[0]);
7830 ret.resize(types.size()); ret2.resize(types.size());
7831 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7832 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7834 TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
7835 std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
7836 ret2[pos].push_back(*it1);
7838 for(std::size_t i=0;i<types.size();i++)
7840 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7841 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
7842 elt->pushBackTimeStep(*it1);//also updates infos in elt
7844 elt->MEDFileFieldNameScope::operator=(*this);
7850 * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
7852 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
7854 std::size_t sz(_time_steps.size());
7855 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7856 std::size_t szOut(std::numeric_limits<std::size_t>::max());
7857 for(std::size_t i=0;i<sz;i++)
7859 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7862 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
7863 throw INTERP_KERNEL::Exception(oss.str());
7865 items[i]=timeStep->splitMultiDiscrPerGeoTypes();
7866 if(szOut==std::numeric_limits<std::size_t>::max())
7867 szOut=items[i].size();
7869 if(items[i].size()!=szOut)
7870 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
7872 if(szOut==std::numeric_limits<std::size_t>::max())
7873 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
7874 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
7875 for(std::size_t i=0;i<szOut;i++)
7877 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7878 for(std::size_t j=0;j<sz;j++)
7879 elt->pushBackTimeStep(items[j][i]);
7881 elt->MEDFileFieldNameScope::operator=(*this);
7886 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
7888 setName(field->getName());
7889 if(field->getMesh())
7890 setMeshName(field->getMesh()->getName());
7892 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
7894 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
7895 _infos=arr->getInfoOnComponents();
7898 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
7900 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
7901 if(_name!=field->getName())
7903 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
7904 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
7905 throw INTERP_KERNEL::Exception(oss.str());
7908 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
7909 checkThatComponentsMatch(arr->getInfoOnComponents());
7912 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
7914 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
7915 if(getInfo().size()!=compos.size())
7917 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
7918 oss << " number of components of element to append (" << compos.size() << ") !";
7919 throw INTERP_KERNEL::Exception(oss.str());
7923 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
7924 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
7925 oss << " But compo in input fields are : ";
7926 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
7928 throw INTERP_KERNEL::Exception(oss.str());
7932 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
7934 std::size_t sz=_infos.size();
7936 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
7938 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7940 if(elt->getInfo().size()!=sz)
7942 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
7943 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
7944 throw INTERP_KERNEL::Exception(oss.str());
7949 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
7952 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7953 if(!_time_steps.empty())
7954 checkCoherencyOfTinyInfo(field,arr);
7955 MEDFileAnyTypeField1TSWithoutSDA *objC(createNew1TSWithoutSDAEmptyInstance());
7956 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7958 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*field));
7959 objC->setFieldNoProfileSBT(field->timeDiscrSafe(),ft,arr,glob,*this);
7961 copyTinyInfoFrom(field,arr);
7962 _time_steps.push_back(obj);
7965 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
7968 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7969 if(!_time_steps.empty())
7970 checkCoherencyOfTinyInfo(field,arr);
7971 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
7972 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7974 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::NewWithoutCheck(*field));
7975 objC->setFieldProfile(field->timeDiscrSafe(),ft,arr,mesh,meshDimRelToMax,profile,glob,*this);
7977 copyTinyInfoFrom(field,arr);
7978 setMeshName(objC->getMeshName());
7979 _time_steps.push_back(obj);
7982 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ts)
7984 int sz=(int)_time_steps.size();
7987 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
7988 throw INTERP_KERNEL::Exception(oss.str());
7990 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
7993 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
7995 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
7996 throw INTERP_KERNEL::Exception(oss.str());
8002 //= MEDFileFieldMultiTSWithoutSDA
8005 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
8006 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
8008 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
8010 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
8011 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8013 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
8014 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
8017 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
8019 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
8020 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8022 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8024 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8027 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
8029 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
8030 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
8031 ret->setIteration(i,elt);
8037 //= MEDFileAnyTypeFieldMultiTS
8039 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
8043 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8044 try:MEDFileFieldGlobsReal(fid)
8046 _content=BuildContentFrom(fid,loadAll,ms);
8049 catch(INTERP_KERNEL::Exception& e)
8054 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8056 med_field_type typcha;
8057 std::vector<std::string> infos;
8059 std::string meshName;
8061 MEDFileAnyTypeField1TS::LocateField(fid,fieldName,i,typcha,infos,dtunit,meshName);
8062 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8067 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8072 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8077 ret=new MEDFileFloatFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8082 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] !";
8083 throw INTERP_KERNEL::Exception(oss.str());
8086 ret->setMeshName(meshName);
8087 ret->setDtUnit(dtunit.c_str());
8091 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8093 med_field_type typcha;
8095 std::vector<std::string> infos;
8096 std::string dtunit,fieldName,meshName;
8097 MEDFileAnyTypeField1TS::LocateField2(fid,0,true,fieldName,typcha,infos,dtunit,meshName);
8098 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8103 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8108 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8113 ret=new MEDFileFloatFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8118 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] !";
8119 throw INTERP_KERNEL::Exception(oss.str());
8122 ret->setMeshName(meshName);
8123 ret->setDtUnit(dtunit.c_str());
8127 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c)
8130 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
8131 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
8133 MCAuto<MEDFileFieldMultiTS> ret(MEDFileFieldMultiTS::New());
8134 ret->_content=c; c->incrRef();
8137 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
8139 MCAuto<MEDFileIntFieldMultiTS> ret(MEDFileIntFieldMultiTS::New());
8140 ret->_content=c; c->incrRef();
8143 if(dynamic_cast<const MEDFileFloatFieldMultiTSWithoutSDA *>(c))
8145 MCAuto<MEDFileFloatFieldMultiTS> ret(MEDFileFloatFieldMultiTS::New());
8146 ret->_content=c; c->incrRef();
8149 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 FLOAT32 and INT32 has been built but not intercepted !");
8152 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, med_idt fid)
8154 MEDFileAnyTypeFieldMultiTS *ret(BuildNewInstanceFromContent(c));
8155 std::string fileName(FileNameFromFID(fid));
8156 ret->setFileName(fileName);
8160 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8161 try:MEDFileFieldGlobsReal(fid)
8163 _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
8166 catch(INTERP_KERNEL::Exception& e)
8171 //= MEDFileAnyTypeFieldMultiTS
8174 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
8175 * that has been read from a specified MED file.
8176 * \param [in] fileName - the name of the MED file to read.
8177 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8178 * is to delete this field using decrRef() as it is no more needed.
8179 * \throw If reading the file fails.
8181 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
8183 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8184 return New(fid,loadAll);
8187 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, bool loadAll)
8189 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
8190 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8191 ret->loadGlobals(fid);
8196 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
8197 * that has been read from a specified MED file.
8198 * \param [in] fileName - the name of the MED file to read.
8199 * \param [in] fieldName - the name of the field to read.
8200 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8201 * is to delete this field using decrRef() as it is no more needed.
8202 * \throw If reading the file fails.
8203 * \throw If there is no field named \a fieldName in the file.
8205 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8207 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8208 return New(fid,fieldName,loadAll);
8211 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
8213 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
8214 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8215 ret->loadGlobals(fid);
8220 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8221 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8223 * \warning this is a shallow copy constructor
8225 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8227 if(!shallowCopyOfContent)
8229 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
8230 otherPtr->incrRef();
8231 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
8235 _content=other.shallowCpy();
8239 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
8241 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8243 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
8247 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
8249 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8251 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
8255 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
8257 return contentNotNullBase()->getPflsReallyUsed2();
8260 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
8262 return contentNotNullBase()->getLocsReallyUsed2();
8265 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
8267 return contentNotNullBase()->getPflsReallyUsedMulti2();
8270 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
8272 return contentNotNullBase()->getLocsReallyUsedMulti2();
8275 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8277 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
8280 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8282 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
8285 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
8287 return contentNotNullBase()->getNumberOfTS();
8290 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
8292 contentNotNullBase()->eraseEmptyTS();
8295 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
8297 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
8300 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
8302 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
8305 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
8307 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
8308 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8313 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
8315 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
8316 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8321 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
8323 return contentNotNullBase()->getIterations();
8326 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
8328 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
8329 pushBackTimeStep(*it);
8332 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
8335 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
8336 int nbOfTS(fmts->getNumberOfTS());
8337 for(int i=0;i<nbOfTS;i++)
8339 MCAuto<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
8340 pushBackTimeStep(elt);
8344 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
8347 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
8348 checkCoherencyOfType(f1ts);
8350 MCAuto<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
8351 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
8353 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
8354 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
8355 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
8356 _content->pushBackTimeStep(cSafe);
8357 appendGlobs(*f1ts,1e-12);
8360 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
8362 contentNotNullBase()->synchronizeNameScope();
8365 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
8367 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
8370 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
8372 return contentNotNullBase()->getPosGivenTime(time,eps);
8375 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8377 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
8380 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
8382 return contentNotNullBase()->getTypesOfFieldAvailable();
8385 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
8387 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
8390 std::string MEDFileAnyTypeFieldMultiTS::getName() const
8392 return contentNotNullBase()->getName();
8395 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
8397 contentNotNullBase()->setName(name);
8400 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
8402 return contentNotNullBase()->getDtUnit();
8405 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
8407 contentNotNullBase()->setDtUnit(dtUnit);
8410 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8412 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
8415 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
8417 return contentNotNullBase()->getTimeSteps(ret1);
8420 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
8422 return contentNotNullBase()->getMeshName();
8425 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
8427 contentNotNullBase()->setMeshName(newMeshName);
8430 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
8432 return contentNotNullBase()->changeMeshNames(modifTab);
8435 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
8437 return contentNotNullBase()->getInfo();
8440 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
8442 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
8445 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
8447 return contentNotNullBase()->setInfo(info);
8450 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
8452 const std::vector<std::string> ret=getInfo();
8453 return (int)ret.size();
8456 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
8458 writeGlobals(fid,*this);
8459 contentNotNullBase()->writeLL(fid,*this);
8463 * This method alloc the arrays and load potentially huge arrays contained in this field.
8464 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
8465 * This method can be also called to refresh or reinit values from a file.
8467 * \throw If the fileName is not set or points to a non readable MED file.
8469 void MEDFileAnyTypeFieldMultiTS::loadArrays()
8471 if(getFileName().empty())
8472 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
8473 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
8474 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
8478 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
8479 * But once data loaded once, this method does nothing.
8481 * \throw If the fileName is not set or points to a non readable MED file.
8482 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
8484 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
8486 if(!getFileName().empty())
8488 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
8489 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
8494 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
8495 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
8496 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
8498 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
8500 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
8502 contentNotNullBase()->unloadArrays();
8506 * 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.
8507 * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
8508 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
8510 * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
8512 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
8514 if(!getFileName().empty())
8515 contentNotNullBase()->unloadArrays();
8518 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
8520 std::ostringstream oss;
8521 contentNotNullBase()->simpleRepr(0,oss,-1);
8522 simpleReprGlobs(oss);
8526 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
8528 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
8531 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
8533 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
8534 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
8539 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
8540 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8541 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
8543 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
8545 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8547 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
8548 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
8549 std::size_t sz(contentsSplit.size());
8550 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8551 for(std::size_t i=0;i<sz;i++)
8553 ret[i]=shallowCpy();
8554 ret[i]->_content=contentsSplit[i];
8560 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
8561 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8563 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
8565 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8567 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
8568 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
8569 std::size_t sz(contentsSplit.size());
8570 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8571 for(std::size_t i=0;i<sz;i++)
8573 ret[i]=shallowCpy();
8574 ret[i]->_content=contentsSplit[i];
8580 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
8581 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8583 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
8585 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8587 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
8588 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
8589 std::size_t sz(contentsSplit.size());
8590 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8591 for(std::size_t i=0;i<sz;i++)
8593 ret[i]=shallowCpy();
8594 ret[i]->_content=contentsSplit[i];
8599 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCopy() const
8601 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8602 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
8603 ret->_content=_content->deepCopy();
8604 ret->deepCpyGlobs(*this);
8608 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
8614 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8615 * \param [in] iteration - the iteration number of a required time step.
8616 * \param [in] order - the iteration order number of required time step.
8617 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
8618 * delete this field using decrRef() as it is no more needed.
8619 * \throw If there is no required time step in \a this field.
8621 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
8623 int pos=getPosOfTimeStep(iteration,order);
8624 return getTimeStepAtPos(pos);
8628 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8629 * \param [in] time - the time of the time step of interest.
8630 * \param [in] eps - a precision used to compare time values.
8631 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8632 * delete this field using decrRef() as it is no more needed.
8633 * \throw If there is no required time step in \a this field.
8635 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
8637 int pos=getPosGivenTime(time,eps);
8638 return getTimeStepAtPos(pos);
8642 * 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.
8643 * The float64 value of time attached to the pair of integers are not considered here.
8644 * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
8646 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
8647 * \throw If there is a null pointer in \a vectFMTS.
8649 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
8651 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
8652 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8653 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8654 while(!lstFMTS.empty())
8656 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8657 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8659 throw INTERP_KERNEL::Exception(msg);
8660 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
8661 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8662 elt.push_back(curIt); it=lstFMTS.erase(it);
8663 while(it!=lstFMTS.end())
8667 throw INTERP_KERNEL::Exception(msg);
8668 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
8670 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8680 * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
8681 * All returned instances in a subvector can be safely loaded, rendered along time
8682 * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
8683 * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
8684 * 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).
8685 * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
8686 * 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.
8688 * \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().
8689 * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
8690 * \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.
8691 * \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.
8693 * \throw If an element in \a vectFMTS has not only one spatial discretization set.
8694 * \throw If an element in \a vectFMTS change of spatial discretization along time.
8695 * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
8696 * \thorw If some elements in \a vectFMTS do not have the same times steps.
8697 * \throw If mesh is null.
8698 * \throw If an element in \a vectFMTS is null.
8699 * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
8701 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& fsc)
8703 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
8705 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
8706 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8707 if(vectFMTS.empty())
8709 std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
8710 MEDFileAnyTypeFieldMultiTS *frstElt(*it);
8712 throw INTERP_KERNEL::Exception(msg);
8714 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
8715 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
8716 for(;it!=vectFMTS.end();it++,i++)
8719 throw INTERP_KERNEL::Exception(msg);
8720 TypeOfField tof0,tof1;
8721 if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
8724 vectFMTSNotNodes.push_back(*it);
8726 vectFMTSNodes.push_back(*it);
8729 vectFMTSNotNodes.push_back(*it);
8731 std::vector< MCAuto<MEDFileFastCellSupportComparator> > cmps;
8732 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
8734 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
8737 bool isFetched(false);
8738 for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
8741 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
8742 if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
8743 { ret[i].push_back(*it2); isFetched=true; }
8747 std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
8748 MCAuto<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
8749 ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
8757 * 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.
8758 * \param [out] cmps - same size than the returned vector.
8760 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& cmps)
8762 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8763 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8764 while(!lstFMTS.empty())
8766 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8767 MEDFileAnyTypeFieldMultiTS *ref(*it);
8768 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8769 elt.push_back(ref); it=lstFMTS.erase(it);
8770 MCAuto<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
8771 MCAuto<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
8772 while(it!=lstFMTS.end())
8774 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8775 if(cmp->isEqual(curIt))
8776 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8780 ret.push_back(elt); cmps.push_back(cmp);
8786 * 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.
8787 * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
8789 * \throw If \a f0 or \a f1 has not only one spatial discretization set.
8790 * \throw If \a f0 or \a f1 change of spatial discretization along time.
8791 * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
8792 * \thorw If \a f0 and \a f1 do not have the same times steps.
8793 * \throw If mesh is null.
8794 * \throw If \a f0 or \a f1 is null.
8795 * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
8797 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
8800 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
8802 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
8803 if(f0->getMeshName()!=mesh->getName())
8805 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8806 throw INTERP_KERNEL::Exception(oss.str());
8808 if(f1->getMeshName()!=mesh->getName())
8810 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8811 throw INTERP_KERNEL::Exception(oss.str());
8813 int nts=f0->getNumberOfTS();
8814 if(nts!=f1->getNumberOfTS())
8815 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
8818 for(int i=0;i<nts;i++)
8820 MCAuto<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
8821 MCAuto<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
8822 std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
8823 if(tofs0.size()!=1 || tofs1.size()!=1)
8824 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
8827 if(tof0!=tofs0[0] || tof1!=tofs1[0])
8828 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
8831 { tof0=tofs0[0]; tof1=tofs1[0]; }
8832 if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
8834 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() << ") !";
8835 throw INTERP_KERNEL::Exception(oss.str());
8837 if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
8839 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() << ") !";
8840 throw INTERP_KERNEL::Exception(oss.str());
8842 if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
8844 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() << ") !";
8845 throw INTERP_KERNEL::Exception(oss.str());
8852 MCAuto<MEDFileAnyTypeField1TS> AggregateHelperF1TS(const std::vector< typename MLFieldTraits<T>::F1TSType const *>& f1tss, const std::vector< std::vector< std::pair<int,int> > >& dts)
8854 MCAuto< typename MLFieldTraits<T>::F1TSType > ret(MLFieldTraits<T>::F1TSType::New());
8856 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : empty vector !");
8857 std::size_t sz(f1tss.size()),i(0);
8858 std::vector< typename MLFieldTraits<T>::F1TSWSDAType const *> f1tsw(sz);
8859 for(typename std::vector< typename MLFieldTraits<T>::F1TSType const *>::const_iterator it=f1tss.begin();it!=f1tss.end();it++,i++)
8861 typename MLFieldTraits<T>::F1TSType const *elt(*it);
8863 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : presence of a null pointer !");
8864 f1tsw[i]=dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType const *>(elt->contentNotNullBase());
8866 typename MLFieldTraits<T>::F1TSWSDAType *retc(dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType *>(ret->contentNotNullBase()));
8868 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : internal error 1 !");
8869 retc->aggregate(f1tsw,dts);
8870 ret->setDtUnit(f1tss[0]->getDtUnit());
8871 return DynamicCast<typename MLFieldTraits<T>::F1TSType , MEDFileAnyTypeField1TS>(ret);
8875 MCAuto< MEDFileAnyTypeFieldMultiTS > AggregateHelperFMTS(const std::vector< typename MLFieldTraits<T>::FMTSType const *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
8877 MCAuto< typename MLFieldTraits<T>::FMTSType > ret(MLFieldTraits<T>::FMTSType::New());
8879 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : empty vector !");
8880 std::size_t sz(fmtss.size());
8881 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
8883 typename MLFieldTraits<T>::FMTSType const *elt(*it);
8885 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : presence of null pointer !");
8887 int nbTS(fmtss[0]->getNumberOfTS());
8888 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
8889 if((*it)->getNumberOfTS()!=nbTS)
8890 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : all fields must have the same number of TS !");
8891 for(int iterTS=0;iterTS<nbTS;iterTS++)
8894 std::vector< typename MLFieldTraits<T>::F1TSType const *> f1tss(sz);
8895 std::vector< MCAuto<typename MLFieldTraits<T>::F1TSType> > f1tss2(sz);
8896 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++,i++)
8897 { f1tss2[i]=(*it)->getTimeStepAtPos(iterTS); f1tss[i]=f1tss2[i]; }
8898 MCAuto<MEDFileAnyTypeField1TS> f1ts(AggregateHelperF1TS<T>(f1tss,dts));
8899 ret->pushBackTimeStep(f1ts);
8900 ret->setDtUnit(f1ts->getDtUnit());
8902 return DynamicCast<typename MLFieldTraits<T>::FMTSType , MEDFileAnyTypeFieldMultiTS>(ret);
8906 * \a dts and \a ftmss are expected to have same size.
8908 MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileAnyTypeFieldMultiTS::Aggregate(const std::vector<const MEDFileAnyTypeFieldMultiTS *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
8911 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : input vector is empty !");
8912 std::size_t sz(fmtss.size());
8913 std::vector<const MEDFileFieldMultiTS *> fmtss1;
8914 std::vector<const MEDFileIntFieldMultiTS *> fmtss2;
8915 for(std::vector<const MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
8918 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : presence of null instance in input vector !");
8919 const MEDFileFieldMultiTS *elt1(dynamic_cast<const MEDFileFieldMultiTS *>(*it));
8922 fmtss1.push_back(elt1);
8925 const MEDFileIntFieldMultiTS *elt2(dynamic_cast<const MEDFileIntFieldMultiTS *>(*it));
8928 fmtss2.push_back(elt2);
8931 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not recognized type !");
8933 if(fmtss1.size()!=sz && fmtss2.size()!=sz)
8934 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : type of data is not homogeneous !");
8935 if(fmtss1.size()==sz)
8936 return AggregateHelperFMTS<double>(fmtss1,dts);
8937 if(fmtss2.size()!=sz)
8938 return AggregateHelperFMTS<int>(fmtss2,dts);
8939 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not implemented yet !");
8942 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
8944 return new MEDFileAnyTypeFieldMultiTSIterator(this);
8947 //= MEDFileFieldMultiTS
8949 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
8951 return new MEDFileFieldMultiTS(*this);
8955 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
8956 * following the given input policy.
8958 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
8959 * By default (true) the globals are deeply copied.
8960 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
8962 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
8964 MCAuto<MEDFileIntFieldMultiTS> ret;
8965 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8968 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
8970 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
8971 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
8972 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc));
8975 ret=MEDFileIntFieldMultiTS::New();
8977 ret->deepCpyGlobs(*this);
8979 ret->shallowCpyGlobs(*this);
8983 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8984 try:MEDFileTemplateFieldMultiTS<double>(fid,loadAll,ms)
8987 catch(INTERP_KERNEL::Exception& e)
8990 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8991 try:MEDFileTemplateFieldMultiTS<double>(fid,fieldName,loadAll,ms,entities)
8994 catch(INTERP_KERNEL::Exception& e)
8997 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileTemplateFieldMultiTS<double>(other,shallowCopyOfContent)
9001 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
9003 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
9006 //= MEDFileAnyTypeFieldMultiTSIterator
9008 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
9013 _nb_iter=fmts->getNumberOfTS();
9017 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
9021 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
9023 if(_iter_id<_nb_iter)
9025 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
9027 return fmts->getTimeStepAtPos(_iter_id++);
9035 //= MEDFileIntFieldMultiTS
9039 MEDFileFields *MEDFileFields::New()
9041 return new MEDFileFields;
9044 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
9046 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9047 return New(fid,loadAll);
9050 MEDFileFields *MEDFileFields::NewAdv(const std::string& fileName, bool loadAll, const MEDFileEntities *entities)
9052 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9053 return NewAdv(fid,loadAll,entities);
9056 MEDFileFields *MEDFileFields::NewAdv(med_idt fid, bool loadAll, const MEDFileEntities *entities)
9058 return new MEDFileFields(fid,loadAll,0,entities);
9061 MEDFileFields *MEDFileFields::NewWithDynGT(const std::string& fileName, const MEDFileStructureElements *se, bool loadAll)
9063 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9064 return NewWithDynGT(fid,se,loadAll);
9067 MEDFileFields *MEDFileFields::NewWithDynGT(med_idt fid, const MEDFileStructureElements *se, bool loadAll)
9070 throw INTERP_KERNEL::Exception("MEDFileFields::NewWithDynGT : null struct element pointer !");
9071 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> entities(MEDFileEntities::BuildFrom(*se));
9072 return new MEDFileFields(fid,loadAll,0,entities);
9075 MEDFileFields *MEDFileFields::New(med_idt fid, bool loadAll)
9077 return new MEDFileFields(fid,loadAll,0,0);
9080 MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9082 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9083 return new MEDFileFields(fid,loadAll,ms,0);
9086 MEDFileFields *MEDFileFields::LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9088 MEDFileUtilities::CheckFileForRead(fileName);
9089 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
9090 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9091 return new MEDFileFields(fid,loadAll,0,ent);
9094 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
9096 std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
9097 ret+=_fields.capacity()*sizeof(MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
9101 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
9103 std::vector<const BigMemoryObject *> ret;
9104 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9105 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
9109 MEDFileFields *MEDFileFields::deepCopy() const
9111 MCAuto<MEDFileFields> ret(shallowCpy());
9113 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9115 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9116 ret->_fields[i]=(*it)->deepCopy();
9118 ret->deepCpyGlobs(*this);
9122 MEDFileFields *MEDFileFields::shallowCpy() const
9124 return new MEDFileFields(*this);
9128 * 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
9129 * 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.
9130 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
9132 * \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.
9133 * \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.
9135 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9137 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
9139 std::set< std::pair<int,int> > s;
9140 bool firstShot=true;
9141 areThereSomeForgottenTS=false;
9142 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9144 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9146 std::vector< std::pair<int,int> > v=(*it)->getIterations();
9147 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
9149 { s=s1; firstShot=false; }
9152 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
9154 areThereSomeForgottenTS=true;
9158 std::vector< std::pair<int,int> > ret;
9159 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
9163 int MEDFileFields::getNumberOfFields() const
9165 return _fields.size();
9168 std::vector<std::string> MEDFileFields::getFieldsNames() const
9170 std::vector<std::string> ret(_fields.size());
9172 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9174 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
9177 ret[i]=f->getName();
9181 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
9182 throw INTERP_KERNEL::Exception(oss.str());
9188 std::vector<std::string> MEDFileFields::getMeshesNames() const
9190 std::vector<std::string> ret;
9191 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9193 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9195 ret.push_back(cur->getMeshName());
9200 std::string MEDFileFields::simpleRepr() const
9202 std::ostringstream oss;
9203 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
9208 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
9210 int nbOfFields(getNumberOfFields());
9211 std::string startLine(bkOffset,' ');
9212 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
9214 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9216 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9219 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
9223 oss << startLine << " - not defined !" << std::endl;
9227 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9229 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9230 std::string chapter(17,'0'+i);
9231 oss << startLine << chapter << std::endl;
9234 cur->simpleRepr(bkOffset+2,oss,i);
9238 oss << startLine << " - not defined !" << std::endl;
9240 oss << startLine << chapter << std::endl;
9242 simpleReprGlobs(oss);
9245 MEDFileFields::MEDFileFields()
9249 MEDFileFields::MEDFileFields(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
9250 try:MEDFileFieldGlobsReal(fid)
9252 int nbFields(MEDnField(fid));
9253 _fields.resize(nbFields);
9254 med_field_type typcha;
9255 for(int i=0;i<nbFields;i++)
9257 std::vector<std::string> infos;
9258 std::string fieldName,dtunit,meshName;
9259 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,i,false,fieldName,typcha,infos,dtunit,meshName));
9264 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName,meshName,typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
9269 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName,meshName,typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
9274 _fields[i]=MEDFileFloatFieldMultiTSWithoutSDA::New(fid,fieldName,meshName,typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
9279 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] !";
9280 throw INTERP_KERNEL::Exception(oss.str());
9284 loadAllGlobals(fid,entities);
9286 catch(INTERP_KERNEL::Exception& e)
9291 void MEDFileFields::writeLL(med_idt fid) const
9294 writeGlobals(fid,*this);
9295 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9297 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
9300 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
9301 throw INTERP_KERNEL::Exception(oss.str());
9303 elt->writeLL(fid,*this);
9308 * This method alloc the arrays and load potentially huge arrays contained in this field.
9309 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
9310 * This method can be also called to refresh or reinit values from a file.
9312 * \throw If the fileName is not set or points to a non readable MED file.
9314 void MEDFileFields::loadArrays()
9316 if(getFileName().empty())
9317 throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
9318 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
9319 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9321 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9323 elt->loadBigArraysRecursively(fid,*elt);
9328 * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
9329 * But once data loaded once, this method does nothing.
9331 * \throw If the fileName is not set or points to a non readable MED file.
9332 * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
9334 void MEDFileFields::loadArraysIfNecessary()
9336 if(!getFileName().empty())
9338 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
9339 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9341 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9343 elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
9349 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
9350 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
9351 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
9353 * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
9355 void MEDFileFields::unloadArrays()
9357 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9359 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9361 elt->unloadArrays();
9366 * 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.
9367 * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
9368 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
9370 * \sa MEDFileFields::loadArraysIfNecessary
9372 void MEDFileFields::unloadArraysWithoutDataLoss()
9374 if(!getFileName().empty())
9378 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
9380 std::vector<std::string> ret;
9381 std::set<std::string> ret2;
9382 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9384 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
9385 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
9386 if(ret2.find(*it2)==ret2.end())
9388 ret.push_back(*it2);
9395 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
9397 std::vector<std::string> ret;
9398 std::set<std::string> ret2;
9399 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9401 std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
9402 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
9403 if(ret2.find(*it2)==ret2.end())
9405 ret.push_back(*it2);
9412 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
9414 std::vector<std::string> ret;
9415 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9417 std::vector<std::string> tmp((*it)->getPflsReallyUsedMulti2());
9418 ret.insert(ret.end(),tmp.begin(),tmp.end());
9423 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
9425 std::vector<std::string> ret;
9426 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9428 std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
9429 ret.insert(ret.end(),tmp.begin(),tmp.end());
9434 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
9436 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
9437 (*it)->changePflsRefsNamesGen2(mapOfModif);
9440 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
9442 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
9443 (*it)->changeLocsRefsNamesGen2(mapOfModif);
9446 void MEDFileFields::resize(int newSize)
9448 _fields.resize(newSize);
9451 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
9453 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
9457 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
9460 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
9461 _fields.push_back(field->getContent());
9462 appendGlobs(*field,1e-12);
9465 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
9468 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
9469 if(i>=(int)_fields.size())
9470 _fields.resize(i+1);
9471 _fields[i]=field->getContent();
9472 appendGlobs(*field,1e-12);
9475 void MEDFileFields::destroyFieldAtPos(int i)
9477 destroyFieldsAtPos(&i,&i+1);
9480 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
9482 std::vector<bool> b(_fields.size(),true);
9483 for(const int *i=startIds;i!=endIds;i++)
9485 if(*i<0 || *i>=(int)_fields.size())
9487 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
9488 throw INTERP_KERNEL::Exception(oss.str());
9492 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
9494 for(std::size_t i=0;i<_fields.size();i++)
9496 fields[j++]=_fields[i];
9500 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
9502 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
9503 int nbOfEntriesToKill(DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg));
9504 std::vector<bool> b(_fields.size(),true);
9506 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
9508 if(k<0 || k>=(int)_fields.size())
9510 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
9511 throw INTERP_KERNEL::Exception(oss.str());
9515 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
9517 for(std::size_t i=0;i<_fields.size();i++)
9519 fields[j++]=_fields[i];
9523 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
9526 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9528 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9530 ret=cur->changeMeshNames(modifTab) || ret;
9536 * \param [in] meshName the name of the mesh that will be renumbered.
9537 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
9538 * This code corresponds to the distribution of types in the corresponding mesh.
9539 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
9540 * \param [in] renumO2N the old to new renumber array.
9541 * \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
9544 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
9547 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9549 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
9552 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
9559 * Return an extraction of \a this using \a extractDef map to specify the extraction.
9560 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
9562 * \return A new object that the caller is responsible to deallocate.
9564 MEDFileFields *MEDFileFields::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
9567 throw INTERP_KERNEL::Exception("MEDFileFields::extractPart : input mesh is NULL !");
9568 MCAuto<MEDFileFields> fsOut(MEDFileFields::New());
9569 int nbFields(getNumberOfFields());
9570 for(int i=0;i<nbFields;i++)
9572 MCAuto<MEDFileAnyTypeFieldMultiTS> fmts(getFieldAtPos(i));
9575 std::ostringstream oss; oss << "MEDFileFields::extractPart : at pos #" << i << " field is null !";
9576 throw INTERP_KERNEL::Exception(oss.str());
9578 MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(fmts->extractPart(extractDef,mm));
9579 fsOut->pushField(fmtsOut);
9581 return fsOut.retn();
9584 void MEDFileFields::accept(MEDFileFieldVisitor& visitor) const
9586 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9587 if((*it).isNotNull())
9589 visitor.newFieldEntry(*it);
9590 (*it)->accept(visitor);
9591 visitor.endFieldEntry(*it);
9595 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
9597 if(i<0 || i>=(int)_fields.size())
9599 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
9600 throw INTERP_KERNEL::Exception(oss.str());
9602 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
9605 MCAuto<MEDFileAnyTypeFieldMultiTS> ret;
9606 const MEDFileFieldMultiTSWithoutSDA *fmtsC(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts));
9607 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts));
9608 const MEDFileFloatFieldMultiTSWithoutSDA *fmtsC3(dynamic_cast<const MEDFileFloatFieldMultiTSWithoutSDA *>(fmts));
9610 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
9612 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
9614 ret=MEDFileFloatFieldMultiTS::New(*fmtsC3,false);
9617 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor float (FLOAT32) nor integer (INT32) !";
9618 throw INTERP_KERNEL::Exception(oss.str());
9620 ret->shallowCpyGlobs(*this);
9625 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
9626 * This method is accessible in python using __getitem__ with a list in input.
9627 * \return a new object that the caller should deal with.
9629 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
9631 MCAuto<MEDFileFields> ret=shallowCpy();
9632 std::size_t sz=std::distance(startIds,endIds);
9633 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
9635 for(const int *i=startIds;i!=endIds;i++,j++)
9637 if(*i<0 || *i>=(int)_fields.size())
9639 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
9640 throw INTERP_KERNEL::Exception(oss.str());
9642 fields[j]=_fields[*i];
9644 ret->_fields=fields;
9648 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
9650 return getFieldAtPos(getPosFromFieldName(fieldName));
9654 * This method removes, if any, fields in \a this having no time steps.
9655 * 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.
9657 * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
9659 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
9661 std::vector<MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
9662 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9664 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9667 if(elt->getNumberOfTS()>0)
9668 newFields.push_back(*it);
9671 if(_fields.size()==newFields.size())
9678 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
9679 * This method can be seen as a filter applied on \a this, that returns an object containing
9680 * 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
9681 * shallow copied from \a this.
9683 * \param [in] meshName - the name of the mesh on w
9684 * \return a new object that the caller should deal with.
9686 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
9688 MCAuto<MEDFileFields> ret(MEDFileFields::New());
9689 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9691 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9694 if(cur->getMeshName()==meshName)
9697 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
9698 ret->_fields.push_back(cur2);
9701 ret->shallowCpyOnlyUsedGlobs(*this);
9706 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
9707 * Input time steps are specified using a pair of integer (iteration, order).
9708 * 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,
9709 * but for each multitimestep only the time steps in \a timeSteps are kept.
9710 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
9712 * The returned object points to shallow copy of elements in \a this.
9714 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
9715 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
9716 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9718 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
9720 MCAuto<MEDFileFields> ret(MEDFileFields::New());
9721 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9723 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9726 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
9727 ret->_fields.push_back(elt);
9729 ret->shallowCpyOnlyUsedGlobs(*this);
9734 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
9736 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
9738 MCAuto<MEDFileFields> ret=MEDFileFields::New();
9739 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9741 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9744 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
9745 if(elt->getNumberOfTS()!=0)
9746 ret->_fields.push_back(elt);
9748 ret->shallowCpyOnlyUsedGlobs(*this);
9752 bool MEDFileFields::presenceOfStructureElements() const
9754 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9755 if((*it).isNotNull())
9756 if((*it)->presenceOfStructureElements())
9761 void MEDFileFields::killStructureElements()
9763 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
9764 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9765 if((*it).isNotNull())
9767 if((*it)->presenceOfStructureElements())
9769 if(!(*it)->onlyStructureElements())
9771 (*it)->killStructureElements();
9783 void MEDFileFields::keepOnlyStructureElements()
9785 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
9786 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9787 if((*it).isNotNull())
9789 if((*it)->presenceOfStructureElements())
9791 if(!(*it)->onlyStructureElements())
9792 (*it)->keepOnlyStructureElements();
9799 void MEDFileFields::keepOnlyOnMeshSE(const std::string& meshName, const std::string& seName)
9801 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
9802 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9803 if((*it).isNotNull())
9805 if((*it)->getMeshName()!=meshName)
9807 std::vector< std::pair<std::string,std::string> > ps;
9808 (*it)->getMeshSENames(ps);
9809 std::pair<std::string,std::string> p(meshName,seName);
9810 if(std::find(ps.begin(),ps.end(),p)!=ps.end())
9811 (*it)->keepOnlyOnSE(seName);
9817 void MEDFileFields::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
9819 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9820 if((*it).isNotNull())
9821 (*it)->getMeshSENames(ps);
9824 void MEDFileFields::blowUpSE(MEDFileMeshes *ms, const MEDFileStructureElements *ses)
9826 MEDFileBlowStrEltUp::DealWithSE(this,ms,ses);
9829 MCAuto<MEDFileFields> MEDFileFields::partOfThisOnStructureElements() const
9831 MCAuto<MEDFileFields> ret(deepCopy());
9832 ret->keepOnlyStructureElements();
9836 MCAuto<MEDFileFields> MEDFileFields::partOfThisLyingOnSpecifiedMeshSEName(const std::string& meshName, const std::string& seName) const
9838 MCAuto<MEDFileFields> ret(deepCopy());
9839 ret->keepOnlyOnMeshSE(meshName,seName);
9843 void MEDFileFields::aggregate(const MEDFileFields& other)
9845 int nbFieldsToAdd(other.getNumberOfFields());
9846 std::vector<std::string> fsn(getFieldsNames());
9847 for(int i=0;i<nbFieldsToAdd;i++)
9849 MCAuto<MEDFileAnyTypeFieldMultiTS> elt(other.getFieldAtPos(i));
9850 std::string name(elt->getName());
9851 if(std::find(fsn.begin(),fsn.end(),name)!=fsn.end())
9853 std::ostringstream oss; oss << "MEDFileFields::aggregate : name \"" << name << "\" already appears !";
9854 throw INTERP_KERNEL::Exception(oss.str());
9860 MEDFileFieldsIterator *MEDFileFields::iterator()
9862 return new MEDFileFieldsIterator(this);
9865 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
9867 std::string tmp(fieldName);
9868 std::vector<std::string> poss;
9869 for(std::size_t i=0;i<_fields.size();i++)
9871 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f(_fields[i]);
9874 std::string fname(f->getName());
9878 poss.push_back(fname);
9881 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
9882 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
9884 throw INTERP_KERNEL::Exception(oss.str());
9887 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
9892 _nb_iter=fs->getNumberOfFields();
9896 MEDFileFieldsIterator::~MEDFileFieldsIterator()
9900 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
9902 if(_iter_id<_nb_iter)
9904 MEDFileFields *fs(_fs);
9906 return fs->getFieldAtPos(_iter_id++);