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 MEDFILESAFECALLERRD0(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 MEDFILESAFECALLERRD0(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 MEDFILESAFECALLERRD0(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 MEDFILESAFECALLERRD0(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 MEDFILESAFECALLERWR0(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 MEDFILESAFECALLERRD0(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 MEDFILESAFECALLERRD0(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 * MED file does not support ' ' at the end of the field name. This method corrects the possibly invalid input \a nonCorrectFieldName to a correct one by right stripping input.
5083 std::string MEDFileAnyTypeField1TSWithoutSDA::FieldNameToMEDFileConvention(const std::string& nonCorrectFieldName)
5085 std::string::size_type pos0(nonCorrectFieldName.find_last_not_of(' '));
5086 if(pos0==std::string::npos)
5087 return nonCorrectFieldName;
5088 if(pos0+1==nonCorrectFieldName.length())
5089 return nonCorrectFieldName;
5090 return nonCorrectFieldName.substr(0,pos0+1);
5094 * 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.
5095 * If false is returned the memory allocation is not required.
5097 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
5099 if(_nb_of_tuples_to_be_allocated>=0)
5101 getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
5102 _nb_of_tuples_to_be_allocated=-2;
5105 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
5107 if(_nb_of_tuples_to_be_allocated==-1)
5108 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
5109 if(_nb_of_tuples_to_be_allocated<-3)
5110 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
5111 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
5114 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
5116 med_int numdt,numit;
5118 med_int meshnumdt,meshnumit;
5119 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt));
5123 INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
5124 MEDFILESAFECALLERRD0(MEDfield23ComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit)); // to check with Adrien for legacy MED files
5126 //MEDFILESAFECALLERRD0(MEDfieldComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt,&meshnumdt,&meshnumit));
5127 if(_iteration!=numdt || _order!=numit)
5128 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
5129 _field_per_mesh.resize(1);
5134 mm=ms->getMeshWithName(getMeshName());
5137 _field_per_mesh[0]=MEDFileFieldPerMesh::NewOnRead(fid,this,0,meshnumdt,meshnumit,nasc,mm,entities);
5138 _nb_of_tuples_to_be_allocated=0;
5139 _field_per_mesh[0]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
5142 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
5144 allocIfNecessaryTheArrayToReceiveDataFromFile();
5145 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5146 (*it)->loadBigArraysRecursively(fid,nasc);
5149 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
5151 if(allocIfNecessaryTheArrayToReceiveDataFromFile())
5152 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5153 (*it)->loadBigArraysRecursively(fid,nasc);
5156 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
5158 loadOnlyStructureOfDataRecursively(fid,nasc,ms,entities);
5159 loadBigArraysRecursively(fid,nasc);
5162 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
5164 DataArray *thisArr(getUndergroundDataArray());
5165 if(thisArr && thisArr->isAllocated())
5167 _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
5168 thisArr->desallocate();
5172 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
5174 return _mesh_name.capacity()+_dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MCAuto< MEDFileFieldPerMesh >);
5177 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
5179 std::vector<const BigMemoryObject *> ret;
5180 if(getUndergroundDataArray())
5181 ret.push_back(getUndergroundDataArray());
5182 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5183 ret.push_back((const MEDFileFieldPerMesh *)*it);
5188 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
5189 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
5190 * "Sort By Type"), if not, an exception is thrown.
5191 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
5192 * \param [in] arr - the array of values.
5193 * \param [in,out] glob - the global data where profiles and localization present in
5194 * \a field, if any, are added.
5195 * \throw If the name of \a field is empty.
5196 * \throw If the data array of \a field is not set.
5197 * \throw If \a this->_arr is already allocated but has different number of components
5199 * \throw If the underlying mesh of \a field has no name.
5200 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
5202 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
5204 const MEDCouplingMesh *mesh(field->getMesh());
5206 TypeOfField type(field->getTypeOfField());
5207 std::vector<DataArrayInt *> dummy;
5209 setMeshName(mesh->getName());
5210 int start(copyTinyInfoFrom(th,field,arr));
5211 int pos(addNewEntryIfNecessary(mesh));
5214 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
5215 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
5218 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
5222 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
5223 * of a given mesh are used as the support of the given field (a real support is not used).
5224 * Elements of the given mesh must be sorted suitable for writing to MED file.
5225 * Order of underlying mesh entities of the given field specified by \a profile parameter
5226 * is not prescribed; this method permutes field values to have them sorted by element
5227 * type as required for writing to MED file. A new profile is added only if no equal
5228 * profile is missing.
5229 * \param [in] field - the field to add to \a this. The field double values are ignored.
5230 * \param [in] arrOfVals - the values of the field \a field used.
5231 * \param [in] mesh - the supporting mesh of \a field.
5232 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
5233 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
5234 * \param [in,out] glob - the global data where profiles and localization present in
5235 * \a field, if any, are added.
5236 * \throw If either \a field or \a mesh or \a profile has an empty name.
5237 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
5238 * \throw If the data array of \a field is not set.
5239 * \throw If \a this->_arr is already allocated but has different number of components
5241 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
5242 * \sa setFieldNoProfileSBT()
5244 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)
5247 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
5248 if(!arrOfVals || !arrOfVals->isAllocated())
5249 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
5250 TypeOfField type=field->getTypeOfField();
5251 std::vector<DataArrayInt *> idsInPflPerType;
5252 std::vector<DataArrayInt *> idsPerType;
5253 std::vector<int> code,code2;
5254 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
5257 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
5258 std::vector< MCAuto<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
5259 std::vector< MCAuto<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin());
5260 std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
5262 MCAuto<MEDCouplingFieldTemplate> field2=field->clone(false);
5263 int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
5264 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
5266 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
5267 throw INTERP_KERNEL::Exception(oss.str());
5270 int start(copyTinyInfoFrom(th,field,arrOfVals));
5271 code2=m->getDistributionOfTypes();
5273 int pos=addNewEntryIfNecessary(m);
5274 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
5278 if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
5279 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
5280 std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
5281 std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
5282 int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
5283 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
5285 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
5286 throw INTERP_KERNEL::Exception(oss.str());
5288 int start(copyTinyInfoFrom(th,field,arrOfVals));
5289 int pos(addNewEntryIfNecessary(m));
5290 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
5295 * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
5297 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
5299 if(_nb_of_tuples_to_be_allocated>=0)
5300 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 !");
5301 DataArray *arr(getOrCreateAndGetArray());
5302 arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
5303 _nb_of_tuples_to_be_allocated=-3;
5307 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
5308 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
5309 * larger by the size of \a field. Returns an id of the first not filled
5310 * tuple of \a this->_arr.
5311 * \param [in] field - the field to copy the info on components and the name from.
5312 * \return int - the id of first not initialized tuple of \a this->_arr.
5313 * \throw If the name of \a field is empty.
5314 * \throw If the data array of \a field is not set.
5315 * \throw If \a this->_arr is already allocated but has different number of components
5318 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arr)
5321 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
5322 std::string name(field->getName());
5323 setName(name.c_str());
5324 if(field->getMesh())
5325 setMeshName(field->getMesh()->getName());
5326 setDtUnit(th->getTimeUnit());
5328 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
5330 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
5331 if(!arr->isAllocated())
5332 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
5333 _dt=th->getTime(_iteration,_order);
5334 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
5335 if(!getOrCreateAndGetArray()->isAllocated())
5337 allocNotFromFile(arr->getNumberOfTuples());
5342 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
5343 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
5344 getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
5345 _nb_of_tuples_to_be_allocated=-3;
5346 return oldNbOfTuples;
5351 * Returns number of components in \a this field
5352 * \return int - the number of components.
5354 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
5356 return getOrCreateAndGetArray()->getNumberOfComponents();
5360 * Change info on components in \a this.
5361 * \throw If size of \a infos is not equal to the number of components already in \a this.
5363 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
5365 DataArray *arr=getOrCreateAndGetArray();
5366 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
5370 * Returns info on components of \a this field.
5371 * \return const std::vector<std::string>& - a sequence of strings each being an
5372 * information on _i_-th component.
5374 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
5376 const DataArray *arr=getOrCreateAndGetArray();
5377 return arr->getInfoOnComponents();
5381 * Returns a mutable info on components of \a this field.
5382 * \return std::vector<std::string>& - a sequence of strings each being an
5383 * information on _i_-th component.
5385 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
5387 DataArray *arr=getOrCreateAndGetArray();
5388 return arr->getInfoOnComponents();
5391 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const
5393 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5395 const MEDFileFieldPerMesh *fpm(*it);
5398 if(fpm->presenceOfMultiDiscPerGeoType())
5404 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfStructureElements() const
5406 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5407 if((*it).isNotNull())
5408 if((*it)->presenceOfStructureElements())
5413 bool MEDFileAnyTypeField1TSWithoutSDA::onlyStructureElements() const
5415 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5416 if((*it).isNotNull())
5417 if(!(*it)->onlyStructureElements())
5422 void MEDFileAnyTypeField1TSWithoutSDA::killStructureElements()
5424 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5425 if((*it).isNotNull())
5426 (*it)->killStructureElements();
5429 void MEDFileAnyTypeField1TSWithoutSDA::keepOnlyStructureElements()
5431 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5432 if((*it).isNotNull())
5433 (*it)->keepOnlyStructureElements();
5436 void MEDFileAnyTypeField1TSWithoutSDA::keepOnlyOnSE(const std::string& seName)
5438 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5439 if((*it).isNotNull())
5440 (*it)->keepOnlyOnSE(seName);
5443 void MEDFileAnyTypeField1TSWithoutSDA::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
5445 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5446 if((*it).isNotNull())
5447 (*it)->getMeshSENames(ps);
5450 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh(const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5452 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 !";
5453 if(_field_per_mesh.empty())
5454 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is empty ! Nothing to extract !");
5455 if(_field_per_mesh.size()>1)
5456 throw INTERP_KERNEL::Exception(MSG0);
5457 if(_field_per_mesh[0].isNull())
5458 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is inconsistent !");
5459 const MEDFileFieldPerMesh *pm(_field_per_mesh[0]);
5460 std::set<TypeOfField> types;
5461 pm->fillTypesOfFieldAvailable(types);
5463 throw INTERP_KERNEL::Exception(MSG0);
5464 TypeOfField type(*types.begin());
5465 int meshDimRelToMax(0);
5470 int myDim(std::numeric_limits<int>::max());
5471 bool isUnique(pm->isUniqueLevel(myDim));
5473 throw INTERP_KERNEL::Exception(MSG0);
5474 meshDimRelToMax=myDim-mesh->getMeshDimension();
5475 if(meshDimRelToMax>0)
5476 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the mesh attached to field is not compatible with the field !");
5478 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,0/*renumPol*/,glob,mesh,arrOut,nasc);
5482 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5483 * \param [in] type - a spatial discretization of the new field.
5484 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5485 * \param [in] mName - a name of the supporting mesh.
5486 * \param [in] renumPol - specifies how to permute values of the result field according to
5487 * the optional numbers of cells and nodes, if any. The valid values are
5488 * - 0 - do not permute.
5489 * - 1 - permute cells.
5490 * - 2 - permute nodes.
5491 * - 3 - permute cells and nodes.
5493 * \param [in] glob - the global data storing profiles and localization.
5494 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5495 * caller is to delete this field using decrRef() as it is no more needed.
5496 * \throw If the MED file is not readable.
5497 * \throw If there is no mesh named \a mName in the MED file.
5498 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5499 * \throw If no field of \a this is lying on the mesh \a mName.
5500 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5502 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5504 MCAuto<MEDFileMesh> mm;
5506 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
5508 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
5509 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
5513 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5514 * \param [in] type - a spatial discretization of the new field.
5515 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5516 * \param [in] renumPol - specifies how to permute values of the result field according to
5517 * the optional numbers of cells and nodes, if any. The valid values are
5518 * - 0 - do not permute.
5519 * - 1 - permute cells.
5520 * - 2 - permute nodes.
5521 * - 3 - permute cells and nodes.
5523 * \param [in] glob - the global data storing profiles and localization.
5524 * \param [in] mesh - the supporting mesh.
5525 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5526 * caller is to delete this field using decrRef() as it is no more needed.
5527 * \throw If the MED file is not readable.
5528 * \throw If no field of \a this is lying on \a mesh.
5529 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5530 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5532 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5534 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax,false));
5535 const DataArrayInt *d(mesh->getNumberFieldAtLevel(meshDimRelToMax)),*e(mesh->getNumberFieldAtLevel(1));
5536 if(meshDimRelToMax==1)
5537 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
5538 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
5542 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
5544 * \param [in] type - a spatial discretization of the new field.
5545 * \param [in] mName - a name of the supporting mesh.
5546 * \param [in] renumPol - specifies how to permute values of the result field according to
5547 * the optional numbers of cells and nodes, if any. The valid values are
5548 * - 0 - do not permute.
5549 * - 1 - permute cells.
5550 * - 2 - permute nodes.
5551 * - 3 - permute cells and nodes.
5553 * \param [in] glob - the global data storing profiles and localization.
5554 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5555 * caller is to delete this field using decrRef() as it is no more needed.
5556 * \throw If the MED file is not readable.
5557 * \throw If there is no mesh named \a mName in the MED file.
5558 * \throw If there are no mesh entities in the mesh.
5559 * \throw If no field values of the given \a type are available.
5561 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5563 MCAuto<MEDFileMesh> mm;
5565 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
5567 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
5568 int absDim=getDimension();
5569 int meshDimRelToMax=absDim-mm->getMeshDimension();
5570 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
5574 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5575 * \param [in] type - a spatial discretization of the new field.
5576 * \param [in] renumPol - specifies how to permute values of the result field according to
5577 * the optional numbers of cells and nodes, if any. The valid values are
5578 * - 0 - do not permute.
5579 * - 1 - permute cells.
5580 * - 2 - permute nodes.
5581 * - 3 - permute cells and nodes.
5583 * \param [in] glob - the global data storing profiles and localization.
5584 * \param [in] mesh - the supporting mesh.
5585 * \param [in] cellRenum - the cell numbers array used for permutation of the result
5586 * field according to \a renumPol.
5587 * \param [in] nodeRenum - the node numbers array used for permutation of the result
5588 * field according to \a renumPol.
5589 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5590 * caller is to delete this field using decrRef() as it is no more needed.
5591 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5592 * \throw If no field of \a this is lying on \a mesh.
5593 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5595 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
5597 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
5599 MCAuto<MEDCouplingFieldDouble> ret=_field_per_mesh[0]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
5604 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5611 throw INTERP_KERNEL::Exception(msg1);
5612 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5615 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
5617 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5618 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
5619 throw INTERP_KERNEL::Exception(oss.str());
5621 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
5622 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
5623 std::vector<DataArray *> arrOut2(1,arrOut);
5624 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
5625 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
5626 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
5633 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5635 throw INTERP_KERNEL::Exception(msg1);
5638 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
5640 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5641 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
5642 throw INTERP_KERNEL::Exception(oss.str());
5644 MCAuto<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
5645 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
5646 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
5647 ret->renumberNodes(nodeRenumSafe->getConstPointer());
5652 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
5657 * Returns values and a profile of the field of a given type lying on a given support.
5658 * \param [in] type - a spatial discretization of the field.
5659 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5660 * \param [in] mesh - the supporting mesh.
5661 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
5662 * field of interest lies on. If the field lies on all entities of the given
5663 * dimension, all ids in \a pfl are zero. The caller is to delete this array
5664 * using decrRef() as it is no more needed.
5665 * \param [in] glob - the global data storing profiles and localization.
5666 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
5667 * field. The caller is to delete this array using decrRef() as it is no more needed.
5668 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
5669 * \throw If no field of \a this is lying on \a mesh.
5670 * \throw If no field values of the given \a type are available.
5672 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
5674 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
5675 MCAuto<DataArray> ret=_field_per_mesh[0]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
5676 ret->setName(nasc.getName().c_str());
5680 //= MEDFileField1TSWithoutSDA
5683 * Throws if a given value is not a valid (non-extended) relative dimension.
5684 * \param [in] meshDimRelToMax - the relative dimension value.
5685 * \throw If \a meshDimRelToMax > 0.
5687 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
5689 if(meshDimRelToMax>0)
5690 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
5694 * Checks if elements of a given mesh are in the order suitable for writing
5695 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
5696 * vector describing types of elements and their number.
5697 * \param [in] mesh - the mesh to check.
5698 * \return std::vector<int> - a vector holding for each element type (1) item of
5699 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
5700 * These values are in full-interlace mode.
5701 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
5703 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
5706 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
5707 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
5708 int nbOfTypes=geoTypes.size();
5709 std::vector<int> code(3*nbOfTypes);
5710 MCAuto<DataArrayInt> arr1=DataArrayInt::New();
5711 arr1->alloc(nbOfTypes,1);
5712 int *arrPtr=arr1->getPointer();
5713 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
5714 for(int i=0;i<nbOfTypes;i++,it++)
5715 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
5716 MCAuto<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
5717 const int *arrPtr2=arr2->getConstPointer();
5719 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
5722 int nbCells=mesh->getNumberOfCellsWithType(*it);
5723 code[3*pos]=(int)(*it);
5724 code[3*pos+1]=nbCells;
5725 code[3*pos+2]=-1;//no profiles
5727 std::vector<const DataArrayInt *> idsPerType;//no profiles
5728 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
5732 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
5737 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5739 return new MEDFileField1TSWithoutSDA(fieldName,meshName,csit,iteration,order,infos);
5743 * Returns all attributes and values of parts of \a this field lying on a given mesh.
5744 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
5745 * item of every of returned sequences refers to the _i_-th part of \a this field.
5746 * Thus all sequences returned by this method are of the same length equal to number
5747 * of different types of supporting entities.<br>
5748 * A field part can include sub-parts with several different spatial discretizations,
5749 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
5750 * for example. Hence, some of the returned sequences contains nested sequences, and an item
5751 * of a nested sequence corresponds to a type of spatial discretization.<br>
5752 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
5753 * The overhead is due to selecting values into new instances of DataArrayDouble.
5754 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
5755 * for the case with only one underlying mesh. (Actually, the number of meshes is
5756 * not checked if \a mname == \c NULL).
5757 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
5758 * a field part is returned.
5759 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
5760 * A field part can include sub-parts with several different spatial discretizations,
5761 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and
5762 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT" for example.
5763 * This sequence is of the same length as \a types.
5764 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
5765 * discretization. A profile name can be empty.
5766 * Length of this and of nested sequences is the same as that of \a typesF.
5767 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
5768 * discretization. A localization name can be empty.
5769 * Length of this and of nested sequences is the same as that of \a typesF.
5770 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
5771 * per each type of spatial discretization within one mesh entity type.
5772 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
5773 * Length of this and of nested sequences is the same as that of \a typesF.
5774 * \throw If no field is lying on \a mname.
5776 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
5779 if(_field_per_mesh.empty())
5780 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
5781 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[0]->getFieldSplitedByType(types,typesF,pfls,locs);
5782 int nbOfRet=ret0.size();
5783 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
5784 for(int i=0;i<nbOfRet;i++)
5786 const std::vector< std::pair<int,int> >& p=ret0[i];
5787 int nbOfRet1=p.size();
5788 ret[i].resize(nbOfRet1);
5789 for(int j=0;j<nbOfRet1;j++)
5791 DataArrayDouble *tmp=_arr->selectByTupleIdSafeSlice(p[j].first,p[j].second,1);
5798 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
5803 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
5805 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
5806 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5807 ret->deepCpyLeavesFrom(*this);
5808 const DataArrayDouble *arr(_arr);
5811 MCAuto<DataArrayInt> arr2(arr->convertToIntArr());
5812 ret->setArray(arr2);
5818 * Returns a pointer to the underground DataArrayDouble instance and a
5819 * sequence describing parameters of a support of each part of \a this field. The
5820 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5821 * direct access to the field values. This method is intended for the field lying on one
5823 * \param [in,out] entries - the sequence describing parameters of a support of each
5824 * part of \a this field. Each item of this sequence consists of two parts. The
5825 * first part describes a type of mesh entity and an id of discretization of a
5826 * current field part. The second part describes a range of values [begin,end)
5827 * within the returned array relating to the current field part.
5828 * \return DataArrayDouble * - the pointer to the field values array.
5829 * \throw If the number of underlying meshes is not equal to 1.
5830 * \throw If no field values are available.
5831 * \sa getUndergroundDataArray()
5833 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5835 return getUndergroundDataArrayTemplateExt(entries);
5838 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)
5840 DataArrayDouble *arr(getOrCreateAndGetArrayTemplate());
5841 arr->setInfoAndChangeNbOfCompo(infos);
5844 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<double>()
5848 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
5850 MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
5851 ret->deepCpyLeavesFrom(*this);
5855 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCopy() const
5857 MCAuto<MEDFileField1TSWithoutSDA> ret(shallowCpy());
5858 if(_arr.isNotNull())
5859 ret->_arr=_arr->deepCopy();
5863 //= MEDFileIntField1TSWithoutSDA
5865 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5867 return new MEDFileIntField1TSWithoutSDA(fieldName,meshName,csit,iteration,order,infos);
5870 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA()
5874 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order,
5875 const std::vector<std::string>& infos):MEDFileField1TSNDTemplateWithoutSDA<int>(fieldName,meshName,csit,iteration,order,infos)
5877 DataArrayInt *arr(getOrCreateAndGetArrayTemplate());
5878 arr->setInfoAndChangeNbOfCompo(infos);
5881 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
5887 * Returns a pointer to the underground DataArrayInt instance and a
5888 * sequence describing parameters of a support of each part of \a this field. The
5889 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5890 * direct access to the field values. This method is intended for the field lying on one
5892 * \param [in,out] entries - the sequence describing parameters of a support of each
5893 * part of \a this field. Each item of this sequence consists of two parts. The
5894 * first part describes a type of mesh entity and an id of discretization of a
5895 * current field part. The second part describes a range of values [begin,end)
5896 * within the returned array relating to the current field part.
5897 * \return DataArrayInt * - the pointer to the field values array.
5898 * \throw If the number of underlying meshes is not equal to 1.
5899 * \throw If no field values are available.
5900 * \sa getUndergroundDataArray()
5902 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5904 return getUndergroundDataArrayIntExt(entries);
5908 * Returns a pointer to the underground DataArrayInt instance and a
5909 * sequence describing parameters of a support of each part of \a this field. The
5910 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5911 * direct access to the field values. This method is intended for the field lying on one
5913 * \param [in,out] entries - the sequence describing parameters of a support of each
5914 * part of \a this field. Each item of this sequence consists of two parts. The
5915 * first part describes a type of mesh entity and an id of discretization of a
5916 * current field part. The second part describes a range of values [begin,end)
5917 * within the returned array relating to the current field part.
5918 * \return DataArrayInt * - the pointer to the field values array.
5919 * \throw If the number of underlying meshes is not equal to 1.
5920 * \throw If no field values are available.
5921 * \sa getUndergroundDataArray()
5923 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5925 if(_field_per_mesh.size()!=1)
5926 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5927 if(_field_per_mesh[0]==0)
5928 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5929 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5930 return getUndergroundDataArrayTemplate();
5933 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5935 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5936 ret->deepCpyLeavesFrom(*this);
5940 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCopy() const
5942 MCAuto<MEDFileIntField1TSWithoutSDA> ret(shallowCpy());
5943 if(_arr.isNotNull())
5944 ret->_arr=_arr->deepCopy();
5948 //= MEDFileFloatField1TSWithoutSDA
5950 MEDFileFloatField1TSWithoutSDA *MEDFileFloatField1TSWithoutSDA::New(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5952 return new MEDFileFloatField1TSWithoutSDA(fieldName,meshName,csit,iteration,order,infos);
5955 MEDFileFloatField1TSWithoutSDA::MEDFileFloatField1TSWithoutSDA()
5959 MEDFileFloatField1TSWithoutSDA::MEDFileFloatField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order,
5960 const std::vector<std::string>& infos):MEDFileField1TSNDTemplateWithoutSDA<float>(fieldName,meshName,csit,iteration,order,infos)
5962 DataArrayFloat *arr(getOrCreateAndGetArrayTemplate());
5963 arr->setInfoAndChangeNbOfCompo(infos);
5966 const char *MEDFileFloatField1TSWithoutSDA::getTypeStr() const
5972 * Returns a pointer to the underground DataArrayFloat instance and a
5973 * sequence describing parameters of a support of each part of \a this field. The
5974 * caller should not decrRef() the returned DataArrayFloat. This method allows for a
5975 * direct access to the field values. This method is intended for the field lying on one
5977 * \param [in,out] entries - the sequence describing parameters of a support of each
5978 * part of \a this field. Each item of this sequence consists of two parts. The
5979 * first part describes a type of mesh entity and an id of discretization of a
5980 * current field part. The second part describes a range of values [begin,end)
5981 * within the returned array relating to the current field part.
5982 * \return DataArrayFloat * - the pointer to the field values array.
5983 * \throw If the number of underlying meshes is not equal to 1.
5984 * \throw If no field values are available.
5985 * \sa getUndergroundDataArray()
5987 DataArray *MEDFileFloatField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5989 return getUndergroundDataArrayFloatExt(entries);
5993 * Returns a pointer to the underground DataArrayFloat instance and a
5994 * sequence describing parameters of a support of each part of \a this field. The
5995 * caller should not decrRef() the returned DataArrayFloat. This method allows for a
5996 * direct access to the field values. This method is intended for the field lying on one
5998 * \param [in,out] entries - the sequence describing parameters of a support of each
5999 * part of \a this field. Each item of this sequence consists of two parts. The
6000 * first part describes a type of mesh entity and an id of discretization of a
6001 * current field part. The second part describes a range of values [begin,end)
6002 * within the returned array relating to the current field part.
6003 * \return DataArrayFloat * - the pointer to the field values array.
6004 * \throw If the number of underlying meshes is not equal to 1.
6005 * \throw If no field values are available.
6006 * \sa getUndergroundDataArray()
6008 DataArrayFloat *MEDFileFloatField1TSWithoutSDA::getUndergroundDataArrayFloatExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
6010 if(_field_per_mesh.size()!=1)
6011 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
6012 if(_field_per_mesh[0]==0)
6013 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
6014 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
6015 return getUndergroundDataArrayTemplate();
6018 MEDFileFloatField1TSWithoutSDA *MEDFileFloatField1TSWithoutSDA::shallowCpy() const
6020 MCAuto<MEDFileFloatField1TSWithoutSDA> ret(new MEDFileFloatField1TSWithoutSDA(*this));
6021 ret->deepCpyLeavesFrom(*this);
6025 MEDFileFloatField1TSWithoutSDA *MEDFileFloatField1TSWithoutSDA::deepCopy() const
6027 MCAuto<MEDFileFloatField1TSWithoutSDA> ret(shallowCpy());
6028 if(_arr.isNotNull())
6029 ret->_arr=_arr->deepCopy();
6033 //= MEDFileAnyTypeField1TS
6035 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
6039 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
6041 med_field_type typcha;
6043 std::vector<std::string> infos;
6044 std::string dtunit,fieldName,meshName;
6045 LocateField2(fid,0,true,fieldName,typcha,infos,dtunit,meshName);
6046 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
6051 ret=MEDFileField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
6056 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
6061 ret=MEDFileFloatField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
6066 if(sizeof(med_int)==sizeof(int))
6068 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
6074 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] !";
6075 throw INTERP_KERNEL::Exception(oss.str());
6078 ret->setDtUnit(dtunit.c_str());
6079 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
6081 med_int numdt,numit;
6083 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
6084 ret->setTime(numdt,numit,dt);
6087 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
6089 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
6093 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
6094 try:MEDFileFieldGlobsReal(fid)
6096 _content=BuildContentFrom(fid,loadAll,ms,entities);
6099 catch(INTERP_KERNEL::Exception& e)
6104 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
6106 med_field_type typcha;
6107 std::vector<std::string> infos;
6108 std::string dtunit,meshName;
6112 nbSteps=LocateField(fid,fieldName,iii,typcha,infos,dtunit,meshName);
6114 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
6119 ret=MEDFileField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
6124 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
6129 ret=MEDFileFloatField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
6134 if(sizeof(med_int)==sizeof(int))
6136 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
6142 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] !";
6143 throw INTERP_KERNEL::Exception(oss.str());
6146 ret->setMeshName(meshName);
6147 ret->setDtUnit(dtunit.c_str());
6148 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
6152 std::ostringstream oss; oss << "MEDFileField1TS(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
6153 throw INTERP_KERNEL::Exception(oss.str());
6156 med_int numdt,numit;
6158 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
6159 ret->setTime(numdt,numit,dt);
6162 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
6164 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
6168 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
6169 try:MEDFileFieldGlobsReal(fid)
6171 _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
6174 catch(INTERP_KERNEL::Exception& e)
6179 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c)
6182 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
6183 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
6185 MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
6186 ret->_content=c; c->incrRef();
6189 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
6191 MCAuto<MEDFileIntField1TS> ret(MEDFileIntField1TS::New());
6192 ret->_content=c; c->incrRef();
6195 if(dynamic_cast<const MEDFileFloatField1TSWithoutSDA *>(c))
6197 MCAuto<MEDFileFloatField1TS> ret(MEDFileFloatField1TS::New());
6198 ret->_content=c; c->incrRef();
6201 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 FLOAT32 and INT32 has been built but not intercepted !");
6204 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, med_idt fid)
6206 MEDFileAnyTypeField1TS *ret(BuildNewInstanceFromContent(c));
6207 ret->setFileName(FileNameFromFID(fid));
6211 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
6213 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6214 return New(fid,loadAll);
6217 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, bool loadAll)
6219 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,loadAll,0,0));
6220 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
6221 ret->loadGlobals(fid);
6225 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6227 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6228 return New(fid,fieldName,loadAll);
6231 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
6233 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
6234 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
6235 ret->loadGlobals(fid);
6239 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6241 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6242 return New(fid,fieldName,iteration,order,loadAll);
6245 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
6247 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0,0));
6248 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
6249 ret->loadGlobals(fid);
6253 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::NewAdv(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileEntities *entities)
6255 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6256 return NewAdv(fid,fieldName,iteration,order,loadAll,entities);
6259 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::NewAdv(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileEntities *entities)
6261 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0,entities));
6262 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
6263 ret->loadGlobals(fid);
6267 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
6269 med_field_type typcha;
6270 std::vector<std::string> infos;
6271 std::string dtunit,meshName;
6273 int nbOfStep2(LocateField(fid,fieldName,iii,typcha,infos,dtunit,meshName));
6274 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
6279 ret=MEDFileField1TSWithoutSDA::New(fieldName,meshName,-1,iteration,order,std::vector<std::string>());
6284 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,meshName,-1,iteration,order,std::vector<std::string>());
6289 ret=MEDFileFloatField1TSWithoutSDA::New(fieldName,meshName,-1,iteration,order,std::vector<std::string>());
6294 if(sizeof(med_int)==sizeof(int))
6296 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,meshName,-1,iteration,order,std::vector<std::string>());
6302 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] !";
6303 throw INTERP_KERNEL::Exception(oss.str());
6306 ret->setDtUnit(dtunit.c_str());
6307 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
6310 std::vector< std::pair<int,int> > dtits(nbOfStep2);
6311 for(int i=0;i<nbOfStep2 && !found;i++)
6313 med_int numdt,numit;
6315 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt));
6316 if(numdt==iteration && numit==order)
6322 dtits[i]=std::pair<int,int>(numdt,numit);
6326 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available iterations are : ";
6327 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
6328 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
6329 throw INTERP_KERNEL::Exception(oss.str());
6332 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
6334 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
6338 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
6339 try:MEDFileFieldGlobsReal(fid)
6341 _content=BuildContentFrom(fid,fieldName,iteration,order,loadAll,ms,entities);
6344 catch(INTERP_KERNEL::Exception& e)
6350 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6351 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6353 * \warning this is a shallow copy constructor
6355 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
6357 if(!shallowCopyOfContent)
6359 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
6360 otherPtr->incrRef();
6361 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
6365 _content=other.shallowCpy();
6369 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)
6373 int nbFields=MEDnField(fid);
6374 if(fieldIdCFormat>=nbFields)
6376 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << FileNameFromFID(fid) << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
6377 throw INTERP_KERNEL::Exception(oss.str());
6380 int ncomp(MEDfieldnComponent(fid,fieldIdCFormat+1));
6381 INTERP_KERNEL::AutoPtr<char> comp(MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE));
6382 INTERP_KERNEL::AutoPtr<char> unit(MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE));
6383 INTERP_KERNEL::AutoPtr<char> dtunit(MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE));
6384 INTERP_KERNEL::AutoPtr<char> nomcha(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
6385 INTERP_KERNEL::AutoPtr<char> nomMaa(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
6388 MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep));
6389 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
6390 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
6391 meshName=MEDLoaderBase::buildStringFromFortran(nomMaa,MED_NAME_SIZE);
6392 infos.clear(); infos.resize(ncomp);
6393 for(int j=0;j<ncomp;j++)
6394 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
6399 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
6402 * \return in case of success the number of time steps available for the field with name \a fieldName.
6404 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)
6406 int nbFields=MEDnField(fid);
6408 std::vector<std::string> fns(nbFields);
6410 for(int i=0;i<nbFields && !found;i++)
6412 std::string tmp,tmp2;
6413 nbOfStep2=LocateField2(fid,i,false,tmp,typcha,infos,dtunitOut,tmp2);
6415 found=(tmp==fieldName);
6424 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available fields are : ";
6425 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
6426 oss << "\"" << *it << "\" ";
6427 throw INTERP_KERNEL::Exception(oss.str());
6433 * This method as MEDFileField1TSW::setLocNameOnLeaf, 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 profile 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 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
6440 * 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.
6442 * \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.
6443 * \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.
6444 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
6445 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
6446 * \param [in] newLocName is the new localization name.
6447 * \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.
6448 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
6450 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
6452 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6453 std::string oldPflName=disc->getProfile();
6454 std::vector<std::string> vv=getPflsReallyUsedMulti();
6455 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
6456 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
6458 disc->setProfile(newPflName);
6459 DataArrayInt *pfl=getProfile(oldPflName.c_str());
6460 pfl->setName(newPflName);
6464 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
6465 throw INTERP_KERNEL::Exception(oss.str());
6470 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
6471 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
6472 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
6473 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
6474 * to keep a valid instance.
6475 * 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.
6476 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
6477 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
6478 * 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.
6480 * \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.
6481 * \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.
6482 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
6483 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
6484 * \param [in] newLocName is the new localization name.
6485 * \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.
6486 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
6488 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
6490 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6491 std::string oldLocName=disc->getLocalization();
6492 std::vector<std::string> vv=getLocsReallyUsedMulti();
6493 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
6494 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
6496 disc->setLocalization(newLocName);
6497 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
6498 loc.setName(newLocName);
6502 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
6503 throw INTERP_KERNEL::Exception(oss.str());
6507 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
6509 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
6511 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
6515 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
6517 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
6519 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
6524 * This method alloc the arrays and load potentially huge arrays contained in this field.
6525 * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
6526 * This method can be also called to refresh or reinit values from a file.
6528 * \throw If the fileName is not set or points to a non readable MED file.
6529 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
6531 void MEDFileAnyTypeField1TS::loadArrays()
6533 if(getFileName().empty())
6534 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
6535 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
6536 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
6540 * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
6541 * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
6542 * this method does not throw if \a this does not come from file read.
6544 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
6546 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
6548 if(!getFileName().empty())
6550 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
6551 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
6556 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
6557 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
6558 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
6560 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
6562 void MEDFileAnyTypeField1TS::unloadArrays()
6564 contentNotNullBase()->unloadArrays();
6568 * 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.
6569 * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
6570 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
6572 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
6574 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
6576 if(!getFileName().empty())
6577 contentNotNullBase()->unloadArrays();
6580 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
6582 int nbComp(getNumberOfComponents());
6583 INTERP_KERNEL::AutoPtr<char> comp(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
6584 INTERP_KERNEL::AutoPtr<char> unit(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
6585 for(int i=0;i<nbComp;i++)
6587 std::string info=getInfo()[i];
6589 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
6590 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
6591 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
6593 if(getName().empty())
6594 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
6595 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
6596 writeGlobals(fid,*this);
6597 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
6600 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
6602 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
6605 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
6607 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
6608 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
6613 * Returns a string describing \a this field. This string is outputted
6614 * by \c print Python command.
6616 std::string MEDFileAnyTypeField1TS::simpleRepr() const
6618 std::ostringstream oss;
6619 contentNotNullBase()->simpleRepr(0,oss,-1);
6620 simpleReprGlobs(oss);
6625 * This method returns all profiles whose name is non empty used.
6626 * \b WARNING If profile is used several times it will be reported \b only \b once.
6627 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
6629 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
6631 return contentNotNullBase()->getPflsReallyUsed2();
6635 * This method returns all localizations whose name is non empty used.
6636 * \b WARNING If localization is used several times it will be reported \b only \b once.
6638 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
6640 return contentNotNullBase()->getLocsReallyUsed2();
6644 * This method returns all profiles whose name is non empty used.
6645 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
6647 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
6649 return contentNotNullBase()->getPflsReallyUsedMulti2();
6653 * This method returns all localizations whose name is non empty used.
6654 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
6656 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
6658 return contentNotNullBase()->getLocsReallyUsedMulti2();
6661 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6663 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
6666 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6668 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
6671 int MEDFileAnyTypeField1TS::getDimension() const
6673 return contentNotNullBase()->getDimension();
6676 int MEDFileAnyTypeField1TS::getIteration() const
6678 return contentNotNullBase()->getIteration();
6681 int MEDFileAnyTypeField1TS::getOrder() const
6683 return contentNotNullBase()->getOrder();
6686 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
6688 return contentNotNullBase()->getTime(iteration,order);
6691 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
6693 contentNotNullBase()->setTime(iteration,order,val);
6696 std::string MEDFileAnyTypeField1TS::getName() const
6698 return contentNotNullBase()->getName();
6701 void MEDFileAnyTypeField1TS::setName(const std::string& name)
6703 contentNotNullBase()->setName(name);
6706 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
6708 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
6711 std::string MEDFileAnyTypeField1TS::getDtUnit() const
6713 return contentNotNullBase()->getDtUnit();
6716 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
6718 contentNotNullBase()->setDtUnit(dtUnit);
6721 std::string MEDFileAnyTypeField1TS::getMeshName() const
6723 return contentNotNullBase()->getMeshName();
6726 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
6728 contentNotNullBase()->setMeshName(newMeshName);
6731 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
6733 return contentNotNullBase()->changeMeshNames(modifTab);
6736 int MEDFileAnyTypeField1TS::getMeshIteration() const
6738 return contentNotNullBase()->getMeshIteration();
6741 int MEDFileAnyTypeField1TS::getMeshOrder() const
6743 return contentNotNullBase()->getMeshOrder();
6746 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
6748 return contentNotNullBase()->getNumberOfComponents();
6751 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
6753 return contentNotNullBase()->isDealingTS(iteration,order);
6756 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
6758 return contentNotNullBase()->getDtIt();
6761 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
6763 contentNotNullBase()->fillIteration(p);
6766 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
6768 contentNotNullBase()->fillTypesOfFieldAvailable(types);
6771 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
6773 contentNotNullBase()->setInfo(infos);
6776 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
6778 return contentNotNullBase()->getInfo();
6780 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
6782 return contentNotNullBase()->getInfo();
6785 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
6787 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
6790 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
6792 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6795 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
6797 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6800 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
6802 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
6805 void MEDFileAnyTypeField1TS::convertMedBallIntoClassic()
6807 return contentNotNullBase()->convertMedBallIntoClassic();
6810 void MEDFileAnyTypeField1TS::makeReduction(INTERP_KERNEL::NormalizedCellType ct, TypeOfField tof, const DataArrayInt *pfl)
6812 return contentNotNullBase()->makeReduction(ct,tof,pfl);
6815 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
6817 return contentNotNullBase()->getTypesOfFieldAvailable();
6820 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,
6821 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6823 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
6827 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
6828 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
6829 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
6831 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
6833 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6835 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
6836 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
6837 std::size_t sz(contentsSplit.size());
6838 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6839 for(std::size_t i=0;i<sz;i++)
6841 ret[i]=shallowCpy();
6842 ret[i]->_content=contentsSplit[i];
6848 * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
6849 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6851 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
6853 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6855 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
6856 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
6857 std::size_t sz(contentsSplit.size());
6858 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6859 for(std::size_t i=0;i<sz;i++)
6861 ret[i]=shallowCpy();
6862 ret[i]->_content=contentsSplit[i];
6868 * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this.
6869 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6871 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const
6873 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6875 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !");
6876 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
6877 std::size_t sz(contentsSplit.size());
6878 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6879 for(std::size_t i=0;i<sz;i++)
6881 ret[i]=shallowCpy();
6882 ret[i]->_content=contentsSplit[i];
6887 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCopy() const
6889 MCAuto<MEDFileAnyTypeField1TS> ret=shallowCpy();
6890 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
6891 ret->_content=_content->deepCopy();
6892 ret->deepCpyGlobs(*this);
6896 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
6898 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*field));
6899 return copyTinyInfoFrom(field->timeDiscrSafe(),ft,arr);
6902 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arr)
6904 return contentNotNullBase()->copyTinyInfoFrom(th,field,arr);
6910 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
6911 * following the given input policy.
6913 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6914 * By default (true) the globals are deeply copied.
6915 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
6917 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
6919 MCAuto<MEDFileIntField1TS> ret;
6920 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6923 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
6925 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
6926 MCAuto<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
6927 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc));
6930 ret=MEDFileIntField1TS::New();
6932 ret->deepCpyGlobs(*this);
6934 ret->shallowCpyGlobs(*this);
6938 MEDFileField1TS::MEDFileField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
6939 try:MEDFileTemplateField1TS<double>(fid,loadAll,ms)
6942 catch(INTERP_KERNEL::Exception& e)
6945 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6946 try:MEDFileTemplateField1TS<double>(fid,fieldName,loadAll,ms)
6949 catch(INTERP_KERNEL::Exception& e)
6952 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6953 try:MEDFileTemplateField1TS<double>(fid,fieldName,iteration,order,loadAll,ms)
6956 catch(INTERP_KERNEL::Exception& e)
6960 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6961 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6963 * \warning this is a shallow copy constructor
6965 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6966 try:MEDFileTemplateField1TS<double>(other,shallowCopyOfContent)
6969 catch(INTERP_KERNEL::Exception& e)
6972 MEDFileField1TS *MEDFileField1TS::shallowCpy() const
6974 return new MEDFileField1TS(*this);
6977 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6978 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6980 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6983 //= MEDFileIntField1TS
6985 MCAuto<MEDCouplingFieldDouble> MEDFileIntField1TS::ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f)
6988 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ConvertFieldIntToFieldDouble : null input field !");
6990 double t0(f->getTime(t1,t2));
6991 std::string tu(f->getTimeUnit());
6992 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
6993 MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(*ft));
6994 ret->setTime(t0,t1,t2); ret->setTimeUnit(tu);
6998 //= MEDFileFloatField1TS
7000 //= MEDFileFloatField1TS
7002 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
7004 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
7008 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName):MEDFileFieldNameScope(fieldName,meshName)
7013 * \param [in] fieldId field id in C mode
7015 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7017 med_field_type typcha;
7018 std::string dtunitOut,meshName;
7019 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fieldId,false,_name,typcha,_infos,dtunitOut,meshName));
7020 setMeshName(meshName);
7021 setDtUnit(dtunitOut.c_str());
7022 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities);
7025 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)
7026 try:MEDFileFieldNameScope(fieldName,meshName),_infos(infos)
7028 setDtUnit(dtunit.c_str());
7029 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities);
7031 catch(INTERP_KERNEL::Exception& e)
7036 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
7038 std::size_t ret(_mesh_name.capacity()+_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MCAuto<MEDFileField1TSWithoutSDA>));
7039 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7040 ret+=(*it).capacity();
7044 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
7046 std::vector<const BigMemoryObject *> ret;
7047 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7048 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
7053 * 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
7056 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
7058 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7059 ret->setInfo(_infos);
7060 int sz=(int)_time_steps.size();
7061 for(const int *id=startIds;id!=endIds;id++)
7063 if(*id>=0 && *id<sz)
7065 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
7066 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7070 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7072 ret->pushBackTimeStep(tse2);
7076 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
7077 oss << " ! Should be in [0," << sz << ") !";
7078 throw INTERP_KERNEL::Exception(oss.str());
7081 if(ret->getNumberOfTS()>0)
7082 ret->synchronizeNameScope();
7083 ret->copyNameScope(*this);
7088 * 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
7091 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
7093 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
7094 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7095 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7096 ret->setInfo(_infos);
7097 int sz=(int)_time_steps.size();
7099 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
7103 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
7104 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7108 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7110 ret->pushBackTimeStep(tse2);
7114 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
7115 oss << " ! Should be in [0," << sz << ") !";
7116 throw INTERP_KERNEL::Exception(oss.str());
7119 if(ret->getNumberOfTS()>0)
7120 ret->synchronizeNameScope();
7121 ret->copyNameScope(*this);
7125 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7128 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7129 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7131 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7134 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7135 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
7136 ids->pushBackSilent(id);
7138 return buildFromTimeStepIds(ids->begin(),ids->end());
7141 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7144 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7145 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7147 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7150 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7151 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
7152 ids->pushBackSilent(id);
7154 return buildFromTimeStepIds(ids->begin(),ids->end());
7157 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfStructureElements() const
7159 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7160 if((*it).isNotNull())
7161 if((*it)->presenceOfStructureElements())
7166 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::onlyStructureElements() const
7168 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7169 if((*it).isNotNull())
7170 if(!(*it)->onlyStructureElements())
7175 void MEDFileAnyTypeFieldMultiTSWithoutSDA::killStructureElements()
7177 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
7178 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7179 if((*it).isNotNull())
7181 if((*it)->presenceOfStructureElements())
7183 if(!(*it)->onlyStructureElements())
7185 (*it)->killStructureElements();
7197 void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyStructureElements()
7199 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
7200 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7201 if((*it).isNotNull())
7203 if((*it)->presenceOfStructureElements())
7205 if(!(*it)->onlyStructureElements())
7206 (*it)->keepOnlyStructureElements();
7213 void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyOnSE(const std::string& seName)
7215 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
7216 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7217 if((*it).isNotNull())
7218 (*it)->keepOnlyOnSE(seName);
7221 void MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
7223 std::vector< std::pair<std::string,std::string> > ps2;
7224 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7225 if((*it).isNotNull())
7227 (*it)->getMeshSENames(ps2);
7231 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames : this appears to not contain SE only !");
7232 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7233 if((*it).isNotNull())
7235 std::vector< std::pair<std::string,std::string> > ps3;
7236 (*it)->getMeshSENames(ps3);
7238 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames : For the moment only homogeneous SE def through time managed !");
7240 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=ps2.begin();it!=ps2.end();it++)
7242 std::vector< std::pair<std::string,std::string> >::iterator it2(std::find(ps.begin(),ps.end(),*it));
7248 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
7250 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7252 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7255 if(cur->presenceOfMultiDiscPerGeoType())
7261 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
7266 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
7271 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
7274 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7276 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
7277 if(pt->isDealingTS(iteration,order))
7280 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
7281 std::vector< std::pair<int,int> > vp=getIterations();
7282 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
7283 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
7284 throw INTERP_KERNEL::Exception(oss.str());
7287 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
7289 return *_time_steps[getTimeStepPos(iteration,order)];
7292 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
7294 return *_time_steps[getTimeStepPos(iteration,order)];
7297 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
7300 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
7302 if((*it).first==getMeshName())
7304 setMeshName((*it).second);
7308 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7310 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7312 ret=cur->changeMeshNames(modifTab) || ret;
7318 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
7320 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
7322 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
7326 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
7328 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7330 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
7333 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
7334 MEDFileFieldGlobsReal& glob)
7337 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7339 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
7341 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
7346 void MEDFileAnyTypeFieldMultiTSWithoutSDA::accept(MEDFileFieldVisitor& visitor) const
7348 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7349 if((*it).isNotNull())
7351 visitor.newTimeStepEntry(*it);
7352 (*it)->accept(visitor);
7353 visitor.endTimeStepEntry(*it);
7357 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7359 std::string startLine(bkOffset,' ');
7360 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
7362 oss << " (" << fmtsId << ")";
7363 oss << " has the following name: \"" << _name << "\"." << std::endl;
7364 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
7365 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7367 oss << startLine << " - \"" << *it << "\"" << std::endl;
7370 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7372 std::string chapter(17,'0'+i);
7373 oss << startLine << chapter << std::endl;
7374 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7376 cur->simpleRepr(bkOffset+2,oss,i);
7378 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
7379 oss << startLine << chapter << std::endl;
7383 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
7385 std::size_t sz=_time_steps.size();
7386 std::vector< std::pair<int,int> > ret(sz);
7388 for(std::size_t i=0;i<sz;i++)
7390 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
7393 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
7397 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
7398 throw INTERP_KERNEL::Exception(oss.str());
7404 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MCAuto<MEDFileAnyTypeField1TSWithoutSDA>& tse)
7406 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
7408 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
7409 checkCoherencyOfType(tse2);
7410 if(_time_steps.empty())
7412 setName(tse2->getName());
7413 setMeshName(tse2->getMeshName());
7414 setInfo(tse2->getInfo());
7416 checkThatComponentsMatch(tse2->getInfo());
7417 if(getDtUnit().empty() && !tse->getDtUnit().empty())
7418 setDtUnit(tse->getDtUnit());
7419 _time_steps.push_back(tse);
7422 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
7424 std::size_t nbOfCompo=_infos.size();
7425 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7427 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7430 if((cur->getInfo()).size()!=nbOfCompo)
7432 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
7433 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
7434 throw INTERP_KERNEL::Exception(oss.str());
7436 cur->copyNameScope(*this);
7441 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7443 _time_steps.resize(nbPdt);
7444 for(int i=0;i<nbPdt;i++)
7446 std::vector< std::pair<int,int> > ts;
7447 med_int numdt=0,numo=0;
7449 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt));
7454 _time_steps[i]=MEDFileField1TSWithoutSDA::New(getName(),getMeshName(),i+1,numdt,numo,_infos);
7459 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(getName(),getMeshName(),i+1,numdt,numo,_infos);
7464 _time_steps[i]=MEDFileFloatField1TSWithoutSDA::New(getName(),getMeshName(),i+1,numdt,numo,_infos);
7469 if(sizeof(med_int)==sizeof(int))
7471 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(getName(),getMeshName(),i+1,numdt,numo,_infos);
7476 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32, FLOAT32 !");
7479 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities);
7481 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entities);
7482 synchronizeNameScope();
7486 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
7488 if(_time_steps.empty())
7489 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
7490 checkThatNbOfCompoOfTSMatchThis();
7491 std::vector<std::string> infos(getInfo());
7492 int nbComp=infos.size();
7493 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7494 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7495 for(int i=0;i<nbComp;i++)
7497 std::string info=infos[i];
7499 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7500 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7501 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7504 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7505 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
7506 int nbOfTS=_time_steps.size();
7507 for(int i=0;i<nbOfTS;i++)
7508 _time_steps[i]->writeLL(fid,opts,*this);
7511 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
7513 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7515 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7517 elt->loadBigArraysRecursively(fid,nasc);
7521 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
7523 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7525 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7527 elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7531 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
7533 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7535 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7537 elt->unloadArrays();
7541 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7543 return _time_steps.size();
7546 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
7548 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7549 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7551 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7553 newTS.push_back(*it);
7558 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
7560 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7561 int maxId=(int)_time_steps.size();
7563 std::set<int> idsToDel;
7564 for(const int *id=startIds;id!=endIds;id++,ii++)
7566 if(*id>=0 && *id<maxId)
7568 idsToDel.insert(*id);
7572 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7573 throw INTERP_KERNEL::Exception(oss.str());
7576 for(int iii=0;iii<maxId;iii++)
7577 if(idsToDel.find(iii)==idsToDel.end())
7578 newTS.push_back(_time_steps[iii]);
7582 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
7584 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7585 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7586 if(nbOfEntriesToKill==0)
7588 std::size_t sz=_time_steps.size();
7589 std::vector<bool> b(sz,true);
7591 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7593 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7594 for(std::size_t i=0;i<sz;i++)
7596 newTS.push_back(_time_steps[i]);
7600 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
7603 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
7604 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7606 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7610 tmp->getTime(it2,ord);
7611 if(it2==iteration && order==ord)
7614 oss << "(" << it2 << "," << ord << "), ";
7617 throw INTERP_KERNEL::Exception(oss.str());
7620 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
7623 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
7625 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7627 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7631 double ti=tmp->getTime(it2,ord);
7632 if(fabs(time-ti)<eps)
7638 throw INTERP_KERNEL::Exception(oss.str());
7641 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
7643 int lgth=_time_steps.size();
7644 std::vector< std::pair<int,int> > ret(lgth);
7645 for(int i=0;i<lgth;i++)
7646 _time_steps[i]->fillIteration(ret[i]);
7651 * 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'
7652 * This method returns two things.
7653 * - The absolute dimension of 'this' in first parameter.
7654 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7655 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
7657 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7658 * Only these 3 discretizations will be taken into account here.
7660 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7661 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7662 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7664 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7665 * 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'.
7667 * Let's consider the typical following case :
7668 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7669 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7670 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7672 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7674 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7676 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7677 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7678 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7679 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7681 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
7683 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7686 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
7688 if(pos<0 || pos>=(int)_time_steps.size())
7690 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7691 throw INTERP_KERNEL::Exception(oss.str());
7693 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7696 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7697 oss << "\nTry to use following method eraseEmptyTS !";
7698 throw INTERP_KERNEL::Exception(oss.str());
7703 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
7705 if(pos<0 || pos>=(int)_time_steps.size())
7707 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7708 throw INTERP_KERNEL::Exception(oss.str());
7710 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7713 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7714 oss << "\nTry to use following method eraseEmptyTS !";
7715 throw INTERP_KERNEL::Exception(oss.str());
7720 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
7722 std::vector<std::string> ret;
7723 std::set<std::string> ret2;
7724 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7726 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
7727 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7728 if(ret2.find(*it2)==ret2.end())
7730 ret.push_back(*it2);
7737 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
7739 std::vector<std::string> ret;
7740 std::set<std::string> ret2;
7741 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7743 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
7744 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7745 if(ret2.find(*it2)==ret2.end())
7747 ret.push_back(*it2);
7754 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
7756 std::vector<std::string> ret;
7757 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7759 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
7760 ret.insert(ret.end(),tmp.begin(),tmp.end());
7765 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
7767 std::vector<std::string> ret;
7768 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7770 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
7771 ret.insert(ret.end(),tmp.begin(),tmp.end());
7776 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7778 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7779 (*it)->changePflsRefsNamesGen2(mapOfModif);
7782 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7784 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7785 (*it)->changeLocsRefsNamesGen2(mapOfModif);
7788 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
7790 int lgth=_time_steps.size();
7791 std::vector< std::vector<TypeOfField> > ret(lgth);
7792 for(int i=0;i<lgth;i++)
7793 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
7798 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
7800 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
7802 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
7805 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCopy() const
7807 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
7809 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7811 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
7812 ret->_time_steps[i]=(*it)->deepCopy();
7817 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
7819 std::size_t sz(_infos.size()),sz2(_time_steps.size());
7820 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7821 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7822 for(std::size_t i=0;i<sz;i++)
7824 ret[i]=shallowCpy();
7825 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7827 for(std::size_t i=0;i<sz2;i++)
7829 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7832 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7833 throw INTERP_KERNEL::Exception(oss.str());
7837 for(std::size_t i=0;i<sz;i++)
7838 for(std::size_t j=0;j<sz2;j++)
7839 ret[i]->_time_steps[j]=ts[j][i];
7844 * This method splits into discretization each time steps in \a this.
7845 * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
7847 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
7849 std::size_t sz(_time_steps.size());
7850 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7851 for(std::size_t i=0;i<sz;i++)
7853 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7856 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
7857 throw INTERP_KERNEL::Exception(oss.str());
7859 items[i]=timeStep->splitDiscretizations();
7862 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
7863 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
7864 std::vector< TypeOfField > types;
7865 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7866 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7868 std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
7870 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
7871 std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
7872 if(it2==types.end())
7873 types.push_back(ts[0]);
7875 ret.resize(types.size()); ret2.resize(types.size());
7876 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7877 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7879 TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
7880 std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
7881 ret2[pos].push_back(*it1);
7883 for(std::size_t i=0;i<types.size();i++)
7885 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7886 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
7887 elt->pushBackTimeStep(*it1);//also updates infos in elt
7889 elt->MEDFileFieldNameScope::operator=(*this);
7895 * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
7897 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
7899 std::size_t sz(_time_steps.size());
7900 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7901 std::size_t szOut(std::numeric_limits<std::size_t>::max());
7902 for(std::size_t i=0;i<sz;i++)
7904 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7907 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
7908 throw INTERP_KERNEL::Exception(oss.str());
7910 items[i]=timeStep->splitMultiDiscrPerGeoTypes();
7911 if(szOut==std::numeric_limits<std::size_t>::max())
7912 szOut=items[i].size();
7914 if(items[i].size()!=szOut)
7915 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
7917 if(szOut==std::numeric_limits<std::size_t>::max())
7918 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
7919 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
7920 for(std::size_t i=0;i<szOut;i++)
7922 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7923 for(std::size_t j=0;j<sz;j++)
7924 elt->pushBackTimeStep(items[j][i]);
7926 elt->MEDFileFieldNameScope::operator=(*this);
7931 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
7933 setName(field->getName());
7934 if(field->getMesh())
7935 setMeshName(field->getMesh()->getName());
7937 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
7939 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
7940 _infos=arr->getInfoOnComponents();
7943 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
7945 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
7946 if(_name!=field->getName())
7948 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
7949 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
7950 throw INTERP_KERNEL::Exception(oss.str());
7953 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
7954 checkThatComponentsMatch(arr->getInfoOnComponents());
7957 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
7959 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
7960 if(getInfo().size()!=compos.size())
7962 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
7963 oss << " number of components of element to append (" << compos.size() << ") !";
7964 throw INTERP_KERNEL::Exception(oss.str());
7968 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
7969 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
7970 oss << " But compo in input fields are : ";
7971 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
7973 throw INTERP_KERNEL::Exception(oss.str());
7977 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
7979 std::size_t sz=_infos.size();
7981 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
7983 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7985 if(elt->getInfo().size()!=sz)
7987 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
7988 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
7989 throw INTERP_KERNEL::Exception(oss.str());
7994 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
7997 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7998 if(!_time_steps.empty())
7999 checkCoherencyOfTinyInfo(field,arr);
8000 MEDFileAnyTypeField1TSWithoutSDA *objC(createNew1TSWithoutSDAEmptyInstance());
8001 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8003 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*field));
8004 objC->setFieldNoProfileSBT(field->timeDiscrSafe(),ft,arr,glob,*this);
8006 copyTinyInfoFrom(field,arr);
8007 _time_steps.push_back(obj);
8010 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
8013 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8014 if(!_time_steps.empty())
8015 checkCoherencyOfTinyInfo(field,arr);
8016 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8017 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8019 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::NewWithoutCheck(*field));
8020 objC->setFieldProfile(field->timeDiscrSafe(),ft,arr,mesh,meshDimRelToMax,profile,glob,*this);
8022 copyTinyInfoFrom(field,arr);
8023 setMeshName(objC->getMeshName());
8024 _time_steps.push_back(obj);
8027 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ts)
8029 int sz=(int)_time_steps.size();
8032 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
8033 throw INTERP_KERNEL::Exception(oss.str());
8035 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
8038 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
8040 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
8041 throw INTERP_KERNEL::Exception(oss.str());
8047 //= MEDFileFieldMultiTSWithoutSDA
8050 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
8051 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
8053 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
8055 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
8056 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8058 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
8059 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
8062 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
8064 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
8065 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8067 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8069 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8072 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
8074 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
8075 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
8076 ret->setIteration(i,elt);
8082 //= MEDFileAnyTypeFieldMultiTS
8084 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
8088 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8089 try:MEDFileFieldGlobsReal(fid)
8091 _content=BuildContentFrom(fid,loadAll,ms);
8094 catch(INTERP_KERNEL::Exception& e)
8099 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8101 med_field_type typcha;
8102 std::vector<std::string> infos;
8104 std::string meshName;
8106 MEDFileAnyTypeField1TS::LocateField(fid,fieldName,i,typcha,infos,dtunit,meshName);
8107 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8112 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8117 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8122 ret=new MEDFileFloatFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8127 if(sizeof(med_int)==sizeof(int))
8129 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8135 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] !";
8136 throw INTERP_KERNEL::Exception(oss.str());
8139 ret->setMeshName(meshName);
8140 ret->setDtUnit(dtunit.c_str());
8144 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8146 med_field_type typcha;
8148 std::vector<std::string> infos;
8149 std::string dtunit,fieldName,meshName;
8150 MEDFileAnyTypeField1TS::LocateField2(fid,0,true,fieldName,typcha,infos,dtunit,meshName);
8151 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8156 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8161 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8166 ret=new MEDFileFloatFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8171 if(sizeof(med_int)==sizeof(int))
8173 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8179 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] !";
8180 throw INTERP_KERNEL::Exception(oss.str());
8183 ret->setMeshName(meshName);
8184 ret->setDtUnit(dtunit.c_str());
8188 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c)
8191 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
8192 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
8194 MCAuto<MEDFileFieldMultiTS> ret(MEDFileFieldMultiTS::New());
8195 ret->_content=c; c->incrRef();
8198 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
8200 MCAuto<MEDFileIntFieldMultiTS> ret(MEDFileIntFieldMultiTS::New());
8201 ret->_content=c; c->incrRef();
8204 if(dynamic_cast<const MEDFileFloatFieldMultiTSWithoutSDA *>(c))
8206 MCAuto<MEDFileFloatFieldMultiTS> ret(MEDFileFloatFieldMultiTS::New());
8207 ret->_content=c; c->incrRef();
8210 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 FLOAT32 and INT32 has been built but not intercepted !");
8213 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, med_idt fid)
8215 MEDFileAnyTypeFieldMultiTS *ret(BuildNewInstanceFromContent(c));
8216 std::string fileName(FileNameFromFID(fid));
8217 ret->setFileName(fileName);
8221 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8222 try:MEDFileFieldGlobsReal(fid)
8224 _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
8227 catch(INTERP_KERNEL::Exception& e)
8232 //= MEDFileAnyTypeFieldMultiTS
8235 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
8236 * that has been read from a specified MED file.
8237 * \param [in] fileName - the name of the MED file to read.
8238 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8239 * is to delete this field using decrRef() as it is no more needed.
8240 * \throw If reading the file fails.
8242 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
8244 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8245 return New(fid,loadAll);
8248 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, bool loadAll)
8250 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
8251 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8252 ret->loadGlobals(fid);
8257 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
8258 * that has been read from a specified MED file.
8259 * \param [in] fileName - the name of the MED file to read.
8260 * \param [in] fieldName - the name of the field to read.
8261 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8262 * is to delete this field using decrRef() as it is no more needed.
8263 * \throw If reading the file fails.
8264 * \throw If there is no field named \a fieldName in the file.
8266 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8268 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8269 return New(fid,fieldName,loadAll);
8272 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
8274 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
8275 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8276 ret->loadGlobals(fid);
8281 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8282 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8284 * \warning this is a shallow copy constructor
8286 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8288 if(!shallowCopyOfContent)
8290 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
8291 otherPtr->incrRef();
8292 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
8296 _content=other.shallowCpy();
8300 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
8302 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8304 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
8308 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
8310 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8312 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
8316 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
8318 return contentNotNullBase()->getPflsReallyUsed2();
8321 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
8323 return contentNotNullBase()->getLocsReallyUsed2();
8326 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
8328 return contentNotNullBase()->getPflsReallyUsedMulti2();
8331 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
8333 return contentNotNullBase()->getLocsReallyUsedMulti2();
8336 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8338 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
8341 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8343 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
8346 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
8348 return contentNotNullBase()->getNumberOfTS();
8351 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
8353 contentNotNullBase()->eraseEmptyTS();
8356 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
8358 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
8361 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
8363 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
8366 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
8368 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
8369 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8374 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
8376 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
8377 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8382 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
8384 return contentNotNullBase()->getIterations();
8387 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
8389 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
8390 pushBackTimeStep(*it);
8393 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
8396 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
8397 int nbOfTS(fmts->getNumberOfTS());
8398 for(int i=0;i<nbOfTS;i++)
8400 MCAuto<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
8401 pushBackTimeStep(elt);
8405 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
8408 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
8409 checkCoherencyOfType(f1ts);
8411 MCAuto<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
8412 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
8414 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
8415 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
8416 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
8417 _content->pushBackTimeStep(cSafe);
8418 appendGlobs(*f1ts,1e-12);
8421 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
8423 contentNotNullBase()->synchronizeNameScope();
8426 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
8428 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
8431 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
8433 return contentNotNullBase()->getPosGivenTime(time,eps);
8436 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8438 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
8441 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
8443 return contentNotNullBase()->getTypesOfFieldAvailable();
8446 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
8448 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
8451 std::string MEDFileAnyTypeFieldMultiTS::getName() const
8453 return contentNotNullBase()->getName();
8456 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
8458 contentNotNullBase()->setName(name);
8461 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
8463 return contentNotNullBase()->getDtUnit();
8466 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
8468 contentNotNullBase()->setDtUnit(dtUnit);
8471 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8473 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
8476 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
8478 return contentNotNullBase()->getTimeSteps(ret1);
8481 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
8483 return contentNotNullBase()->getMeshName();
8486 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
8488 contentNotNullBase()->setMeshName(newMeshName);
8491 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
8493 return contentNotNullBase()->changeMeshNames(modifTab);
8496 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
8498 return contentNotNullBase()->getInfo();
8501 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
8503 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
8506 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
8508 return contentNotNullBase()->setInfo(info);
8511 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
8513 const std::vector<std::string> ret=getInfo();
8514 return (int)ret.size();
8517 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
8519 writeGlobals(fid,*this);
8520 contentNotNullBase()->writeLL(fid,*this);
8524 * This method alloc the arrays and load potentially huge arrays contained in this field.
8525 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
8526 * This method can be also called to refresh or reinit values from a file.
8528 * \throw If the fileName is not set or points to a non readable MED file.
8530 void MEDFileAnyTypeFieldMultiTS::loadArrays()
8532 if(getFileName().empty())
8533 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
8534 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
8535 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
8539 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
8540 * But once data loaded once, this method does nothing.
8542 * \throw If the fileName is not set or points to a non readable MED file.
8543 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
8545 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
8547 if(!getFileName().empty())
8549 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
8550 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
8555 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
8556 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
8557 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
8559 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
8561 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
8563 contentNotNullBase()->unloadArrays();
8567 * 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.
8568 * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
8569 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
8571 * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
8573 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
8575 if(!getFileName().empty())
8576 contentNotNullBase()->unloadArrays();
8579 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
8581 std::ostringstream oss;
8582 contentNotNullBase()->simpleRepr(0,oss,-1);
8583 simpleReprGlobs(oss);
8587 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
8589 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
8592 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
8594 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
8595 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
8600 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
8601 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8602 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
8604 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
8606 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8608 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
8609 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
8610 std::size_t sz(contentsSplit.size());
8611 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8612 for(std::size_t i=0;i<sz;i++)
8614 ret[i]=shallowCpy();
8615 ret[i]->_content=contentsSplit[i];
8621 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
8622 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8624 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
8626 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8628 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
8629 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
8630 std::size_t sz(contentsSplit.size());
8631 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8632 for(std::size_t i=0;i<sz;i++)
8634 ret[i]=shallowCpy();
8635 ret[i]->_content=contentsSplit[i];
8641 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
8642 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8644 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
8646 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8648 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
8649 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
8650 std::size_t sz(contentsSplit.size());
8651 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8652 for(std::size_t i=0;i<sz;i++)
8654 ret[i]=shallowCpy();
8655 ret[i]->_content=contentsSplit[i];
8660 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCopy() const
8662 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8663 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
8664 ret->_content=_content->deepCopy();
8665 ret->deepCpyGlobs(*this);
8669 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
8675 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8676 * \param [in] iteration - the iteration number of a required time step.
8677 * \param [in] order - the iteration order number of required time step.
8678 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
8679 * delete this field using decrRef() as it is no more needed.
8680 * \throw If there is no required time step in \a this field.
8682 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
8684 int pos=getPosOfTimeStep(iteration,order);
8685 return getTimeStepAtPos(pos);
8689 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8690 * \param [in] time - the time of the time step of interest.
8691 * \param [in] eps - a precision used to compare time values.
8692 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8693 * delete this field using decrRef() as it is no more needed.
8694 * \throw If there is no required time step in \a this field.
8696 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
8698 int pos=getPosGivenTime(time,eps);
8699 return getTimeStepAtPos(pos);
8703 * 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.
8704 * The float64 value of time attached to the pair of integers are not considered here.
8705 * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
8707 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
8708 * \throw If there is a null pointer in \a vectFMTS.
8710 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
8712 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
8713 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8714 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8715 while(!lstFMTS.empty())
8717 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8718 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8720 throw INTERP_KERNEL::Exception(msg);
8721 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
8722 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8723 elt.push_back(curIt); it=lstFMTS.erase(it);
8724 while(it!=lstFMTS.end())
8728 throw INTERP_KERNEL::Exception(msg);
8729 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
8731 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8741 * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
8742 * All returned instances in a subvector can be safely loaded, rendered along time
8743 * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
8744 * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
8745 * 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).
8746 * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
8747 * 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.
8749 * \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().
8750 * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
8751 * \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.
8752 * \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.
8754 * \throw If an element in \a vectFMTS has not only one spatial discretization set.
8755 * \throw If an element in \a vectFMTS change of spatial discretization along time.
8756 * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
8757 * \thorw If some elements in \a vectFMTS do not have the same times steps.
8758 * \throw If mesh is null.
8759 * \throw If an element in \a vectFMTS is null.
8760 * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
8762 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& fsc)
8764 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
8766 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
8767 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8768 if(vectFMTS.empty())
8770 std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
8771 MEDFileAnyTypeFieldMultiTS *frstElt(*it);
8773 throw INTERP_KERNEL::Exception(msg);
8775 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
8776 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
8777 for(;it!=vectFMTS.end();it++,i++)
8780 throw INTERP_KERNEL::Exception(msg);
8781 TypeOfField tof0,tof1;
8782 if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
8785 vectFMTSNotNodes.push_back(*it);
8787 vectFMTSNodes.push_back(*it);
8790 vectFMTSNotNodes.push_back(*it);
8792 std::vector< MCAuto<MEDFileFastCellSupportComparator> > cmps;
8793 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
8795 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
8798 bool isFetched(false);
8799 for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
8802 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
8803 if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
8804 { ret[i].push_back(*it2); isFetched=true; }
8808 std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
8809 MCAuto<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
8810 ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
8818 * 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.
8819 * \param [out] cmps - same size than the returned vector.
8821 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& cmps)
8823 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8824 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8825 while(!lstFMTS.empty())
8827 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8828 MEDFileAnyTypeFieldMultiTS *ref(*it);
8829 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8830 elt.push_back(ref); it=lstFMTS.erase(it);
8831 MCAuto<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
8832 MCAuto<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
8833 while(it!=lstFMTS.end())
8835 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8836 if(cmp->isEqual(curIt))
8837 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8841 ret.push_back(elt); cmps.push_back(cmp);
8847 * 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.
8848 * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
8850 * \throw If \a f0 or \a f1 has not only one spatial discretization set.
8851 * \throw If \a f0 or \a f1 change of spatial discretization along time.
8852 * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
8853 * \thorw If \a f0 and \a f1 do not have the same times steps.
8854 * \throw If mesh is null.
8855 * \throw If \a f0 or \a f1 is null.
8856 * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
8858 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
8861 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
8863 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
8864 if(f0->getMeshName()!=mesh->getName())
8866 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8867 throw INTERP_KERNEL::Exception(oss.str());
8869 if(f1->getMeshName()!=mesh->getName())
8871 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8872 throw INTERP_KERNEL::Exception(oss.str());
8874 int nts=f0->getNumberOfTS();
8875 if(nts!=f1->getNumberOfTS())
8876 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
8879 for(int i=0;i<nts;i++)
8881 MCAuto<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
8882 MCAuto<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
8883 std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
8884 if(tofs0.size()!=1 || tofs1.size()!=1)
8885 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
8888 if(tof0!=tofs0[0] || tof1!=tofs1[0])
8889 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
8892 { tof0=tofs0[0]; tof1=tofs1[0]; }
8893 if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
8895 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() << ") !";
8896 throw INTERP_KERNEL::Exception(oss.str());
8898 if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
8900 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() << ") !";
8901 throw INTERP_KERNEL::Exception(oss.str());
8903 if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
8905 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() << ") !";
8906 throw INTERP_KERNEL::Exception(oss.str());
8913 MCAuto<MEDFileAnyTypeField1TS> AggregateHelperF1TS(const std::vector< typename MLFieldTraits<T>::F1TSType const *>& f1tss, const std::vector< std::vector< std::pair<int,int> > >& dts)
8915 MCAuto< typename MLFieldTraits<T>::F1TSType > ret(MLFieldTraits<T>::F1TSType::New());
8917 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : empty vector !");
8918 std::size_t sz(f1tss.size()),i(0);
8919 std::vector< typename MLFieldTraits<T>::F1TSWSDAType const *> f1tsw(sz);
8920 for(typename std::vector< typename MLFieldTraits<T>::F1TSType const *>::const_iterator it=f1tss.begin();it!=f1tss.end();it++,i++)
8922 typename MLFieldTraits<T>::F1TSType const *elt(*it);
8924 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : presence of a null pointer !");
8925 f1tsw[i]=dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType const *>(elt->contentNotNullBase());
8927 typename MLFieldTraits<T>::F1TSWSDAType *retc(dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType *>(ret->contentNotNullBase()));
8929 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : internal error 1 !");
8930 retc->aggregate(f1tsw,dts);
8931 ret->setDtUnit(f1tss[0]->getDtUnit());
8932 return DynamicCast<typename MLFieldTraits<T>::F1TSType , MEDFileAnyTypeField1TS>(ret);
8936 MCAuto< MEDFileAnyTypeFieldMultiTS > AggregateHelperFMTS(const std::vector< typename MLFieldTraits<T>::FMTSType const *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
8938 MCAuto< typename MLFieldTraits<T>::FMTSType > ret(MLFieldTraits<T>::FMTSType::New());
8940 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : empty vector !");
8941 std::size_t sz(fmtss.size());
8942 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
8944 typename MLFieldTraits<T>::FMTSType const *elt(*it);
8946 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : presence of null pointer !");
8948 int nbTS(fmtss[0]->getNumberOfTS());
8949 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
8950 if((*it)->getNumberOfTS()!=nbTS)
8951 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : all fields must have the same number of TS !");
8952 for(int iterTS=0;iterTS<nbTS;iterTS++)
8955 std::vector< typename MLFieldTraits<T>::F1TSType const *> f1tss(sz);
8956 std::vector< MCAuto<typename MLFieldTraits<T>::F1TSType> > f1tss2(sz);
8957 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++,i++)
8958 { f1tss2[i]=(*it)->getTimeStepAtPos(iterTS); f1tss[i]=f1tss2[i]; }
8959 MCAuto<MEDFileAnyTypeField1TS> f1ts(AggregateHelperF1TS<T>(f1tss,dts));
8960 ret->pushBackTimeStep(f1ts);
8961 ret->setDtUnit(f1ts->getDtUnit());
8963 return DynamicCast<typename MLFieldTraits<T>::FMTSType , MEDFileAnyTypeFieldMultiTS>(ret);
8967 * \a dts and \a ftmss are expected to have same size.
8969 MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileAnyTypeFieldMultiTS::Aggregate(const std::vector<const MEDFileAnyTypeFieldMultiTS *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
8972 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : input vector is empty !");
8973 std::size_t sz(fmtss.size());
8974 std::vector<const MEDFileFieldMultiTS *> fmtss1;
8975 std::vector<const MEDFileIntFieldMultiTS *> fmtss2;
8976 for(std::vector<const MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
8979 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : presence of null instance in input vector !");
8980 const MEDFileFieldMultiTS *elt1(dynamic_cast<const MEDFileFieldMultiTS *>(*it));
8983 fmtss1.push_back(elt1);
8986 const MEDFileIntFieldMultiTS *elt2(dynamic_cast<const MEDFileIntFieldMultiTS *>(*it));
8989 fmtss2.push_back(elt2);
8992 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not recognized type !");
8994 if(fmtss1.size()!=sz && fmtss2.size()!=sz)
8995 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : type of data is not homogeneous !");
8996 if(fmtss1.size()==sz)
8997 return AggregateHelperFMTS<double>(fmtss1,dts);
8998 if(fmtss2.size()!=sz)
8999 return AggregateHelperFMTS<int>(fmtss2,dts);
9000 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not implemented yet !");
9003 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
9005 return new MEDFileAnyTypeFieldMultiTSIterator(this);
9008 //= MEDFileFieldMultiTS
9010 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
9012 return new MEDFileFieldMultiTS(*this);
9016 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
9017 * following the given input policy.
9019 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9020 * By default (true) the globals are deeply copied.
9021 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
9023 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
9025 MCAuto<MEDFileIntFieldMultiTS> ret;
9026 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9029 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
9031 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
9032 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
9033 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc));
9036 ret=MEDFileIntFieldMultiTS::New();
9038 ret->deepCpyGlobs(*this);
9040 ret->shallowCpyGlobs(*this);
9044 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
9045 try:MEDFileTemplateFieldMultiTS<double>(fid,loadAll,ms)
9048 catch(INTERP_KERNEL::Exception& e)
9051 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
9052 try:MEDFileTemplateFieldMultiTS<double>(fid,fieldName,loadAll,ms,entities)
9055 catch(INTERP_KERNEL::Exception& e)
9058 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileTemplateFieldMultiTS<double>(other,shallowCopyOfContent)
9062 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
9064 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
9067 //= MEDFileAnyTypeFieldMultiTSIterator
9069 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
9074 _nb_iter=fmts->getNumberOfTS();
9078 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
9082 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
9084 if(_iter_id<_nb_iter)
9086 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
9088 return fmts->getTimeStepAtPos(_iter_id++);
9096 //= MEDFileIntFieldMultiTS
9100 MEDFileFields *MEDFileFields::New()
9102 return new MEDFileFields;
9105 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
9107 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9108 return New(fid,loadAll);
9111 MEDFileFields *MEDFileFields::NewAdv(const std::string& fileName, bool loadAll, const MEDFileEntities *entities)
9113 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9114 return NewAdv(fid,loadAll,entities);
9117 MEDFileFields *MEDFileFields::NewAdv(med_idt fid, bool loadAll, const MEDFileEntities *entities)
9119 return new MEDFileFields(fid,loadAll,0,entities);
9122 MEDFileFields *MEDFileFields::NewWithDynGT(const std::string& fileName, const MEDFileStructureElements *se, bool loadAll)
9124 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9125 return NewWithDynGT(fid,se,loadAll);
9128 MEDFileFields *MEDFileFields::NewWithDynGT(med_idt fid, const MEDFileStructureElements *se, bool loadAll)
9131 throw INTERP_KERNEL::Exception("MEDFileFields::NewWithDynGT : null struct element pointer !");
9132 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> entities(MEDFileEntities::BuildFrom(*se));
9133 return new MEDFileFields(fid,loadAll,0,entities);
9136 MEDFileFields *MEDFileFields::New(med_idt fid, bool loadAll)
9138 return new MEDFileFields(fid,loadAll,0,0);
9141 MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9143 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9144 return new MEDFileFields(fid,loadAll,ms,0);
9147 MEDFileFields *MEDFileFields::LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9149 MEDFileUtilities::CheckFileForRead(fileName);
9150 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
9151 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9152 return new MEDFileFields(fid,loadAll,0,ent);
9155 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
9157 std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
9158 ret+=_fields.capacity()*sizeof(MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
9162 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
9164 std::vector<const BigMemoryObject *> ret;
9165 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9166 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
9170 MEDFileFields *MEDFileFields::deepCopy() const
9172 MCAuto<MEDFileFields> ret(shallowCpy());
9174 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9176 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9177 ret->_fields[i]=(*it)->deepCopy();
9179 ret->deepCpyGlobs(*this);
9183 MEDFileFields *MEDFileFields::shallowCpy() const
9185 return new MEDFileFields(*this);
9189 * 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
9190 * 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.
9191 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
9193 * \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.
9194 * \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.
9196 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9198 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
9200 std::set< std::pair<int,int> > s;
9201 bool firstShot=true;
9202 areThereSomeForgottenTS=false;
9203 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9205 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9207 std::vector< std::pair<int,int> > v=(*it)->getIterations();
9208 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
9210 { s=s1; firstShot=false; }
9213 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
9215 areThereSomeForgottenTS=true;
9219 std::vector< std::pair<int,int> > ret;
9220 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
9224 int MEDFileFields::getNumberOfFields() const
9226 return _fields.size();
9229 std::vector<std::string> MEDFileFields::getFieldsNames() const
9231 std::vector<std::string> ret(_fields.size());
9233 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9235 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
9238 ret[i]=f->getName();
9242 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
9243 throw INTERP_KERNEL::Exception(oss.str());
9249 std::vector<std::string> MEDFileFields::getMeshesNames() const
9251 std::vector<std::string> ret;
9252 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9254 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9256 ret.push_back(cur->getMeshName());
9261 std::string MEDFileFields::simpleRepr() const
9263 std::ostringstream oss;
9264 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
9269 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
9271 int nbOfFields(getNumberOfFields());
9272 std::string startLine(bkOffset,' ');
9273 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
9275 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9277 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9280 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
9284 oss << startLine << " - not defined !" << std::endl;
9288 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9290 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9291 std::string chapter(17,'0'+i);
9292 oss << startLine << chapter << std::endl;
9295 cur->simpleRepr(bkOffset+2,oss,i);
9299 oss << startLine << " - not defined !" << std::endl;
9301 oss << startLine << chapter << std::endl;
9303 simpleReprGlobs(oss);
9306 MEDFileFields::MEDFileFields()
9310 MEDFileFields::MEDFileFields(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
9311 try:MEDFileFieldGlobsReal(fid)
9313 int nbFields(MEDnField(fid));
9314 _fields.resize(nbFields);
9315 med_field_type typcha;
9316 for(int i=0;i<nbFields;i++)
9318 std::vector<std::string> infos;
9319 std::string fieldName,dtunit,meshName;
9320 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,i,false,fieldName,typcha,infos,dtunit,meshName));
9325 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName,meshName,typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
9330 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName,meshName,typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
9335 _fields[i]=MEDFileFloatFieldMultiTSWithoutSDA::New(fid,fieldName,meshName,typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
9340 if(sizeof(med_int)==sizeof(int))
9342 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName,meshName,typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
9348 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] !";
9349 throw INTERP_KERNEL::Exception(oss.str());
9353 loadAllGlobals(fid,entities);
9355 catch(INTERP_KERNEL::Exception& e)
9360 void MEDFileFields::writeLL(med_idt fid) const
9363 writeGlobals(fid,*this);
9364 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9366 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
9369 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
9370 throw INTERP_KERNEL::Exception(oss.str());
9372 elt->writeLL(fid,*this);
9377 * This method alloc the arrays and load potentially huge arrays contained in this field.
9378 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
9379 * This method can be also called to refresh or reinit values from a file.
9381 * \throw If the fileName is not set or points to a non readable MED file.
9383 void MEDFileFields::loadArrays()
9385 if(getFileName().empty())
9386 throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
9387 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
9388 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9390 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9392 elt->loadBigArraysRecursively(fid,*elt);
9397 * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
9398 * But once data loaded once, this method does nothing.
9400 * \throw If the fileName is not set or points to a non readable MED file.
9401 * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
9403 void MEDFileFields::loadArraysIfNecessary()
9405 if(!getFileName().empty())
9407 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
9408 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9410 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9412 elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
9418 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
9419 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
9420 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
9422 * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
9424 void MEDFileFields::unloadArrays()
9426 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9428 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9430 elt->unloadArrays();
9435 * 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.
9436 * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
9437 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
9439 * \sa MEDFileFields::loadArraysIfNecessary
9441 void MEDFileFields::unloadArraysWithoutDataLoss()
9443 if(!getFileName().empty())
9447 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
9449 std::vector<std::string> ret;
9450 std::set<std::string> ret2;
9451 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9453 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
9454 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
9455 if(ret2.find(*it2)==ret2.end())
9457 ret.push_back(*it2);
9464 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
9466 std::vector<std::string> ret;
9467 std::set<std::string> ret2;
9468 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9470 std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
9471 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
9472 if(ret2.find(*it2)==ret2.end())
9474 ret.push_back(*it2);
9481 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
9483 std::vector<std::string> ret;
9484 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9486 std::vector<std::string> tmp((*it)->getPflsReallyUsedMulti2());
9487 ret.insert(ret.end(),tmp.begin(),tmp.end());
9492 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
9494 std::vector<std::string> ret;
9495 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9497 std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
9498 ret.insert(ret.end(),tmp.begin(),tmp.end());
9503 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
9505 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
9506 (*it)->changePflsRefsNamesGen2(mapOfModif);
9509 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
9511 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
9512 (*it)->changeLocsRefsNamesGen2(mapOfModif);
9515 void MEDFileFields::resize(int newSize)
9517 _fields.resize(newSize);
9520 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
9522 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
9526 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
9529 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
9530 _fields.push_back(field->getContent());
9531 appendGlobs(*field,1e-12);
9534 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
9537 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
9538 if(i>=(int)_fields.size())
9539 _fields.resize(i+1);
9540 _fields[i]=field->getContent();
9541 appendGlobs(*field,1e-12);
9544 void MEDFileFields::destroyFieldAtPos(int i)
9546 destroyFieldsAtPos(&i,&i+1);
9549 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
9551 std::vector<bool> b(_fields.size(),true);
9552 for(const int *i=startIds;i!=endIds;i++)
9554 if(*i<0 || *i>=(int)_fields.size())
9556 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
9557 throw INTERP_KERNEL::Exception(oss.str());
9561 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
9563 for(std::size_t i=0;i<_fields.size();i++)
9565 fields[j++]=_fields[i];
9569 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
9571 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
9572 int nbOfEntriesToKill(DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg));
9573 std::vector<bool> b(_fields.size(),true);
9575 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
9577 if(k<0 || k>=(int)_fields.size())
9579 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
9580 throw INTERP_KERNEL::Exception(oss.str());
9584 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
9586 for(std::size_t i=0;i<_fields.size();i++)
9588 fields[j++]=_fields[i];
9592 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
9595 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9597 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9599 ret=cur->changeMeshNames(modifTab) || ret;
9605 * \param [in] meshName the name of the mesh that will be renumbered.
9606 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
9607 * This code corresponds to the distribution of types in the corresponding mesh.
9608 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
9609 * \param [in] renumO2N the old to new renumber array.
9610 * \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
9613 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
9616 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9618 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
9621 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
9628 * Return an extraction of \a this using \a extractDef map to specify the extraction.
9629 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
9631 * \return A new object that the caller is responsible to deallocate.
9633 MEDFileFields *MEDFileFields::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
9636 throw INTERP_KERNEL::Exception("MEDFileFields::extractPart : input mesh is NULL !");
9637 MCAuto<MEDFileFields> fsOut(MEDFileFields::New());
9638 int nbFields(getNumberOfFields());
9639 for(int i=0;i<nbFields;i++)
9641 MCAuto<MEDFileAnyTypeFieldMultiTS> fmts(getFieldAtPos(i));
9644 std::ostringstream oss; oss << "MEDFileFields::extractPart : at pos #" << i << " field is null !";
9645 throw INTERP_KERNEL::Exception(oss.str());
9647 MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(fmts->extractPart(extractDef,mm));
9648 fsOut->pushField(fmtsOut);
9650 return fsOut.retn();
9653 void MEDFileFields::accept(MEDFileFieldVisitor& visitor) const
9655 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9656 if((*it).isNotNull())
9658 visitor.newFieldEntry(*it);
9659 (*it)->accept(visitor);
9660 visitor.endFieldEntry(*it);
9664 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
9666 if(i<0 || i>=(int)_fields.size())
9668 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
9669 throw INTERP_KERNEL::Exception(oss.str());
9671 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
9674 MCAuto<MEDFileAnyTypeFieldMultiTS> ret;
9675 const MEDFileFieldMultiTSWithoutSDA *fmtsC(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts));
9676 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts));
9677 const MEDFileFloatFieldMultiTSWithoutSDA *fmtsC3(dynamic_cast<const MEDFileFloatFieldMultiTSWithoutSDA *>(fmts));
9679 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
9681 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
9683 ret=MEDFileFloatFieldMultiTS::New(*fmtsC3,false);
9686 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor float (FLOAT32) nor integer (INT32) !";
9687 throw INTERP_KERNEL::Exception(oss.str());
9689 ret->shallowCpyGlobs(*this);
9694 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
9695 * This method is accessible in python using __getitem__ with a list in input.
9696 * \return a new object that the caller should deal with.
9698 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
9700 MCAuto<MEDFileFields> ret=shallowCpy();
9701 std::size_t sz=std::distance(startIds,endIds);
9702 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
9704 for(const int *i=startIds;i!=endIds;i++,j++)
9706 if(*i<0 || *i>=(int)_fields.size())
9708 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
9709 throw INTERP_KERNEL::Exception(oss.str());
9711 fields[j]=_fields[*i];
9713 ret->_fields=fields;
9717 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
9719 return getFieldAtPos(getPosFromFieldName(fieldName));
9723 * This method removes, if any, fields in \a this having no time steps.
9724 * 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.
9726 * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
9728 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
9730 std::vector<MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
9731 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9733 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9736 if(elt->getNumberOfTS()>0)
9737 newFields.push_back(*it);
9740 if(_fields.size()==newFields.size())
9747 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
9748 * This method can be seen as a filter applied on \a this, that returns an object containing
9749 * 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
9750 * shallow copied from \a this.
9752 * \param [in] meshName - the name of the mesh on w
9753 * \return a new object that the caller should deal with.
9755 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
9757 MCAuto<MEDFileFields> ret(MEDFileFields::New());
9758 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9760 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9763 if(cur->getMeshName()==meshName)
9766 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
9767 ret->_fields.push_back(cur2);
9770 ret->shallowCpyOnlyUsedGlobs(*this);
9775 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
9776 * Input time steps are specified using a pair of integer (iteration, order).
9777 * 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,
9778 * but for each multitimestep only the time steps in \a timeSteps are kept.
9779 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
9781 * The returned object points to shallow copy of elements in \a this.
9783 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
9784 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
9785 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9787 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
9789 MCAuto<MEDFileFields> ret(MEDFileFields::New());
9790 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9792 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9795 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
9796 ret->_fields.push_back(elt);
9798 ret->shallowCpyOnlyUsedGlobs(*this);
9803 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
9805 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
9807 MCAuto<MEDFileFields> ret=MEDFileFields::New();
9808 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9810 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9813 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
9814 if(elt->getNumberOfTS()!=0)
9815 ret->_fields.push_back(elt);
9817 ret->shallowCpyOnlyUsedGlobs(*this);
9821 bool MEDFileFields::presenceOfStructureElements() const
9823 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9824 if((*it).isNotNull())
9825 if((*it)->presenceOfStructureElements())
9830 void MEDFileFields::killStructureElements()
9832 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
9833 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9834 if((*it).isNotNull())
9836 if((*it)->presenceOfStructureElements())
9838 if(!(*it)->onlyStructureElements())
9840 (*it)->killStructureElements();
9852 void MEDFileFields::keepOnlyStructureElements()
9854 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
9855 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9856 if((*it).isNotNull())
9858 if((*it)->presenceOfStructureElements())
9860 if(!(*it)->onlyStructureElements())
9861 (*it)->keepOnlyStructureElements();
9868 void MEDFileFields::keepOnlyOnMeshSE(const std::string& meshName, const std::string& seName)
9870 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
9871 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9872 if((*it).isNotNull())
9874 if((*it)->getMeshName()!=meshName)
9876 std::vector< std::pair<std::string,std::string> > ps;
9877 (*it)->getMeshSENames(ps);
9878 std::pair<std::string,std::string> p(meshName,seName);
9879 if(std::find(ps.begin(),ps.end(),p)!=ps.end())
9880 (*it)->keepOnlyOnSE(seName);
9886 void MEDFileFields::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
9888 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9889 if((*it).isNotNull())
9890 (*it)->getMeshSENames(ps);
9893 void MEDFileFields::blowUpSE(MEDFileMeshes *ms, const MEDFileStructureElements *ses)
9895 MEDFileBlowStrEltUp::DealWithSE(this,ms,ses);
9898 MCAuto<MEDFileFields> MEDFileFields::partOfThisOnStructureElements() const
9900 MCAuto<MEDFileFields> ret(deepCopy());
9901 ret->keepOnlyStructureElements();
9905 MCAuto<MEDFileFields> MEDFileFields::partOfThisLyingOnSpecifiedMeshSEName(const std::string& meshName, const std::string& seName) const
9907 MCAuto<MEDFileFields> ret(deepCopy());
9908 ret->keepOnlyOnMeshSE(meshName,seName);
9912 void MEDFileFields::aggregate(const MEDFileFields& other)
9914 int nbFieldsToAdd(other.getNumberOfFields());
9915 std::vector<std::string> fsn(getFieldsNames());
9916 for(int i=0;i<nbFieldsToAdd;i++)
9918 MCAuto<MEDFileAnyTypeFieldMultiTS> elt(other.getFieldAtPos(i));
9919 std::string name(elt->getName());
9920 if(std::find(fsn.begin(),fsn.end(),name)!=fsn.end())
9922 std::ostringstream oss; oss << "MEDFileFields::aggregate : name \"" << name << "\" already appears !";
9923 throw INTERP_KERNEL::Exception(oss.str());
9929 MEDFileFieldsIterator *MEDFileFields::iterator()
9931 return new MEDFileFieldsIterator(this);
9934 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
9936 std::string tmp(fieldName);
9937 std::vector<std::string> poss;
9938 for(std::size_t i=0;i<_fields.size();i++)
9940 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f(_fields[i]);
9943 std::string fname(f->getName());
9947 poss.push_back(fname);
9950 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
9951 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
9953 throw INTERP_KERNEL::Exception(oss.str());
9956 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
9961 _nb_iter=fs->getNumberOfFields();
9965 MEDFileFieldsIterator::~MEDFileFieldsIterator()
9969 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
9971 if(_iter_id<_nb_iter)
9973 MEDFileFields *fs(_fs);
9975 return fs->getFieldAtPos(_iter_id++);