1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (CEA/DEN)
21 #include "MEDFileField.txx"
22 #include "MEDFileMesh.hxx"
23 #include "MEDLoaderBase.hxx"
24 #include "MEDLoaderTraits.hxx"
25 #include "MEDFileSafeCaller.txx"
26 #include "MEDFileFieldOverView.hxx"
27 #include "MEDFileBlowStrEltUp.hxx"
28 #include "MEDFileFieldVisitor.hxx"
30 #include "MEDCouplingFieldDouble.hxx"
31 #include "MEDCouplingFieldTemplate.hxx"
32 #include "MEDCouplingFieldDiscretization.hxx"
34 #include "InterpKernelAutoPtr.hxx"
35 #include "CellModel.hxx"
40 extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
41 extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
42 extern med_geometry_type typmainoeud[1];
43 extern med_geometry_type typmai3[34];
45 using namespace MEDCoupling;
47 template class MEDFileField1TSTemplateWithoutSDA<int>;
48 template class MEDFileField1TSTemplateWithoutSDA<double>;
50 const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64";
51 const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32";
53 MEDFileGTKeeper::~MEDFileGTKeeper()
57 MEDFileGTKeeper *MEDFileGTKeeperSta::deepCopy() const
59 return new MEDFileGTKeeperSta(_geo_type);
62 INTERP_KERNEL::NormalizedCellType MEDFileGTKeeperSta::getGeoType() const
67 std::string MEDFileGTKeeperSta::getRepr() const
69 return INTERP_KERNEL::CellModel::GetCellModel(_geo_type).getRepr();
72 bool MEDFileGTKeeperSta::isEqual(const MEDFileGTKeeper *other) const
74 const MEDFileGTKeeperSta *otherC(dynamic_cast<const MEDFileGTKeeperSta *>(other));
77 return _geo_type==otherC->_geo_type;
80 MEDFileGTKeeperDyn::MEDFileGTKeeperDyn(const MEDFileUMesh *mesh, const MEDFileUMesh *section, const MEDFileStructureElement *se):_mesh(mesh),_section(section),_se(se)
88 if(_mesh.isNull() || _section.isNull() || _se.isNull())
89 throw INTERP_KERNEL::Exception("MEDFileGTKeeperDyn constructor : null pointer not allowed !");
92 MEDFileGTKeeper *MEDFileGTKeeperDyn::deepCopy() const
94 return new MEDFileGTKeeperDyn(_mesh,_section,_se);
97 INTERP_KERNEL::NormalizedCellType MEDFileGTKeeperDyn::getGeoType() const
99 throw INTERP_KERNEL::Exception("MEDFileGTKeeperDyn::getGeoType : not valid !");
102 std::string MEDFileGTKeeperDyn::getRepr() const
104 std::ostringstream oss;
105 oss << _se->getDynGT();
109 bool MEDFileGTKeeperDyn::isEqual(const MEDFileGTKeeper *other) const
111 const MEDFileGTKeeperDyn *otherC(dynamic_cast<const MEDFileGTKeeperDyn *>(other));
117 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const std::string& locName)
119 return new MEDFileFieldLoc(fid,locName);
122 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, int id, const MEDFileEntities *entities)
124 return new MEDFileFieldLoc(fid,id,entities);
127 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)
129 return new MEDFileFieldLoc(locName,geoType,refCoo,gsCoo,w);
132 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, const std::string& locName):_name(locName)
134 med_geometry_type geotype;
135 med_geometry_type sectiongeotype;
136 int nsectionmeshcell;
137 INTERP_KERNEL::AutoPtr<char> geointerpname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
138 INTERP_KERNEL::AutoPtr<char> sectionmeshname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
139 MEDlocalizationInfoByName(fid,locName.c_str(),&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
140 _gt=new MEDFileGTKeeperSta((INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype))));
141 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
142 _nb_node_per_cell=cm.getNumberOfNodes();
143 _ref_coo.resize(_dim*_nb_node_per_cell);
144 _gs_coo.resize(_dim*_nb_gauss_pt);
145 _w.resize(_nb_gauss_pt);
146 MEDlocalizationRd(fid,locName.c_str(),MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
149 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id, const MEDFileEntities *entities)
151 med_geometry_type geotype;
152 med_geometry_type sectiongeotype;
153 int nsectionmeshcell;
154 INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
155 INTERP_KERNEL::AutoPtr<char> geointerpname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
156 INTERP_KERNEL::AutoPtr<char> sectionmeshname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
157 MEDlocalizationInfo(fid,id+1,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
159 std::string sectionName(MEDLoaderBase::buildStringFromFortran(sectionmeshname,MED_NAME_SIZE));
160 if(sectionName.empty())
162 _gt=new MEDFileGTKeeperSta((INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype))));
163 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
164 _nb_node_per_cell=cm.getNumberOfNodes();
168 const MEDFileAllStaticEntitiesPlusDyn *entities2(dynamic_cast<const MEDFileAllStaticEntitiesPlusDyn *>(entities));
171 std::ostringstream oss; oss << "MEDFileFieldLoc cstr : for loc \"" << _name << "\" presence of non static type ! Expect entities !";
172 throw INTERP_KERNEL::Exception(oss.str());
174 const MEDFileStructureElement *se(entities2->getWithGT(geotype));
175 const MEDFileUMesh *um(entities2->getSupMeshWithName(se->getMeshName()));
176 const MEDFileUMesh *section(entities2->getSupMeshWithName(sectionName));
177 _gt=new MEDFileGTKeeperDyn(um,section,se);
180 MEDFILESAFECALLERWR0(MEDmeshGeotypeParameter,(fid,geotype,&dummy,&_nb_node_per_cell));
183 _ref_coo.resize(_dim*_nb_node_per_cell);
184 _gs_coo.resize(_dim*_nb_gauss_pt);
185 _w.resize(_nb_gauss_pt);
186 MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
189 MEDFileFieldLoc::MEDFileFieldLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType,
190 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)
192 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
193 _dim=cm.getDimension();
194 _nb_node_per_cell=cm.getNumberOfNodes();
195 _nb_gauss_pt=_w.size();
199 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)
203 MEDFileFieldLoc *MEDFileFieldLoc::deepCopy() const
205 return new MEDFileFieldLoc(*this);
208 bool MEDFileFieldLoc::isOnStructureElement() const
210 const MEDFileGTKeeper *gt(_gt);
212 throw INTERP_KERNEL::Exception("MEDFileFieldLoc::isOnStructureElement : null pointer !");
213 const MEDFileGTKeeperDyn *gt2(dynamic_cast<const MEDFileGTKeeperDyn *>(gt));
217 std::size_t MEDFileFieldLoc::getHeapMemorySizeWithoutChildren() const
219 return (_ref_coo.capacity()+_gs_coo.capacity()+_w.capacity())*sizeof(double)+_name.capacity();
222 std::vector<const BigMemoryObject *> MEDFileFieldLoc::getDirectChildrenWithNull() const
224 return std::vector<const BigMemoryObject *>();
227 void MEDFileFieldLoc::simpleRepr(std::ostream& oss) const
229 static const char OFF7[]="\n ";
230 oss << "\"" << _name << "\"" << OFF7;
231 oss << "GeoType=" << _gt->getRepr() << OFF7;
232 oss << "Dimension=" << _dim << OFF7;
233 oss << "Number of Gauss points=" << _nb_gauss_pt << OFF7;
234 oss << "Number of nodes per cell=" << _nb_node_per_cell << OFF7;
235 oss << "RefCoords="; std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
236 oss << "Weights="; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
237 oss << "GaussPtsCoords="; std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," ")); oss << std::endl;
240 void MEDFileFieldLoc::setName(const std::string& name)
245 bool MEDFileFieldLoc::isEqual(const MEDFileFieldLoc& other, double eps) const
247 if(_name!=other._name)
251 if(_nb_gauss_pt!=other._nb_gauss_pt)
253 if(_nb_node_per_cell!=other._nb_node_per_cell)
255 if(!_gt->isEqual(other._gt))
257 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_ref_coo,other._ref_coo,eps))
259 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_gs_coo,other._gs_coo,eps))
261 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_w,other._w,eps))
267 void MEDFileFieldLoc::writeLL(med_idt fid) const
269 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);
272 std::string MEDFileFieldLoc::repr() const
274 std::ostringstream oss; oss.precision(15);
275 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
276 oss << "Localization \"" << _name << "\" :\n" << " - Geometric Type : " << cm.getRepr();
277 oss << "\n - Dimension : " << _dim << "\n - Number of gauss points : ";
278 oss << _nb_gauss_pt << "\n - Number of nodes in cell : " << _nb_node_per_cell;
279 oss << "\n - Ref coords are : ";
280 int sz=_ref_coo.size();
283 int nbOfTuples=sz/_dim;
284 for(int i=0;i<nbOfTuples;i++)
287 for(int j=0;j<_dim;j++)
288 { oss << _ref_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
293 std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," "));
294 oss << "\n - Gauss coords in reference element : ";
298 int nbOfTuples=sz/_dim;
299 for(int i=0;i<nbOfTuples;i++)
302 for(int j=0;j<_dim;j++)
303 { oss << _gs_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
308 std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," "));
309 oss << "\n - Weights of Gauss coords are : "; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," "));
313 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
315 _type=field->getTypeOfField();
321 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,offset,offset+nbOfCells,1);
322 _end=_start+nbOfCells;
328 MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
329 const int *arrPtr=arr->getConstPointer();
330 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,arrPtr[offset],arrPtr[offset+nbOfCells],1);
331 _end=_start+(arrPtr[offset+nbOfCells]-arrPtr[offset]);
337 const MEDCouplingFieldDiscretization *disc(field->getDiscretization());
338 const MEDCouplingGaussLocalization& gsLoc(field->getGaussLocalization(_loc_id));
339 const MEDCouplingFieldDiscretizationGauss *disc2(dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc));
341 throw INTERP_KERNEL::Exception("assignFieldNoProfile : invalid call to this method ! Internal Error !");
342 const DataArrayInt *dai(disc2->getArrayOfDiscIds());
343 MCAuto<DataArrayInt> dai2(disc2->getOffsetArr(field->getMesh()));
344 const int *dai2Ptr(dai2->getConstPointer());
345 int nbi(gsLoc.getWeights().size());
346 MCAuto<DataArrayInt> da2(dai->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1));
347 MCAuto<DataArrayInt> da3(da2->findIdsEqual(_loc_id));
348 const int *da3Ptr(da3->getConstPointer());
349 if(da3->getNumberOfTuples()!=nbOfCells)
350 {//profile : for gauss even in NoProfile !!!
351 std::ostringstream oss; oss << "Pfl_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
353 da3->setName(_profile.c_str());
354 glob.appendProfile(da3);
356 MCAuto<DataArrayInt> da4(DataArrayInt::New());
357 _nval=da3->getNbOfElems();
358 da4->alloc(_nval*nbi,1);
359 int *da4Ptr(da4->getPointer());
360 for(int i=0;i<_nval;i++)
362 int ref=dai2Ptr[offset+da3Ptr[i]];
363 for(int j=0;j<nbi;j++)
366 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
367 _localization=oss2.str();
368 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,da4);
369 _end=_start+_nval*nbi;
370 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
374 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile : not implemented yet for such discretization type of field !");
380 * Leaf method of field with profile assignement. This method is the most general one. No optimization is done here.
381 * \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).
382 * \param [in] multiTypePfl is the end user profile specified in high level API
383 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
384 * \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.
385 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
386 * \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.
388 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arrr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
391 _type=field->getTypeOfField();
392 std::string pflName(multiTypePfl->getName());
393 std::ostringstream oss; oss << pflName;
397 { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType()); oss << "_" << cm.getRepr(); }
404 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : existing profile with empty name !");
405 if(_type!=ON_GAUSS_PT)
407 locIds->setName(oss.str());
408 glob.appendProfile(locIds);
417 _nval=idsInPfl->getNumberOfTuples();
418 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,0,arrr->getNumberOfTuples(),1);
424 _nval=idsInPfl->getNumberOfTuples();
425 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,idsInPfl);
431 MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
432 MCAuto<DataArrayInt> arr2=arr->deltaShiftIndex();
433 MCAuto<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->begin(),multiTypePfl->end());
434 arr3->computeOffsetsFull();
435 MCAuto<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
436 int trueNval=tmp->getNumberOfTuples();
437 _nval=idsInPfl->getNumberOfTuples();
438 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
439 _end=_start+trueNval;
444 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(field->getDiscretization());
446 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
447 const DataArrayInt *da1=disc2->getArrayOfDiscIds();
448 const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
449 MCAuto<DataArrayInt> da2=da1->selectByTupleId(idsInPfl->begin(),idsInPfl->end());
450 MCAuto<DataArrayInt> da3=da2->findIdsEqual(_loc_id);
451 MCAuto<DataArrayInt> da4=idsInPfl->selectByTupleId(da3->begin(),da3->end());
453 MCAuto<MEDCouplingMesh> mesh2=mesh->buildPart(multiTypePfl->begin(),multiTypePfl->end());
454 MCAuto<DataArrayInt> arr=disc2->getOffsetArr(mesh2);
456 MCAuto<DataArrayInt> tmp=DataArrayInt::New();
458 for(const int *pt=da4->begin();pt!=da4->end();pt++)
459 trueNval+=arr->getIJ(*pt+1,0)-arr->getIJ(*pt,0);
460 tmp->alloc(trueNval,1);
461 int *tmpPtr=tmp->getPointer();
462 for(const int *pt=da4->begin();pt!=da4->end();pt++)
463 for(int j=arr->getIJ(*pt,0);j<arr->getIJ(*pt+1,0);j++)
466 _nval=da4->getNumberOfTuples();
467 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
468 _end=_start+trueNval;
469 oss << "_loc_" << _loc_id;
472 MCAuto<DataArrayInt> da5=locIds->selectByTupleId(da3->begin(),da3->end());
473 da5->setName(oss.str());
474 glob.appendProfile(da5);
479 if(!da3->isIota(nbOfEltsInWholeMesh))
481 da3->setName(oss.str());
482 glob.appendProfile(da3);
486 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
487 _localization=oss2.str();
488 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
492 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for such discretization type of field !");
497 void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob)
500 _nval=arrr->getNumberOfTuples();
501 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,0,_nval,1);
506 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int profileIt, const PartDefinition *pd)
508 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt,pd);
511 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int locId)
513 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string());
516 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(const MEDFileFieldPerMeshPerTypePerDisc& other)
518 return new MEDFileFieldPerMeshPerTypePerDisc(other);
521 std::size_t MEDFileFieldPerMeshPerTypePerDisc::getHeapMemorySizeWithoutChildren() const
523 return _profile.capacity()+_localization.capacity()+sizeof(MEDFileFieldPerMeshPerTypePerDisc);
526 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypePerDisc::getDirectChildrenWithNull() const
528 std::vector<const BigMemoryObject *> ret(1);
529 ret[0]=(const PartDefinition*)_pd;
533 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCopy(MEDFileFieldPerMeshPerTypeCommon *father) const
535 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret(new MEDFileFieldPerMeshPerTypePerDisc(*this));
540 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField atype, int profileIt, const PartDefinition *pd)
541 try:_type(atype),_father(fath),_profile_it(profileIt),_pd(const_cast<PartDefinition *>(pd))
546 catch(INTERP_KERNEL::Exception& e)
551 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
555 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)
559 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(0),_start(-std::numeric_limits<int>::max()),_end(-std::numeric_limits<int>::max()),
560 _nval(-std::numeric_limits<int>::max()),_loc_id(-std::numeric_limits<int>::max())
564 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)
566 const PartDefinition *pd(_pd);
569 INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
571 med_int nbValsInFile(MEDfieldnValueWithProfileByName(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile.c_str(),MED_COMPACT_PFLMODE,&tmp1,locname,&nbi));
572 if(_end-_start!=nbValsInFile*nbi)
574 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 !";
575 throw INTERP_KERNEL::Exception(oss.str());
577 MEDFILESAFECALLERRD0(MEDfieldValueWithProfileRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,_profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,startFeedingPtr));
581 if(!_profile.empty())
582 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : not implemented !");
583 INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)),locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
585 int overallNval(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
586 const SlicePartDefinition *spd(dynamic_cast<const SlicePartDefinition *>(pd));
590 spd->getSlice(start,stop,step);
591 int nbOfEltsToLoad(DataArray::GetNumberOfItemGivenBES(start,stop,step,"MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile"));
592 med_filter filter=MED_FILTER_INIT;
593 MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
594 MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
595 /*start*/start+1,/*stride*/step,/*count*/1,/*blocksize*/nbOfEltsToLoad,
596 /*lastblocksize=useless because count=1*/0,&filter);
597 MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,startFeedingPtr));
598 MEDfilterClose(&filter);
601 const DataArrayPartDefinition *dpd(dynamic_cast<const DataArrayPartDefinition *>(pd));
604 dpd->checkConsistencyLight();
605 MCAuto<DataArrayInt> myIds(dpd->toDAI());
606 int a(myIds->getMinValueInArray()),b(myIds->getMaxValueInArray());
607 myIds=myIds->deepCopy();// WARNING deep copy here because _pd is modified by applyLin !!!
608 myIds->applyLin(1,-a);
609 int nbOfEltsToLoad(b-a+1);
610 med_filter filter=MED_FILTER_INIT;
611 {//TODO : manage int32 !
612 MCAuto<DataArrayDouble> tmp(DataArrayDouble::New());
613 tmp->alloc(nbOfEltsToLoad,nbOfCompo);
614 MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
615 MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
616 /*start*/a+1,/*stride*/1,/*count*/1,/*blocksize*/nbOfEltsToLoad,
617 /*lastblocksize=useless because count=1*/0,&filter);
618 MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,reinterpret_cast<unsigned char *>(tmp->getPointer())));
619 MCAuto<DataArrayDouble> feeder(DataArrayDouble::New());
620 feeder->useExternalArrayWithRWAccess(reinterpret_cast<double *>(startFeedingPtr),_nval,nbOfCompo);
621 feeder->setContigPartOfSelectedValues(0,tmp,myIds);
623 MEDfilterClose(&filter);
626 throw INTERP_KERNEL::Exception("Not implemented yet for not slices!");
630 const MEDFileFieldPerMeshPerTypeCommon *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
635 void MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
637 INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
638 INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
639 std::string fieldName(nasc.getName()),meshName(getMeshName());
640 int iteration(getIteration()),order(getOrder()),profilesize,nbi;
641 TypeOfField type(getType());
642 med_geometry_type mgeoti;
643 med_entity_type menti;
644 _father->entriesForMEDfile(type,mgeoti,menti);
645 int zeNVal(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
646 _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
647 _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
648 const PartDefinition *pd(_pd);
655 if(!_profile.empty())
656 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively : profiles are not managed yet with part of def !");
657 _nval=pd->getNumberOfElems();
660 _end=start+_nval*nbi;
662 if(type==ON_CELLS && !_localization.empty())
664 if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
665 setType(ON_GAUSS_PT);
668 setType(ON_GAUSS_NE);
669 _localization.clear();
674 void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, const MEDFileFieldNameScope& nasc)
676 std::string fieldName(nasc.getName()),meshName(getMeshName());
677 int iteration(getIteration()),order(getOrder());
678 TypeOfField type(getType());
679 med_geometry_type mgeoti;
680 med_entity_type menti;
681 _father->entriesForMEDfile(type,mgeoti,menti);
683 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !");
686 DataArray *arr(getOrCreateAndGetArray());//arr is not null due to the spec of getOrCreateAndGetArray
687 if(_start<0 || _start>=arr->getNumberOfTuples())
689 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << ") !";
690 throw INTERP_KERNEL::Exception(oss.str());
692 if(_end<0 || _end>arr->getNumberOfTuples())
694 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !";
695 throw INTERP_KERNEL::Exception(oss.str());
697 int nbOfCompo(arr->getNumberOfComponents());
698 DataArrayDouble *arrD(dynamic_cast<DataArrayDouble *>(arr));
701 double *startFeeding(arrD->getPointer()+_start*nbOfCompo);
702 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
705 DataArrayInt *arrI(dynamic_cast<DataArrayInt *>(arr));
708 int *startFeeding(arrI->getPointer()+_start*nbOfCompo);
709 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
712 throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
716 * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
718 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart)
720 int delta=_end-_start;
721 _start=newValueOfStart;
725 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
727 return _father->getIteration();
730 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
732 return _father->getOrder();
735 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
737 return _father->getTime();
740 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
742 return _father->getMeshName();
745 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
747 const char startLine[]=" ## ";
748 std::string startLine2(bkOffset,' ');
749 startLine2+=startLine;
750 INTERP_KERNEL::AutoCppPtr<MEDCouplingFieldDiscretization> tmp(MEDCouplingFieldDiscretization::New(_type));
751 oss << startLine2 << "Localization #" << id << "." << std::endl;
752 oss << startLine2 << " Type=" << tmp->getRepr() << "." << std::endl;
753 oss << startLine2 << " This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
754 oss << startLine2 << " This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
755 oss << startLine2 << " This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
758 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
763 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
765 return _father->getGeoType();
768 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
773 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
778 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
780 return _father->getNumberOfComponents();
783 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
788 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray()
790 return _father->getOrCreateAndGetArray();
793 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const
795 const MEDFileFieldPerMeshPerTypeCommon *fath=_father;
796 return fath->getOrCreateAndGetArray();
799 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
801 return _father->getInfo();
804 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
809 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const std::string& newPflName)
814 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
816 return _localization;
819 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const std::string& newLocName)
821 _localization=newLocName;
824 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
826 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
828 if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
830 _profile=(*it2).second;
836 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
838 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
840 if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
842 _localization=(*it2).second;
848 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
852 dads.push_back(std::pair<int,int>(_start,_end));
853 geoTypes.push_back(getGeoType());
858 pfls.push_back(glob->getProfile(_profile.c_str()));
860 if(_localization.empty())
864 locs.push_back(glob->getLocalizationId(_localization.c_str()));
868 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
870 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));
874 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
876 TypeOfField type=getType();
877 INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
878 med_geometry_type mgeoti;
879 med_entity_type menti;
880 _father->entriesForMEDfile(getType(),mgeoti,menti);
881 const DataArray *arr(getOrCreateAndGetArray());
883 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
884 if(!arr->isAllocated())
885 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : the array to be written is not allocated !");
886 const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
887 const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
888 const unsigned char *locToWrite=0;
890 locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
892 locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
894 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
895 MEDFILESAFECALLERWR0(MEDfieldValueWithProfileWr,(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
896 MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
900 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const
905 dad.first=_start; dad.second=_end;
909 * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
910 * This code corresponds to the distribution of types in the corresponding mesh.
911 * \param [out] ptToFill memory zone where the output will be stored.
912 * \return the size of data pushed into output param \a ptToFill
914 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const
917 std::ostringstream oss;
918 std::size_t nbOfType=codeOfMesh.size()/3;
920 for(std::size_t i=0;i<nbOfType && found==-1;i++)
921 if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
925 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
926 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
927 throw INTERP_KERNEL::Exception(oss.str());
932 if(_nval!=codeOfMesh[3*found+1])
934 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
935 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
936 oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
937 throw INTERP_KERNEL::Exception(oss.str());
939 for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
944 const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
945 if(pfl->getNumberOfTuples()!=_nval)
947 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
948 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
950 oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
951 throw INTERP_KERNEL::Exception(oss.str());
953 int offset2=codeOfMesh[3*found+2];
954 for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
956 if(*pflId<codeOfMesh[3*found+1])
957 *work++=offset2+*pflId;
963 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const
965 for(int i=_start;i<_end;i++)
970 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId)
981 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
985 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
988 std::map<std::pair<std::string,TypeOfField>,int> m;
989 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
990 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
991 if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
992 m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
994 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
995 ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
1000 * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
1002 * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
1003 * \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.
1004 * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
1005 * \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)
1006 * \param [in,out] glob if necessary by the method, new profiles can be added to it
1007 * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
1008 * \param [out] result All new entries will be appended on it.
1009 * \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 !)
1011 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
1012 const DataArrayInt *explicitIdsInMesh,
1013 const std::vector<int>& newCode,
1014 MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
1015 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >& result)
1017 if(entriesOnSameDisc.empty())
1019 TypeOfField type=entriesOnSameDisc[0]->getType();
1020 int szEntities=0,szTuples=0;
1021 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
1022 { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
1023 int nbi=szTuples/szEntities;
1024 if(szTuples%szEntities!=0)
1025 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
1026 MCAuto<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
1027 MCAuto<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
1028 std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
1029 std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
1030 std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
1031 std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
1032 MCAuto<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
1034 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
1036 int startOfEltIdOfChunk=(*it)->_start;
1037 MCAuto<DataArrayInt> newEltIds=explicitIdsInMesh->subArray(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
1038 MCAuto<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
1039 MCAuto<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
1041 MCAuto<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
1042 newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
1044 newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
1045 newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
1047 MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
1048 MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
1049 MCAuto<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
1050 MCAuto<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
1052 MCAuto<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
1054 MCAuto<DataArrayDouble> arrPart=arr->subArray(offset,offset+szTuples);
1055 arrPart->renumberInPlace(renumTupleIds->begin());
1056 arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
1058 const int *idIt=diffVals->begin();
1059 std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
1061 for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
1063 MCAuto<DataArrayInt> ids=newGeoTypesEltIdsAllGather->findIdsEqual(*idIt);
1064 MCAuto<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
1065 int nbEntityElts=subIds->getNumberOfTuples();
1067 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
1068 NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIota(newCode[3*(*idIt)+1]),nbi,
1072 result.push_back(eltToAdd);
1073 offset2+=nbEntityElts*nbi;
1075 ret=ret || li.empty();
1080 * \param [in] typeF type of field of new chunk
1081 * \param [in] geoType the geometric type of the chunk
1082 * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
1083 * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
1084 * \param [in] nbi number of integration points
1085 * \param [in] offset The offset in the **global array of data**.
1086 * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
1087 * to the new chunk to create.
1088 * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
1089 * \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
1090 * and corresponding entry erased from \a entriesOnSameDisc.
1091 * \return a newly allocated chunk
1093 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
1094 bool isPfl, int nbi, int offset,
1095 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
1096 MEDFileFieldGlobsReal& glob,
1097 bool ¬InExisting)
1099 int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
1100 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
1101 for(;it!=entriesOnSameDisc.end();it++)
1103 if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
1107 if((*it)->_profile.empty())
1110 if(!(*it)->_profile.empty())
1112 const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
1113 if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
1119 if(it==entriesOnSameDisc.end())
1122 MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
1124 ret->_loc_id=(int)geoType;
1125 ret->_nval=nbMeshEntities;
1127 ret->_end=ret->_start+ret->_nval*nbi;
1130 idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
1131 glob.appendProfile(idsOfMeshElt);
1132 ret->_profile=idsOfMeshElt->getName();
1134 //tony treatment of localization
1139 notInExisting=false;
1140 MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1141 ret->_loc_id=(int)geoType;
1142 ret->setNewStart(offset);
1143 entriesOnSameDisc.erase(it);
1149 ////////////////////////////////////
1151 MEDFileFieldPerMeshPerTypeCommon::~MEDFileFieldPerMeshPerTypeCommon()
1155 void MEDFileFieldPerMeshPerTypeCommon::setFather(MEDFileFieldPerMesh *father)
1160 void MEDFileFieldPerMeshPerTypeCommon::accept(MEDFileFieldVisitor& visitor) const
1162 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1163 if((*it).isNotNull())
1165 visitor.newPerMeshPerTypePerDisc(*it);
1169 void MEDFileFieldPerMeshPerTypeCommon::deepCopyElements()
1172 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1174 if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
1175 _field_pm_pt_pd[i]=(*it)->deepCopy(this);
1179 std::size_t MEDFileFieldPerMeshPerTypeCommon::getHeapMemorySizeWithoutChildren() const
1181 return _field_pm_pt_pd.capacity()*sizeof(MCAuto<MEDFileFieldPerMeshPerTypePerDisc>);
1184 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypeCommon::getDirectChildrenWithNull() const
1186 std::vector<const BigMemoryObject *> ret;
1187 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1188 ret.push_back((const MEDFileFieldPerMeshPerTypePerDisc *)*it);
1192 void MEDFileFieldPerMeshPerTypeCommon::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1194 std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
1195 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1196 _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1200 * This method is the most general one. No optimization is done here.
1201 * \param [in] multiTypePfl is the end user profile specified in high level API
1202 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1203 * \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.
1204 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1205 * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1206 * \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.
1208 void MEDFileFieldPerMeshPerTypeCommon::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1210 std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1211 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1212 _field_pm_pt_pd[*it]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1215 void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1217 _field_pm_pt_pd.resize(1);
1218 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1219 _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1222 void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1224 MCAuto<DataArrayInt> pfl2=pfl->deepCopy();
1225 if(!arr || !arr->isAllocated())
1226 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile : input array is null, or not allocated !");
1227 _field_pm_pt_pd.resize(1);
1228 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1229 _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.
1232 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1234 TypeOfField type=field->getTypeOfField();
1235 if(type!=ON_GAUSS_PT)
1237 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1238 int sz=_field_pm_pt_pd.size();
1240 for(int j=0;j<sz && !found;j++)
1242 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1244 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1250 _field_pm_pt_pd.resize(sz+1);
1251 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1253 std::vector<int> ret(1,(int)sz);
1258 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1259 int sz2=ret2.size();
1260 std::vector<int> ret3(sz2);
1262 for(int i=0;i<sz2;i++)
1264 int sz=_field_pm_pt_pd.size();
1265 int locIdToFind=ret2[i];
1267 for(int j=0;j<sz && !found;j++)
1269 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1271 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1278 _field_pm_pt_pd.resize(sz+1);
1279 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1287 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1289 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1290 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1292 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1293 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1295 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1296 MCAuto<DataArrayInt> da2=da->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1);
1297 MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1298 if(retTmp->presenceOfValue(-1))
1299 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1300 std::vector<int> ret(retTmp->begin(),retTmp->end());
1304 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1306 TypeOfField type=field->getTypeOfField();
1307 if(type!=ON_GAUSS_PT)
1309 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1310 int sz=_field_pm_pt_pd.size();
1312 for(int j=0;j<sz && !found;j++)
1314 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1316 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1322 _field_pm_pt_pd.resize(sz+1);
1323 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1325 std::vector<int> ret(1,0);
1330 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1331 int sz2=ret2.size();
1332 std::vector<int> ret3(sz2);
1334 for(int i=0;i<sz2;i++)
1336 int sz=_field_pm_pt_pd.size();
1337 int locIdToFind=ret2[i];
1339 for(int j=0;j<sz && !found;j++)
1341 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1343 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1350 _field_pm_pt_pd.resize(sz+1);
1351 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1359 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1361 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1362 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1364 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1365 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1367 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1368 MCAuto<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1369 MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1370 if(retTmp->presenceOfValue(-1))
1371 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1372 std::vector<int> ret(retTmp->begin(),retTmp->end());
1376 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerTypeCommon::getFather() const
1381 bool MEDFileFieldPerMeshPerTypeCommon::isUniqueLevel(int& dim) const
1383 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
1384 int curDim((int)cm.getDimension());
1385 if(dim!=std::numeric_limits<int>::max())
1395 void MEDFileFieldPerMeshPerTypeCommon::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1397 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1399 (*it)->fillTypesOfFieldAvailable(types);
1403 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
1405 int sz=_field_pm_pt_pd.size();
1406 dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1407 for(int i=0;i<sz;i++)
1409 _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1413 int MEDFileFieldPerMeshPerTypeCommon::getIteration() const
1415 return _father->getIteration();
1418 int MEDFileFieldPerMeshPerTypeCommon::getOrder() const
1420 return _father->getOrder();
1423 double MEDFileFieldPerMeshPerTypeCommon::getTime() const
1425 return _father->getTime();
1428 std::string MEDFileFieldPerMeshPerTypeCommon::getMeshName() const
1430 return _father->getMeshName();
1433 void MEDFileFieldPerMeshPerTypeCommon::getSizes(int& globalSz, int& nbOfEntries) const
1435 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1437 globalSz+=(*it)->getNumberOfTuples();
1439 nbOfEntries+=(int)_field_pm_pt_pd.size();
1442 int MEDFileFieldPerMeshPerTypeCommon::getNumberOfComponents() const
1444 return _father->getNumberOfComponents();
1447 bool MEDFileFieldPerMeshPerTypeCommon::presenceOfMultiDiscPerGeoType() const
1450 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1452 const MEDFileFieldPerMeshPerTypePerDisc *fmtd(*it);
1459 void MEDFileFieldPerMeshPerTypeCommon::pushDiscretization(MEDFileFieldPerMeshPerTypePerDisc *disc)
1461 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt;
1463 _field_pm_pt_pd.push_back(elt);
1466 DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray()
1468 return _father->getOrCreateAndGetArray();
1471 const DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray() const
1473 const MEDFileFieldPerMesh *fath=_father;
1474 return fath->getOrCreateAndGetArray();
1477 const std::vector<std::string>& MEDFileFieldPerMeshPerTypeCommon::getInfo() const
1479 return _father->getInfo();
1482 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsed() const
1484 std::vector<std::string> ret;
1485 std::set<std::string> ret2;
1486 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1488 std::string tmp=(*it1)->getProfile();
1490 if(ret2.find(tmp)==ret2.end())
1499 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsed() const
1501 std::vector<std::string> ret;
1502 std::set<std::string> ret2;
1503 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1505 std::string tmp=(*it1)->getLocalization();
1506 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1507 if(ret2.find(tmp)==ret2.end())
1516 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsedMulti() const
1518 std::vector<std::string> ret;
1519 std::set<std::string> ret2;
1520 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1522 std::string tmp=(*it1)->getProfile();
1529 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsedMulti() const
1531 std::vector<std::string> ret;
1532 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1534 std::string tmp=(*it1)->getLocalization();
1535 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1541 void MEDFileFieldPerMeshPerTypeCommon::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1543 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1544 (*it1)->changePflsRefsNamesGen(mapOfModif);
1547 void MEDFileFieldPerMeshPerTypeCommon::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1549 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1550 (*it1)->changeLocsRefsNamesGen(mapOfModif);
1553 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId)
1555 if(_field_pm_pt_pd.empty())
1557 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << getGeoTypeRepr() << "\" !";
1558 throw INTERP_KERNEL::Exception(oss.str());
1560 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1561 return _field_pm_pt_pd[locId];
1562 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
1563 oss2 << ") for geometric type \"" << getGeoTypeRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1564 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1565 return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1568 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId) const
1570 if(_field_pm_pt_pd.empty())
1572 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << getGeoTypeRepr() << "\" !";
1573 throw INTERP_KERNEL::Exception(oss.str());
1575 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1576 return _field_pm_pt_pd[locId];
1577 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
1578 oss2 << ") for geometric type \"" << getGeoTypeRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1579 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1580 return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1583 void MEDFileFieldPerMeshPerTypeCommon::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1586 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1588 (*it)->fillValues(i,startEntryId,entries);
1592 void MEDFileFieldPerMeshPerTypeCommon::setLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
1594 _field_pm_pt_pd=leaves;
1595 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1596 (*it)->setFather(this);
1600 * \param [in,out] globalNum a global numbering counter for the renumbering.
1601 * \param [out] its - list of pair (start,stop) kept
1602 * \return bool - false if the type of field \a tof is not contained in \a this.
1604 bool MEDFileFieldPerMeshPerTypeCommon::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
1607 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1608 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1609 if((*it)->getType()==tof)
1611 newPmPtPd.push_back(*it);
1612 std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1613 (*it)->setNewStart(globalNum);
1614 globalNum=(*it)->getEnd();
1615 its.push_back(bgEnd);
1619 _field_pm_pt_pd=newPmPtPd;
1624 * \param [in,out] globalNum a global numbering counter for the renumbering.
1625 * \param [out] its - list of pair (start,stop) kept
1626 * \return bool - false if the type of field \a tof is not contained in \a this.
1628 bool MEDFileFieldPerMeshPerTypeCommon::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
1630 if(_field_pm_pt_pd.size()<=idOfDisc)
1632 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt(_field_pm_pt_pd[idOfDisc]);
1633 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd(1,elt);
1634 std::pair<int,int> bgEnd; bgEnd.first=_field_pm_pt_pd[idOfDisc]->getStart(); bgEnd.second=_field_pm_pt_pd[idOfDisc]->getEnd();
1635 elt->setNewStart(globalNum);
1636 globalNum=elt->getEnd();
1637 its.push_back(bgEnd);
1638 _field_pm_pt_pd=newPmPtPd;
1642 void MEDFileFieldPerMeshPerTypeCommon::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
1644 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1645 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1648 void MEDFileFieldPerMeshPerTypeCommon::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1650 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1651 (*it)->loadBigArray(fid,nasc);
1654 void MEDFileFieldPerMeshPerTypeCommon::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1656 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1658 (*it)->copyOptionsFrom(*this);
1659 (*it)->writeLL(fid,nasc);
1663 med_entity_type MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1668 medfGeoType=typmai3[(int)ikGeoType];
1671 medfGeoType=MED_NONE;
1674 medfGeoType=typmai3[(int)ikGeoType];
1675 return MED_NODE_ELEMENT;
1677 medfGeoType=typmai3[(int)ikGeoType];
1680 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1682 return MED_UNDEF_ENTITY_TYPE;
1685 //////////////////////////////////////////////////
1687 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd)
1689 return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc,pd);
1692 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType)
1694 return new MEDFileFieldPerMeshPerType(fath,geoType);
1697 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCopy(MEDFileFieldPerMesh *father) const
1699 MCAuto<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
1700 ret->setFather(father);
1701 ret->deepCopyElements();
1705 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
1707 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1709 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1710 if(meshDim!=(int)cm.getDimension())
1713 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1714 (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1717 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1722 void MEDFileFieldPerMeshPerType::entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const
1724 ent=MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(mct,_geo_type,gt);
1727 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1729 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1730 int curDim((int)cm.getDimension());
1731 dim=std::max(dim,curDim);
1734 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1736 const char startLine[]=" ## ";
1737 std::string startLine2(bkOffset,' ');
1738 std::string startLine3(startLine2);
1739 startLine3+=startLine;
1740 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1742 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1743 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1746 oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1747 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1749 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1751 const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1753 cur->simpleRepr(bkOffset,oss,i);
1756 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1761 std::string MEDFileFieldPerMeshPerType::getGeoTypeRepr() const
1763 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1764 return std::string(cm.getRepr());
1767 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *father, INTERP_KERNEL::NormalizedCellType gt):MEDFileFieldPerMeshPerTypeCommon(father),_geo_type(gt)
1771 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):MEDFileFieldPerMeshPerTypeCommon(fath),_geo_type(geoType)
1773 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1774 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1775 med_geometry_type mgeoti;
1776 med_entity_type menti(ConvertIntoMEDFileType(type,geoType,mgeoti));
1777 int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName));
1778 _field_pm_pt_pd.resize(nbProfiles);
1779 for(int i=0;i<nbProfiles;i++)
1781 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i,pd);
1785 int nbProfiles2(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName));
1786 for(int i=0;i<nbProfiles2;i++)
1787 _field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i,pd));
1791 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)
1793 MCAuto<MEDFileFieldPerMeshPerType> ret(MEDFileFieldPerMeshPerType::New(father,gt));
1794 std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > > m;
1795 for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerType *> >::const_iterator it=pms.begin();it!=pms.end();it++)
1797 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it2=(*it).second->_field_pm_pt_pd.begin();it2!=(*it).second->_field_pm_pt_pd.end();it2++)
1798 m[(*it2)->getType()].push_back(std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * >((*it).first,*it2));
1800 for(std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > >::const_iterator it=m.begin();it!=m.end();it++)
1802 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> agg(MEDFileFieldPerMeshPerTypePerDisc::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
1803 ret->_field_pm_pt_pd.push_back(agg);
1808 //////////////////////////////////////////////////
1810 MEDFileFieldPerMeshPerTypeDyn *MEDFileFieldPerMeshPerTypeDyn::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileEntities *entities, int idGT, const MEDFileFieldNameScope& nasc)
1813 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeDyn::NewOnRead : null pointer !");
1814 const MEDFileAllStaticEntitiesPlusDyn *entities2(dynamic_cast<const MEDFileAllStaticEntitiesPlusDyn *>(entities));
1816 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeDyn::NewOnRead : invalid type of entities !");
1817 const MEDFileStructureElement *se(entities2->getWithGT(idGT));
1818 return new MEDFileFieldPerMeshPerTypeDyn(fid,fath,se,nasc);
1821 MEDFileFieldPerMeshPerTypeDyn::MEDFileFieldPerMeshPerTypeDyn(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileStructureElement *se, const MEDFileFieldNameScope& nasc):MEDFileFieldPerMeshPerTypeCommon(fath)
1824 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1825 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1826 int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,_se->getDynGT(),pflName,locName));
1827 _field_pm_pt_pd.resize(nbProfiles);
1828 for(int i=0;i<nbProfiles;i++)
1830 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,_se->getEntity(),i,NULL);
1834 int MEDFileFieldPerMeshPerTypeDyn::getDynGT() const
1836 return _se->getDynGT();
1839 std::string MEDFileFieldPerMeshPerTypeDyn::getModelName() const
1841 return _se->getName();
1844 void MEDFileFieldPerMeshPerTypeDyn::getDimension(int& dim) const
1846 throw INTERP_KERNEL::Exception("not implemented yet !");
1849 void MEDFileFieldPerMeshPerTypeDyn::entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const
1852 ent=MED_STRUCT_ELEMENT;
1855 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypeDyn::getGeoType() const
1857 throw INTERP_KERNEL::Exception("not implemented yet !");
1860 void MEDFileFieldPerMeshPerTypeDyn::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1862 const char startLine[]=" ## ";
1863 std::string startLine2(bkOffset,' ');
1864 std::string startLine3(startLine2);
1865 startLine3+=startLine;
1866 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry STRUCTURE_ELEMENT type " << getDynGT() << "." << std::endl;
1867 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1869 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1871 if((*it).isNotNull())
1872 (*it)->simpleRepr(bkOffset,oss,i);
1875 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1880 std::string MEDFileFieldPerMeshPerTypeDyn::getGeoTypeRepr() const
1882 throw INTERP_KERNEL::Exception("not implemented yet !");
1885 MEDFileFieldPerMeshPerTypeDyn *MEDFileFieldPerMeshPerTypeDyn::deepCopy(MEDFileFieldPerMesh *father) const
1887 MCAuto<MEDFileFieldPerMeshPerTypeDyn> ret(new MEDFileFieldPerMeshPerTypeDyn(*this));
1888 ret->setFather(father);
1889 ret->deepCopyElements();
1893 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
1895 throw INTERP_KERNEL::Exception("not implemented yet !");
1898 //////////////////////////////////////////////////
1900 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const MEDFileEntities *entities)
1902 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm,entities);
1905 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1907 return new MEDFileFieldPerMesh(fath,mesh);
1910 std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
1912 return _mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MCAuto< MEDFileFieldPerMeshPerType >);
1915 std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildrenWithNull() const
1917 std::vector<const BigMemoryObject *> ret;
1918 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1923 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCopy(MEDFileAnyTypeField1TSWithoutSDA *father) const
1925 MCAuto< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1926 ret->_father=father;
1928 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1930 if((*it).isNotNull())
1931 ret->_field_pm_pt[i]=(*it)->deepCopy((MEDFileFieldPerMesh *)(ret));
1936 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1938 std::string startLine(bkOffset,' ');
1939 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1940 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1942 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1944 if((*it).isNotNull())
1945 (*it)->simpleRepr(bkOffset,oss,i);
1948 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1953 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh)
1955 _mesh_name=mesh->getName();
1956 mesh->getTime(_mesh_iteration,_mesh_order);
1959 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1961 int nbOfTypes=code.size()/3;
1963 for(int i=0;i<nbOfTypes;i++)
1965 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1966 int nbOfCells=code[3*i+1];
1967 int pos=addNewEntryIfNecessary(type);
1968 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1974 * This method is the most general one. No optimization is done here.
1975 * \param [in] multiTypePfl is the end user profile specified in high level API
1976 * \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].
1977 * \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.
1978 * \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.
1979 * \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.
1980 * \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.
1982 void MEDFileFieldPerMesh::assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const std::vector<int>& code, const std::vector<int>& code2, const std::vector<DataArrayInt *>& idsInPflPerType, const std::vector<DataArrayInt *>& idsPerType, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1984 int nbOfTypes(code.size()/3);
1985 for(int i=0;i<nbOfTypes;i++)
1987 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1988 int pos=addNewEntryIfNecessary(type);
1989 DataArrayInt *pfl=0;
1991 pfl=idsPerType[code[3*i+2]];
1992 int nbOfTupes2=code2.size()/3;
1994 for(;found<nbOfTupes2;found++)
1995 if(code[3*i]==code2[3*found])
1997 if(found==nbOfTupes2)
1998 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1999 _field_pm_pt[pos]->assignFieldProfile(nbOfTypes==1,start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
2003 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
2005 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
2006 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
2009 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
2011 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
2012 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
2015 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
2017 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2018 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
2021 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
2023 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2024 (*it)->loadBigArraysRecursively(fid,nasc);
2027 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
2029 int nbOfTypes=_field_pm_pt.size();
2030 for(int i=0;i<nbOfTypes;i++)
2032 _field_pm_pt[i]->copyOptionsFrom(*this);
2033 _field_pm_pt[i]->writeLL(fid,nasc);
2037 void MEDFileFieldPerMesh::getDimension(int& dim) const
2039 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2040 (*it)->getDimension(dim);
2043 bool MEDFileFieldPerMesh::isUniqueLevel(int& dim) const
2045 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2046 if(!(*it)->isUniqueLevel(dim))
2051 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
2053 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2054 (*it)->fillTypesOfFieldAvailable(types);
2057 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
2059 int sz=_field_pm_pt.size();
2060 std::vector< std::vector<std::pair<int,int> > > ret(sz);
2061 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
2062 for(int i=0;i<sz;i++)
2064 types[i]=_field_pm_pt[i]->getGeoType();
2065 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
2070 double MEDFileFieldPerMesh::getTime() const
2073 return _father->getTime(tmp1,tmp2);
2076 int MEDFileFieldPerMesh::getIteration() const
2078 return _father->getIteration();
2081 int MEDFileFieldPerMesh::getOrder() const
2083 return _father->getOrder();
2086 int MEDFileFieldPerMesh::getNumberOfComponents() const
2088 return _father->getNumberOfComponents();
2091 bool MEDFileFieldPerMesh::presenceOfMultiDiscPerGeoType() const
2093 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2097 if((*it)->presenceOfMultiDiscPerGeoType())
2103 bool MEDFileFieldPerMesh::presenceOfStructureElements() const
2105 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2106 if((*it).isNotNull())
2108 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2115 bool MEDFileFieldPerMesh::onlyStructureElements() const
2117 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2118 if((*it).isNotNull())
2120 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2127 void MEDFileFieldPerMesh::killStructureElements()
2129 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
2130 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2132 if((*it).isNotNull())
2134 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2142 void MEDFileFieldPerMesh::keepOnlyStructureElements()
2144 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
2145 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2147 if((*it).isNotNull())
2149 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2157 void MEDFileFieldPerMesh::keepOnlyOnSE(const std::string& seName)
2159 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
2160 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2162 if((*it).isNotNull())
2164 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2166 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::keepOnlyOnSE : presence of non SE !");
2167 if(pt->getModelName()==seName)
2174 void MEDFileFieldPerMesh::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
2176 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2178 if((*it).isNotNull())
2180 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2183 ps.push_back(std::pair<std::string,std::string>(getMeshName(),pt->getModelName()));
2186 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getMeshSENames : presence of a non structure element part !");
2191 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
2194 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
2195 return _father->getOrCreateAndGetArray();
2198 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
2201 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
2202 return _father->getOrCreateAndGetArray();
2205 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
2207 return _father->getInfo();
2211 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
2212 * 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.
2213 * It returns 2 output vectors :
2214 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
2215 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
2216 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
2218 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)
2220 int notNullPflsSz=0;
2221 int nbOfArrs=geoTypes.size();
2222 for(int i=0;i<nbOfArrs;i++)
2225 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
2226 int nbOfDiffGeoTypes=geoTypes3.size();
2227 code.resize(3*nbOfDiffGeoTypes);
2228 notNullPfls.resize(notNullPflsSz);
2231 for(int i=0;i<nbOfDiffGeoTypes;i++)
2234 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
2235 std::vector<const DataArrayInt *> notNullTmp;
2237 notNullTmp.push_back(pfls[j]);
2239 for(;j<nbOfArrs;j++)
2240 if(geoTypes[j]==refType)
2243 notNullTmp.push_back(pfls[j]);
2247 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
2248 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
2249 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
2250 code[3*i]=(int)refType;
2251 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
2252 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
2253 if(notNullTmp.empty())
2257 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
2258 code[3*i+2]=notNullPflsSz++;
2264 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
2266 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)
2270 for(int i=0;i<sz;i++)
2274 if(type!=ON_GAUSS_NE)
2275 ret+=dads[i].second-dads[i].first;
2278 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
2279 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
2284 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
2285 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
2291 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
2293 std::vector<std::string> ret;
2294 std::set<std::string> ret2;
2295 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2297 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
2298 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
2299 if(ret2.find(*it2)==ret2.end())
2301 ret.push_back(*it2);
2308 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
2310 std::vector<std::string> ret;
2311 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2313 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
2314 ret.insert(ret.end(),tmp.begin(),tmp.end());
2319 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
2321 std::vector<std::string> ret;
2322 std::set<std::string> ret2;
2323 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2325 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
2326 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
2327 if(ret2.find(*it2)==ret2.end())
2329 ret.push_back(*it2);
2336 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
2338 std::vector<std::string> ret;
2339 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2341 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
2342 ret.insert(ret.end(),tmp.begin(),tmp.end());
2347 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
2349 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
2351 if((*it).first==_mesh_name)
2353 _mesh_name=(*it).second;
2360 void MEDFileFieldPerMesh::convertMedBallIntoClassic()
2362 if(_field_pm_pt.size()!=1)
2363 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : Only managed for single mesh !");
2364 if(_field_pm_pt[0].isNull())
2365 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : null pointer !");
2366 MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<MEDFileFieldPerMeshPerTypeDyn *>((MEDFileFieldPerMeshPerTypeCommon *)_field_pm_pt[0]));
2368 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : this is expected to be marked as structure element !");
2369 if(pt->getNumberOfLoc()!=1)
2370 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : only one loc managed !");
2371 const MEDFileFieldPerMeshPerTypePerDisc *disc(pt->getLeafGivenLocId(0));
2373 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : internal error !");
2374 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> disc2(MEDFileFieldPerMeshPerTypePerDisc::New(*disc));
2375 disc2->setType(ON_NODES);
2376 MCAuto<MEDFileFieldPerMeshPerType> pt2(MEDFileFieldPerMeshPerType::New(this,INTERP_KERNEL::NORM_ERROR));
2377 disc2->setFather(pt2);
2378 pt2->setFather(this);
2379 pt2->pushDiscretization(disc2);
2380 _field_pm_pt[0]=DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(pt2);
2383 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
2384 MEDFileFieldGlobsReal& glob)
2386 if(_mesh_name!=meshName)
2388 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
2389 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
2390 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
2391 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
2392 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
2393 getUndergroundDataArrayExt(entries);
2394 DataArray *arr0(getOrCreateAndGetArray());//tony
2396 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
2397 DataArrayDouble *arr(dynamic_cast<DataArrayDouble *>(arr0));//tony
2399 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
2402 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
2403 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
2405 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
2407 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2408 sz+=(*it).second.second-(*it).second.first;
2411 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2413 MCAuto<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
2414 ////////////////////
2415 MCAuto<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
2416 int *workI2=explicitIdsOldInMesh->getPointer();
2417 int sz1=0,sz2=0,sid=1;
2418 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
2419 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
2420 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
2422 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
2423 MCAuto<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
2424 int *workI=explicitIdsOldInArr->getPointer();
2425 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
2427 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
2428 (*itL2)->setLocId(sz2);
2429 (*itL2)->_tmp_work1=(*itL2)->getStart();
2430 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
2432 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
2434 explicitIdsOldInMesh->reAlloc(sz2);
2435 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
2436 ////////////////////
2437 MCAuto<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
2438 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
2439 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
2440 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
2442 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
2443 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
2444 otherEntriesNew.back()->setLocId((*it)->getGeoType());
2446 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
2447 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
2448 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
2450 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
2451 int newStart=elt->getLocId();
2452 elt->setLocId((*it)->getGeoType());
2453 elt->setNewStart(newStart);
2454 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
2455 entriesKeptNew.push_back(elt);
2456 entriesKeptNew2.push_back(elt);
2458 MCAuto<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
2459 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
2460 MCAuto<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
2461 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
2463 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
2466 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
2468 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
2469 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
2471 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
2472 glob,arr2,otherEntriesNew) || ret;
2476 // Assign new dispatching
2477 assignNewLeaves(otherEntriesNew);
2478 arr->deepCopyFrom(*arr2);
2483 * \param [in,out] globalNum a global numbering counter for the renumbering.
2484 * \param [out] its - list of pair (start,stop) kept
2486 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
2488 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > ret;
2489 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2491 std::vector< std::pair<int,int> > its2;
2492 if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
2495 its.insert(its.end(),its2.begin(),its2.end());
2502 * \param [in,out] globalNum a global numbering counter for the renumbering.
2503 * \param [out] its - list of pair (start,stop) kept
2505 void MEDFileFieldPerMesh::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
2507 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > ret;
2508 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2510 std::vector< std::pair<int,int> > its2;
2511 if((*it)->keepOnlyGaussDiscretization(idOfDisc,globalNum,its2))
2514 its.insert(its.end(),its2.begin(),its2.end());
2520 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
2522 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > > types;
2523 for( std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
2524 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
2526 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > fieldPmPt(types.size());
2527 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
2528 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it2=fieldPmPt.begin();
2529 for(;it1!=types.end();it1++,it2++)
2531 MCAuto<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
2532 elt->setLeaves((*it1).second);
2533 MCAuto<MEDFileFieldPerMeshPerTypeCommon> elt2(DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(elt));
2536 _field_pm_pt=fieldPmPt;
2539 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2541 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2542 (*it)->changePflsRefsNamesGen(mapOfModif);
2545 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2547 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2548 (*it)->changeLocsRefsNamesGen(mapOfModif);
2552 * \param [in] mesh is the whole mesh
2554 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2556 if(_field_pm_pt.empty())
2557 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2559 std::vector< std::pair<int,int> > dads;
2560 std::vector<const DataArrayInt *> pfls;
2561 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2562 std::vector<int> locs,code;
2563 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2564 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2565 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2567 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2570 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2571 throw INTERP_KERNEL::Exception(oss.str());
2574 std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2575 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2578 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2580 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2583 MCAuto<DataArrayInt> arr2(arr);
2584 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2590 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2594 if(nb!=mesh->getNumberOfNodes())
2596 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2597 oss << " nodes in mesh !";
2598 throw INTERP_KERNEL::Exception(oss.str());
2600 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2603 return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2607 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
2609 if(_field_pm_pt.empty())
2610 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2612 std::vector<std::pair<int,int> > dads;
2613 std::vector<const DataArrayInt *> pfls;
2614 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2615 std::vector<int> locs,code;
2616 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2617 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2618 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2620 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2623 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2624 throw INTERP_KERNEL::Exception(oss.str());
2626 std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2627 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2630 MCAuto<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2631 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2636 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2640 if(nb!=mesh->getNumberOfNodes())
2642 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2643 oss << " nodes in mesh !";
2644 throw INTERP_KERNEL::Exception(oss.str());
2647 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2653 void MEDFileFieldPerMesh::accept(MEDFileFieldVisitor& visitor) const
2655 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2656 if((*it).isNotNull())
2658 visitor.newPerMeshPerTypeEntry(*it);
2659 (*it)->accept(visitor);
2660 visitor.endPerMeshPerTypeEntry(*it);
2664 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
2668 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2670 (*it)->getSizes(globalSz,nbOfEntries);
2672 entries.resize(nbOfEntries);
2674 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2676 (*it)->fillValues(nbOfEntries,entries);
2680 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
2682 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2684 if((*it)->getGeoType()==typ)
2685 return (*it)->getLeafGivenLocId(locId);
2687 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2688 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2689 oss << "Possiblities are : ";
2690 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2692 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2693 oss << "\"" << cm2.getRepr() << "\", ";
2695 throw INTERP_KERNEL::Exception(oss.str());
2698 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
2700 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2702 if((*it)->getGeoType()==typ)
2703 return (*it)->getLeafGivenLocId(locId);
2705 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2706 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2707 oss << "Possiblities are : ";
2708 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2710 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2711 oss << "\"" << cm2.getRepr() << "\", ";
2713 throw INTERP_KERNEL::Exception(oss.str());
2717 * \param [in,out] start - Integer that gives the current position in the final aggregated array
2718 * \param [in] pms - list of elements to aggregate. integer gives the mesh id
2719 * \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.
2720 * \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.
2722 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)
2724 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret(new MEDFileFieldPerMeshPerTypePerDisc(father,tof));
2726 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : empty input vector !");
2727 for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it=pms.begin();it!=pms.end();it++)
2730 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : presence of null pointer !");
2731 if(!(*it).second->getProfile().empty())
2732 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for profiles !");
2733 if(!(*it).second->getLocalization().empty())
2734 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for gauss pts !");
2736 INTERP_KERNEL::NormalizedCellType gt(pms[0].second->getGeoType());
2738 std::vector< std::pair<int,int> > filteredDTS;
2739 for(std::vector< std::vector< std::pair<int,int> > >::const_iterator it=dts.begin();it!=dts.end();it++,i++)
2740 for(std::vector< std::pair<int,int> >::const_iterator it2=(*it).begin();it2!=(*it).end();it2++)
2741 if((*it2).first==gt)
2742 filteredDTS.push_back(std::pair<int,int>(i,(*it2).second));
2743 if(pms.size()!=filteredDTS.size())
2744 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles !");
2745 std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it1(pms.begin());
2746 std::vector< std::pair<int,int> >::const_iterator it2(filteredDTS.begin());
2747 int zeStart(start),nval(0);
2748 for(;it1!=pms.end();it1++,it2++)
2750 if((*it1).first!=(*it2).first)
2751 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles 2 !");
2752 int s1((*it1).second->getStart()),e1((*it1).second->getEnd());
2753 extractInfo.push_back(std::pair<int, std::pair<int,int> >((*it1).first,std::pair<int,int>(s1,e1)));
2755 nval+=((*it1).second)->getNumberOfVals();
2757 ret->_start=zeStart; ret->_end=start; ret->_nval=nval;
2761 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)
2763 MCAuto<MEDFileFieldPerMesh> ret(new MEDFileFieldPerMesh(father,pms[0]->getMeshName(),pms[0]->getMeshIteration(),pms[0]->getMeshOrder()));
2764 std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > > m;
2766 for(std::vector<const MEDFileFieldPerMesh *>::const_iterator it=pms.begin();it!=pms.end();it++,i++)
2768 const std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >& v((*it)->_field_pm_pt);
2769 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it2=v.begin();it2!=v.end();it2++)
2771 INTERP_KERNEL::NormalizedCellType gt((*it2)->getGeoType());
2772 const MEDFileFieldPerMeshPerType *elt(dynamic_cast<const MEDFileFieldPerMeshPerType *>((const MEDFileFieldPerMeshPerTypeCommon *)(*it2)));
2774 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::Aggregate : not managed for structelement !");
2775 m[gt].push_back(std::pair<int,const MEDFileFieldPerMeshPerType *>(i,elt));
2778 for(std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > >::const_iterator it=m.begin();it!=m.end();it++)
2780 MCAuto<MEDFileFieldPerMeshPerType> agg(MEDFileFieldPerMeshPerType::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
2781 MCAuto<MEDFileFieldPerMeshPerTypeCommon> agg2(DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(agg));
2782 ret->_field_pm_pt.push_back(agg2);
2787 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2790 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2791 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it2=_field_pm_pt.begin();
2792 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2794 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2799 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2804 int ret=std::distance(_field_pm_pt.begin(),it2);
2805 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2810 * 'dads' and 'locs' input parameters have the same number of elements
2811 * \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
2813 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2814 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2815 const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2818 MCAuto<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2819 ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2820 MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2821 const std::vector<std::string>& infos=getInfo();
2822 da->setInfoOnComponents(infos);
2824 if(type==ON_GAUSS_PT)
2827 int nbOfArrs=dads.size();
2828 for(int i=0;i<nbOfArrs;i++)
2830 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2831 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2832 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2833 MCAuto<DataArrayInt> di=DataArrayInt::New();
2834 di->alloc(nbOfElems,1);
2836 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2837 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2846 * 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.
2847 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2848 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2849 * The order of cells in the returned field is those imposed by the profile.
2850 * \param [in] mesh is the global mesh.
2852 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2853 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2854 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2855 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2857 if(da->isIota(mesh->getNumberOfCells()))
2858 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2859 MCAuto<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2860 m2->setName(mesh->getName().c_str());
2861 MCAuto<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2867 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2869 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2870 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2871 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2873 if(da->isIota(mesh->getNumberOfNodes()))
2874 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2875 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2876 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2879 if(meshu->getNodalConnectivity()==0)
2881 MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2882 int nb=da->getNbOfElems();
2883 const int *ptr=da->getConstPointer();
2884 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2885 meshuc->allocateCells(nb);
2886 for(int i=0;i<nb;i++)
2887 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2888 meshuc->finishInsertingCells();
2889 ret->setMesh(meshuc);
2890 const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2891 if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2892 disc->checkCoherencyBetween(meshuc,arrOut);
2897 MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2899 DataArrayInt *arr2=0;
2900 MCAuto<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2901 MCAuto<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2902 MCAuto<DataArrayInt> arr3(arr2);
2903 int nnodes=mesh2->getNumberOfNodes();
2904 if(nnodes==(int)da->getNbOfElems())
2906 MCAuto<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2907 arrOut->renumberInPlace(da3->getConstPointer());
2908 mesh2->setName(mesh->getName().c_str());
2909 ret->setMesh(mesh2);
2914 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 !!!";
2915 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2916 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2917 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2918 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2919 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2920 throw INTERP_KERNEL::Exception(oss.str());
2926 * This method is the most light method of field retrieving.
2928 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
2932 pflOut=DataArrayInt::New();
2933 pflOut->alloc(nbOfElems,1);
2938 pflOut=const_cast<DataArrayInt*>(pflIn);
2941 MCAuto<DataArrayInt> safePfl(pflOut);
2942 MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2943 const std::vector<std::string>& infos=getInfo();
2944 int nbOfComp=infos.size();
2945 for(int i=0;i<nbOfComp;i++)
2946 da->setInfoOnComponent(i,infos[i].c_str());
2957 static MFFPMIter *NewCell(const MEDFileEntities *entities);
2958 static bool IsPresenceOfNode(const MEDFileEntities *entities);
2959 virtual ~MFFPMIter() { }
2960 virtual void begin() = 0;
2961 virtual bool finished() const = 0;
2962 virtual void next() = 0;
2963 virtual int current() const = 0;
2966 class MFFPMIterSimple : public MFFPMIter
2969 MFFPMIterSimple():_pos(0) { }
2970 void begin() { _pos=0; }
2971 bool finished() const { return _pos>=MED_N_CELL_FIXED_GEO; }
2972 void next() { _pos++; }
2973 int current() const { return _pos; }
2978 class MFFPMIter2 : public MFFPMIter
2981 MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts);
2982 void begin() { _it=_ids.begin(); }
2983 bool finished() const { return _it==_ids.end(); }
2984 void next() { _it++; }
2985 int current() const { return *_it; }
2987 std::vector<int> _ids;
2988 std::vector<int>::const_iterator _it;
2991 MFFPMIter *MFFPMIter::NewCell(const MEDFileEntities *entities)
2994 return new MFFPMIterSimple;
2997 const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
3000 std::vector<INTERP_KERNEL::NormalizedCellType> tmp;
3001 const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
3002 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
3004 if((*it).first==ON_CELLS || (*it).first==ON_GAUSS_NE || (*it).first==ON_GAUSS_PT)
3005 tmp.push_back((*it).second);
3007 return new MFFPMIter2(tmp);
3009 return new MFFPMIterSimple;// for MEDFileAllStaticEntites and MEDFileAllStaticEntitiesPlusDyn cells are in
3013 bool MFFPMIter::IsPresenceOfNode(const MEDFileEntities *entities)
3019 const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
3022 const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
3023 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
3024 if((*it).first==ON_NODES)
3028 return true;// for MEDFileAllStaticEntites and MEDFileAllStaticEntitiesPlusDyn nodes are in
3032 MFFPMIter2::MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts)
3034 std::size_t sz(cts.size());
3036 for(std::size_t i=0;i<sz;i++)
3038 INTERP_KERNEL::NormalizedCellType *loc(std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,cts[i]));
3039 if(loc!=typmai2+MED_N_CELL_FIXED_GEO)
3040 _ids[i]=(int)std::distance(typmai2,loc);
3042 throw INTERP_KERNEL::Exception("MFFPMIter2 : The specified geo type does not exists !");
3048 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),
3051 INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
3052 INTERP_KERNEL::AutoPtr<char> pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
3053 INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
3054 const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
3055 INTERP_KERNEL::AutoCppPtr<MFFPMIter> iter0(MFFPMIter::NewCell(entities));
3056 for(iter0->begin();!iter0->finished();iter0->next())
3058 int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL ,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
3059 std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
3060 int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
3061 std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
3062 if(nbProfile>0 || nbProfile2>0)
3064 const PartDefinition *pd(0);
3066 pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[iter0->current()]),typmai2[iter0->current()]);
3067 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nasc,pd));
3074 if(MFFPMIter::IsPresenceOfNode(entities))
3076 int nbProfile(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName));
3079 const PartDefinition *pd(0);
3081 pd=mmu->getPartDefAtLevel(1,INTERP_KERNEL::NORM_ERROR);
3082 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd));
3083 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
3088 std::vector<int> dynGT(entities->getDynGTAvail());
3089 for(std::vector<int>::const_iterator it=dynGT.begin();it!=dynGT.end();it++)
3091 int nbPfl(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,*it,pflName,locName));
3094 _field_pm_pt.push_back(MEDFileFieldPerMeshPerTypeDyn::NewOnRead(fid,this,entities,*it,nasc));
3095 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
3100 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
3102 copyTinyInfoFrom(mesh);
3105 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3107 if(id>=(int)_pfls.size())
3109 _pfls[id]=DataArrayInt::New();
3110 int lgth(MEDprofileSizeByName(fid,pflName.c_str()));
3111 _pfls[id]->setName(pflName);
3112 _pfls[id]->alloc(lgth,1);
3113 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName.c_str(),_pfls[id]->getPointer()));
3114 _pfls[id]->applyLin(1,-1,0);//Converting into C format
3117 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
3119 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
3121 MEDFILESAFECALLERRD0(MEDprofileInfo,(fid,i+1,pflName,&sz));
3122 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
3123 if(i>=(int)_pfls.size())
3125 _pfls[i]=DataArrayInt::New();
3126 _pfls[i]->alloc(sz,1);
3127 _pfls[i]->setName(pflCpp.c_str());
3128 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName,_pfls[i]->getPointer()));
3129 _pfls[i]->applyLin(1,-1,0);//Converting into C format
3132 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3134 int nbOfPfls=_pfls.size();
3135 for(int i=0;i<nbOfPfls;i++)
3137 MCAuto<DataArrayInt> cpy=_pfls[i]->deepCopy();
3138 cpy->applyLin(1,1,0);
3139 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
3140 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
3141 MEDFILESAFECALLERWR0(MEDprofileWr,(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer()));
3144 int nbOfLocs=_locs.size();
3145 for(int i=0;i<nbOfLocs;i++)
3146 _locs[i]->writeLL(fid);
3149 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
3151 std::vector<std::string> pfls=getPfls();
3152 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
3154 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
3157 _pfls.push_back(*it);
3161 int id=std::distance(pfls.begin(),it2);
3162 if(!(*it)->isEqual(*_pfls[id]))
3164 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
3165 throw INTERP_KERNEL::Exception(oss.str());
3169 std::vector<std::string> locs=getLocs();
3170 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
3172 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
3175 _locs.push_back(*it);
3179 int id=std::distance(locs.begin(),it2);
3180 if(!(*it)->isEqual(*_locs[id],eps))
3182 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
3183 throw INTERP_KERNEL::Exception(oss.str());
3189 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
3191 for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
3192 getProfile((*it).c_str());
3195 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
3197 for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
3198 getLocalization((*it).c_str());
3201 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
3203 std::vector<std::string> profiles=real.getPflsReallyUsed();
3204 int sz=profiles.size();
3206 for(int i=0;i<sz;i++)
3207 loadProfileInFile(fid,i,profiles[i].c_str());
3209 std::vector<std::string> locs=real.getLocsReallyUsed();
3212 for(int i=0;i<sz;i++)
3213 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
3216 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid, const MEDFileEntities *entities)
3218 int nProfil=MEDnProfile(fid);
3219 for(int i=0;i<nProfil;i++)
3220 loadProfileInFile(fid,i);
3221 int sz=MEDnLocalization(fid);
3223 for(int i=0;i<sz;i++)
3225 _locs[i]=MEDFileFieldLoc::New(fid,i,entities);
3229 MEDFileFieldGlobs *MEDFileFieldGlobs::New(med_idt fid)
3231 return new MEDFileFieldGlobs(fid);
3234 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
3236 return new MEDFileFieldGlobs;
3239 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
3241 return _file_name.capacity()+_pfls.capacity()*sizeof(MCAuto<DataArrayInt>)+_locs.capacity()*sizeof(MCAuto<MEDFileFieldLoc>);
3244 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildrenWithNull() const
3246 std::vector<const BigMemoryObject *> ret;
3247 for(std::vector< MCAuto< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3248 ret.push_back((const DataArrayInt *)*it);
3249 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3250 ret.push_back((const MEDFileFieldLoc *)*it);
3254 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCopy() const
3256 MCAuto<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
3258 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3260 if((const DataArrayInt *)*it)
3261 ret->_pfls[i]=(*it)->deepCopy();
3264 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3266 if((const MEDFileFieldLoc*)*it)
3267 ret->_locs[i]=(*it)->deepCopy();
3273 * \throw if a profile in \a pfls in not in \a this.
3274 * \throw if a localization in \a locs in not in \a this.
3275 * \sa MEDFileFieldGlobs::deepCpyPart
3277 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
3279 MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
3280 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
3282 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
3284 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
3286 MCAuto<DataArrayInt> pfl2(pfl);
3287 ret->_pfls.push_back(pfl2);
3289 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
3291 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
3293 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
3295 MCAuto<MEDFileFieldLoc> loc2(loc);
3296 ret->_locs.push_back(loc2);
3298 ret->setFileName(getFileName());
3303 * \throw if a profile in \a pfls in not in \a this.
3304 * \throw if a localization in \a locs in not in \a this.
3305 * \sa MEDFileFieldGlobs::shallowCpyPart
3307 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
3309 MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
3310 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
3312 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
3314 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
3315 ret->_pfls.push_back(pfl->deepCopy());
3317 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
3319 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
3321 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
3322 ret->_locs.push_back(loc->deepCopy());
3324 ret->setFileName(getFileName());
3328 MEDFileFieldGlobs::MEDFileFieldGlobs(med_idt fid):_file_name(MEDFileWritable::FileNameFromFID(fid))
3332 MEDFileFieldGlobs::MEDFileFieldGlobs()
3336 MEDFileFieldGlobs::~MEDFileFieldGlobs()
3340 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
3342 oss << "Profiles :\n";
3343 std::size_t n=_pfls.size();
3344 for(std::size_t i=0;i<n;i++)
3346 oss << " - #" << i << " ";
3347 const DataArrayInt *pfl=_pfls[i];
3349 oss << "\"" << pfl->getName() << "\"\n";
3354 oss << "Localizations :\n";
3355 for(std::size_t i=0;i<n;i++)
3357 oss << " - #" << i << " ";
3358 const MEDFileFieldLoc *loc=_locs[i];
3360 loc->simpleRepr(oss);
3366 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3368 for(std::vector< MCAuto<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
3370 DataArrayInt *elt(*it);
3373 std::string name(elt->getName());
3374 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3376 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3378 elt->setName((*it2).second.c_str());
3386 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3388 for(std::vector< MCAuto<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
3390 MEDFileFieldLoc *elt(*it);
3393 std::string name(elt->getName());
3394 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3396 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3398 elt->setName((*it2).second.c_str());
3406 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
3408 if(locId<0 || locId>=(int)_locs.size())
3409 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
3410 return _locs[locId]->getNbOfGaussPtPerCell();
3413 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
3415 return getLocalizationFromId(getLocalizationId(locName));
3418 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
3420 if(locId<0 || locId>=(int)_locs.size())
3421 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3422 return *_locs[locId];
3426 namespace MEDCouplingImpl
3431 LocFinder(const std::string& loc):_loc(loc) { }
3432 bool operator() (const MCAuto<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
3434 const std::string &_loc;
3440 PflFinder(const std::string& pfl):_pfl(pfl) { }
3441 bool operator() (const MCAuto<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
3443 const std::string& _pfl;
3448 int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
3450 std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),MEDCouplingImpl::LocFinder(loc));
3453 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
3454 for(it=_locs.begin();it!=_locs.end();it++)
3455 oss << "\"" << (*it)->getName() << "\", ";
3456 throw INTERP_KERNEL::Exception(oss.str());
3458 return std::distance(_locs.begin(),it);
3462 * The returned value is never null.
3464 const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
3466 std::string pflNameCpp(pflName);
3467 std::vector< MCAuto<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3470 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3471 for(it=_pfls.begin();it!=_pfls.end();it++)
3472 oss << "\"" << (*it)->getName() << "\", ";
3473 throw INTERP_KERNEL::Exception(oss.str());
3478 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
3480 if(pflId<0 || pflId>=(int)_pfls.size())
3481 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3482 return _pfls[pflId];
3485 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
3487 if(locId<0 || locId>=(int)_locs.size())
3488 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3489 return *_locs[locId];
3492 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
3494 return getLocalizationFromId(getLocalizationId(locName));
3498 * The returned value is never null.
3500 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
3502 std::string pflNameCpp(pflName);
3503 std::vector< MCAuto<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3506 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3507 for(it=_pfls.begin();it!=_pfls.end();it++)
3508 oss << "\"" << (*it)->getName() << "\", ";
3509 throw INTERP_KERNEL::Exception(oss.str());
3514 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
3516 if(pflId<0 || pflId>=(int)_pfls.size())
3517 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3518 return _pfls[pflId];
3521 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
3523 std::vector< MCAuto<DataArrayInt> > newPfls;
3525 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3527 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
3528 newPfls.push_back(*it);
3533 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
3535 std::vector< MCAuto<MEDFileFieldLoc> > newLocs;
3537 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3539 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
3540 newLocs.push_back(*it);
3545 void MEDFileFieldGlobs::killStructureElementsInGlobs()
3547 std::vector< MCAuto<MEDFileFieldLoc> > newLocs;
3548 for(std::vector< MCAuto<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
3552 if(!(*it)->isOnStructureElement())
3553 newLocs.push_back(*it);
3558 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
3560 int sz=_pfls.size();
3561 std::vector<std::string> ret(sz);
3562 for(int i=0;i<sz;i++)
3563 ret[i]=_pfls[i]->getName();
3567 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
3569 int sz=_locs.size();
3570 std::vector<std::string> ret(sz);
3571 for(int i=0;i<sz;i++)
3572 ret[i]=_locs[i]->getName();
3576 bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
3578 std::vector<std::string> v=getPfls();
3579 std::string s(pflName);
3580 return std::find(v.begin(),v.end(),s)!=v.end();
3583 bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
3585 std::vector<std::string> v=getLocs();
3586 std::string s(locName);
3587 return std::find(v.begin(),v.end(),s)!=v.end();
3590 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
3592 std::map<int,std::vector<int> > m;
3594 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3596 const DataArrayInt *tmp=(*it);
3599 m[tmp->getHashCode()].push_back(i);
3602 std::vector< std::vector<int> > ret;
3603 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
3605 if((*it2).second.size()>1)
3607 std::vector<int> ret0;
3608 bool equalityOrNot=false;
3609 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
3611 std::vector<int>::const_iterator it4=it3; it4++;
3612 for(;it4!=(*it2).second.end();it4++)
3614 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
3617 ret0.push_back(*it3);
3618 ret0.push_back(*it4);
3624 ret.push_back(ret0);
3630 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
3632 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
3635 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
3637 std::string name(pfl->getName());
3639 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
3640 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3641 if(name==(*it)->getName())
3643 if(!pfl->isEqual(*(*it)))
3645 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
3646 throw INTERP_KERNEL::Exception(oss.str());
3650 _pfls.push_back(pfl);
3653 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)
3655 std::string name(locName);
3657 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
3658 MCAuto<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
3659 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3660 if((*it)->isName(locName))
3662 if(!(*it)->isEqual(*obj,1e-12))
3664 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
3665 throw INTERP_KERNEL::Exception(oss.str());
3668 _locs.push_back(obj);
3671 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
3673 std::vector<std::string> names=getPfls();
3674 return CreateNewNameNotIn("NewPfl_",names);
3677 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
3679 std::vector<std::string> names=getLocs();
3680 return CreateNewNameNotIn("NewLoc_",names);
3683 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
3685 for(std::size_t sz=0;sz<100000;sz++)
3687 std::ostringstream tryName;
3688 tryName << prefix << sz;
3689 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
3690 return tryName.str();
3692 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
3696 * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
3697 * \param [in] fname - the file name.
3699 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(med_idt fid):_globals(MEDFileFieldGlobs::New(fid))
3704 * Creates an empty MEDFileFieldGlobsReal.
3706 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
3710 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
3715 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildrenWithNull() const
3717 std::vector<const BigMemoryObject *> ret;
3718 ret.push_back((const MEDFileFieldGlobs *)_globals);
3723 * Returns a string describing profiles and Gauss points held in \a this.
3724 * \return std::string - the description string.
3726 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
3728 const MEDFileFieldGlobs *glob=_globals;
3729 std::ostringstream oss2; oss2 << glob;
3730 std::string stars(oss2.str().length(),'*');
3731 oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n";
3733 glob->simpleRepr(oss);
3735 oss << "NO GLOBAL INFORMATION !\n";
3738 void MEDFileFieldGlobsReal::resetContent()
3740 _globals=MEDFileFieldGlobs::New();
3743 void MEDFileFieldGlobsReal::killStructureElementsInGlobs()
3745 contentNotNull()->killStructureElementsInGlobs();
3748 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
3753 * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
3754 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3756 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3758 _globals=other._globals;
3762 * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3763 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3765 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3767 const MEDFileFieldGlobs *otherg(other._globals);
3770 _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3774 * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3775 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3777 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3779 const MEDFileFieldGlobs *otherg(other._globals);
3782 _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3785 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3787 _globals=other._globals;
3788 if((const MEDFileFieldGlobs *)_globals)
3789 _globals=other._globals->deepCopy();
3793 * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3794 * \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3795 * \param [in] eps - a precision used to compare Gauss points with same name held by
3796 * \a this and \a other MEDFileFieldGlobsReal.
3797 * \throw If \a this and \a other hold profiles with equal names but different ids.
3798 * \throw If \a this and \a other hold different Gauss points with equal names.
3800 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
3802 const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3803 if(thisGlobals==otherGlobals)
3807 _globals=other._globals;
3810 _globals->appendGlobs(*other._globals,eps);
3813 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
3815 checkGlobsPflsPartCoherency();
3816 checkGlobsLocsPartCoherency();
3819 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
3821 contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3824 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
3826 contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3829 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3831 contentNotNull()->loadProfileInFile(fid,id,pflName);
3834 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3836 contentNotNull()->loadProfileInFile(fid,id);
3839 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
3841 contentNotNull()->loadGlobals(fid,*this);
3844 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid, const MEDFileEntities *entities)
3846 contentNotNull()->loadAllGlobals(fid,entities);
3849 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3851 contentNotNull()->writeGlobals(fid,opt);
3855 * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3856 * or getPflsReallyUsedMulti().
3857 * \return std::vector<std::string> - a sequence of names of all profiles.
3859 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3861 return contentNotNull()->getPfls();
3865 * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3866 * or getLocsReallyUsedMulti().
3867 * \return std::vector<std::string> - a sequence of names of all localizations.
3869 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3871 return contentNotNull()->getLocs();
3875 * Checks if the profile with a given name exists.
3876 * \param [in] pflName - the profile name of interest.
3877 * \return bool - \c true if the profile named \a pflName exists.
3879 bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
3881 return contentNotNull()->existsPfl(pflName);
3885 * Checks if the localization with a given name exists.
3886 * \param [in] locName - the localization name of interest.
3887 * \return bool - \c true if the localization named \a locName exists.
3889 bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
3891 return contentNotNull()->existsLoc(locName);
3894 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
3896 return contentNotNull()->createNewNameOfPfl();
3899 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
3901 return contentNotNull()->createNewNameOfLoc();
3905 * Sets the name of a MED file.
3906 * \param [inout] fileName - the file name.
3908 void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
3910 contentNotNull()->setFileName(fileName);
3914 * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3915 * in the same order.
3916 * \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3917 * Each item of this sequence is a vector containing ids of equal profiles.
3919 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3921 return contentNotNull()->whichAreEqualProfiles();
3925 * Finds equal localizations.
3926 * \param [in] eps - a precision used to compare real values of the localizations.
3927 * \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3928 * Each item of this sequence is a vector containing ids of equal localizations.
3930 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3932 return contentNotNull()->whichAreEqualLocs(eps);
3936 * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3937 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3938 * this sequence is a pair whose
3939 * - the first item is a vector of profile names to replace by the second item,
3940 * - the second item is a profile name to replace every profile name of the first item.
3942 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3944 contentNotNull()->changePflsNamesInStruct(mapOfModif);
3948 * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3949 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3950 * this sequence is a pair whose
3951 * - the first item is a vector of localization names to replace by the second item,
3952 * - the second item is a localization name to replace every localization name of the first item.
3954 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3956 contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3960 * Replaces references to some profiles (a reference is a profile name) by references
3961 * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3962 * them-selves accordingly. <br>
3963 * This method is a generalization of changePflName().
3964 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3965 * this sequence is a pair whose
3966 * - the first item is a vector of profile names to replace by the second item,
3967 * - the second item is a profile name to replace every profile of the first item.
3968 * \sa changePflsRefsNamesGen()
3969 * \sa changePflName()
3971 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3973 changePflsRefsNamesGen(mapOfModif);
3974 changePflsNamesInStruct(mapOfModif);
3978 * Replaces references to some localizations (a reference is a localization name) by references
3979 * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3980 * them-selves accordingly. <br>
3981 * This method is a generalization of changeLocName().
3982 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3983 * this sequence is a pair whose
3984 * - the first item is a vector of localization names to replace by the second item,
3985 * - the second item is a localization name to replace every localization of the first item.
3986 * \sa changeLocsRefsNamesGen()
3987 * \sa changeLocName()
3989 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3991 changeLocsRefsNamesGen(mapOfModif);
3992 changeLocsNamesInStruct(mapOfModif);
3996 * Renames the profile having a given name and updates references to this profile.
3997 * \param [in] oldName - the name of the profile to rename.
3998 * \param [in] newName - a new name of the profile.
3999 * \sa changePflsNames().
4001 void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
4003 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
4004 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
4006 changePflsNames(mapOfModif);
4010 * Renames the localization having a given name and updates references to this localization.
4011 * \param [in] oldName - the name of the localization to rename.
4012 * \param [in] newName - a new name of the localization.
4013 * \sa changeLocsNames().
4015 void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
4017 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
4018 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
4020 changeLocsNames(mapOfModif);
4024 * Removes duplicated profiles. Returns a map used to update references to removed
4025 * profiles via changePflsRefsNamesGen().
4026 * Equal profiles are found using whichAreEqualProfiles().
4027 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
4028 * a sequence describing the performed replacements of profiles. Each element of
4029 * this sequence is a pair whose
4030 * - the first item is a vector of profile names replaced by the second item,
4031 * - the second item is a profile name replacing every profile of the first item.
4033 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
4035 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
4036 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
4038 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
4040 std::vector< std::string > tmp((*it).size());
4042 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
4043 tmp[j]=std::string(getProfileFromId(*it2)->getName());
4044 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
4046 std::vector<int> tmp2((*it).begin()+1,(*it).end());
4047 killProfileIds(tmp2);
4049 changePflsRefsNamesGen(ret);
4054 * Removes duplicated localizations. Returns a map used to update references to removed
4055 * localizations via changeLocsRefsNamesGen().
4056 * Equal localizations are found using whichAreEqualLocs().
4057 * \param [in] eps - a precision used to compare real values of the localizations.
4058 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
4059 * a sequence describing the performed replacements of localizations. Each element of
4060 * this sequence is a pair whose
4061 * - the first item is a vector of localization names replaced by the second item,
4062 * - the second item is a localization name replacing every localization of the first item.
4064 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
4066 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
4067 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
4069 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
4071 std::vector< std::string > tmp((*it).size());
4073 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
4074 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
4075 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
4077 std::vector<int> tmp2((*it).begin()+1,(*it).end());
4078 killLocalizationIds(tmp2);
4080 changeLocsRefsNamesGen(ret);
4085 * Returns number of Gauss points per cell in a given localization.
4086 * \param [in] locId - an id of the localization of interest.
4087 * \return int - the number of the Gauss points per cell.
4089 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
4091 return contentNotNull()->getNbOfGaussPtPerCell(locId);
4095 * Returns an id of a localization by its name.
4096 * \param [in] loc - the localization name of interest.
4097 * \return int - the id of the localization.
4098 * \throw If there is no a localization named \a loc.
4100 int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
4102 return contentNotNull()->getLocalizationId(loc);
4106 * Returns the name of the MED file.
4107 * \return const std::string& - the MED file name.
4109 std::string MEDFileFieldGlobsReal::getFileName() const
4111 return contentNotNull()->getFileName();
4115 * Returns a localization object by its name.
4116 * \param [in] locName - the name of the localization of interest.
4117 * \return const MEDFileFieldLoc& - the localization object having the name \a locName.
4118 * \throw If there is no a localization named \a locName.
4120 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
4122 return contentNotNull()->getLocalization(locName);
4126 * Returns a localization object by its id.
4127 * \param [in] locId - the id of the localization of interest.
4128 * \return const MEDFileFieldLoc& - the localization object having the id \a locId.
4129 * \throw If there is no a localization with id \a locId.
4131 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
4133 return contentNotNull()->getLocalizationFromId(locId);
4137 * Returns a profile array by its name.
4138 * \param [in] pflName - the name of the profile of interest.
4139 * \return const DataArrayInt * - the profile array having the name \a pflName.
4140 * \throw If there is no a profile named \a pflName.
4142 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
4144 return contentNotNull()->getProfile(pflName);
4148 * Returns a profile array by its id.
4149 * \param [in] pflId - the id of the profile of interest.
4150 * \return const DataArrayInt * - the profile array having the id \a pflId.
4151 * \throw If there is no a profile with id \a pflId.
4153 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
4155 return contentNotNull()->getProfileFromId(pflId);
4159 * Returns a localization object, apt for modification, by its id.
4160 * \param [in] locId - the id of the localization of interest.
4161 * \return MEDFileFieldLoc& - a non-const reference to the localization object
4162 * having the id \a locId.
4163 * \throw If there is no a localization with id \a locId.
4165 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
4167 return contentNotNull()->getLocalizationFromId(locId);
4171 * Returns a localization object, apt for modification, by its name.
4172 * \param [in] locName - the name of the localization of interest.
4173 * \return MEDFileFieldLoc& - a non-const reference to the localization object
4174 * having the name \a locName.
4175 * \throw If there is no a localization named \a locName.
4177 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
4179 return contentNotNull()->getLocalization(locName);
4183 * Returns a profile array, apt for modification, by its name.
4184 * \param [in] pflName - the name of the profile of interest.
4185 * \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
4186 * \throw If there is no a profile named \a pflName.
4188 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
4190 return contentNotNull()->getProfile(pflName);
4194 * Returns a profile array, apt for modification, by its id.
4195 * \param [in] pflId - the id of the profile of interest.
4196 * \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
4197 * \throw If there is no a profile with id \a pflId.
4199 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
4201 return contentNotNull()->getProfileFromId(pflId);
4205 * Removes profiles given by their ids. No data is updated to track this removal.
4206 * \param [in] pflIds - a sequence of ids of the profiles to remove.
4208 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
4210 contentNotNull()->killProfileIds(pflIds);
4214 * Removes localizations given by their ids. No data is updated to track this removal.
4215 * \param [in] locIds - a sequence of ids of the localizations to remove.
4217 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
4219 contentNotNull()->killLocalizationIds(locIds);
4223 * Stores a profile array.
4224 * \param [in] pfl - the profile array to store.
4225 * \throw If the name of \a pfl is empty.
4226 * \throw If a profile with the same name as that of \a pfl already exists but contains
4229 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
4231 contentNotNull()->appendProfile(pfl);
4235 * Adds a new localization of Gauss points.
4236 * \param [in] locName - the name of the new localization.
4237 * \param [in] geoType - a geometrical type of the reference cell.
4238 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
4239 * must be \c nbOfNodesPerCell * \c dimOfType.
4240 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
4241 * must be _wg_.size() * \c dimOfType.
4242 * \param [in] w - the weights of Gauss points.
4243 * \throw If \a locName is empty.
4244 * \throw If a localization with the name \a locName already exists but is
4245 * different form the new one.
4247 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)
4249 contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
4252 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
4254 MEDFileFieldGlobs *g(_globals);
4256 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
4260 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
4262 const MEDFileFieldGlobs *g(_globals);
4264 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
4268 //= MEDFileFieldNameScope
4270 MEDFileFieldNameScope::MEDFileFieldNameScope()
4274 MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName):_name(fieldName)
4279 * Returns the name of \a this field.
4280 * \return std::string - a string containing the field name.
4282 std::string MEDFileFieldNameScope::getName() const
4288 * Sets name of \a this field
4289 * \param [in] name - the new field name.
4291 void MEDFileFieldNameScope::setName(const std::string& fieldName)
4296 std::string MEDFileFieldNameScope::getDtUnit() const
4301 void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
4306 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
4309 _dt_unit=other._dt_unit;
4312 //= MEDFileAnyTypeField1TSWithoutSDA
4314 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
4316 _field_per_mesh.resize(other._field_per_mesh.size());
4318 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
4320 if((const MEDFileFieldPerMesh *)*it)
4321 _field_per_mesh[i]=(*it)->deepCopy(this);
4325 void MEDFileAnyTypeField1TSWithoutSDA::accept(MEDFileFieldVisitor& visitor) const
4327 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4328 if((*it).isNotNull())
4330 visitor.newMeshEntry(*it);
4331 (*it)->accept(visitor);
4332 visitor.endMeshEntry(*it);
4337 * Prints a string describing \a this field into a stream. This string is outputted
4338 * by \c print Python command.
4339 * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
4340 * \param [in,out] oss - the out stream.
4341 * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
4342 * info id printed, else, not.
4344 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
4346 std::string startOfLine(bkOffset,' ');
4347 oss << startOfLine << "Field ";
4349 oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
4350 oss << "on one time Step ";
4352 oss << "(" << f1tsId << ") ";
4353 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
4354 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
4355 const DataArray *arr=getUndergroundDataArray();
4358 const std::vector<std::string> &comps=arr->getInfoOnComponents();
4361 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
4362 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
4363 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
4365 if(arr->isAllocated())
4367 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
4370 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
4374 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
4376 oss << startOfLine << "----------------------" << std::endl;
4377 if(!_field_per_mesh.empty())
4380 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
4382 const MEDFileFieldPerMesh *cur=(*it2);
4384 cur->simpleRepr(bkOffset,oss,i);
4386 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
4391 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
4393 oss << startOfLine << "----------------------" << std::endl;
4396 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
4398 const DataArray *arr(getUndergroundDataArray());
4400 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
4401 int nbOfCompo=arr->getNumberOfComponents();
4402 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
4403 for(int i=0;i<nbOfCompo;i++)
4406 std::vector<int> v(1,i);
4407 MCAuto<DataArray> arr2=arr->keepSelectedComponents(v);
4408 ret[i]->setArray(arr2);
4413 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order):MEDFileFieldNameScope(fieldName),_iteration(iteration),_order(order),_csit(csit),_nb_of_tuples_to_be_allocated(-2)
4417 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
4422 * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
4423 * empty. Returns -1 if this in on nodes.
4424 * \return int - the dimension of \a this.
4426 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
4429 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4430 (*it)->getDimension(ret);
4435 * Returns the mesh name.
4436 * \return std::string - a string holding the mesh name.
4437 * \throw If \c _field_per_mesh.empty()
4439 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const
4441 if(_field_per_mesh.empty())
4442 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
4443 return _field_per_mesh[0]->getMeshName();
4446 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const std::string& newMeshName)
4448 std::string oldName(getMeshName());
4449 std::vector< std::pair<std::string,std::string> > v(1);
4450 v[0].first=oldName; v[0].second=newMeshName;
4454 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
4457 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4459 MEDFileFieldPerMesh *cur(*it);
4461 ret=cur->changeMeshNames(modifTab) || ret;
4467 * Returns the number of iteration of the state of underlying mesh.
4468 * \return int - the iteration number.
4469 * \throw If \c _field_per_mesh.empty()
4471 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
4473 if(_field_per_mesh.empty())
4474 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
4475 return _field_per_mesh[0]->getMeshIteration();
4479 * Returns the order number of iteration of the state of underlying mesh.
4480 * \return int - the order number.
4481 * \throw If \c _field_per_mesh.empty()
4483 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
4485 if(_field_per_mesh.empty())
4486 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
4487 return _field_per_mesh[0]->getMeshOrder();
4491 * Checks if \a this field is tagged by a given iteration number and a given
4492 * iteration order number.
4493 * \param [in] iteration - the iteration number of interest.
4494 * \param [in] order - the iteration order number of interest.
4495 * \return bool - \c true if \a this->getIteration() == \a iteration &&
4496 * \a this->getOrder() == \a order.
4498 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
4500 return iteration==_iteration && order==_order;
4504 * Returns number of iteration and order number of iteration when
4505 * \a this field has been calculated.
4506 * \return std::pair<int,int> - a pair of the iteration number and the iteration
4509 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
4511 std::pair<int,int> p;
4517 * Returns number of iteration and order number of iteration when
4518 * \a this field has been calculated.
4519 * \param [in,out] p - a pair returning the iteration number and the iteration
4522 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
4529 * Returns all types of spatial discretization of \a this field.
4530 * \param [in,out] types - a sequence of types of \a this field.
4532 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
4534 std::set<TypeOfField> types2;
4535 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4537 (*it)->fillTypesOfFieldAvailable(types2);
4539 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
4540 std::copy(types2.begin(),types2.end(),bi);
4544 * Returns all types of spatial discretization of \a this field.
4545 * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
4548 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
4550 std::vector<TypeOfField> ret;
4551 fillTypesOfFieldAvailable(ret);
4555 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
4557 std::vector<std::string> ret;
4558 std::set<std::string> ret2;
4559 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4561 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
4562 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4563 if(ret2.find(*it2)==ret2.end())
4565 ret.push_back(*it2);
4572 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
4574 std::vector<std::string> ret;
4575 std::set<std::string> ret2;
4576 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4578 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
4579 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4580 if(ret2.find(*it2)==ret2.end())
4582 ret.push_back(*it2);
4589 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
4591 std::vector<std::string> ret;
4592 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4594 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
4595 ret.insert(ret.end(),tmp.begin(),tmp.end());
4600 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
4602 std::vector<std::string> ret;
4603 std::set<std::string> ret2;
4604 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4606 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
4607 ret.insert(ret.end(),tmp.begin(),tmp.end());
4612 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4614 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4615 (*it)->changePflsRefsNamesGen(mapOfModif);
4618 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4620 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4621 (*it)->changeLocsRefsNamesGen(mapOfModif);
4625 * Returns all attributes of parts of \a this field lying on a given mesh.
4626 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4627 * item of every of returned sequences refers to the _i_-th part of \a this field.
4628 * Thus all sequences returned by this method are of the same length equal to number
4629 * of different types of supporting entities.<br>
4630 * A field part can include sub-parts with several different spatial discretizations,
4631 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
4632 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4633 * of a nested sequence corresponds to a type of spatial discretization.<br>
4634 * This method allows for iteration over MEDFile DataStructure without any overhead.
4635 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4636 * for the case with only one underlying mesh. (Actually, the number of meshes is
4637 * not checked if \a mname == \c NULL).
4638 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4639 * a field part is returned.
4640 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4641 * This sequence is of the same length as \a types.
4642 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4643 * discretization. A profile name can be empty.
4644 * Length of this and of nested sequences is the same as that of \a typesF.
4645 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4646 * discretization. A localization name can be empty.
4647 * Length of this and of nested sequences is the same as that of \a typesF.
4648 * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
4649 * of ids of tuples within the data array, per each type of spatial
4650 * discretization within one mesh entity type.
4651 * Length of this and of nested sequences is the same as that of \a typesF.
4652 * \throw If no field is lying on \a mname.
4654 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
4658 meshId=getMeshIdFromMeshName(mname);
4660 if(_field_per_mesh.empty())
4661 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4662 return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4666 * Returns dimensions of mesh elements \a this field lies on. The returned value is a
4667 * maximal absolute dimension and values returned via the out parameter \a levs are
4668 * dimensions relative to the maximal absolute dimension. <br>
4669 * This method is designed for MEDFileField1TS instances that have a discretization
4670 * \ref MEDCoupling::ON_CELLS "ON_CELLS",
4671 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT",
4672 * \ref MEDCoupling::ON_GAUSS_NE "ON_GAUSS_NE".
4673 * Only these 3 discretizations will be taken into account here. If \a this is
4674 * \ref MEDCoupling::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
4675 * This method is useful to make the link between the dimension of the underlying mesh
4676 * and the levels of \a this, because it is possible that the highest dimension of \a this
4677 * field is not equal to the dimension of the underlying mesh.
4679 * Let's consider the following case:
4680 * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
4681 * TETRA4, HEXA8, TRI3 and SEG2.
4682 * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
4683 * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
4685 * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
4686 * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
4687 * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
4688 * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
4689 * parameter of getFieldAtLevel() is computed basing on the returned values as this:
4690 * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
4692 * to retrieve the highest level of
4693 * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br>
4694 * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
4695 * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
4696 * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
4697 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4698 * for the case with only one underlying mesh. (Actually, the number of meshes is
4699 * not checked if \a mname == \c NULL).
4700 * \param [in,out] levs - a sequence returning the dimensions relative to the maximal
4701 * absolute one. They are in decreasing order. This sequence is cleared before
4703 * \return int - the maximal absolute dimension of elements \a this fields lies on.
4704 * \throw If no field is lying on \a mname.
4706 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
4709 int meshId=getMeshIdFromMeshName(mname);
4710 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4711 std::vector< std::vector<TypeOfField> > typesF;
4712 std::vector< std::vector<std::string> > pfls, locs;
4713 _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4715 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
4716 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
4717 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
4719 st.erase(INTERP_KERNEL::NORM_ERROR);
4721 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
4723 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
4724 ret1.insert((int)cm.getDimension());
4726 int ret=*std::max_element(ret1.begin(),ret1.end());
4727 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
4728 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
4732 void MEDFileAnyTypeField1TSWithoutSDA::convertMedBallIntoClassic()
4734 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it<_field_per_mesh.end();it++)
4735 if((*it).isNotNull())
4736 (*it)->convertMedBallIntoClassic();
4739 void MEDFileAnyTypeField1TSWithoutSDA::makeReduction(INTERP_KERNEL::NormalizedCellType ct, TypeOfField tof, const DataArrayInt *pfl)
4742 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : null pfl !");
4743 std::string name(pfl->getName());
4744 pfl->checkAllocated();
4745 if(pfl->getNumberOfComponents()!=1)
4746 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : non mono compo array !");
4748 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : empty pfl name !");
4749 if(_field_per_mesh.size()!=1)
4750 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : only single mesh supported !");
4751 MCAuto<MEDFileFieldPerMesh> fpm(_field_per_mesh[0]);
4753 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : only single not null mesh supported !");
4754 MEDFileFieldPerMeshPerTypePerDisc *disc(fpm->getLeafGivenTypeAndLocId(ct,0));
4755 if(disc->getType()!=tof)
4756 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : error !");
4757 int s(disc->getStart()),e(disc->getEnd()),nt(pfl->getNumberOfTuples());
4758 DataArray *arr(getUndergroundDataArray());
4759 int nt2(arr->getNumberOfTuples()),delta((e-s)-nt);
4761 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : internal error !");
4762 MCAuto<DataArray> arr0(arr->selectByTupleIdSafeSlice(0,s,1)),arr1(arr->selectByTupleIdSafeSlice(s,e,1)),arr2(arr->selectByTupleIdSafeSlice(e,nt2,1));
4763 MCAuto<DataArray> arr11(arr1->selectByTupleIdSafe(pfl->begin(),pfl->end()));
4764 MCAuto<DataArray> arrOut(arr->buildNewEmptyInstance());
4765 arrOut->alloc(nt2-delta,arr->getNumberOfComponents());
4766 arrOut->copyStringInfoFrom(*arr);
4767 arrOut->setContigPartOfSelectedValuesSlice(0,arr0,0,s,1);
4768 arrOut->setContigPartOfSelectedValuesSlice(s,arr11,0,nt,1);
4769 arrOut->setContigPartOfSelectedValuesSlice(e-delta,arr2,0,nt2-e,1);
4771 disc->setEnd(e-delta);
4772 disc->setProfile(name);
4776 * \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.
4777 * \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.
4778 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4779 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4781 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
4783 int mid=getMeshIdFromMeshName(mName);
4784 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4788 * \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.
4789 * \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.
4790 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4791 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4793 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
4795 int mid=getMeshIdFromMeshName(mName);
4796 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4800 * \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.
4802 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
4804 if(_field_per_mesh.empty())
4805 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4808 std::string mName2(mName);
4810 std::vector<std::string> msg;
4811 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4812 if(mName2==(*it)->getMeshName())
4815 msg.push_back((*it)->getMeshName());
4816 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4817 oss << "Possible meshes are : ";
4818 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4819 oss << "\"" << (*it2) << "\" ";
4820 throw INTERP_KERNEL::Exception(oss.str());
4823 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
4826 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4827 std::string tmp(mesh->getName());
4829 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4830 std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4832 for(;it!=_field_per_mesh.end();it++,i++)
4834 if((*it)->getMeshName()==tmp)
4837 int sz=_field_per_mesh.size();
4838 _field_per_mesh.resize(sz+1);
4839 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4843 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4844 MEDFileFieldGlobsReal& glob)
4847 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4849 MEDFileFieldPerMesh *fpm(*it);
4851 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4857 * This method splits \a this into several sub-parts so that each sub parts have exactly one spatial discretization. This method implements the minimal
4858 * splitting that leads to single spatial discretization of this.
4860 * \sa splitMultiDiscrPerGeoTypes
4862 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
4864 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4865 std::vector< std::vector<TypeOfField> > typesF;
4866 std::vector< std::vector<std::string> > pfls,locs;
4867 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4868 std::set<TypeOfField> allEnt;
4869 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4870 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4871 allEnt.insert(*it2);
4872 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4873 std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4874 for(std::size_t i=0;i<allEnt.size();i++,it3++)
4876 std::vector< std::pair<int,int> > its;
4877 ret[i]=shallowCpy();
4878 int newLgth(ret[i]->keepOnlySpatialDiscretization(*it3,its));
4879 ret[i]->updateData(newLgth,its);
4885 * This method performs a sub splitting as splitDiscretizations does but finer. This is the finest spliting level that can be done.
4886 * This method implements the minimal splitting so that each returned elements are mono Gauss discretization per geometric type.
4888 * \sa splitDiscretizations
4890 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes() const
4892 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4893 std::vector< std::vector<TypeOfField> > typesF;
4894 std::vector< std::vector<std::string> > pfls,locs;
4895 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4896 std::set<TypeOfField> allEnt;
4897 std::size_t nbOfMDPGT(0),ii(0);
4898 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++,ii++)
4900 nbOfMDPGT=std::max(nbOfMDPGT,locs[ii].size());
4901 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4902 allEnt.insert(*it2);
4904 if(allEnt.size()!=1)
4905 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : this field is expected to be defined only on one spatial discretization !");
4907 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
4910 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret0(1);
4911 ret0[0]=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(this); this->incrRef();
4914 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfMDPGT);
4915 for(std::size_t i=0;i<nbOfMDPGT;i++)
4917 std::vector< std::pair<int,int> > its;
4918 ret[i]=shallowCpy();
4919 int newLgth(ret[i]->keepOnlyGaussDiscretization(i,its));
4920 ret[i]->updateData(newLgth,its);
4925 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
4927 int globalCounter(0);
4928 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4929 (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4930 return globalCounter;
4933 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlyGaussDiscretization(std::size_t idOfDisc, std::vector< std::pair<int,int> >& its)
4935 int globalCounter(0);
4936 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4937 (*it)->keepOnlyGaussDiscretization(idOfDisc,globalCounter,its);
4938 return globalCounter;
4941 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
4943 if(_nb_of_tuples_to_be_allocated>=0)
4945 _nb_of_tuples_to_be_allocated=newLgth;
4946 const DataArray *oldArr(getUndergroundDataArray());
4949 MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4950 newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
4952 _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
4956 if(_nb_of_tuples_to_be_allocated==-1)
4958 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4960 const DataArray *oldArr(getUndergroundDataArray());
4961 if(!oldArr || !oldArr->isAllocated())
4962 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4963 MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4964 newArr->alloc(newLgth,getNumberOfComponents());
4966 newArr->copyStringInfoFrom(*oldArr);
4968 for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4970 if((*it).second<(*it).first)
4971 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4972 newArr->setContigPartOfSelectedValuesSlice(pos,oldArr,(*it).first,(*it).second,1);
4973 pos+=(*it).second-(*it).first;
4978 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4981 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
4983 if(_field_per_mesh.empty())
4984 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4985 if(_field_per_mesh.size()>1)
4986 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4987 _field_per_mesh[0]->copyOptionsFrom(opts);
4988 _field_per_mesh[0]->writeLL(fid,nasc);
4992 * 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.
4993 * If false is returned the memory allocation is not required.
4995 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
4997 if(_nb_of_tuples_to_be_allocated>=0)
4999 getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
5000 _nb_of_tuples_to_be_allocated=-2;
5003 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
5005 if(_nb_of_tuples_to_be_allocated==-1)
5006 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
5007 if(_nb_of_tuples_to_be_allocated<-3)
5008 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
5009 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
5012 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
5014 med_int numdt,numit;
5018 med_int meshnumdt,meshnumit;
5019 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5020 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt));
5021 MEDFILESAFECALLERRD0(MEDfield23ComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit));
5022 if(_iteration!=numdt || _order!=numit)
5023 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
5024 _field_per_mesh.resize(nmesh);
5029 std::string meshNameCpp(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
5030 mm=ms->getMeshWithName(meshNameCpp);
5033 for(int i=0;i<nmesh;i++)
5034 _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i,meshnumdt,meshnumit,nasc,mm,entities);
5035 _nb_of_tuples_to_be_allocated=0;
5036 for(int i=0;i<nmesh;i++)
5037 _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
5040 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
5042 allocIfNecessaryTheArrayToReceiveDataFromFile();
5043 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5044 (*it)->loadBigArraysRecursively(fid,nasc);
5047 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
5049 if(allocIfNecessaryTheArrayToReceiveDataFromFile())
5050 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5051 (*it)->loadBigArraysRecursively(fid,nasc);
5054 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
5056 loadOnlyStructureOfDataRecursively(fid,nasc,ms,entities);
5057 loadBigArraysRecursively(fid,nasc);
5060 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
5062 DataArray *thisArr(getUndergroundDataArray());
5063 if(thisArr && thisArr->isAllocated())
5065 _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
5066 thisArr->desallocate();
5070 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
5072 return _dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MCAuto< MEDFileFieldPerMesh >);
5075 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
5077 std::vector<const BigMemoryObject *> ret;
5078 if(getUndergroundDataArray())
5079 ret.push_back(getUndergroundDataArray());
5080 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5081 ret.push_back((const MEDFileFieldPerMesh *)*it);
5086 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
5087 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
5088 * "Sort By Type"), if not, an exception is thrown.
5089 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
5090 * \param [in] arr - the array of values.
5091 * \param [in,out] glob - the global data where profiles and localization present in
5092 * \a field, if any, are added.
5093 * \throw If the name of \a field is empty.
5094 * \throw If the data array of \a field is not set.
5095 * \throw If \a this->_arr is already allocated but has different number of components
5097 * \throw If the underlying mesh of \a field has no name.
5098 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
5100 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
5102 const MEDCouplingMesh *mesh=field->getMesh();
5104 TypeOfField type=field->getTypeOfField();
5105 std::vector<DataArrayInt *> dummy;
5106 int start=copyTinyInfoFrom(field,arr);
5107 int pos=addNewEntryIfNecessary(mesh);
5110 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
5111 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
5114 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
5118 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
5119 * of a given mesh are used as the support of the given field (a real support is not used).
5120 * Elements of the given mesh must be sorted suitable for writing to MED file.
5121 * Order of underlying mesh entities of the given field specified by \a profile parameter
5122 * is not prescribed; this method permutes field values to have them sorted by element
5123 * type as required for writing to MED file. A new profile is added only if no equal
5124 * profile is missing.
5125 * \param [in] field - the field to add to \a this. The field double values are ignored.
5126 * \param [in] arrOfVals - the values of the field \a field used.
5127 * \param [in] mesh - the supporting mesh of \a field.
5128 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
5129 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
5130 * \param [in,out] glob - the global data where profiles and localization present in
5131 * \a field, if any, are added.
5132 * \throw If either \a field or \a mesh or \a profile has an empty name.
5133 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
5134 * \throw If the data array of \a field is not set.
5135 * \throw If \a this->_arr is already allocated but has different number of components
5137 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
5138 * \sa setFieldNoProfileSBT()
5140 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
5143 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
5144 if(!arrOfVals || !arrOfVals->isAllocated())
5145 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
5146 TypeOfField type=field->getTypeOfField();
5147 std::vector<DataArrayInt *> idsInPflPerType;
5148 std::vector<DataArrayInt *> idsPerType;
5149 std::vector<int> code,code2;
5150 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
5153 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
5154 std::vector< MCAuto<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
5155 std::vector< MCAuto<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin());
5156 std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
5158 MCAuto<MEDCouplingFieldDouble> field2=field->clone(false);
5159 int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
5160 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
5162 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
5163 throw INTERP_KERNEL::Exception(oss.str());
5166 int start=copyTinyInfoFrom(field,arrOfVals);
5167 code2=m->getDistributionOfTypes();
5169 int pos=addNewEntryIfNecessary(m);
5170 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
5174 if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
5175 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
5176 std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
5177 std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
5178 int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
5179 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
5181 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
5182 throw INTERP_KERNEL::Exception(oss.str());
5184 int start=copyTinyInfoFrom(field,arrOfVals);
5185 int pos=addNewEntryIfNecessary(m);
5186 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
5191 * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
5193 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
5195 if(_nb_of_tuples_to_be_allocated>=0)
5196 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 !");
5197 DataArray *arr(getOrCreateAndGetArray());
5198 arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
5199 _nb_of_tuples_to_be_allocated=-3;
5203 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
5204 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
5205 * larger by the size of \a field. Returns an id of the first not filled
5206 * tuple of \a this->_arr.
5207 * \param [in] field - the field to copy the info on components and the name from.
5208 * \return int - the id of first not initialized tuple of \a this->_arr.
5209 * \throw If the name of \a field is empty.
5210 * \throw If the data array of \a field is not set.
5211 * \throw If \a this->_arr is already allocated but has different number of components
5214 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
5217 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
5218 std::string name(field->getName());
5219 setName(name.c_str());
5220 setDtUnit(field->getTimeUnit());
5222 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
5224 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
5225 if(!arr->isAllocated())
5226 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
5227 _dt=field->getTime(_iteration,_order);
5228 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
5229 if(!getOrCreateAndGetArray()->isAllocated())
5231 allocNotFromFile(arr->getNumberOfTuples());
5236 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
5237 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
5238 getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
5239 _nb_of_tuples_to_be_allocated=-3;
5240 return oldNbOfTuples;
5245 * Returns number of components in \a this field
5246 * \return int - the number of components.
5248 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
5250 return getOrCreateAndGetArray()->getNumberOfComponents();
5254 * Change info on components in \a this.
5255 * \throw If size of \a infos is not equal to the number of components already in \a this.
5257 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
5259 DataArray *arr=getOrCreateAndGetArray();
5260 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
5264 * Returns info on components of \a this field.
5265 * \return const std::vector<std::string>& - a sequence of strings each being an
5266 * information on _i_-th component.
5268 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
5270 const DataArray *arr=getOrCreateAndGetArray();
5271 return arr->getInfoOnComponents();
5275 * Returns a mutable info on components of \a this field.
5276 * \return std::vector<std::string>& - a sequence of strings each being an
5277 * information on _i_-th component.
5279 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
5281 DataArray *arr=getOrCreateAndGetArray();
5282 return arr->getInfoOnComponents();
5285 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const
5287 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5289 const MEDFileFieldPerMesh *fpm(*it);
5292 if(fpm->presenceOfMultiDiscPerGeoType())
5298 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfStructureElements() const
5300 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5301 if((*it).isNotNull())
5302 if((*it)->presenceOfStructureElements())
5307 bool MEDFileAnyTypeField1TSWithoutSDA::onlyStructureElements() const
5309 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5310 if((*it).isNotNull())
5311 if(!(*it)->onlyStructureElements())
5316 void MEDFileAnyTypeField1TSWithoutSDA::killStructureElements()
5318 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5319 if((*it).isNotNull())
5320 (*it)->killStructureElements();
5323 void MEDFileAnyTypeField1TSWithoutSDA::keepOnlyStructureElements()
5325 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5326 if((*it).isNotNull())
5327 (*it)->keepOnlyStructureElements();
5330 void MEDFileAnyTypeField1TSWithoutSDA::keepOnlyOnSE(const std::string& seName)
5332 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5333 if((*it).isNotNull())
5334 (*it)->keepOnlyOnSE(seName);
5337 void MEDFileAnyTypeField1TSWithoutSDA::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
5339 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5340 if((*it).isNotNull())
5341 (*it)->getMeshSENames(ps);
5344 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh(const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5346 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 !";
5347 if(_field_per_mesh.empty())
5348 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is empty ! Nothing to extract !");
5349 if(_field_per_mesh.size()>1)
5350 throw INTERP_KERNEL::Exception(MSG0);
5351 if(_field_per_mesh[0].isNull())
5352 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is inconsistent !");
5353 const MEDFileFieldPerMesh *pm(_field_per_mesh[0]);
5354 std::set<TypeOfField> types;
5355 pm->fillTypesOfFieldAvailable(types);
5357 throw INTERP_KERNEL::Exception(MSG0);
5358 TypeOfField type(*types.begin());
5359 int meshDimRelToMax(0);
5364 int myDim(std::numeric_limits<int>::max());
5365 bool isUnique(pm->isUniqueLevel(myDim));
5367 throw INTERP_KERNEL::Exception(MSG0);
5368 meshDimRelToMax=myDim-mesh->getMeshDimension();
5369 if(meshDimRelToMax>0)
5370 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the mesh attached to field is not compatible with the field !");
5372 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,0/*renumPol*/,glob,mesh,arrOut,nasc);
5376 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5377 * \param [in] type - a spatial discretization of the new field.
5378 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5379 * \param [in] mName - a name of the supporting mesh.
5380 * \param [in] renumPol - specifies how to permute values of the result field according to
5381 * the optional numbers of cells and nodes, if any. The valid values are
5382 * - 0 - do not permute.
5383 * - 1 - permute cells.
5384 * - 2 - permute nodes.
5385 * - 3 - permute cells and nodes.
5387 * \param [in] glob - the global data storing profiles and localization.
5388 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5389 * caller is to delete this field using decrRef() as it is no more needed.
5390 * \throw If the MED file is not readable.
5391 * \throw If there is no mesh named \a mName in the MED file.
5392 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5393 * \throw If no field of \a this is lying on the mesh \a mName.
5394 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5396 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5398 MCAuto<MEDFileMesh> mm;
5400 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
5402 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
5403 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
5407 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5408 * \param [in] type - a spatial discretization of the new field.
5409 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5410 * \param [in] renumPol - specifies how to permute values of the result field according to
5411 * the optional numbers of cells and nodes, if any. The valid values are
5412 * - 0 - do not permute.
5413 * - 1 - permute cells.
5414 * - 2 - permute nodes.
5415 * - 3 - permute cells and nodes.
5417 * \param [in] glob - the global data storing profiles and localization.
5418 * \param [in] mesh - the supporting mesh.
5419 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5420 * caller is to delete this field using decrRef() as it is no more needed.
5421 * \throw If the MED file is not readable.
5422 * \throw If no field of \a this is lying on \a mesh.
5423 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5424 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5426 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5428 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax,false));
5429 const DataArrayInt *d(mesh->getNumberFieldAtLevel(meshDimRelToMax)),*e(mesh->getNumberFieldAtLevel(1));
5430 if(meshDimRelToMax==1)
5431 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
5432 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
5436 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
5438 * \param [in] type - a spatial discretization of the new field.
5439 * \param [in] mName - a name of the supporting mesh.
5440 * \param [in] renumPol - specifies how to permute values of the result field according to
5441 * the optional numbers of cells and nodes, if any. The valid values are
5442 * - 0 - do not permute.
5443 * - 1 - permute cells.
5444 * - 2 - permute nodes.
5445 * - 3 - permute cells and nodes.
5447 * \param [in] glob - the global data storing profiles and localization.
5448 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5449 * caller is to delete this field using decrRef() as it is no more needed.
5450 * \throw If the MED file is not readable.
5451 * \throw If there is no mesh named \a mName in the MED file.
5452 * \throw If there are no mesh entities in the mesh.
5453 * \throw If no field values of the given \a type are available.
5455 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5457 MCAuto<MEDFileMesh> mm;
5459 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
5461 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
5462 int absDim=getDimension();
5463 int meshDimRelToMax=absDim-mm->getMeshDimension();
5464 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
5468 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5469 * \param [in] type - a spatial discretization of the new field.
5470 * \param [in] renumPol - specifies how to permute values of the result field according to
5471 * the optional numbers of cells and nodes, if any. The valid values are
5472 * - 0 - do not permute.
5473 * - 1 - permute cells.
5474 * - 2 - permute nodes.
5475 * - 3 - permute cells and nodes.
5477 * \param [in] glob - the global data storing profiles and localization.
5478 * \param [in] mesh - the supporting mesh.
5479 * \param [in] cellRenum - the cell numbers array used for permutation of the result
5480 * field according to \a renumPol.
5481 * \param [in] nodeRenum - the node numbers array used for permutation of the result
5482 * field according to \a renumPol.
5483 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5484 * caller is to delete this field using decrRef() as it is no more needed.
5485 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5486 * \throw If no field of \a this is lying on \a mesh.
5487 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5489 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
5491 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
5492 int meshId=getMeshIdFromMeshName(mesh->getName());
5494 MCAuto<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
5499 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5506 throw INTERP_KERNEL::Exception(msg1);
5507 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5510 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
5512 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5513 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
5514 throw INTERP_KERNEL::Exception(oss.str());
5516 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
5517 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
5518 std::vector<DataArray *> arrOut2(1,arrOut);
5519 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
5520 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
5521 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
5528 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5530 throw INTERP_KERNEL::Exception(msg1);
5533 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
5535 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5536 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
5537 throw INTERP_KERNEL::Exception(oss.str());
5539 MCAuto<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
5540 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
5541 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
5542 ret->renumberNodes(nodeRenumSafe->getConstPointer());
5547 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
5552 * Returns values and a profile of the field of a given type lying on a given support.
5553 * \param [in] type - a spatial discretization of the field.
5554 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5555 * \param [in] mesh - the supporting mesh.
5556 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
5557 * field of interest lies on. If the field lies on all entities of the given
5558 * dimension, all ids in \a pfl are zero. The caller is to delete this array
5559 * using decrRef() as it is no more needed.
5560 * \param [in] glob - the global data storing profiles and localization.
5561 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
5562 * field. The caller is to delete this array using decrRef() as it is no more needed.
5563 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
5564 * \throw If no field of \a this is lying on \a mesh.
5565 * \throw If no field values of the given \a type are available.
5567 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
5569 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
5570 int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
5571 MCAuto<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
5572 ret->setName(nasc.getName().c_str());
5576 //= MEDFileField1TSWithoutSDA
5579 * Throws if a given value is not a valid (non-extended) relative dimension.
5580 * \param [in] meshDimRelToMax - the relative dimension value.
5581 * \throw If \a meshDimRelToMax > 0.
5583 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
5585 if(meshDimRelToMax>0)
5586 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
5590 * Checks if elements of a given mesh are in the order suitable for writing
5591 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
5592 * vector describing types of elements and their number.
5593 * \param [in] mesh - the mesh to check.
5594 * \return std::vector<int> - a vector holding for each element type (1) item of
5595 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
5596 * These values are in full-interlace mode.
5597 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
5599 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
5602 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
5603 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
5604 int nbOfTypes=geoTypes.size();
5605 std::vector<int> code(3*nbOfTypes);
5606 MCAuto<DataArrayInt> arr1=DataArrayInt::New();
5607 arr1->alloc(nbOfTypes,1);
5608 int *arrPtr=arr1->getPointer();
5609 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
5610 for(int i=0;i<nbOfTypes;i++,it++)
5611 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
5612 MCAuto<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
5613 const int *arrPtr2=arr2->getConstPointer();
5615 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
5618 int nbCells=mesh->getNumberOfCellsWithType(*it);
5619 code[3*pos]=(int)(*it);
5620 code[3*pos+1]=nbCells;
5621 code[3*pos+2]=-1;//no profiles
5623 std::vector<const DataArrayInt *> idsPerType;//no profiles
5624 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
5628 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
5633 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5635 return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5639 * Returns all attributes and values of parts of \a this field lying on a given mesh.
5640 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
5641 * item of every of returned sequences refers to the _i_-th part of \a this field.
5642 * Thus all sequences returned by this method are of the same length equal to number
5643 * of different types of supporting entities.<br>
5644 * A field part can include sub-parts with several different spatial discretizations,
5645 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
5646 * for example. Hence, some of the returned sequences contains nested sequences, and an item
5647 * of a nested sequence corresponds to a type of spatial discretization.<br>
5648 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
5649 * The overhead is due to selecting values into new instances of DataArrayDouble.
5650 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
5651 * for the case with only one underlying mesh. (Actually, the number of meshes is
5652 * not checked if \a mname == \c NULL).
5653 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
5654 * a field part is returned.
5655 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
5656 * A field part can include sub-parts with several different spatial discretizations,
5657 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and
5658 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT" for example.
5659 * This sequence is of the same length as \a types.
5660 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
5661 * discretization. A profile name can be empty.
5662 * Length of this and of nested sequences is the same as that of \a typesF.
5663 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
5664 * discretization. A localization name can be empty.
5665 * Length of this and of nested sequences is the same as that of \a typesF.
5666 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
5667 * per each type of spatial discretization within one mesh entity type.
5668 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
5669 * Length of this and of nested sequences is the same as that of \a typesF.
5670 * \throw If no field is lying on \a mname.
5672 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
5676 meshId=getMeshIdFromMeshName(mname);
5678 if(_field_per_mesh.empty())
5679 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
5680 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
5681 int nbOfRet=ret0.size();
5682 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
5683 for(int i=0;i<nbOfRet;i++)
5685 const std::vector< std::pair<int,int> >& p=ret0[i];
5686 int nbOfRet1=p.size();
5687 ret[i].resize(nbOfRet1);
5688 for(int j=0;j<nbOfRet1;j++)
5690 DataArrayDouble *tmp=_arr->selectByTupleIdSafeSlice(p[j].first,p[j].second,1);
5697 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
5702 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
5704 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
5705 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5706 ret->deepCpyLeavesFrom(*this);
5707 const DataArrayDouble *arr(_arr);
5710 MCAuto<DataArrayInt> arr2(arr->convertToIntArr());
5711 ret->setArray(arr2);
5717 * Returns a pointer to the underground DataArrayDouble instance and a
5718 * sequence describing parameters of a support of each part of \a this field. The
5719 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5720 * direct access to the field values. This method is intended for the field lying on one
5722 * \param [in,out] entries - the sequence describing parameters of a support of each
5723 * part of \a this field. Each item of this sequence consists of two parts. The
5724 * first part describes a type of mesh entity and an id of discretization of a
5725 * current field part. The second part describes a range of values [begin,end)
5726 * within the returned array relating to the current field part.
5727 * \return DataArrayDouble * - the pointer to the field values array.
5728 * \throw If the number of underlying meshes is not equal to 1.
5729 * \throw If no field values are available.
5730 * \sa getUndergroundDataArray()
5732 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5734 if(_field_per_mesh.size()!=1)
5735 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5736 if(_field_per_mesh[0]==0)
5737 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5738 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5739 return getUndergroundDataArrayTemplate();
5743 * Returns a pointer to the underground DataArrayDouble instance and a
5744 * sequence describing parameters of a support of each part of \a this field. The
5745 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5746 * direct access to the field values. This method is intended for the field lying on one
5748 * \param [in,out] entries - the sequence describing parameters of a support of each
5749 * part of \a this field. Each item of this sequence consists of two parts. The
5750 * first part describes a type of mesh entity and an id of discretization of a
5751 * current field part. The second part describes a range of values [begin,end)
5752 * within the returned array relating to the current field part.
5753 * \return DataArrayDouble * - the pointer to the field values array.
5754 * \throw If the number of underlying meshes is not equal to 1.
5755 * \throw If no field values are available.
5756 * \sa getUndergroundDataArray()
5758 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5760 return getUndergroundDataArrayDoubleExt(entries);
5763 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<double>(fieldName,csit,iteration,order)
5765 DataArrayDouble *arr(getOrCreateAndGetArrayTemplate());
5766 arr->setInfoAndChangeNbOfCompo(infos);
5769 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<double>()
5773 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
5775 MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
5776 ret->deepCpyLeavesFrom(*this);
5780 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCopy() const
5782 MCAuto<MEDFileField1TSWithoutSDA> ret(shallowCpy());
5783 if(_arr.isNotNull())
5784 ret->_arr=_arr->deepCopy();
5788 //= MEDFileIntField1TSWithoutSDA
5790 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5792 return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5795 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<int>()
5799 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order,
5800 const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<int>(fieldName,csit,iteration,order)
5802 DataArrayInt *arr(getOrCreateAndGetArrayTemplate());
5803 arr->setInfoAndChangeNbOfCompo(infos);
5806 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
5811 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const
5813 MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
5814 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5815 ret->deepCpyLeavesFrom(*this);
5816 const DataArrayInt *arr(_arr);
5819 MCAuto<DataArrayDouble> arr2(arr->convertToDblArr());
5820 ret->setArray(arr2);
5826 * Returns a pointer to the underground DataArrayInt instance and a
5827 * sequence describing parameters of a support of each part of \a this field. The
5828 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5829 * direct access to the field values. This method is intended for the field lying on one
5831 * \param [in,out] entries - the sequence describing parameters of a support of each
5832 * part of \a this field. Each item of this sequence consists of two parts. The
5833 * first part describes a type of mesh entity and an id of discretization of a
5834 * current field part. The second part describes a range of values [begin,end)
5835 * within the returned array relating to the current field part.
5836 * \return DataArrayInt * - the pointer to the field values array.
5837 * \throw If the number of underlying meshes is not equal to 1.
5838 * \throw If no field values are available.
5839 * \sa getUndergroundDataArray()
5841 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5843 return getUndergroundDataArrayIntExt(entries);
5847 * Returns a pointer to the underground DataArrayInt instance and a
5848 * sequence describing parameters of a support of each part of \a this field. The
5849 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5850 * direct access to the field values. This method is intended for the field lying on one
5852 * \param [in,out] entries - the sequence describing parameters of a support of each
5853 * part of \a this field. Each item of this sequence consists of two parts. The
5854 * first part describes a type of mesh entity and an id of discretization of a
5855 * current field part. The second part describes a range of values [begin,end)
5856 * within the returned array relating to the current field part.
5857 * \return DataArrayInt * - the pointer to the field values array.
5858 * \throw If the number of underlying meshes is not equal to 1.
5859 * \throw If no field values are available.
5860 * \sa getUndergroundDataArray()
5862 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5864 if(_field_per_mesh.size()!=1)
5865 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5866 if(_field_per_mesh[0]==0)
5867 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5868 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5869 return getUndergroundDataArrayTemplate();
5872 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5874 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5875 ret->deepCpyLeavesFrom(*this);
5879 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCopy() const
5881 MCAuto<MEDFileIntField1TSWithoutSDA> ret(shallowCpy());
5882 if(_arr.isNotNull())
5883 ret->_arr=_arr->deepCopy();
5887 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5891 //= MEDFileAnyTypeField1TS
5893 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
5895 med_field_type typcha;
5897 std::vector<std::string> infos;
5898 std::string dtunit,fieldName;
5899 LocateField2(fid,0,true,fieldName,typcha,infos,dtunit);
5900 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5905 ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5910 ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5915 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] !";
5916 throw INTERP_KERNEL::Exception(oss.str());
5919 ret->setDtUnit(dtunit.c_str());
5920 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5922 med_int numdt,numit;
5924 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5925 ret->setTime(numdt,numit,dt);
5928 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5930 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5934 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
5935 try:MEDFileFieldGlobsReal(fid)
5937 _content=BuildContentFrom(fid,loadAll,ms);
5940 catch(INTERP_KERNEL::Exception& e)
5945 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5947 med_field_type typcha;
5948 std::vector<std::string> infos;
5951 int nbSteps=LocateField(fid,fieldName,iii,typcha,infos,dtunit);
5952 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5957 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5962 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5967 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] !";
5968 throw INTERP_KERNEL::Exception(oss.str());
5971 ret->setDtUnit(dtunit.c_str());
5972 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5976 std::ostringstream oss; oss << "MEDFileField1TS(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5977 throw INTERP_KERNEL::Exception(oss.str());
5980 med_int numdt,numit;
5982 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5983 ret->setTime(numdt,numit,dt);
5986 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5988 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5992 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5993 try:MEDFileFieldGlobsReal(fid)
5995 _content=BuildContentFrom(fid,fieldName,loadAll,ms);
5998 catch(INTERP_KERNEL::Exception& e)
6003 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c)
6006 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
6007 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
6009 MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
6010 ret->_content=c; c->incrRef();
6013 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
6015 MCAuto<MEDFileIntField1TS> ret(MEDFileIntField1TS::New());
6016 ret->_content=c; c->incrRef();
6019 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
6022 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, med_idt fid)
6024 MEDFileAnyTypeField1TS *ret(BuildNewInstanceFromContent(c));
6025 ret->setFileName(FileNameFromFID(fid));
6029 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
6031 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6032 return New(fid,loadAll);
6035 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, bool loadAll)
6037 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
6038 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
6039 ret->loadGlobals(fid);
6043 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6045 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6046 return New(fid,fieldName,loadAll);
6049 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
6051 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0));
6052 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
6053 ret->loadGlobals(fid);
6057 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6059 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6060 return New(fid,fieldName,iteration,order,loadAll);
6063 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
6065 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0));
6066 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
6067 ret->loadGlobals(fid);
6071 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6073 med_field_type typcha;
6074 std::vector<std::string> infos;
6077 int nbOfStep2(LocateField(fid,fieldName,iii,typcha,infos,dtunit));
6078 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
6083 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
6088 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
6093 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] !";
6094 throw INTERP_KERNEL::Exception(oss.str());
6097 ret->setDtUnit(dtunit.c_str());
6098 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
6101 std::vector< std::pair<int,int> > dtits(nbOfStep2);
6102 for(int i=0;i<nbOfStep2 && !found;i++)
6104 med_int numdt,numit;
6106 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt));
6107 if(numdt==iteration && numit==order)
6113 dtits[i]=std::pair<int,int>(numdt,numit);
6117 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available iterations are : ";
6118 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
6119 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
6120 throw INTERP_KERNEL::Exception(oss.str());
6123 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
6125 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
6129 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6130 try:MEDFileFieldGlobsReal(fid)
6132 _content=BuildContentFrom(fid,fieldName,iteration,order,loadAll,ms);
6135 catch(INTERP_KERNEL::Exception& e)
6141 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6142 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6144 * \warning this is a shallow copy constructor
6146 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
6148 if(!shallowCopyOfContent)
6150 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
6151 otherPtr->incrRef();
6152 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
6156 _content=other.shallowCpy();
6160 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)
6164 int nbFields=MEDnField(fid);
6165 if(fieldIdCFormat>=nbFields)
6167 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << FileNameFromFID(fid) << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
6168 throw INTERP_KERNEL::Exception(oss.str());
6171 int ncomp(MEDfieldnComponent(fid,fieldIdCFormat+1));
6172 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
6173 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
6174 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
6175 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
6176 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
6179 MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep));
6180 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
6181 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
6182 infos.clear(); infos.resize(ncomp);
6183 for(int j=0;j<ncomp;j++)
6184 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
6189 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
6192 * \return in case of success the number of time steps available for the field with name \a fieldName.
6194 int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const std::string& fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
6196 int nbFields=MEDnField(fid);
6198 std::vector<std::string> fns(nbFields);
6200 for(int i=0;i<nbFields && !found;i++)
6203 nbOfStep2=LocateField2(fid,i,false,tmp,typcha,infos,dtunitOut);
6205 found=(tmp==fieldName);
6211 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available fields are : ";
6212 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
6213 oss << "\"" << *it << "\" ";
6214 throw INTERP_KERNEL::Exception(oss.str());
6220 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
6221 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
6222 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
6223 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
6224 * to keep a valid instance.
6225 * 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.
6226 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
6227 * 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.
6229 * \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.
6230 * \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.
6231 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
6232 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
6233 * \param [in] newLocName is the new localization name.
6234 * \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.
6235 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
6237 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
6239 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6240 std::string oldPflName=disc->getProfile();
6241 std::vector<std::string> vv=getPflsReallyUsedMulti();
6242 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
6243 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
6245 disc->setProfile(newPflName);
6246 DataArrayInt *pfl=getProfile(oldPflName.c_str());
6247 pfl->setName(newPflName);
6251 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
6252 throw INTERP_KERNEL::Exception(oss.str());
6257 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
6258 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
6259 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
6260 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
6261 * to keep a valid instance.
6262 * 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.
6263 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
6264 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
6265 * 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.
6267 * \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.
6268 * \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.
6269 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
6270 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
6271 * \param [in] newLocName is the new localization name.
6272 * \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.
6273 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
6275 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
6277 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6278 std::string oldLocName=disc->getLocalization();
6279 std::vector<std::string> vv=getLocsReallyUsedMulti();
6280 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
6281 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
6283 disc->setLocalization(newLocName);
6284 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
6285 loc.setName(newLocName);
6289 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
6290 throw INTERP_KERNEL::Exception(oss.str());
6294 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
6296 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
6298 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
6302 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
6304 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
6306 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
6311 * This method alloc the arrays and load potentially huge arrays contained in this field.
6312 * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
6313 * This method can be also called to refresh or reinit values from a file.
6315 * \throw If the fileName is not set or points to a non readable MED file.
6316 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
6318 void MEDFileAnyTypeField1TS::loadArrays()
6320 if(getFileName().empty())
6321 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
6322 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
6323 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
6327 * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
6328 * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
6329 * this method does not throw if \a this does not come from file read.
6331 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
6333 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
6335 if(!getFileName().empty())
6337 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
6338 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
6343 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
6344 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
6345 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
6347 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
6349 void MEDFileAnyTypeField1TS::unloadArrays()
6351 contentNotNullBase()->unloadArrays();
6355 * 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.
6356 * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
6357 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
6359 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
6361 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
6363 if(!getFileName().empty())
6364 contentNotNullBase()->unloadArrays();
6367 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
6369 int nbComp(getNumberOfComponents());
6370 INTERP_KERNEL::AutoPtr<char> comp(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
6371 INTERP_KERNEL::AutoPtr<char> unit(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
6372 for(int i=0;i<nbComp;i++)
6374 std::string info=getInfo()[i];
6376 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
6377 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
6378 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
6380 if(getName().empty())
6381 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
6382 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
6383 writeGlobals(fid,*this);
6384 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
6387 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
6389 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
6392 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
6394 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
6395 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
6400 * Returns a string describing \a this field. This string is outputted
6401 * by \c print Python command.
6403 std::string MEDFileAnyTypeField1TS::simpleRepr() const
6405 std::ostringstream oss;
6406 contentNotNullBase()->simpleRepr(0,oss,-1);
6407 simpleReprGlobs(oss);
6412 * This method returns all profiles whose name is non empty used.
6413 * \b WARNING If profile is used several times it will be reported \b only \b once.
6414 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
6416 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
6418 return contentNotNullBase()->getPflsReallyUsed2();
6422 * This method returns all localizations whose name is non empty used.
6423 * \b WARNING If localization is used several times it will be reported \b only \b once.
6425 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
6427 return contentNotNullBase()->getLocsReallyUsed2();
6431 * This method returns all profiles whose name is non empty used.
6432 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
6434 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
6436 return contentNotNullBase()->getPflsReallyUsedMulti2();
6440 * This method returns all localizations whose name is non empty used.
6441 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
6443 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
6445 return contentNotNullBase()->getLocsReallyUsedMulti2();
6448 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6450 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
6453 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6455 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
6458 int MEDFileAnyTypeField1TS::getDimension() const
6460 return contentNotNullBase()->getDimension();
6463 int MEDFileAnyTypeField1TS::getIteration() const
6465 return contentNotNullBase()->getIteration();
6468 int MEDFileAnyTypeField1TS::getOrder() const
6470 return contentNotNullBase()->getOrder();
6473 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
6475 return contentNotNullBase()->getTime(iteration,order);
6478 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
6480 contentNotNullBase()->setTime(iteration,order,val);
6483 std::string MEDFileAnyTypeField1TS::getName() const
6485 return contentNotNullBase()->getName();
6488 void MEDFileAnyTypeField1TS::setName(const std::string& name)
6490 contentNotNullBase()->setName(name);
6493 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
6495 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
6498 std::string MEDFileAnyTypeField1TS::getDtUnit() const
6500 return contentNotNullBase()->getDtUnit();
6503 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
6505 contentNotNullBase()->setDtUnit(dtUnit);
6508 std::string MEDFileAnyTypeField1TS::getMeshName() const
6510 return contentNotNullBase()->getMeshName();
6513 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
6515 contentNotNullBase()->setMeshName(newMeshName);
6518 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
6520 return contentNotNullBase()->changeMeshNames(modifTab);
6523 int MEDFileAnyTypeField1TS::getMeshIteration() const
6525 return contentNotNullBase()->getMeshIteration();
6528 int MEDFileAnyTypeField1TS::getMeshOrder() const
6530 return contentNotNullBase()->getMeshOrder();
6533 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
6535 return contentNotNullBase()->getNumberOfComponents();
6538 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
6540 return contentNotNullBase()->isDealingTS(iteration,order);
6543 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
6545 return contentNotNullBase()->getDtIt();
6548 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
6550 contentNotNullBase()->fillIteration(p);
6553 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
6555 contentNotNullBase()->fillTypesOfFieldAvailable(types);
6558 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
6560 contentNotNullBase()->setInfo(infos);
6563 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
6565 return contentNotNullBase()->getInfo();
6567 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
6569 return contentNotNullBase()->getInfo();
6572 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
6574 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
6577 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
6579 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6582 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
6584 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6587 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
6589 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
6592 void MEDFileAnyTypeField1TS::convertMedBallIntoClassic()
6594 return contentNotNullBase()->convertMedBallIntoClassic();
6597 void MEDFileAnyTypeField1TS::makeReduction(INTERP_KERNEL::NormalizedCellType ct, TypeOfField tof, const DataArrayInt *pfl)
6599 return contentNotNullBase()->makeReduction(ct,tof,pfl);
6602 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
6604 return contentNotNullBase()->getTypesOfFieldAvailable();
6607 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,
6608 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6610 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
6614 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
6615 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
6616 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
6618 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
6620 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6622 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
6623 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
6624 std::size_t sz(contentsSplit.size());
6625 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6626 for(std::size_t i=0;i<sz;i++)
6628 ret[i]=shallowCpy();
6629 ret[i]->_content=contentsSplit[i];
6635 * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
6636 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6638 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
6640 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6642 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
6643 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
6644 std::size_t sz(contentsSplit.size());
6645 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6646 for(std::size_t i=0;i<sz;i++)
6648 ret[i]=shallowCpy();
6649 ret[i]->_content=contentsSplit[i];
6655 * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this.
6656 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6658 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const
6660 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6662 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !");
6663 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
6664 std::size_t sz(contentsSplit.size());
6665 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6666 for(std::size_t i=0;i<sz;i++)
6668 ret[i]=shallowCpy();
6669 ret[i]->_content=contentsSplit[i];
6674 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCopy() const
6676 MCAuto<MEDFileAnyTypeField1TS> ret=shallowCpy();
6677 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
6678 ret->_content=_content->deepCopy();
6679 ret->deepCpyGlobs(*this);
6683 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
6685 return contentNotNullBase()->copyTinyInfoFrom(field,arr);
6691 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6692 * the first field that has been read from a specified MED file.
6693 * \param [in] fileName - the name of the MED file to read.
6694 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6695 * is to delete this field using decrRef() as it is no more needed.
6696 * \throw If reading the file fails.
6698 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll)
6700 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6701 return New(fid,loadAll);
6704 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, bool loadAll)
6706 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,loadAll,0));
6707 ret->contentNotNull();
6712 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6713 * a given field that has been read from a specified MED file.
6714 * \param [in] fileName - the name of the MED file to read.
6715 * \param [in] fieldName - the name of the field to read.
6716 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6717 * is to delete this field using decrRef() as it is no more needed.
6718 * \throw If reading the file fails.
6719 * \throw If there is no field named \a fieldName in the file.
6721 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6723 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6724 return New(fid,fieldName,loadAll);
6727 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
6729 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,fieldName,loadAll,0));
6730 ret->contentNotNull();
6735 * Returns a new instance of MEDFileField1TS holding data of a given time step of
6736 * a given field that has been read from a specified MED file.
6737 * \param [in] fileName - the name of the MED file to read.
6738 * \param [in] fieldName - the name of the field to read.
6739 * \param [in] iteration - the iteration number of a required time step.
6740 * \param [in] order - the iteration order number of required time step.
6741 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6742 * is to delete this field using decrRef() as it is no more needed.
6743 * \throw If reading the file fails.
6744 * \throw If there is no field named \a fieldName in the file.
6745 * \throw If the required time step is missing from the file.
6747 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6749 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6750 return New(fid,fieldName,iteration,order,loadAll);
6753 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
6755 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,fieldName,iteration,order,loadAll,0));
6756 ret->contentNotNull();
6761 * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6762 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6764 * Returns a new instance of MEDFileField1TS holding either a shallow copy
6765 * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
6766 * \warning this is a shallow copy constructor
6767 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
6768 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
6769 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6770 * is to delete this field using decrRef() as it is no more needed.
6772 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6774 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(other,shallowCopyOfContent));
6775 ret->contentNotNull();
6780 * Returns a new empty instance of MEDFileField1TS.
6781 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6782 * is to delete this field using decrRef() as it is no more needed.
6784 MEDFileField1TS *MEDFileField1TS::New()
6786 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS);
6787 ret->contentNotNull();
6792 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
6793 * following the given input policy.
6795 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6796 * By default (true) the globals are deeply copied.
6797 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
6799 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
6801 MCAuto<MEDFileIntField1TS> ret;
6802 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6805 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
6807 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
6808 MCAuto<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
6809 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc));
6812 ret=MEDFileIntField1TS::New();
6814 ret->deepCpyGlobs(*this);
6816 ret->shallowCpyGlobs(*this);
6820 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const
6822 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6824 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
6825 const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
6827 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is not null but it is not of type double ! Reason is maybe that the read field has not the type FLOAT64 !");
6831 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull()
6833 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6835 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
6836 MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
6838 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is not null but it is not of type double ! Reason is maybe that the read field has not the type FLOAT64 !");
6842 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
6845 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
6847 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
6848 DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6850 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6851 f->setArray(arrOutC);
6854 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MCAuto<DataArray>& arr)
6857 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
6858 DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6860 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6866 * Return an extraction of \a this using \a extractDef map to specify the extraction.
6867 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
6869 * \return A new object that the caller is responsible to deallocate.
6870 * \sa MEDFileUMesh::deduceNodeSubPartFromCellSubPart , MEDFileUMesh::extractPart
6872 MEDFileField1TS *MEDFileField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
6875 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : input mesh is NULL !");
6876 MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
6877 std::vector<TypeOfField> tof(getTypesOfFieldAvailable());
6878 for(std::vector<TypeOfField>::const_iterator it0=tof.begin();it0!=tof.end();it0++)
6880 if((*it0)!=ON_NODES)
6882 std::vector<int> levs;
6883 getNonEmptyLevels(mm->getName(),levs);
6884 for(std::vector<int>::const_iterator lev=levs.begin();lev!=levs.end();lev++)
6886 std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(*lev));
6887 if(it2!=extractDef.end())
6889 MCAuto<DataArrayInt> t((*it2).second);
6891 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6892 MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_CELLS,(*lev),mm));
6893 MCAuto<MEDCouplingFieldDouble> fOut(f->buildSubPart(t));
6894 ret->setFieldNoProfileSBT(fOut);
6900 std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(1));
6901 if(it2==extractDef.end())
6902 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a NODE field and no extract array available for NODE !");
6903 MCAuto<DataArrayInt> t((*it2).second);
6905 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6906 MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_NODES,0,mm));
6907 MCAuto<MEDCouplingFieldDouble> fOut(f->deepCopy());
6908 DataArrayDouble *arr(f->getArray());
6909 MCAuto<DataArrayDouble> newArr(arr->selectByTupleIdSafe(t->begin(),t->end()));
6910 fOut->setArray(newArr);
6911 ret->setFieldNoProfileSBT(fOut);
6917 MEDFileField1TS::MEDFileField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
6918 try:MEDFileAnyTypeField1TS(fid,loadAll,ms)
6921 catch(INTERP_KERNEL::Exception& e)
6924 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6925 try:MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms)
6928 catch(INTERP_KERNEL::Exception& e)
6931 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6932 try:MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms)
6935 catch(INTERP_KERNEL::Exception& e)
6939 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6940 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6942 * \warning this is a shallow copy constructor
6944 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6945 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6948 catch(INTERP_KERNEL::Exception& e)
6951 MEDFileField1TS::MEDFileField1TS()
6953 _content=new MEDFileField1TSWithoutSDA;
6957 * This is the simplest version to fetch a field for MED structure. One drawback : if \a this is a complex field (multi spatial discretization inside a same field) this method will throw exception and more advance
6958 * method should be called (getFieldOnMeshAtLevel for example).
6959 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
6961 * \param [in] mesh - the mesh the field is lying on
6962 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6963 * caller is to delete this field using decrRef() as it is no more needed.
6965 MEDCouplingFieldDouble *MEDFileField1TS::field(const MEDFileMesh *mesh) const
6967 MCAuto<DataArray> arrOut;
6968 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
6969 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6974 * Returns a new MEDCouplingFieldDouble of a given type lying on
6975 * mesh entities of a given dimension of the first mesh in MED file. If \a this field
6976 * has not been constructed via file reading, an exception is thrown.
6977 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6978 * \param [in] type - a spatial discretization of interest.
6979 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6980 * \param [in] renumPol - specifies how to permute values of the result field according to
6981 * the optional numbers of cells and nodes, if any. The valid values are
6982 * - 0 - do not permute.
6983 * - 1 - permute cells.
6984 * - 2 - permute nodes.
6985 * - 3 - permute cells and nodes.
6987 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6988 * caller is to delete this field using decrRef() as it is no more needed.
6989 * \throw If \a this field has not been constructed via file reading.
6990 * \throw If the MED file is not readable.
6991 * \throw If there is no mesh in the MED file.
6992 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6993 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6994 * \sa getFieldOnMeshAtLevel()
6996 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6998 if(getFileName().empty())
6999 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7000 MCAuto<DataArray> arrOut;
7001 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
7002 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
7007 * Returns a new MEDCouplingFieldDouble of a given type lying on
7008 * the top level cells of the first mesh in MED file. If \a this field
7009 * has not been constructed via file reading, an exception is thrown.
7010 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7011 * \param [in] type - a spatial discretization of interest.
7012 * \param [in] renumPol - specifies how to permute values of the result field according to
7013 * the optional numbers of cells and nodes, if any. The valid values are
7014 * - 0 - do not permute.
7015 * - 1 - permute cells.
7016 * - 2 - permute nodes.
7017 * - 3 - permute cells and nodes.
7019 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
7020 * caller is to delete this field using decrRef() as it is no more needed.
7021 * \throw If \a this field has not been constructed via file reading.
7022 * \throw If the MED file is not readable.
7023 * \throw If there is no mesh in the MED file.
7024 * \throw If no field values of the given \a type.
7025 * \throw If no field values lying on the top level support.
7026 * \sa getFieldAtLevel()
7028 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
7030 if(getFileName().empty())
7031 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
7032 MCAuto<DataArray> arrOut;
7033 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
7034 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
7039 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
7040 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7041 * \param [in] type - a spatial discretization of the new field.
7042 * \param [in] mesh - the supporting mesh.
7043 * \param [in] renumPol - specifies how to permute values of the result field according to
7044 * the optional numbers of cells and nodes, if any. The valid values are
7045 * - 0 - do not permute.
7046 * - 1 - permute cells.
7047 * - 2 - permute nodes.
7048 * - 3 - permute cells and nodes.
7050 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
7051 * caller is to delete this field using decrRef() as it is no more needed.
7052 * \throw If no field of \a this is lying on \a mesh.
7053 * \throw If the mesh is empty.
7054 * \throw If no field values of the given \a type are available.
7055 * \sa getFieldAtLevel()
7056 * \sa getFieldOnMeshAtLevel()
7058 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
7060 MCAuto<DataArray> arrOut;
7061 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
7062 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
7067 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
7068 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7069 * \param [in] type - a spatial discretization of interest.
7070 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7071 * \param [in] mesh - the supporting mesh.
7072 * \param [in] renumPol - specifies how to permute values of the result field according to
7073 * the optional numbers of cells and nodes, if any. The valid values are
7074 * - 0 - do not permute.
7075 * - 1 - permute cells.
7076 * - 2 - permute nodes.
7077 * - 3 - permute cells and nodes.
7079 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
7080 * caller is to delete this field using decrRef() as it is no more needed.
7081 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7082 * \throw If no field of \a this is lying on \a mesh.
7083 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7084 * \sa getFieldAtLevel()
7085 * \sa getFieldOnMeshAtLevel()
7087 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
7089 MCAuto<DataArray> arrOut;
7090 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
7091 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
7096 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
7097 * This method is called "Old" because in MED3 norm a field has only one meshName
7098 * attached, so this method is for readers of MED2 files. If \a this field
7099 * has not been constructed via file reading, an exception is thrown.
7100 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7101 * \param [in] type - a spatial discretization of interest.
7102 * \param [in] mName - a name of the supporting mesh.
7103 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7104 * \param [in] renumPol - specifies how to permute values of the result field according to
7105 * the optional numbers of cells and nodes, if any. The valid values are
7106 * - 0 - do not permute.
7107 * - 1 - permute cells.
7108 * - 2 - permute nodes.
7109 * - 3 - permute cells and nodes.
7111 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
7112 * caller is to delete this field using decrRef() as it is no more needed.
7113 * \throw If the MED file is not readable.
7114 * \throw If there is no mesh named \a mName in the MED file.
7115 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7116 * \throw If \a this field has not been constructed via file reading.
7117 * \throw If no field of \a this is lying on the mesh named \a mName.
7118 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7119 * \sa getFieldAtLevel()
7121 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
7123 if(getFileName().empty())
7124 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7125 MCAuto<DataArray> arrOut;
7126 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull()));
7127 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
7132 * Returns values and a profile of the field of a given type lying on a given support.
7133 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7134 * \param [in] type - a spatial discretization of the field.
7135 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7136 * \param [in] mesh - the supporting mesh.
7137 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
7138 * field of interest lies on. If the field lies on all entities of the given
7139 * dimension, all ids in \a pfl are zero. The caller is to delete this array
7140 * using decrRef() as it is no more needed.
7141 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
7142 * field. The caller is to delete this array using decrRef() as it is no more needed.
7143 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7144 * \throw If no field of \a this is lying on \a mesh.
7145 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7147 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
7149 MCAuto<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
7150 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
7154 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
7155 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
7156 * "Sort By Type"), if not, an exception is thrown.
7157 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7158 * \param [in] field - the field to add to \a this.
7159 * \throw If the name of \a field is empty.
7160 * \throw If the data array of \a field is not set.
7161 * \throw If the data array is already allocated but has different number of components
7163 * \throw If the underlying mesh of \a field has no name.
7164 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
7166 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
7169 contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
7173 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
7174 * can be an aggregation of several MEDCouplingFieldDouble instances.
7175 * The mesh support of input parameter \a field is ignored here, it can be NULL.
7176 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
7179 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
7180 * A new profile is added only if no equal profile is missing.
7181 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7182 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
7183 * \param [in] mesh - the supporting mesh of \a field.
7184 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
7185 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
7186 * \throw If either \a field or \a mesh or \a profile has an empty name.
7187 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7188 * \throw If the data array of \a field is not set.
7189 * \throw If the data array of \a this is already allocated but has different number of
7190 * components than \a field.
7191 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
7192 * \sa setFieldNoProfileSBT()
7194 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
7197 contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
7200 MEDFileField1TS *MEDFileField1TS::shallowCpy() const
7202 return new MEDFileField1TS(*this);
7205 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const
7207 return contentNotNull()->getUndergroundDataArrayTemplate();
7210 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7212 return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
7215 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
7216 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
7218 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
7221 //= MEDFileIntField1TS
7223 MEDFileIntField1TS *MEDFileIntField1TS::New()
7225 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS);
7226 ret->contentNotNull();
7230 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll)
7232 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
7233 return MEDFileIntField1TS::New(fid,loadAll);
7236 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, bool loadAll)
7238 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,loadAll,0));
7239 ret->contentNotNull();
7243 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
7245 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
7246 return MEDFileIntField1TS::New(fid,fieldName,loadAll);
7249 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
7251 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,loadAll,0));
7252 ret->contentNotNull();
7256 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
7258 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
7259 return MEDFileIntField1TS::New(fid,fieldName,iteration,order,loadAll);
7262 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
7264 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,iteration,order,loadAll,0));
7265 ret->contentNotNull();
7269 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
7271 MCAuto<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
7272 ret->contentNotNull();
7276 MEDFileIntField1TS::MEDFileIntField1TS()
7278 _content=new MEDFileIntField1TSWithoutSDA;
7281 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
7282 try:MEDFileAnyTypeField1TS(fid,loadAll,ms)
7285 catch(INTERP_KERNEL::Exception& e)
7288 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
7289 try:MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms)
7292 catch(INTERP_KERNEL::Exception& e)
7295 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
7296 try:MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms)
7299 catch(INTERP_KERNEL::Exception& e)
7303 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
7304 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
7306 * \warning this is a shallow copy constructor
7308 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
7312 MEDFileIntField1TS *MEDFileIntField1TS::shallowCpy() const
7314 return new MEDFileIntField1TS(*this);
7318 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
7319 * following the given input policy.
7321 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
7322 * By default (true) the globals are deeply copied.
7323 * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
7325 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const
7327 MCAuto<MEDFileField1TS> ret;
7328 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
7331 const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
7333 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
7334 MCAuto<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
7335 ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc));
7338 ret=MEDFileField1TS::New();
7340 ret->deepCpyGlobs(*this);
7342 ret->shallowCpyGlobs(*this);
7347 * Adds a MEDCouplingFieldInt to \a this. The underlying mesh of the given field is
7348 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
7349 * "Sort By Type"), if not, an exception is thrown.
7350 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7351 * \param [in] field - the field to add to \a this.
7352 * \throw If the name of \a field is empty.
7353 * \throw If the data array of \a field is not set.
7354 * \throw If the data array is already allocated but has different number of components
7356 * \throw If the underlying mesh of \a field has no name.
7357 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
7359 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldInt *field)
7361 MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
7363 contentNotNull()->setFieldNoProfileSBT(field2,field->getArray(),*this,*contentNotNull());
7367 * Adds a MEDCouplingFieldInt to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
7368 * can be an aggregation of several MEDCouplingFieldDouble instances.
7369 * The mesh support of input parameter \a field is ignored here, it can be NULL.
7370 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
7373 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
7374 * A new profile is added only if no equal profile is missing.
7375 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7376 * \param [in] field - the field to add to \a this.
7377 * \param [in] mesh - the supporting mesh of \a field.
7378 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
7379 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
7380 * \throw If either \a field or \a mesh or \a profile has an empty name.
7381 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7382 * \throw If the data array of \a field is not set.
7383 * \throw If the data array of \a this is already allocated but has different number of
7384 * components than \a field.
7385 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
7386 * \sa setFieldNoProfileSBT()
7388 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
7390 MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
7392 contentNotNull()->setFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
7395 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const
7397 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7399 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
7400 const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
7402 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is not null but it is not of type int32 ! Reason is maybe that the read field has not the type INT32 !");
7406 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
7408 if(getFileName().empty())
7409 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7410 MCAuto<DataArray> arrOut;
7411 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
7412 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7416 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MCAuto<DataArray>& arr)
7419 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
7420 DataArrayInt *arrC(dynamic_cast<DataArrayInt *>((DataArray *)arr));
7422 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
7427 MCAuto<MEDCouplingFieldInt> MEDFileIntField1TS::SetDataArrayDoubleInIntField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
7430 double t0(f->getTime(t1,t2));
7431 MCAuto<DataArrayInt> arr2(DynamicCastSafe<DataArray,DataArrayInt>(arr));
7432 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
7433 MCAuto<MEDCouplingFieldInt> ret(MEDCouplingFieldInt::New(*ft));
7434 ret->setTime(t0,t1,t2); ret->setArray(arr2);
7438 MCAuto<MEDCouplingFieldDouble> MEDFileIntField1TS::ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f)
7441 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ConvertFieldIntToFieldDouble : null input field !");
7443 double t0(f->getTime(t1,t2));
7444 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
7445 MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(*ft));
7446 ret->setTime(t0,t1,t2);
7450 MEDFileIntField1TS *MEDFileIntField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
7452 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::extractPart : not implemented yet !");
7456 * This is the simplest version to fetch a field for MED structure. One drawback : if \a this is a complex field (multi spatial discretization inside a same field) this method will throw exception and more advance
7457 * method should be called (getFieldOnMeshAtLevel for example).
7458 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
7460 * \param [in] mesh - the mesh the field is lying on
7461 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
7462 * caller is to delete this field using decrRef() as it is no more needed.
7464 MEDCouplingFieldInt *MEDFileIntField1TS::field(const MEDFileMesh *mesh) const
7466 MCAuto<DataArray> arrOut;
7467 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
7468 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7473 * Returns a new MEDCouplingFieldInt of a given type lying on
7474 * the top level cells of the first mesh in MED file. If \a this field
7475 * has not been constructed via file reading, an exception is thrown.
7476 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7477 * \param [in] type - a spatial discretization of interest.
7478 * \param [in] renumPol - specifies how to permute values of the result field according to
7479 * the optional numbers of cells and nodes, if any. The valid values are
7480 * - 0 - do not permute.
7481 * - 1 - permute cells.
7482 * - 2 - permute nodes.
7483 * - 3 - permute cells and nodes.
7485 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7486 * caller is to delete this field using decrRef() as it is no more needed.
7487 * \throw If \a this field has not been constructed via file reading.
7488 * \throw If the MED file is not readable.
7489 * \throw If there is no mesh in the MED file.
7490 * \throw If no field values of the given \a type.
7491 * \throw If no field values lying on the top level support.
7492 * \sa getFieldAtLevel()
7494 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
7496 if(getFileName().empty())
7497 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
7498 MCAuto<DataArray> arrOut;
7499 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
7500 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7505 * Returns a new MEDCouplingFieldInt of given type lying on a given mesh.
7506 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7507 * \param [in] type - a spatial discretization of the new field.
7508 * \param [in] mesh - the supporting mesh.
7509 * \param [in] renumPol - specifies how to permute values of the result field according to
7510 * the optional numbers of cells and nodes, if any. The valid values are
7511 * - 0 - do not permute.
7512 * - 1 - permute cells.
7513 * - 2 - permute nodes.
7514 * - 3 - permute cells and nodes.
7516 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7517 * caller is to delete this field using decrRef() as it is no more needed.
7518 * \throw If no field of \a this is lying on \a mesh.
7519 * \throw If the mesh is empty.
7520 * \throw If no field values of the given \a type are available.
7521 * \sa getFieldAtLevel()
7522 * \sa getFieldOnMeshAtLevel()
7524 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
7526 MCAuto<DataArray> arrOut;
7527 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
7528 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7533 * Returns a new MEDCouplingFieldInt of a given type lying on a given support.
7534 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7535 * \param [in] type - a spatial discretization of interest.
7536 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7537 * \param [in] mesh - the supporting mesh.
7538 * \param [in] renumPol - specifies how to permute values of the result field according to
7539 * the optional numbers of cells and nodes, if any. The valid values are
7540 * - 0 - do not permute.
7541 * - 1 - permute cells.
7542 * - 2 - permute nodes.
7543 * - 3 - permute cells and nodes.
7545 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7546 * caller is to delete this field using decrRef() as it is no more needed.
7547 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7548 * \throw If no field of \a this is lying on \a mesh.
7549 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7550 * \sa getFieldAtLevel()
7551 * \sa getFieldOnMeshAtLevel()
7553 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
7555 MCAuto<DataArray> arrOut;
7556 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
7557 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7562 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
7563 * This method is called "Old" because in MED3 norm a field has only one meshName
7564 * attached, so this method is for readers of MED2 files. If \a this field
7565 * has not been constructed via file reading, an exception is thrown.
7566 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7567 * \param [in] type - a spatial discretization of interest.
7568 * \param [in] mName - a name of the supporting mesh.
7569 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7570 * \param [in] renumPol - specifies how to permute values of the result field according to
7571 * the optional numbers of cells and nodes, if any. The valid values are
7572 * - 0 - do not permute.
7573 * - 1 - permute cells.
7574 * - 2 - permute nodes.
7575 * - 3 - permute cells and nodes.
7577 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7578 * caller is to delete this field using decrRef() as it is no more needed.
7579 * \throw If the MED file is not readable.
7580 * \throw If there is no mesh named \a mName in the MED file.
7581 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7582 * \throw If \a this field has not been constructed via file reading.
7583 * \throw If no field of \a this is lying on the mesh named \a mName.
7584 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7585 * \sa getFieldAtLevel()
7587 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
7589 if(getFileName().empty())
7590 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7591 MCAuto<DataArray> arrOut;
7592 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
7593 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7598 * Returns values and a profile of the field of a given type lying on a given support.
7599 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7600 * \param [in] type - a spatial discretization of the field.
7601 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7602 * \param [in] mesh - the supporting mesh.
7603 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
7604 * field of interest lies on. If the field lies on all entities of the given
7605 * dimension, all ids in \a pfl are zero. The caller is to delete this array
7606 * using decrRef() as it is no more needed.
7607 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
7608 * field. The caller is to delete this array using decrRef() as it is no more needed.
7609 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7610 * \throw If no field of \a this is lying on \a mesh.
7611 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7613 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
7615 MCAuto<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
7616 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
7619 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull()
7621 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7623 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
7624 MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
7626 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is not null but it is not of type int32 ! Reason is maybe that the read field has not the type INT32 !");
7630 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const
7632 return contentNotNull()->getUndergroundDataArrayTemplate();
7635 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
7637 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
7641 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileFieldNameScope(fieldName)
7646 * \param [in] fieldId field id in C mode
7648 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7650 med_field_type typcha;
7651 std::string dtunitOut;
7652 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fieldId,false,_name,typcha,_infos,dtunitOut));
7653 setDtUnit(dtunitOut.c_str());
7654 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities);
7657 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7658 try:MEDFileFieldNameScope(fieldName),_infos(infos)
7660 setDtUnit(dtunit.c_str());
7661 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities);
7663 catch(INTERP_KERNEL::Exception& e)
7668 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
7670 std::size_t ret(_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MCAuto<MEDFileField1TSWithoutSDA>));
7671 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7672 ret+=(*it).capacity();
7676 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
7678 std::vector<const BigMemoryObject *> ret;
7679 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7680 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
7685 * 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
7688 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
7690 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7691 ret->setInfo(_infos);
7692 int sz=(int)_time_steps.size();
7693 for(const int *id=startIds;id!=endIds;id++)
7695 if(*id>=0 && *id<sz)
7697 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
7698 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7702 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7704 ret->pushBackTimeStep(tse2);
7708 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
7709 oss << " ! Should be in [0," << sz << ") !";
7710 throw INTERP_KERNEL::Exception(oss.str());
7713 if(ret->getNumberOfTS()>0)
7714 ret->synchronizeNameScope();
7715 ret->copyNameScope(*this);
7720 * 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
7723 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
7725 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
7726 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7727 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7728 ret->setInfo(_infos);
7729 int sz=(int)_time_steps.size();
7731 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
7735 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
7736 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7740 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7742 ret->pushBackTimeStep(tse2);
7746 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
7747 oss << " ! Should be in [0," << sz << ") !";
7748 throw INTERP_KERNEL::Exception(oss.str());
7751 if(ret->getNumberOfTS()>0)
7752 ret->synchronizeNameScope();
7753 ret->copyNameScope(*this);
7757 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7760 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7761 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7763 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7766 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7767 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
7768 ids->pushBackSilent(id);
7770 return buildFromTimeStepIds(ids->begin(),ids->end());
7773 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7776 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7777 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7779 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7782 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7783 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
7784 ids->pushBackSilent(id);
7786 return buildFromTimeStepIds(ids->begin(),ids->end());
7789 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfStructureElements() const
7791 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7792 if((*it).isNotNull())
7793 if((*it)->presenceOfStructureElements())
7798 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::onlyStructureElements() const
7800 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7801 if((*it).isNotNull())
7802 if(!(*it)->onlyStructureElements())
7807 void MEDFileAnyTypeFieldMultiTSWithoutSDA::killStructureElements()
7809 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
7810 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7811 if((*it).isNotNull())
7813 if((*it)->presenceOfStructureElements())
7815 if(!(*it)->onlyStructureElements())
7817 (*it)->killStructureElements();
7829 void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyStructureElements()
7831 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
7832 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7833 if((*it).isNotNull())
7835 if((*it)->presenceOfStructureElements())
7837 if(!(*it)->onlyStructureElements())
7838 (*it)->keepOnlyStructureElements();
7845 void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyOnSE(const std::string& seName)
7847 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
7848 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7849 if((*it).isNotNull())
7850 (*it)->keepOnlyOnSE(seName);
7853 void MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
7855 std::vector< std::pair<std::string,std::string> > ps2;
7856 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7857 if((*it).isNotNull())
7859 (*it)->getMeshSENames(ps2);
7863 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames : this appears to not contain SE only !");
7864 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7865 if((*it).isNotNull())
7867 std::vector< std::pair<std::string,std::string> > ps3;
7868 (*it)->getMeshSENames(ps3);
7870 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames : For the moment only homogeneous SE def through time managed !");
7872 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=ps2.begin();it!=ps2.end();it++)
7874 std::vector< std::pair<std::string,std::string> >::iterator it2(std::find(ps.begin(),ps.end(),*it));
7880 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
7882 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7884 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7887 if(cur->presenceOfMultiDiscPerGeoType())
7893 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
7898 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
7903 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
7906 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7908 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
7909 if(pt->isDealingTS(iteration,order))
7912 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
7913 std::vector< std::pair<int,int> > vp=getIterations();
7914 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
7915 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
7916 throw INTERP_KERNEL::Exception(oss.str());
7919 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
7921 return *_time_steps[getTimeStepPos(iteration,order)];
7924 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
7926 return *_time_steps[getTimeStepPos(iteration,order)];
7929 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const
7931 if(_time_steps.empty())
7932 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
7933 return _time_steps[0]->getMeshName();
7936 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const std::string& newMeshName)
7938 std::string oldName(getMeshName());
7939 std::vector< std::pair<std::string,std::string> > v(1);
7940 v[0].first=oldName; v[0].second=newMeshName;
7944 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
7947 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7949 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7951 ret=cur->changeMeshNames(modifTab) || ret;
7957 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
7959 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
7961 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
7965 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
7967 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7969 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
7972 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
7973 MEDFileFieldGlobsReal& glob)
7976 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7978 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
7980 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
7985 void MEDFileAnyTypeFieldMultiTSWithoutSDA::accept(MEDFileFieldVisitor& visitor) const
7987 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7988 if((*it).isNotNull())
7990 visitor.newTimeStepEntry(*it);
7991 (*it)->accept(visitor);
7992 visitor.endTimeStepEntry(*it);
7996 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7998 std::string startLine(bkOffset,' ');
7999 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
8001 oss << " (" << fmtsId << ")";
8002 oss << " has the following name: \"" << _name << "\"." << std::endl;
8003 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
8004 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
8006 oss << startLine << " - \"" << *it << "\"" << std::endl;
8009 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8011 std::string chapter(17,'0'+i);
8012 oss << startLine << chapter << std::endl;
8013 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
8015 cur->simpleRepr(bkOffset+2,oss,i);
8017 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
8018 oss << startLine << chapter << std::endl;
8022 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
8024 std::size_t sz=_time_steps.size();
8025 std::vector< std::pair<int,int> > ret(sz);
8027 for(std::size_t i=0;i<sz;i++)
8029 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
8032 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
8036 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
8037 throw INTERP_KERNEL::Exception(oss.str());
8043 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MCAuto<MEDFileAnyTypeField1TSWithoutSDA>& tse)
8045 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
8047 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
8048 checkCoherencyOfType(tse2);
8049 if(_time_steps.empty())
8051 setName(tse2->getName().c_str());
8052 setInfo(tse2->getInfo());
8054 checkThatComponentsMatch(tse2->getInfo());
8055 if(getDtUnit().empty() && !tse->getDtUnit().empty())
8056 setDtUnit(tse->getDtUnit());
8057 _time_steps.push_back(tse);
8060 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
8062 std::size_t nbOfCompo=_infos.size();
8063 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8065 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
8068 if((cur->getInfo()).size()!=nbOfCompo)
8070 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
8071 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
8072 throw INTERP_KERNEL::Exception(oss.str());
8074 cur->copyNameScope(*this);
8079 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8081 _time_steps.resize(nbPdt);
8082 for(int i=0;i<nbPdt;i++)
8084 std::vector< std::pair<int,int> > ts;
8085 med_int numdt=0,numo=0;
8087 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt));
8092 _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
8097 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
8101 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
8104 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities);
8106 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entities);
8107 synchronizeNameScope();
8111 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
8113 if(_time_steps.empty())
8114 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
8115 checkThatNbOfCompoOfTSMatchThis();
8116 std::vector<std::string> infos(getInfo());
8117 int nbComp=infos.size();
8118 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
8119 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
8120 for(int i=0;i<nbComp;i++)
8122 std::string info=infos[i];
8124 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
8125 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
8126 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
8129 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
8130 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
8131 int nbOfTS=_time_steps.size();
8132 for(int i=0;i<nbOfTS;i++)
8133 _time_steps[i]->writeLL(fid,opts,*this);
8136 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
8138 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8140 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
8142 elt->loadBigArraysRecursively(fid,nasc);
8146 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
8148 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8150 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
8152 elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
8156 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
8158 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8160 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
8162 elt->unloadArrays();
8166 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
8168 return _time_steps.size();
8171 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
8173 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
8174 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8176 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
8178 newTS.push_back(*it);
8183 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
8185 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
8186 int maxId=(int)_time_steps.size();
8188 std::set<int> idsToDel;
8189 for(const int *id=startIds;id!=endIds;id++,ii++)
8191 if(*id>=0 && *id<maxId)
8193 idsToDel.insert(*id);
8197 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
8198 throw INTERP_KERNEL::Exception(oss.str());
8201 for(int iii=0;iii<maxId;iii++)
8202 if(idsToDel.find(iii)==idsToDel.end())
8203 newTS.push_back(_time_steps[iii]);
8207 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
8209 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
8210 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
8211 if(nbOfEntriesToKill==0)
8213 std::size_t sz=_time_steps.size();
8214 std::vector<bool> b(sz,true);
8216 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
8218 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
8219 for(std::size_t i=0;i<sz;i++)
8221 newTS.push_back(_time_steps[i]);
8225 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
8228 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
8229 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
8231 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
8235 tmp->getTime(it2,ord);
8236 if(it2==iteration && order==ord)
8239 oss << "(" << it2 << "," << ord << "), ";
8242 throw INTERP_KERNEL::Exception(oss.str());
8245 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
8248 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
8250 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
8252 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
8256 double ti=tmp->getTime(it2,ord);
8257 if(fabs(time-ti)<eps)
8263 throw INTERP_KERNEL::Exception(oss.str());
8266 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
8268 int lgth=_time_steps.size();
8269 std::vector< std::pair<int,int> > ret(lgth);
8270 for(int i=0;i<lgth;i++)
8271 _time_steps[i]->fillIteration(ret[i]);
8276 * 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'
8277 * This method returns two things.
8278 * - The absolute dimension of 'this' in first parameter.
8279 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
8280 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
8282 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
8283 * Only these 3 discretizations will be taken into account here.
8285 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
8286 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
8287 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
8289 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
8290 * 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'.
8292 * Let's consider the typical following case :
8293 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
8294 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
8295 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
8297 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
8299 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
8301 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
8302 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
8303 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
8304 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
8306 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8308 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
8311 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
8313 if(pos<0 || pos>=(int)_time_steps.size())
8315 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
8316 throw INTERP_KERNEL::Exception(oss.str());
8318 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
8321 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
8322 oss << "\nTry to use following method eraseEmptyTS !";
8323 throw INTERP_KERNEL::Exception(oss.str());
8328 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
8330 if(pos<0 || pos>=(int)_time_steps.size())
8332 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
8333 throw INTERP_KERNEL::Exception(oss.str());
8335 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
8338 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
8339 oss << "\nTry to use following method eraseEmptyTS !";
8340 throw INTERP_KERNEL::Exception(oss.str());
8345 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
8347 std::vector<std::string> ret;
8348 std::set<std::string> ret2;
8349 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8351 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
8352 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
8353 if(ret2.find(*it2)==ret2.end())
8355 ret.push_back(*it2);
8362 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
8364 std::vector<std::string> ret;
8365 std::set<std::string> ret2;
8366 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8368 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
8369 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
8370 if(ret2.find(*it2)==ret2.end())
8372 ret.push_back(*it2);
8379 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
8381 std::vector<std::string> ret;
8382 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8384 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
8385 ret.insert(ret.end(),tmp.begin(),tmp.end());
8390 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
8392 std::vector<std::string> ret;
8393 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8395 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
8396 ret.insert(ret.end(),tmp.begin(),tmp.end());
8401 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8403 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8404 (*it)->changePflsRefsNamesGen2(mapOfModif);
8407 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8409 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8410 (*it)->changeLocsRefsNamesGen2(mapOfModif);
8413 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
8415 int lgth=_time_steps.size();
8416 std::vector< std::vector<TypeOfField> > ret(lgth);
8417 for(int i=0;i<lgth;i++)
8418 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
8423 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
8425 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
8427 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
8430 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCopy() const
8432 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
8434 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8436 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
8437 ret->_time_steps[i]=(*it)->deepCopy();
8442 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
8444 std::size_t sz(_infos.size()),sz2(_time_steps.size());
8445 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
8446 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
8447 for(std::size_t i=0;i<sz;i++)
8449 ret[i]=shallowCpy();
8450 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
8452 for(std::size_t i=0;i<sz2;i++)
8454 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
8457 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
8458 throw INTERP_KERNEL::Exception(oss.str());
8462 for(std::size_t i=0;i<sz;i++)
8463 for(std::size_t j=0;j<sz2;j++)
8464 ret[i]->_time_steps[j]=ts[j][i];
8469 * This method splits into discretization each time steps in \a this.
8470 * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
8472 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
8474 std::size_t sz(_time_steps.size());
8475 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
8476 for(std::size_t i=0;i<sz;i++)
8478 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
8481 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
8482 throw INTERP_KERNEL::Exception(oss.str());
8484 items[i]=timeStep->splitDiscretizations();
8487 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
8488 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
8489 std::vector< TypeOfField > types;
8490 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
8491 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
8493 std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
8495 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
8496 std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
8497 if(it2==types.end())
8498 types.push_back(ts[0]);
8500 ret.resize(types.size()); ret2.resize(types.size());
8501 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
8502 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
8504 TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
8505 std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
8506 ret2[pos].push_back(*it1);
8508 for(std::size_t i=0;i<types.size();i++)
8510 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
8511 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
8512 elt->pushBackTimeStep(*it1);//also updates infos in elt
8514 elt->MEDFileFieldNameScope::operator=(*this);
8520 * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
8522 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
8524 std::size_t sz(_time_steps.size());
8525 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
8526 std::size_t szOut(std::numeric_limits<std::size_t>::max());
8527 for(std::size_t i=0;i<sz;i++)
8529 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
8532 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
8533 throw INTERP_KERNEL::Exception(oss.str());
8535 items[i]=timeStep->splitMultiDiscrPerGeoTypes();
8536 if(szOut==std::numeric_limits<std::size_t>::max())
8537 szOut=items[i].size();
8539 if(items[i].size()!=szOut)
8540 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
8542 if(szOut==std::numeric_limits<std::size_t>::max())
8543 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
8544 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
8545 for(std::size_t i=0;i<szOut;i++)
8547 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
8548 for(std::size_t j=0;j<sz;j++)
8549 elt->pushBackTimeStep(items[j][i]);
8551 elt->MEDFileFieldNameScope::operator=(*this);
8556 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
8558 _name=field->getName();
8560 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
8562 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
8563 _infos=arr->getInfoOnComponents();
8566 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
8568 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
8569 if(_name!=field->getName())
8571 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
8572 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
8573 throw INTERP_KERNEL::Exception(oss.str());
8576 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
8577 checkThatComponentsMatch(arr->getInfoOnComponents());
8580 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
8582 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
8583 if(getInfo().size()!=compos.size())
8585 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
8586 oss << " number of components of element to append (" << compos.size() << ") !";
8587 throw INTERP_KERNEL::Exception(oss.str());
8591 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
8592 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
8593 oss << " But compo in input fields are : ";
8594 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
8596 throw INTERP_KERNEL::Exception(oss.str());
8600 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
8602 std::size_t sz=_infos.size();
8604 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
8606 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
8608 if(elt->getInfo().size()!=sz)
8610 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
8611 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
8612 throw INTERP_KERNEL::Exception(oss.str());
8617 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
8620 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8621 if(!_time_steps.empty())
8622 checkCoherencyOfTinyInfo(field,arr);
8623 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8624 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8625 objC->setFieldNoProfileSBT(field,arr,glob,*this);
8626 copyTinyInfoFrom(field,arr);
8627 _time_steps.push_back(obj);
8630 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
8633 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8634 if(!_time_steps.empty())
8635 checkCoherencyOfTinyInfo(field,arr);
8636 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8637 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8638 objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
8639 copyTinyInfoFrom(field,arr);
8640 _time_steps.push_back(obj);
8643 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ts)
8645 int sz=(int)_time_steps.size();
8648 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
8649 throw INTERP_KERNEL::Exception(oss.str());
8651 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
8654 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
8656 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
8657 throw INTERP_KERNEL::Exception(oss.str());
8663 //= MEDFileFieldMultiTSWithoutSDA
8665 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8667 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8670 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
8674 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8679 * \param [in] fieldId field id in C mode
8681 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8682 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8685 catch(INTERP_KERNEL::Exception& e)
8688 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8689 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8692 catch(INTERP_KERNEL::Exception& e)
8695 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8697 return new MEDFileField1TSWithoutSDA;
8700 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8703 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8704 const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
8706 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8709 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const
8711 return MEDFileField1TSWithoutSDA::TYPE_STR;
8714 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const
8716 return new MEDFileFieldMultiTSWithoutSDA(*this);
8719 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const
8721 return new MEDFileFieldMultiTSWithoutSDA;
8725 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
8726 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
8728 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
8730 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
8731 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8733 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
8734 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
8737 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
8739 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
8740 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8742 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8744 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8747 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
8749 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
8750 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
8751 ret->setIteration(i,elt);
8757 //= MEDFileAnyTypeFieldMultiTS
8759 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
8763 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8764 try:MEDFileFieldGlobsReal(fid)
8766 _content=BuildContentFrom(fid,loadAll,ms);
8769 catch(INTERP_KERNEL::Exception& e)
8774 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8776 med_field_type typcha;
8777 std::vector<std::string> infos;
8780 MEDFileAnyTypeField1TS::LocateField(fid,fieldName,i,typcha,infos,dtunit);
8781 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8786 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8791 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8796 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] !";
8797 throw INTERP_KERNEL::Exception(oss.str());
8800 ret->setDtUnit(dtunit.c_str());
8804 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8806 med_field_type typcha;
8808 std::vector<std::string> infos;
8809 std::string dtunit,fieldName;
8810 MEDFileAnyTypeField1TS::LocateField2(fid,0,true,fieldName,typcha,infos,dtunit);
8811 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8816 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8821 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8826 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] !";
8827 throw INTERP_KERNEL::Exception(oss.str());
8830 ret->setDtUnit(dtunit.c_str());
8834 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c)
8837 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
8838 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
8840 MCAuto<MEDFileFieldMultiTS> ret(MEDFileFieldMultiTS::New());
8841 ret->_content=c; c->incrRef();
8844 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
8846 MCAuto<MEDFileIntFieldMultiTS> ret(MEDFileIntFieldMultiTS::New());
8847 ret->_content=c; c->incrRef();
8850 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
8853 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, med_idt fid)
8855 MEDFileAnyTypeFieldMultiTS *ret(BuildNewInstanceFromContent(c));
8856 std::string fileName(FileNameFromFID(fid));
8857 ret->setFileName(fileName);
8861 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8862 try:MEDFileFieldGlobsReal(fid)
8864 _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
8867 catch(INTERP_KERNEL::Exception& e)
8872 //= MEDFileIntFieldMultiTSWithoutSDA
8874 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8876 return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8879 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
8883 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8887 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8888 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8891 catch(INTERP_KERNEL::Exception& e)
8895 * \param [in] fieldId field id in C mode
8897 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8898 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8901 catch(INTERP_KERNEL::Exception& e)
8904 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8906 return new MEDFileIntField1TSWithoutSDA;
8909 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8912 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8913 const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
8915 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8918 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const
8920 return MEDFileIntField1TSWithoutSDA::TYPE_STR;
8923 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const
8925 return new MEDFileIntFieldMultiTSWithoutSDA(*this);
8928 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const
8930 return new MEDFileIntFieldMultiTSWithoutSDA;
8933 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const
8935 MCAuto<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
8936 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8938 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8940 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8943 const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
8945 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
8946 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
8947 ret->setIteration(i,elt);
8953 //= MEDFileAnyTypeFieldMultiTS
8956 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
8957 * that has been read from a specified MED file.
8958 * \param [in] fileName - the name of the MED file to read.
8959 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8960 * is to delete this field using decrRef() as it is no more needed.
8961 * \throw If reading the file fails.
8963 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
8965 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8966 return New(fid,loadAll);
8969 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, bool loadAll)
8971 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
8972 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8973 ret->loadGlobals(fid);
8978 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
8979 * that has been read from a specified MED file.
8980 * \param [in] fileName - the name of the MED file to read.
8981 * \param [in] fieldName - the name of the field to read.
8982 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8983 * is to delete this field using decrRef() as it is no more needed.
8984 * \throw If reading the file fails.
8985 * \throw If there is no field named \a fieldName in the file.
8987 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8989 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8990 return New(fid,fieldName,loadAll);
8993 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
8995 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
8996 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8997 ret->loadGlobals(fid);
9002 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9003 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9005 * \warning this is a shallow copy constructor
9007 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9009 if(!shallowCopyOfContent)
9011 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
9012 otherPtr->incrRef();
9013 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
9017 _content=other.shallowCpy();
9021 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
9023 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
9025 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
9029 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
9031 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
9033 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
9037 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
9039 return contentNotNullBase()->getPflsReallyUsed2();
9042 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
9044 return contentNotNullBase()->getLocsReallyUsed2();
9047 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
9049 return contentNotNullBase()->getPflsReallyUsedMulti2();
9052 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
9054 return contentNotNullBase()->getLocsReallyUsedMulti2();
9057 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
9059 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
9062 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
9064 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
9067 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
9069 return contentNotNullBase()->getNumberOfTS();
9072 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
9074 contentNotNullBase()->eraseEmptyTS();
9077 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
9079 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
9082 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
9084 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
9087 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
9089 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
9090 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
9095 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
9097 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
9098 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
9103 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
9105 return contentNotNullBase()->getIterations();
9108 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
9110 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
9111 pushBackTimeStep(*it);
9114 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
9117 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
9118 int nbOfTS(fmts->getNumberOfTS());
9119 for(int i=0;i<nbOfTS;i++)
9121 MCAuto<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
9122 pushBackTimeStep(elt);
9126 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
9129 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
9130 checkCoherencyOfType(f1ts);
9132 MCAuto<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
9133 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
9135 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
9136 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
9137 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
9138 _content->pushBackTimeStep(cSafe);
9139 appendGlobs(*f1ts,1e-12);
9142 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
9144 contentNotNullBase()->synchronizeNameScope();
9147 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
9149 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
9152 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
9154 return contentNotNullBase()->getPosGivenTime(time,eps);
9157 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
9159 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
9162 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
9164 return contentNotNullBase()->getTypesOfFieldAvailable();
9167 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
9169 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
9172 std::string MEDFileAnyTypeFieldMultiTS::getName() const
9174 return contentNotNullBase()->getName();
9177 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
9179 contentNotNullBase()->setName(name);
9182 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
9184 return contentNotNullBase()->getDtUnit();
9187 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
9189 contentNotNullBase()->setDtUnit(dtUnit);
9192 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
9194 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
9197 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
9199 return contentNotNullBase()->getTimeSteps(ret1);
9202 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
9204 return contentNotNullBase()->getMeshName();
9207 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
9209 contentNotNullBase()->setMeshName(newMeshName);
9212 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
9214 return contentNotNullBase()->changeMeshNames(modifTab);
9217 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
9219 return contentNotNullBase()->getInfo();
9222 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
9224 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
9227 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
9229 return contentNotNullBase()->setInfo(info);
9232 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
9234 const std::vector<std::string> ret=getInfo();
9235 return (int)ret.size();
9238 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
9240 writeGlobals(fid,*this);
9241 contentNotNullBase()->writeLL(fid,*this);
9245 * This method alloc the arrays and load potentially huge arrays contained in this field.
9246 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
9247 * This method can be also called to refresh or reinit values from a file.
9249 * \throw If the fileName is not set or points to a non readable MED file.
9251 void MEDFileAnyTypeFieldMultiTS::loadArrays()
9253 if(getFileName().empty())
9254 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
9255 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
9256 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
9260 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
9261 * But once data loaded once, this method does nothing.
9263 * \throw If the fileName is not set or points to a non readable MED file.
9264 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
9266 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
9268 if(!getFileName().empty())
9270 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
9271 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
9276 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
9277 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
9278 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
9280 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
9282 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
9284 contentNotNullBase()->unloadArrays();
9288 * 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.
9289 * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
9290 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
9292 * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
9294 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
9296 if(!getFileName().empty())
9297 contentNotNullBase()->unloadArrays();
9300 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
9302 std::ostringstream oss;
9303 contentNotNullBase()->simpleRepr(0,oss,-1);
9304 simpleReprGlobs(oss);
9308 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
9310 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
9313 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
9315 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
9316 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
9321 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
9322 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
9323 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
9325 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
9327 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9329 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
9330 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
9331 std::size_t sz(contentsSplit.size());
9332 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
9333 for(std::size_t i=0;i<sz;i++)
9335 ret[i]=shallowCpy();
9336 ret[i]->_content=contentsSplit[i];
9342 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
9343 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
9345 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
9347 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9349 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
9350 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
9351 std::size_t sz(contentsSplit.size());
9352 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
9353 for(std::size_t i=0;i<sz;i++)
9355 ret[i]=shallowCpy();
9356 ret[i]->_content=contentsSplit[i];
9362 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
9363 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
9365 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
9367 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9369 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
9370 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
9371 std::size_t sz(contentsSplit.size());
9372 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
9373 for(std::size_t i=0;i<sz;i++)
9375 ret[i]=shallowCpy();
9376 ret[i]->_content=contentsSplit[i];
9381 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCopy() const
9383 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
9384 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
9385 ret->_content=_content->deepCopy();
9386 ret->deepCpyGlobs(*this);
9390 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
9396 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
9397 * \param [in] iteration - the iteration number of a required time step.
9398 * \param [in] order - the iteration order number of required time step.
9399 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
9400 * delete this field using decrRef() as it is no more needed.
9401 * \throw If there is no required time step in \a this field.
9403 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
9405 int pos=getPosOfTimeStep(iteration,order);
9406 return getTimeStepAtPos(pos);
9410 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
9411 * \param [in] time - the time of the time step of interest.
9412 * \param [in] eps - a precision used to compare time values.
9413 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9414 * delete this field using decrRef() as it is no more needed.
9415 * \throw If there is no required time step in \a this field.
9417 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
9419 int pos=getPosGivenTime(time,eps);
9420 return getTimeStepAtPos(pos);
9424 * 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.
9425 * The float64 value of time attached to the pair of integers are not considered here.
9426 * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
9428 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
9429 * \throw If there is a null pointer in \a vectFMTS.
9431 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
9433 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
9434 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9435 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
9436 while(!lstFMTS.empty())
9438 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
9439 MEDFileAnyTypeFieldMultiTS *curIt(*it);
9441 throw INTERP_KERNEL::Exception(msg);
9442 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
9443 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
9444 elt.push_back(curIt); it=lstFMTS.erase(it);
9445 while(it!=lstFMTS.end())
9449 throw INTERP_KERNEL::Exception(msg);
9450 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
9452 { elt.push_back(curIt); it=lstFMTS.erase(it); }
9462 * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
9463 * All returned instances in a subvector can be safely loaded, rendered along time
9464 * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
9465 * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
9466 * 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).
9467 * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
9468 * 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.
9470 * \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().
9471 * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
9472 * \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.
9473 * \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.
9475 * \throw If an element in \a vectFMTS has not only one spatial discretization set.
9476 * \throw If an element in \a vectFMTS change of spatial discretization along time.
9477 * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
9478 * \thorw If some elements in \a vectFMTS do not have the same times steps.
9479 * \throw If mesh is null.
9480 * \throw If an element in \a vectFMTS is null.
9481 * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
9483 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& fsc)
9485 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
9487 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
9488 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9489 if(vectFMTS.empty())
9491 std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
9492 MEDFileAnyTypeFieldMultiTS *frstElt(*it);
9494 throw INTERP_KERNEL::Exception(msg);
9496 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
9497 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
9498 for(;it!=vectFMTS.end();it++,i++)
9501 throw INTERP_KERNEL::Exception(msg);
9502 TypeOfField tof0,tof1;
9503 if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
9506 vectFMTSNotNodes.push_back(*it);
9508 vectFMTSNodes.push_back(*it);
9511 vectFMTSNotNodes.push_back(*it);
9513 std::vector< MCAuto<MEDFileFastCellSupportComparator> > cmps;
9514 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
9516 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
9519 bool isFetched(false);
9520 for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
9523 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
9524 if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
9525 { ret[i].push_back(*it2); isFetched=true; }
9529 std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
9530 MCAuto<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
9531 ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
9539 * 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.
9540 * \param [out] cmps - same size than the returned vector.
9542 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& cmps)
9544 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9545 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
9546 while(!lstFMTS.empty())
9548 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
9549 MEDFileAnyTypeFieldMultiTS *ref(*it);
9550 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
9551 elt.push_back(ref); it=lstFMTS.erase(it);
9552 MCAuto<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
9553 MCAuto<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
9554 while(it!=lstFMTS.end())
9556 MEDFileAnyTypeFieldMultiTS *curIt(*it);
9557 if(cmp->isEqual(curIt))
9558 { elt.push_back(curIt); it=lstFMTS.erase(it); }
9562 ret.push_back(elt); cmps.push_back(cmp);
9568 * 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.
9569 * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
9571 * \throw If \a f0 or \a f1 has not only one spatial discretization set.
9572 * \throw If \a f0 or \a f1 change of spatial discretization along time.
9573 * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
9574 * \thorw If \a f0 and \a f1 do not have the same times steps.
9575 * \throw If mesh is null.
9576 * \throw If \a f0 or \a f1 is null.
9577 * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
9579 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
9582 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
9584 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
9585 if(f0->getMeshName()!=mesh->getName())
9587 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9588 throw INTERP_KERNEL::Exception(oss.str());
9590 if(f1->getMeshName()!=mesh->getName())
9592 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9593 throw INTERP_KERNEL::Exception(oss.str());
9595 int nts=f0->getNumberOfTS();
9596 if(nts!=f1->getNumberOfTS())
9597 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
9600 for(int i=0;i<nts;i++)
9602 MCAuto<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
9603 MCAuto<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
9604 std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
9605 if(tofs0.size()!=1 || tofs1.size()!=1)
9606 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
9609 if(tof0!=tofs0[0] || tof1!=tofs1[0])
9610 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
9613 { tof0=tofs0[0]; tof1=tofs1[0]; }
9614 if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
9616 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() << ") !";
9617 throw INTERP_KERNEL::Exception(oss.str());
9619 if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
9621 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() << ") !";
9622 throw INTERP_KERNEL::Exception(oss.str());
9624 if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
9626 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() << ") !";
9627 throw INTERP_KERNEL::Exception(oss.str());
9634 * Return an extraction of \a this using \a extractDef map to specify the extraction.
9635 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
9637 * \return A new object that the caller is responsible to deallocate.
9639 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
9642 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::extractPart : mesh is null !");
9643 MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(buildNewEmpty());
9644 int nbTS(getNumberOfTS());
9645 for(int i=0;i<nbTS;i++)
9647 MCAuto<MEDFileAnyTypeField1TS> f1ts(getTimeStepAtPos(i));
9648 MCAuto<MEDFileAnyTypeField1TS> f1tsOut(f1ts->extractPart(extractDef,mm));
9649 fmtsOut->pushBackTimeStep(f1tsOut);
9651 return fmtsOut.retn();
9655 MCAuto<MEDFileAnyTypeField1TS> AggregateHelperF1TS(const std::vector< typename MLFieldTraits<T>::F1TSType const *>& f1tss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9657 MCAuto< typename MLFieldTraits<T>::F1TSType > ret(MLFieldTraits<T>::F1TSType::New());
9659 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : empty vector !");
9660 std::size_t sz(f1tss.size()),i(0);
9661 std::vector< typename MLFieldTraits<T>::F1TSWSDAType const *> f1tsw(sz);
9662 for(typename std::vector< typename MLFieldTraits<T>::F1TSType const *>::const_iterator it=f1tss.begin();it!=f1tss.end();it++,i++)
9664 typename MLFieldTraits<T>::F1TSType const *elt(*it);
9666 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : presence of a null pointer !");
9667 f1tsw[i]=dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType const *>(elt->contentNotNullBase());
9669 typename MLFieldTraits<T>::F1TSWSDAType *retc(dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType *>(ret->contentNotNullBase()));
9671 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : internal error 1 !");
9672 retc->aggregate(f1tsw,dts);
9673 ret->setDtUnit(f1tss[0]->getDtUnit());
9674 return DynamicCast<typename MLFieldTraits<T>::F1TSType , MEDFileAnyTypeField1TS>(ret);
9678 MCAuto< MEDFileAnyTypeFieldMultiTS > AggregateHelperFMTS(const std::vector< typename MLFieldTraits<T>::FMTSType const *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9680 MCAuto< typename MLFieldTraits<T>::FMTSType > ret(MLFieldTraits<T>::FMTSType::New());
9682 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : empty vector !");
9683 std::size_t sz(fmtss.size());
9684 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9686 typename MLFieldTraits<T>::FMTSType const *elt(*it);
9688 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : presence of null pointer !");
9690 int nbTS(fmtss[0]->getNumberOfTS());
9691 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9692 if((*it)->getNumberOfTS()!=nbTS)
9693 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : all fields must have the same number of TS !");
9694 for(int iterTS=0;iterTS<nbTS;iterTS++)
9697 std::vector< typename MLFieldTraits<T>::F1TSType const *> f1tss(sz);
9698 std::vector< MCAuto<typename MLFieldTraits<T>::F1TSType> > f1tss2(sz);
9699 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++,i++)
9700 { f1tss2[i]=(*it)->getTimeStepAtPos(iterTS); f1tss[i]=f1tss2[i]; }
9701 MCAuto<MEDFileAnyTypeField1TS> f1ts(AggregateHelperF1TS<T>(f1tss,dts));
9702 ret->pushBackTimeStep(f1ts);
9703 ret->setDtUnit(f1ts->getDtUnit());
9705 return DynamicCast<typename MLFieldTraits<T>::FMTSType , MEDFileAnyTypeFieldMultiTS>(ret);
9709 * \a dts and \a ftmss are expected to have same size.
9711 MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileAnyTypeFieldMultiTS::Aggregate(const std::vector<const MEDFileAnyTypeFieldMultiTS *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9714 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : input vector is empty !");
9715 std::size_t sz(fmtss.size());
9716 std::vector<const MEDFileFieldMultiTS *> fmtss1;
9717 std::vector<const MEDFileIntFieldMultiTS *> fmtss2;
9718 for(std::vector<const MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9721 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : presence of null instance in input vector !");
9722 const MEDFileFieldMultiTS *elt1(dynamic_cast<const MEDFileFieldMultiTS *>(*it));
9725 fmtss1.push_back(elt1);
9728 const MEDFileIntFieldMultiTS *elt2(dynamic_cast<const MEDFileIntFieldMultiTS *>(*it));
9731 fmtss2.push_back(elt2);
9734 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not recognized type !");
9736 if(fmtss1.size()!=sz && fmtss2.size()!=sz)
9737 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : type of data is not homogeneous !");
9738 if(fmtss1.size()==sz)
9739 return AggregateHelperFMTS<double>(fmtss1,dts);
9740 if(fmtss2.size()!=sz)
9741 return AggregateHelperFMTS<int>(fmtss2,dts);
9742 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not implemented yet !");
9745 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
9747 return new MEDFileAnyTypeFieldMultiTSIterator(this);
9750 //= MEDFileFieldMultiTS
9753 * Returns a new empty instance of MEDFileFieldMultiTS.
9754 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9755 * is to delete this field using decrRef() as it is no more needed.
9757 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
9759 return new MEDFileFieldMultiTS;
9763 * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
9764 * that has been read from a specified MED file.
9765 * \param [in] fileName - the name of the MED file to read.
9766 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9767 * is to delete this field using decrRef() as it is no more needed.
9768 * \throw If reading the file fails.
9770 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll)
9772 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9773 return New(fid,loadAll);
9776 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, bool loadAll)
9778 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,loadAll,0));
9779 ret->contentNotNull();//to check that content type matches with \a this type.
9784 * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
9785 * that has been read from a specified MED file.
9786 * \param [in] fileName - the name of the MED file to read.
9787 * \param [in] fieldName - the name of the field to read.
9788 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9789 * is to delete this field using decrRef() as it is no more needed.
9790 * \throw If reading the file fails.
9791 * \throw If there is no field named \a fieldName in the file.
9793 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9795 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9796 return New(fid,fieldName,loadAll);
9799 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
9801 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0));
9802 ret->contentNotNull();//to check that content type matches with \a this type.
9807 * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9808 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9810 * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
9811 * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9812 * \warning this is a shallow copy constructor
9813 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
9814 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9815 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9816 * is to delete this field using decrRef() as it is no more needed.
9818 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9820 return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
9823 MEDFileFieldMultiTS *MEDFileFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9825 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9826 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
9827 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0,ent));
9828 ret->contentNotNull();//to check that content type matches with \a this type.
9832 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
9834 return new MEDFileFieldMultiTS(*this);
9837 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9840 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9841 const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
9843 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
9847 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
9848 * following the given input policy.
9850 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9851 * By default (true) the globals are deeply copied.
9852 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
9854 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
9856 MCAuto<MEDFileIntFieldMultiTS> ret;
9857 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9860 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
9862 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
9863 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
9864 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc));
9867 ret=MEDFileIntFieldMultiTS::New();
9869 ret->deepCpyGlobs(*this);
9871 ret->shallowCpyGlobs(*this);
9876 * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
9877 * \param [in] pos - a time step id.
9878 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9879 * delete this field using decrRef() as it is no more needed.
9880 * \throw If \a pos is not a valid time step id.
9882 MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const
9884 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9887 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9888 throw INTERP_KERNEL::Exception(oss.str());
9890 const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
9893 MCAuto<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
9894 ret->shallowCpyGlobs(*this);
9897 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
9898 throw INTERP_KERNEL::Exception(oss.str());
9902 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9903 * mesh entities of a given dimension of the first mesh in MED file.
9904 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9905 * \param [in] type - a spatial discretization of interest.
9906 * \param [in] iteration - the iteration number of a required time step.
9907 * \param [in] order - the iteration order number of required time step.
9908 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9909 * \param [in] renumPol - specifies how to permute values of the result field according to
9910 * the optional numbers of cells and nodes, if any. The valid values are
9911 * - 0 - do not permute.
9912 * - 1 - permute cells.
9913 * - 2 - permute nodes.
9914 * - 3 - permute cells and nodes.
9916 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9917 * caller is to delete this field using decrRef() as it is no more needed.
9918 * \throw If the MED file is not readable.
9919 * \throw If there is no mesh in the MED file.
9920 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9921 * \throw If no field values of the required parameters are available.
9923 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9925 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9926 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9928 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
9929 MCAuto<DataArray> arrOut;
9930 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9931 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9936 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9937 * the top level cells of the first mesh in MED file.
9938 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9939 * \param [in] type - a spatial discretization of interest.
9940 * \param [in] iteration - the iteration number of a required time step.
9941 * \param [in] order - the iteration order number of required time step.
9942 * \param [in] renumPol - specifies how to permute values of the result field according to
9943 * the optional numbers of cells and nodes, if any. The valid values are
9944 * - 0 - do not permute.
9945 * - 1 - permute cells.
9946 * - 2 - permute nodes.
9947 * - 3 - permute cells and nodes.
9949 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9950 * caller is to delete this field using decrRef() as it is no more needed.
9951 * \throw If the MED file is not readable.
9952 * \throw If there is no mesh in the MED file.
9953 * \throw If no field values of the required parameters are available.
9955 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9957 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9958 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9960 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
9961 MCAuto<DataArray> arrOut;
9962 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9963 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9968 * This is the simplest version to fetch a field for MED structure. One drawback : if \a this is a complex field (multi spatial discretization inside a same field) this method will throw exception and more advance
9969 * method should be called (getFieldOnMeshAtLevel for example).
9970 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
9972 * \param [in] iteration - the iteration number of a required time step.
9973 * \param [in] order - the iteration order number of required time step.
9974 * \param [in] mesh - the mesh the field is lying on
9975 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9976 * caller is to delete this field using decrRef() as it is no more needed.
9978 MEDCouplingFieldDouble *MEDFileFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
9980 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9981 MCAuto<DataArray> arrOut;
9982 MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
9983 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9988 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9990 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9991 * \param [in] type - a spatial discretization of interest.
9992 * \param [in] iteration - the iteration number of a required time step.
9993 * \param [in] order - the iteration order number of required time step.
9994 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9995 * \param [in] mesh - the supporting mesh.
9996 * \param [in] renumPol - specifies how to permute values of the result field according to
9997 * the optional numbers of cells and nodes, if any. The valid values are
9998 * - 0 - do not permute.
9999 * - 1 - permute cells.
10000 * - 2 - permute nodes.
10001 * - 3 - permute cells and nodes.
10003 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
10004 * caller is to delete this field using decrRef() as it is no more needed.
10005 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
10006 * \throw If no field of \a this is lying on \a mesh.
10007 * \throw If no field values of the required parameters are available.
10009 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
10011 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10012 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
10014 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
10015 MCAuto<DataArray> arrOut;
10016 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
10017 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
10022 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
10024 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10025 * \param [in] type - a spatial discretization of the new field.
10026 * \param [in] iteration - the iteration number of a required time step.
10027 * \param [in] order - the iteration order number of required time step.
10028 * \param [in] mesh - the supporting mesh.
10029 * \param [in] renumPol - specifies how to permute values of the result field according to
10030 * the optional numbers of cells and nodes, if any. The valid values are
10031 * - 0 - do not permute.
10032 * - 1 - permute cells.
10033 * - 2 - permute nodes.
10034 * - 3 - permute cells and nodes.
10036 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
10037 * caller is to delete this field using decrRef() as it is no more needed.
10038 * \throw If no field of \a this is lying on \a mesh.
10039 * \throw If no field values of the required parameters are available.
10041 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
10043 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
10044 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
10046 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
10047 MCAuto<DataArray> arrOut;
10048 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
10049 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
10054 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
10055 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
10056 * This method is useful for MED2 file format when field on different mesh was autorized.
10058 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
10060 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
10061 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
10063 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
10064 MCAuto<DataArray> arrOut;
10065 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
10066 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
10071 * Returns values and a profile of the field of a given type, of a given time step,
10072 * lying on a given support.
10073 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10074 * \param [in] type - a spatial discretization of the field.
10075 * \param [in] iteration - the iteration number of a required time step.
10076 * \param [in] order - the iteration order number of required time step.
10077 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10078 * \param [in] mesh - the supporting mesh.
10079 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
10080 * field of interest lies on. If the field lies on all entities of the given
10081 * dimension, all ids in \a pfl are zero. The caller is to delete this array
10082 * using decrRef() as it is no more needed.
10083 * \param [in] glob - the global data storing profiles and localization.
10084 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
10085 * field. The caller is to delete this array using decrRef() as it is no more needed.
10086 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10087 * \throw If no field of \a this is lying on \a mesh.
10088 * \throw If no field values of the required parameters are available.
10090 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
10092 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
10093 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
10095 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
10096 MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
10097 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
10100 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const
10102 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10104 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
10105 const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
10107 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is not null but it is not of type double ! Reason is maybe that the read field has not the type FLOAT64 !");
10111 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull()
10113 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10115 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
10116 MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
10118 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is not null but it is not of type double ! Reason is maybe that the read field has not the type FLOAT64 !");
10123 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
10124 * the given field is checked if its elements are sorted suitable for writing to MED file
10125 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
10126 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10127 * \param [in] field - the field to add to \a this.
10128 * \throw If the name of \a field is empty.
10129 * \throw If the data array of \a field is not set.
10130 * \throw If existing time steps have different name or number of components than \a field.
10131 * \throw If the underlying mesh of \a field has no name.
10132 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
10134 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
10136 const DataArrayDouble *arr=0;
10138 arr=field->getArray();
10139 contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
10143 * Adds a MEDCouplingFieldDouble to \a this as another time step.
10144 * The mesh support of input parameter \a field is ignored here, it can be NULL.
10145 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
10148 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
10149 * A new profile is added only if no equal profile is missing.
10150 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10151 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
10152 * \param [in] mesh - the supporting mesh of \a field.
10153 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
10154 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
10155 * \throw If either \a field or \a mesh or \a profile has an empty name.
10156 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10157 * \throw If the data array of \a field is not set.
10158 * \throw If the data array of \a this is already allocated but has different number of
10159 * components than \a field.
10160 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
10161 * \sa setFieldNoProfileSBT()
10163 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
10165 const DataArrayDouble *arr=0;
10167 arr=field->getArray();
10168 contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
10171 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
10173 _content=new MEDFileFieldMultiTSWithoutSDA;
10176 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
10177 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
10180 catch(INTERP_KERNEL::Exception& e)
10183 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10184 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
10187 catch(INTERP_KERNEL::Exception& e)
10190 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
10194 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
10196 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
10199 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
10201 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
10204 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
10206 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
10209 MEDFileFieldMultiTS *MEDFileFieldMultiTS::buildNewEmpty() const
10211 return MEDFileFieldMultiTS::New();
10214 //= MEDFileAnyTypeFieldMultiTSIterator
10216 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
10221 _nb_iter=fmts->getNumberOfTS();
10225 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
10229 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
10231 if(_iter_id<_nb_iter)
10233 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
10235 return fmts->getTimeStepAtPos(_iter_id++);
10243 //= MEDFileIntFieldMultiTS
10246 * Returns a new empty instance of MEDFileFieldMultiTS.
10247 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
10248 * is to delete this field using decrRef() as it is no more needed.
10250 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
10252 return new MEDFileIntFieldMultiTS;
10256 * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
10257 * that has been read from a specified MED file.
10258 * \param [in] fileName - the name of the MED file to read.
10259 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
10260 * is to delete this field using decrRef() as it is no more needed.
10261 * \throw If reading the file fails.
10263 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll)
10265 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10266 return New(fid,loadAll);
10269 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, bool loadAll)
10271 MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,loadAll,0));
10272 ret->contentNotNull();//to check that content type matches with \a this type.
10277 * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
10278 * that has been read from a specified MED file.
10279 * \param [in] fileName - the name of the MED file to read.
10280 * \param [in] fieldName - the name of the field to read.
10281 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
10282 * is to delete this field using decrRef() as it is no more needed.
10283 * \throw If reading the file fails.
10284 * \throw If there is no field named \a fieldName in the file.
10286 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
10288 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10289 return New(fid,fieldName,loadAll);
10292 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
10294 MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0));
10295 ret->contentNotNull();//to check that content type matches with \a this type.
10300 * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
10301 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
10303 * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
10304 * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
10305 * \warning this is a shallow copy constructor
10306 * \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
10307 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
10308 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
10309 * is to delete this field using decrRef() as it is no more needed.
10311 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
10313 return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
10316 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
10318 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10319 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
10320 MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0,ent));
10321 ret->contentNotNull();//to check that content type matches with \a this type.
10326 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
10327 * following the given input policy.
10329 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
10330 * By default (true) the globals are deeply copied.
10331 * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
10333 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const
10335 MCAuto<MEDFileFieldMultiTS> ret;
10336 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
10339 const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
10341 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
10342 MCAuto<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
10343 ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc));
10346 ret=MEDFileFieldMultiTS::New();
10348 ret->deepCpyGlobs(*this);
10350 ret->shallowCpyGlobs(*this);
10354 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const
10356 return new MEDFileIntFieldMultiTS(*this);
10359 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
10362 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
10363 const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
10365 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
10369 * This is the simplest version to fetch a field for MED structure. One drawback : if \a this is a complex field (multi spatial discretization inside a same field) this method will throw exception and more advance
10370 * method should be called (getFieldOnMeshAtLevel for example).
10371 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
10373 * \param [in] iteration - the iteration number of a required time step.
10374 * \param [in] order - the iteration order number of required time step.
10375 * \param [in] mesh - the mesh the field is lying on
10376 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
10377 * caller is to delete this field using decrRef() as it is no more needed.
10379 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
10381 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10382 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10384 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::field : mismatch of type of field expecting INT32 !");
10385 MCAuto<DataArray> arrOut;
10386 MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
10387 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arrOut));
10388 return ret2.retn();
10392 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
10393 * mesh entities of a given dimension of the first mesh in MED file.
10394 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10395 * \param [in] type - a spatial discretization of interest.
10396 * \param [in] iteration - the iteration number of a required time step.
10397 * \param [in] order - the iteration order number of required time step.
10398 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10399 * \param [in] renumPol - specifies how to permute values of the result field according to
10400 * the optional numbers of cells and nodes, if any. The valid values are
10401 * - 0 - do not permute.
10402 * - 1 - permute cells.
10403 * - 2 - permute nodes.
10404 * - 3 - permute cells and nodes.
10406 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10407 * caller is to delete this field using decrRef() as it is no more needed.
10408 * \throw If the MED file is not readable.
10409 * \throw If there is no mesh in the MED file.
10410 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
10411 * \throw If no field values of the required parameters are available.
10413 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
10415 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10416 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10418 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
10419 MCAuto<DataArray> arr;
10420 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase()));
10421 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10422 return ret2.retn();
10426 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
10427 * the top level cells of the first mesh in MED file.
10428 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10429 * \param [in] type - a spatial discretization of interest.
10430 * \param [in] iteration - the iteration number of a required time step.
10431 * \param [in] order - the iteration order number of required time step.
10432 * \param [in] renumPol - specifies how to permute values of the result field according to
10433 * the optional numbers of cells and nodes, if any. The valid values are
10434 * - 0 - do not permute.
10435 * - 1 - permute cells.
10436 * - 2 - permute nodes.
10437 * - 3 - permute cells and nodes.
10439 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10440 * caller is to delete this field using decrRef() as it is no more needed.
10441 * \throw If the MED file is not readable.
10442 * \throw If there is no mesh in the MED file.
10443 * \throw If no field values of the required parameters are available.
10445 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
10447 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10448 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10450 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
10451 MCAuto<DataArray> arr;
10452 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase()));
10453 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10454 return ret2.retn();
10458 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
10460 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10461 * \param [in] type - a spatial discretization of interest.
10462 * \param [in] iteration - the iteration number of a required time step.
10463 * \param [in] order - the iteration order number of required time step.
10464 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10465 * \param [in] mesh - the supporting mesh.
10466 * \param [in] renumPol - specifies how to permute values of the result field according to
10467 * the optional numbers of cells and nodes, if any. The valid values are
10468 * - 0 - do not permute.
10469 * - 1 - permute cells.
10470 * - 2 - permute nodes.
10471 * - 3 - permute cells and nodes.
10473 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10474 * caller is to delete this field using decrRef() as it is no more needed.
10475 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
10476 * \throw If no field of \a this is lying on \a mesh.
10477 * \throw If no field values of the required parameters are available.
10479 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
10481 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10482 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10484 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10485 MCAuto<DataArray> arr;
10486 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase()));
10487 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10488 return ret2.retn();
10492 * Returns a new MEDCouplingFieldInt of given type, of a given time step, lying on a
10494 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10495 * \param [in] type - a spatial discretization of the new field.
10496 * \param [in] iteration - the iteration number of a required time step.
10497 * \param [in] order - the iteration order number of required time step.
10498 * \param [in] mesh - the supporting mesh.
10499 * \param [out] arrOut - the DataArrayInt containing values of field.
10500 * \param [in] renumPol - specifies how to permute values of the result field according to
10501 * the optional numbers of cells and nodes, if any. The valid values are
10502 * - 0 - do not permute.
10503 * - 1 - permute cells.
10504 * - 2 - permute nodes.
10505 * - 3 - permute cells and nodes.
10507 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10508 * caller is to delete this field using decrRef() as it is no more needed.
10509 * \throw If no field of \a this is lying on \a mesh.
10510 * \throw If no field values of the required parameters are available.
10512 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
10514 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10515 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10517 throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10518 MCAuto<DataArray> arr;
10519 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase()));
10520 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10521 return ret2.retn();
10525 * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
10526 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
10527 * This method is useful for MED2 file format when field on different mesh was autorized.
10529 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol) const
10531 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10532 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10534 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10535 MCAuto<DataArray> arr;
10536 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase()));
10537 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10538 return ret2.retn();
10542 * Returns values and a profile of the field of a given type, of a given time step,
10543 * lying on a given support.
10544 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10545 * \param [in] type - a spatial discretization of the field.
10546 * \param [in] iteration - the iteration number of a required time step.
10547 * \param [in] order - the iteration order number of required time step.
10548 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10549 * \param [in] mesh - the supporting mesh.
10550 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
10551 * field of interest lies on. If the field lies on all entities of the given
10552 * dimension, all ids in \a pfl are zero. The caller is to delete this array
10553 * using decrRef() as it is no more needed.
10554 * \param [in] glob - the global data storing profiles and localization.
10555 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
10556 * field. The caller is to delete this array using decrRef() as it is no more needed.
10557 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10558 * \throw If no field of \a this is lying on \a mesh.
10559 * \throw If no field values of the required parameters are available.
10561 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
10563 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
10564 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
10566 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
10567 MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
10568 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
10572 * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
10573 * \param [in] pos - a time step id.
10574 * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
10575 * delete this field using decrRef() as it is no more needed.
10576 * \throw If \a pos is not a valid time step id.
10578 MEDFileIntField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
10580 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
10583 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
10584 throw INTERP_KERNEL::Exception(oss.str());
10586 const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
10589 MCAuto<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
10590 ret->shallowCpyGlobs(*this);
10593 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
10594 throw INTERP_KERNEL::Exception(oss.str());
10598 * Adds a MEDCouplingFieldInt to \a this as another time step. The underlying mesh of
10599 * the given field is checked if its elements are sorted suitable for writing to MED file
10600 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
10601 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10602 * \param [in] field - the field to add to \a this.
10603 * \throw If the name of \a field is empty.
10604 * \throw If the data array of \a field is not set.
10605 * \throw If existing time steps have different name or number of components than \a field.
10606 * \throw If the underlying mesh of \a field has no name.
10607 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
10609 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldInt *field)
10611 MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
10612 contentNotNull()->appendFieldNoProfileSBT(field2,field->getArray(),*this);
10616 * Adds a MEDCouplingFieldDouble to \a this as another time step.
10617 * The mesh support of input parameter \a field is ignored here, it can be NULL.
10618 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
10621 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
10622 * A new profile is added only if no equal profile is missing.
10623 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10624 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
10625 * \param [in] arrOfVals - the values of the field \a field used.
10626 * \param [in] mesh - the supporting mesh of \a field.
10627 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
10628 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
10629 * \throw If either \a field or \a mesh or \a profile has an empty name.
10630 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10631 * \throw If the data array of \a field is not set.
10632 * \throw If the data array of \a this is already allocated but has different number of
10633 * components than \a field.
10634 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
10635 * \sa setFieldNoProfileSBT()
10637 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
10639 MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
10640 contentNotNull()->appendFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this);
10643 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const
10645 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10647 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
10648 const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10650 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is not null but it is not of type int ! Reason is maybe that the read field has not the type INT32 !");
10654 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull()
10656 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10658 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
10659 MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10661 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is not null but it is not of type int ! Reason is maybe that the read field has not the type INT32 !");
10665 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
10667 _content=new MEDFileIntFieldMultiTSWithoutSDA;
10670 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
10674 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
10675 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
10678 catch(INTERP_KERNEL::Exception& e)
10681 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10682 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
10685 catch(INTERP_KERNEL::Exception& e)
10688 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
10690 return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
10693 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::buildNewEmpty() const
10695 return MEDFileIntFieldMultiTS::New();
10700 MEDFileFields *MEDFileFields::New()
10702 return new MEDFileFields;
10705 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
10707 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10708 return New(fid,loadAll);
10711 MEDFileFields *MEDFileFields::NewWithDynGT(const std::string& fileName, const MEDFileStructureElements *se, bool loadAll)
10713 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10714 return NewWithDynGT(fid,se,loadAll);
10717 MEDFileFields *MEDFileFields::NewWithDynGT(med_idt fid, const MEDFileStructureElements *se, bool loadAll)
10720 throw INTERP_KERNEL::Exception("MEDFileFields::NewWithDynGT : null struct element pointer !");
10721 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> entities(MEDFileEntities::BuildFrom(*se));
10722 return new MEDFileFields(fid,loadAll,0,entities);
10725 MEDFileFields *MEDFileFields::New(med_idt fid, bool loadAll)
10727 return new MEDFileFields(fid,loadAll,0,0);
10730 MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
10732 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10733 return new MEDFileFields(fid,loadAll,ms,0);
10736 MEDFileFields *MEDFileFields::LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
10738 MEDFileUtilities::CheckFileForRead(fileName);
10739 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
10740 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10741 return new MEDFileFields(fid,loadAll,0,ent);
10744 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
10746 std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
10747 ret+=_fields.capacity()*sizeof(MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
10751 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
10753 std::vector<const BigMemoryObject *> ret;
10754 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10755 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
10759 MEDFileFields *MEDFileFields::deepCopy() const
10761 MCAuto<MEDFileFields> ret(shallowCpy());
10763 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10765 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10766 ret->_fields[i]=(*it)->deepCopy();
10768 ret->deepCpyGlobs(*this);
10772 MEDFileFields *MEDFileFields::shallowCpy() const
10774 return new MEDFileFields(*this);
10778 * 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
10779 * 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.
10780 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
10782 * \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.
10783 * \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.
10785 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10787 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
10789 std::set< std::pair<int,int> > s;
10790 bool firstShot=true;
10791 areThereSomeForgottenTS=false;
10792 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10794 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10796 std::vector< std::pair<int,int> > v=(*it)->getIterations();
10797 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
10799 { s=s1; firstShot=false; }
10802 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
10804 areThereSomeForgottenTS=true;
10808 std::vector< std::pair<int,int> > ret;
10809 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
10813 int MEDFileFields::getNumberOfFields() const
10815 return _fields.size();
10818 std::vector<std::string> MEDFileFields::getFieldsNames() const
10820 std::vector<std::string> ret(_fields.size());
10822 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10824 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
10827 ret[i]=f->getName();
10831 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
10832 throw INTERP_KERNEL::Exception(oss.str());
10838 std::vector<std::string> MEDFileFields::getMeshesNames() const
10840 std::vector<std::string> ret;
10841 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10843 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10845 ret.push_back(cur->getMeshName());
10850 std::string MEDFileFields::simpleRepr() const
10852 std::ostringstream oss;
10853 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
10858 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
10860 int nbOfFields(getNumberOfFields());
10861 std::string startLine(bkOffset,' ');
10862 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
10864 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10866 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10869 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
10873 oss << startLine << " - not defined !" << std::endl;
10877 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10879 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10880 std::string chapter(17,'0'+i);
10881 oss << startLine << chapter << std::endl;
10884 cur->simpleRepr(bkOffset+2,oss,i);
10888 oss << startLine << " - not defined !" << std::endl;
10890 oss << startLine << chapter << std::endl;
10892 simpleReprGlobs(oss);
10895 MEDFileFields::MEDFileFields()
10899 MEDFileFields::MEDFileFields(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10900 try:MEDFileFieldGlobsReal(fid)
10902 int nbFields(MEDnField(fid));
10903 _fields.resize(nbFields);
10904 med_field_type typcha;
10905 for(int i=0;i<nbFields;i++)
10907 std::vector<std::string> infos;
10908 std::string fieldName,dtunit;
10909 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,i,false,fieldName,typcha,infos,dtunit));
10914 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10919 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10924 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] !";
10925 throw INTERP_KERNEL::Exception(oss.str());
10929 loadAllGlobals(fid,entities);
10931 catch(INTERP_KERNEL::Exception& e)
10936 void MEDFileFields::writeLL(med_idt fid) const
10939 writeGlobals(fid,*this);
10940 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10942 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
10945 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
10946 throw INTERP_KERNEL::Exception(oss.str());
10948 elt->writeLL(fid,*this);
10953 * This method alloc the arrays and load potentially huge arrays contained in this field.
10954 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
10955 * This method can be also called to refresh or reinit values from a file.
10957 * \throw If the fileName is not set or points to a non readable MED file.
10959 void MEDFileFields::loadArrays()
10961 if(getFileName().empty())
10962 throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
10963 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
10964 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10966 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10968 elt->loadBigArraysRecursively(fid,*elt);
10973 * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
10974 * But once data loaded once, this method does nothing.
10976 * \throw If the fileName is not set or points to a non readable MED file.
10977 * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
10979 void MEDFileFields::loadArraysIfNecessary()
10981 if(!getFileName().empty())
10983 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
10984 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10986 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10988 elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
10994 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
10995 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
10996 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
10998 * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
11000 void MEDFileFields::unloadArrays()
11002 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11004 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
11006 elt->unloadArrays();
11011 * 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.
11012 * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
11013 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
11015 * \sa MEDFileFields::loadArraysIfNecessary
11017 void MEDFileFields::unloadArraysWithoutDataLoss()
11019 if(!getFileName().empty())
11023 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
11025 std::vector<std::string> ret;
11026 std::set<std::string> ret2;
11027 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11029 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
11030 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
11031 if(ret2.find(*it2)==ret2.end())
11033 ret.push_back(*it2);
11040 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
11042 std::vector<std::string> ret;
11043 std::set<std::string> ret2;
11044 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11046 std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
11047 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
11048 if(ret2.find(*it2)==ret2.end())
11050 ret.push_back(*it2);
11057 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
11059 std::vector<std::string> ret;
11060 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11062 std::vector<std::string> tmp((*it)->getPflsReallyUsedMulti2());
11063 ret.insert(ret.end(),tmp.begin(),tmp.end());
11068 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
11070 std::vector<std::string> ret;
11071 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11073 std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
11074 ret.insert(ret.end(),tmp.begin(),tmp.end());
11079 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
11081 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
11082 (*it)->changePflsRefsNamesGen2(mapOfModif);
11085 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
11087 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
11088 (*it)->changeLocsRefsNamesGen2(mapOfModif);
11091 void MEDFileFields::resize(int newSize)
11093 _fields.resize(newSize);
11096 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
11098 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
11102 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
11105 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
11106 _fields.push_back(field->getContent());
11107 appendGlobs(*field,1e-12);
11110 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
11113 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
11114 if(i>=(int)_fields.size())
11115 _fields.resize(i+1);
11116 _fields[i]=field->getContent();
11117 appendGlobs(*field,1e-12);
11120 void MEDFileFields::destroyFieldAtPos(int i)
11122 destroyFieldsAtPos(&i,&i+1);
11125 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
11127 std::vector<bool> b(_fields.size(),true);
11128 for(const int *i=startIds;i!=endIds;i++)
11130 if(*i<0 || *i>=(int)_fields.size())
11132 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
11133 throw INTERP_KERNEL::Exception(oss.str());
11137 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
11139 for(std::size_t i=0;i<_fields.size();i++)
11141 fields[j++]=_fields[i];
11145 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
11147 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
11148 int nbOfEntriesToKill(DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg));
11149 std::vector<bool> b(_fields.size(),true);
11151 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
11153 if(k<0 || k>=(int)_fields.size())
11155 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
11156 throw INTERP_KERNEL::Exception(oss.str());
11160 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
11162 for(std::size_t i=0;i<_fields.size();i++)
11164 fields[j++]=_fields[i];
11168 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
11171 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11173 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
11175 ret=cur->changeMeshNames(modifTab) || ret;
11181 * \param [in] meshName the name of the mesh that will be renumbered.
11182 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
11183 * This code corresponds to the distribution of types in the corresponding mesh.
11184 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
11185 * \param [in] renumO2N the old to new renumber array.
11186 * \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
11187 * field in \a this.
11189 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
11192 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11194 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
11197 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
11204 * Return an extraction of \a this using \a extractDef map to specify the extraction.
11205 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
11207 * \return A new object that the caller is responsible to deallocate.
11209 MEDFileFields *MEDFileFields::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
11212 throw INTERP_KERNEL::Exception("MEDFileFields::extractPart : input mesh is NULL !");
11213 MCAuto<MEDFileFields> fsOut(MEDFileFields::New());
11214 int nbFields(getNumberOfFields());
11215 for(int i=0;i<nbFields;i++)
11217 MCAuto<MEDFileAnyTypeFieldMultiTS> fmts(getFieldAtPos(i));
11220 std::ostringstream oss; oss << "MEDFileFields::extractPart : at pos #" << i << " field is null !";
11221 throw INTERP_KERNEL::Exception(oss.str());
11223 MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(fmts->extractPart(extractDef,mm));
11224 fsOut->pushField(fmtsOut);
11226 return fsOut.retn();
11229 void MEDFileFields::accept(MEDFileFieldVisitor& visitor) const
11231 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11232 if((*it).isNotNull())
11234 visitor.newFieldEntry(*it);
11235 (*it)->accept(visitor);
11236 visitor.endFieldEntry(*it);
11240 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
11242 if(i<0 || i>=(int)_fields.size())
11244 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
11245 throw INTERP_KERNEL::Exception(oss.str());
11247 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
11250 MCAuto<MEDFileAnyTypeFieldMultiTS> ret;
11251 const MEDFileFieldMultiTSWithoutSDA *fmtsC(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts));
11252 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts));
11254 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
11256 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
11259 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
11260 throw INTERP_KERNEL::Exception(oss.str());
11262 ret->shallowCpyGlobs(*this);
11267 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
11268 * This method is accessible in python using __getitem__ with a list in input.
11269 * \return a new object that the caller should deal with.
11271 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
11273 MCAuto<MEDFileFields> ret=shallowCpy();
11274 std::size_t sz=std::distance(startIds,endIds);
11275 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
11277 for(const int *i=startIds;i!=endIds;i++,j++)
11279 if(*i<0 || *i>=(int)_fields.size())
11281 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
11282 throw INTERP_KERNEL::Exception(oss.str());
11284 fields[j]=_fields[*i];
11286 ret->_fields=fields;
11290 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
11292 return getFieldAtPos(getPosFromFieldName(fieldName));
11296 * This method removes, if any, fields in \a this having no time steps.
11297 * 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.
11299 * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
11301 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
11303 std::vector<MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
11304 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11306 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
11309 if(elt->getNumberOfTS()>0)
11310 newFields.push_back(*it);
11313 if(_fields.size()==newFields.size())
11320 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
11321 * This method can be seen as a filter applied on \a this, that returns an object containing
11322 * 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
11323 * shallow copied from \a this.
11325 * \param [in] meshName - the name of the mesh on w
11326 * \return a new object that the caller should deal with.
11328 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
11330 MCAuto<MEDFileFields> ret(MEDFileFields::New());
11331 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11333 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
11336 if(cur->getMeshName()==meshName)
11339 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
11340 ret->_fields.push_back(cur2);
11343 ret->shallowCpyOnlyUsedGlobs(*this);
11348 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
11349 * Input time steps are specified using a pair of integer (iteration, order).
11350 * 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,
11351 * but for each multitimestep only the time steps in \a timeSteps are kept.
11352 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
11354 * The returned object points to shallow copy of elements in \a this.
11356 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
11357 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
11358 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
11360 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
11362 MCAuto<MEDFileFields> ret(MEDFileFields::New());
11363 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11365 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
11368 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
11369 ret->_fields.push_back(elt);
11371 ret->shallowCpyOnlyUsedGlobs(*this);
11376 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
11378 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
11380 MCAuto<MEDFileFields> ret=MEDFileFields::New();
11381 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11383 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
11386 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
11387 if(elt->getNumberOfTS()!=0)
11388 ret->_fields.push_back(elt);
11390 ret->shallowCpyOnlyUsedGlobs(*this);
11394 bool MEDFileFields::presenceOfStructureElements() const
11396 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11397 if((*it).isNotNull())
11398 if((*it)->presenceOfStructureElements())
11403 void MEDFileFields::killStructureElements()
11405 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
11406 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11407 if((*it).isNotNull())
11409 if((*it)->presenceOfStructureElements())
11411 if(!(*it)->onlyStructureElements())
11413 (*it)->killStructureElements();
11414 ret.push_back(*it);
11419 ret.push_back(*it);
11425 void MEDFileFields::keepOnlyStructureElements()
11427 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
11428 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11429 if((*it).isNotNull())
11431 if((*it)->presenceOfStructureElements())
11433 if(!(*it)->onlyStructureElements())
11434 (*it)->keepOnlyStructureElements();
11435 ret.push_back(*it);
11441 void MEDFileFields::keepOnlyOnMeshSE(const std::string& meshName, const std::string& seName)
11443 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
11444 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11445 if((*it).isNotNull())
11447 if((*it)->getMeshName()!=meshName)
11449 std::vector< std::pair<std::string,std::string> > ps;
11450 (*it)->getMeshSENames(ps);
11451 std::pair<std::string,std::string> p(meshName,seName);
11452 if(std::find(ps.begin(),ps.end(),p)!=ps.end())
11453 (*it)->keepOnlyOnSE(seName);
11454 ret.push_back(*it);
11459 void MEDFileFields::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
11461 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11462 if((*it).isNotNull())
11463 (*it)->getMeshSENames(ps);
11466 void MEDFileFields::blowUpSE(MEDFileMeshes *ms, const MEDFileStructureElements *ses)
11468 MEDFileBlowStrEltUp::DealWithSE(this,ms,ses);
11471 MCAuto<MEDFileFields> MEDFileFields::partOfThisOnStructureElements() const
11473 MCAuto<MEDFileFields> ret(deepCopy());
11474 ret->keepOnlyStructureElements();
11478 MCAuto<MEDFileFields> MEDFileFields::partOfThisLyingOnSpecifiedMeshSEName(const std::string& meshName, const std::string& seName) const
11480 MCAuto<MEDFileFields> ret(deepCopy());
11481 ret->keepOnlyOnMeshSE(meshName,seName);
11485 void MEDFileFields::aggregate(const MEDFileFields& other)
11487 int nbFieldsToAdd(other.getNumberOfFields());
11488 std::vector<std::string> fsn(getFieldsNames());
11489 for(int i=0;i<nbFieldsToAdd;i++)
11491 MCAuto<MEDFileAnyTypeFieldMultiTS> elt(other.getFieldAtPos(i));
11492 std::string name(elt->getName());
11493 if(std::find(fsn.begin(),fsn.end(),name)!=fsn.end())
11495 std::ostringstream oss; oss << "MEDFileFields::aggregate : name \"" << name << "\" already appears !";
11496 throw INTERP_KERNEL::Exception(oss.str());
11502 MEDFileFieldsIterator *MEDFileFields::iterator()
11504 return new MEDFileFieldsIterator(this);
11507 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
11509 std::string tmp(fieldName);
11510 std::vector<std::string> poss;
11511 for(std::size_t i=0;i<_fields.size();i++)
11513 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f(_fields[i]);
11516 std::string fname(f->getName());
11520 poss.push_back(fname);
11523 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
11524 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
11526 throw INTERP_KERNEL::Exception(oss.str());
11529 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
11534 _nb_iter=fs->getNumberOfFields();
11538 MEDFileFieldsIterator::~MEDFileFieldsIterator()
11542 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
11544 if(_iter_id<_nb_iter)
11546 MEDFileFields *fs(_fs);
11548 return fs->getFieldAtPos(_iter_id++);