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, const MEDFileEntities *entities)
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,entities);
5930 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
5934 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
5935 try:MEDFileFieldGlobsReal(fid)
5937 _content=BuildContentFrom(fid,loadAll,ms,entities);
5940 catch(INTERP_KERNEL::Exception& e)
5945 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
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,entities);
5988 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
5992 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
5993 try:MEDFileFieldGlobsReal(fid)
5995 _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
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,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,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,0));
6066 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
6067 ret->loadGlobals(fid);
6071 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::NewAdv(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileEntities *entities)
6073 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6074 return NewAdv(fid,fieldName,iteration,order,loadAll,entities);
6077 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::NewAdv(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileEntities *entities)
6079 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0,entities));
6080 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
6081 ret->loadGlobals(fid);
6085 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
6087 med_field_type typcha;
6088 std::vector<std::string> infos;
6091 int nbOfStep2(LocateField(fid,fieldName,iii,typcha,infos,dtunit));
6092 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
6097 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
6102 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
6107 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] !";
6108 throw INTERP_KERNEL::Exception(oss.str());
6111 ret->setDtUnit(dtunit.c_str());
6112 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
6115 std::vector< std::pair<int,int> > dtits(nbOfStep2);
6116 for(int i=0;i<nbOfStep2 && !found;i++)
6118 med_int numdt,numit;
6120 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt));
6121 if(numdt==iteration && numit==order)
6127 dtits[i]=std::pair<int,int>(numdt,numit);
6131 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available iterations are : ";
6132 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
6133 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
6134 throw INTERP_KERNEL::Exception(oss.str());
6137 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
6139 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
6143 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
6144 try:MEDFileFieldGlobsReal(fid)
6146 _content=BuildContentFrom(fid,fieldName,iteration,order,loadAll,ms,entities);
6149 catch(INTERP_KERNEL::Exception& e)
6155 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6156 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6158 * \warning this is a shallow copy constructor
6160 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
6162 if(!shallowCopyOfContent)
6164 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
6165 otherPtr->incrRef();
6166 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
6170 _content=other.shallowCpy();
6174 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)
6178 int nbFields=MEDnField(fid);
6179 if(fieldIdCFormat>=nbFields)
6181 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << FileNameFromFID(fid) << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
6182 throw INTERP_KERNEL::Exception(oss.str());
6185 int ncomp(MEDfieldnComponent(fid,fieldIdCFormat+1));
6186 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
6187 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
6188 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
6189 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
6190 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
6193 MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep));
6194 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
6195 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
6196 infos.clear(); infos.resize(ncomp);
6197 for(int j=0;j<ncomp;j++)
6198 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
6203 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
6206 * \return in case of success the number of time steps available for the field with name \a fieldName.
6208 int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const std::string& fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
6210 int nbFields=MEDnField(fid);
6212 std::vector<std::string> fns(nbFields);
6214 for(int i=0;i<nbFields && !found;i++)
6217 nbOfStep2=LocateField2(fid,i,false,tmp,typcha,infos,dtunitOut);
6219 found=(tmp==fieldName);
6225 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available fields are : ";
6226 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
6227 oss << "\"" << *it << "\" ";
6228 throw INTERP_KERNEL::Exception(oss.str());
6234 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
6235 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
6236 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
6237 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
6238 * to keep a valid instance.
6239 * 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.
6240 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
6241 * 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.
6243 * \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.
6244 * \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.
6245 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
6246 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
6247 * \param [in] newLocName is the new localization name.
6248 * \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.
6249 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
6251 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
6253 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6254 std::string oldPflName=disc->getProfile();
6255 std::vector<std::string> vv=getPflsReallyUsedMulti();
6256 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
6257 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
6259 disc->setProfile(newPflName);
6260 DataArrayInt *pfl=getProfile(oldPflName.c_str());
6261 pfl->setName(newPflName);
6265 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
6266 throw INTERP_KERNEL::Exception(oss.str());
6271 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
6272 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
6273 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
6274 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
6275 * to keep a valid instance.
6276 * 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.
6277 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
6278 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
6279 * 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.
6281 * \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.
6282 * \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.
6283 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
6284 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
6285 * \param [in] newLocName is the new localization name.
6286 * \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.
6287 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
6289 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
6291 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6292 std::string oldLocName=disc->getLocalization();
6293 std::vector<std::string> vv=getLocsReallyUsedMulti();
6294 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
6295 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
6297 disc->setLocalization(newLocName);
6298 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
6299 loc.setName(newLocName);
6303 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
6304 throw INTERP_KERNEL::Exception(oss.str());
6308 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
6310 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
6312 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
6316 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
6318 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
6320 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
6325 * This method alloc the arrays and load potentially huge arrays contained in this field.
6326 * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
6327 * This method can be also called to refresh or reinit values from a file.
6329 * \throw If the fileName is not set or points to a non readable MED file.
6330 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
6332 void MEDFileAnyTypeField1TS::loadArrays()
6334 if(getFileName().empty())
6335 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
6336 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
6337 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
6341 * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
6342 * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
6343 * this method does not throw if \a this does not come from file read.
6345 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
6347 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
6349 if(!getFileName().empty())
6351 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
6352 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
6357 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
6358 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
6359 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
6361 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
6363 void MEDFileAnyTypeField1TS::unloadArrays()
6365 contentNotNullBase()->unloadArrays();
6369 * 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.
6370 * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
6371 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
6373 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
6375 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
6377 if(!getFileName().empty())
6378 contentNotNullBase()->unloadArrays();
6381 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
6383 int nbComp(getNumberOfComponents());
6384 INTERP_KERNEL::AutoPtr<char> comp(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
6385 INTERP_KERNEL::AutoPtr<char> unit(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
6386 for(int i=0;i<nbComp;i++)
6388 std::string info=getInfo()[i];
6390 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
6391 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
6392 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
6394 if(getName().empty())
6395 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
6396 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
6397 writeGlobals(fid,*this);
6398 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
6401 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
6403 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
6406 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
6408 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
6409 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
6414 * Returns a string describing \a this field. This string is outputted
6415 * by \c print Python command.
6417 std::string MEDFileAnyTypeField1TS::simpleRepr() const
6419 std::ostringstream oss;
6420 contentNotNullBase()->simpleRepr(0,oss,-1);
6421 simpleReprGlobs(oss);
6426 * This method returns all profiles whose name is non empty used.
6427 * \b WARNING If profile is used several times it will be reported \b only \b once.
6428 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
6430 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
6432 return contentNotNullBase()->getPflsReallyUsed2();
6436 * This method returns all localizations whose name is non empty used.
6437 * \b WARNING If localization is used several times it will be reported \b only \b once.
6439 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
6441 return contentNotNullBase()->getLocsReallyUsed2();
6445 * This method returns all profiles whose name is non empty used.
6446 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
6448 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
6450 return contentNotNullBase()->getPflsReallyUsedMulti2();
6454 * This method returns all localizations whose name is non empty used.
6455 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
6457 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
6459 return contentNotNullBase()->getLocsReallyUsedMulti2();
6462 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6464 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
6467 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6469 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
6472 int MEDFileAnyTypeField1TS::getDimension() const
6474 return contentNotNullBase()->getDimension();
6477 int MEDFileAnyTypeField1TS::getIteration() const
6479 return contentNotNullBase()->getIteration();
6482 int MEDFileAnyTypeField1TS::getOrder() const
6484 return contentNotNullBase()->getOrder();
6487 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
6489 return contentNotNullBase()->getTime(iteration,order);
6492 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
6494 contentNotNullBase()->setTime(iteration,order,val);
6497 std::string MEDFileAnyTypeField1TS::getName() const
6499 return contentNotNullBase()->getName();
6502 void MEDFileAnyTypeField1TS::setName(const std::string& name)
6504 contentNotNullBase()->setName(name);
6507 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
6509 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
6512 std::string MEDFileAnyTypeField1TS::getDtUnit() const
6514 return contentNotNullBase()->getDtUnit();
6517 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
6519 contentNotNullBase()->setDtUnit(dtUnit);
6522 std::string MEDFileAnyTypeField1TS::getMeshName() const
6524 return contentNotNullBase()->getMeshName();
6527 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
6529 contentNotNullBase()->setMeshName(newMeshName);
6532 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
6534 return contentNotNullBase()->changeMeshNames(modifTab);
6537 int MEDFileAnyTypeField1TS::getMeshIteration() const
6539 return contentNotNullBase()->getMeshIteration();
6542 int MEDFileAnyTypeField1TS::getMeshOrder() const
6544 return contentNotNullBase()->getMeshOrder();
6547 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
6549 return contentNotNullBase()->getNumberOfComponents();
6552 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
6554 return contentNotNullBase()->isDealingTS(iteration,order);
6557 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
6559 return contentNotNullBase()->getDtIt();
6562 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
6564 contentNotNullBase()->fillIteration(p);
6567 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
6569 contentNotNullBase()->fillTypesOfFieldAvailable(types);
6572 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
6574 contentNotNullBase()->setInfo(infos);
6577 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
6579 return contentNotNullBase()->getInfo();
6581 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
6583 return contentNotNullBase()->getInfo();
6586 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
6588 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
6591 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
6593 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6596 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
6598 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6601 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
6603 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
6606 void MEDFileAnyTypeField1TS::convertMedBallIntoClassic()
6608 return contentNotNullBase()->convertMedBallIntoClassic();
6611 void MEDFileAnyTypeField1TS::makeReduction(INTERP_KERNEL::NormalizedCellType ct, TypeOfField tof, const DataArrayInt *pfl)
6613 return contentNotNullBase()->makeReduction(ct,tof,pfl);
6616 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
6618 return contentNotNullBase()->getTypesOfFieldAvailable();
6621 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,
6622 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6624 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
6628 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
6629 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
6630 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
6632 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
6634 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6636 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
6637 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
6638 std::size_t sz(contentsSplit.size());
6639 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6640 for(std::size_t i=0;i<sz;i++)
6642 ret[i]=shallowCpy();
6643 ret[i]->_content=contentsSplit[i];
6649 * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
6650 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6652 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
6654 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6656 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
6657 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
6658 std::size_t sz(contentsSplit.size());
6659 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6660 for(std::size_t i=0;i<sz;i++)
6662 ret[i]=shallowCpy();
6663 ret[i]->_content=contentsSplit[i];
6669 * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this.
6670 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6672 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const
6674 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6676 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !");
6677 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
6678 std::size_t sz(contentsSplit.size());
6679 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6680 for(std::size_t i=0;i<sz;i++)
6682 ret[i]=shallowCpy();
6683 ret[i]->_content=contentsSplit[i];
6688 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCopy() const
6690 MCAuto<MEDFileAnyTypeField1TS> ret=shallowCpy();
6691 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
6692 ret->_content=_content->deepCopy();
6693 ret->deepCpyGlobs(*this);
6697 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
6699 return contentNotNullBase()->copyTinyInfoFrom(field,arr);
6705 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6706 * the first field that has been read from a specified MED file.
6707 * \param [in] fileName - the name of the MED file to read.
6708 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6709 * is to delete this field using decrRef() as it is no more needed.
6710 * \throw If reading the file fails.
6712 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll)
6714 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6715 return New(fid,loadAll);
6718 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, bool loadAll)
6720 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,loadAll,0));
6721 ret->contentNotNull();
6726 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6727 * a given field that has been read from a specified MED file.
6728 * \param [in] fileName - the name of the MED file to read.
6729 * \param [in] fieldName - the name of the field to read.
6730 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6731 * is to delete this field using decrRef() as it is no more needed.
6732 * \throw If reading the file fails.
6733 * \throw If there is no field named \a fieldName in the file.
6735 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6737 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6738 return New(fid,fieldName,loadAll);
6741 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
6743 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,fieldName,loadAll,0));
6744 ret->contentNotNull();
6749 * Returns a new instance of MEDFileField1TS holding data of a given time step of
6750 * a given field that has been read from a specified MED file.
6751 * \param [in] fileName - the name of the MED file to read.
6752 * \param [in] fieldName - the name of the field to read.
6753 * \param [in] iteration - the iteration number of a required time step.
6754 * \param [in] order - the iteration order number of required time step.
6755 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6756 * is to delete this field using decrRef() as it is no more needed.
6757 * \throw If reading the file fails.
6758 * \throw If there is no field named \a fieldName in the file.
6759 * \throw If the required time step is missing from the file.
6761 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6763 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6764 return New(fid,fieldName,iteration,order,loadAll);
6767 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
6769 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,fieldName,iteration,order,loadAll,0));
6770 ret->contentNotNull();
6775 * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6776 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6778 * Returns a new instance of MEDFileField1TS holding either a shallow copy
6779 * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
6780 * \warning this is a shallow copy constructor
6781 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
6782 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
6783 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6784 * is to delete this field using decrRef() as it is no more needed.
6786 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6788 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(other,shallowCopyOfContent));
6789 ret->contentNotNull();
6794 * Returns a new empty instance of MEDFileField1TS.
6795 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6796 * is to delete this field using decrRef() as it is no more needed.
6798 MEDFileField1TS *MEDFileField1TS::New()
6800 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS);
6801 ret->contentNotNull();
6806 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
6807 * following the given input policy.
6809 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6810 * By default (true) the globals are deeply copied.
6811 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
6813 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
6815 MCAuto<MEDFileIntField1TS> ret;
6816 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6819 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
6821 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
6822 MCAuto<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
6823 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc));
6826 ret=MEDFileIntField1TS::New();
6828 ret->deepCpyGlobs(*this);
6830 ret->shallowCpyGlobs(*this);
6834 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const
6836 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6838 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
6839 const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
6841 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 !");
6845 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull()
6847 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6849 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
6850 MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
6852 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 !");
6856 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
6859 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
6861 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
6862 DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6864 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6865 f->setArray(arrOutC);
6868 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MCAuto<DataArray>& arr)
6871 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
6872 DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6874 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6880 * Return an extraction of \a this using \a extractDef map to specify the extraction.
6881 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
6883 * \return A new object that the caller is responsible to deallocate.
6884 * \sa MEDFileUMesh::deduceNodeSubPartFromCellSubPart , MEDFileUMesh::extractPart
6886 MEDFileField1TS *MEDFileField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
6889 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : input mesh is NULL !");
6890 MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
6891 std::vector<TypeOfField> tof(getTypesOfFieldAvailable());
6892 for(std::vector<TypeOfField>::const_iterator it0=tof.begin();it0!=tof.end();it0++)
6894 if((*it0)!=ON_NODES)
6896 std::vector<int> levs;
6897 getNonEmptyLevels(mm->getName(),levs);
6898 for(std::vector<int>::const_iterator lev=levs.begin();lev!=levs.end();lev++)
6900 std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(*lev));
6901 if(it2!=extractDef.end())
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_CELLS,(*lev),mm));
6907 MCAuto<MEDCouplingFieldDouble> fOut(f->buildSubPart(t));
6908 ret->setFieldNoProfileSBT(fOut);
6914 std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(1));
6915 if(it2==extractDef.end())
6916 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a NODE field and no extract array available for NODE !");
6917 MCAuto<DataArrayInt> t((*it2).second);
6919 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6920 MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_NODES,0,mm));
6921 MCAuto<MEDCouplingFieldDouble> fOut(f->deepCopy());
6922 DataArrayDouble *arr(f->getArray());
6923 MCAuto<DataArrayDouble> newArr(arr->selectByTupleIdSafe(t->begin(),t->end()));
6924 fOut->setArray(newArr);
6925 ret->setFieldNoProfileSBT(fOut);
6931 MEDFileField1TS::MEDFileField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
6932 try:MEDFileAnyTypeField1TS(fid,loadAll,ms)
6935 catch(INTERP_KERNEL::Exception& e)
6938 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6939 try:MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms)
6942 catch(INTERP_KERNEL::Exception& e)
6945 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6946 try:MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms)
6949 catch(INTERP_KERNEL::Exception& e)
6953 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6954 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6956 * \warning this is a shallow copy constructor
6958 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6959 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6962 catch(INTERP_KERNEL::Exception& e)
6965 MEDFileField1TS::MEDFileField1TS()
6967 _content=new MEDFileField1TSWithoutSDA;
6971 * 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
6972 * method should be called (getFieldOnMeshAtLevel for example).
6973 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
6975 * \param [in] mesh - the mesh the field is lying on
6976 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6977 * caller is to delete this field using decrRef() as it is no more needed.
6979 MEDCouplingFieldDouble *MEDFileField1TS::field(const MEDFileMesh *mesh) const
6981 MCAuto<DataArray> arrOut;
6982 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
6983 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6988 * Returns a new MEDCouplingFieldDouble of a given type lying on
6989 * mesh entities of a given dimension of the first mesh in MED file. If \a this field
6990 * has not been constructed via file reading, an exception is thrown.
6991 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6992 * \param [in] type - a spatial discretization of interest.
6993 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6994 * \param [in] renumPol - specifies how to permute values of the result field according to
6995 * the optional numbers of cells and nodes, if any. The valid values are
6996 * - 0 - do not permute.
6997 * - 1 - permute cells.
6998 * - 2 - permute nodes.
6999 * - 3 - permute cells and nodes.
7001 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
7002 * caller is to delete this field using decrRef() as it is no more needed.
7003 * \throw If \a this field has not been constructed via file reading.
7004 * \throw If the MED file is not readable.
7005 * \throw If there is no mesh in the MED file.
7006 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7007 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7008 * \sa getFieldOnMeshAtLevel()
7010 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
7012 if(getFileName().empty())
7013 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7014 MCAuto<DataArray> arrOut;
7015 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
7016 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
7021 * Returns a new MEDCouplingFieldDouble of a given type lying on
7022 * the top level cells of the first mesh in MED file. If \a this field
7023 * has not been constructed via file reading, an exception is thrown.
7024 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7025 * \param [in] type - a spatial discretization of interest.
7026 * \param [in] renumPol - specifies how to permute values of the result field according to
7027 * the optional numbers of cells and nodes, if any. The valid values are
7028 * - 0 - do not permute.
7029 * - 1 - permute cells.
7030 * - 2 - permute nodes.
7031 * - 3 - permute cells and nodes.
7033 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
7034 * caller is to delete this field using decrRef() as it is no more needed.
7035 * \throw If \a this field has not been constructed via file reading.
7036 * \throw If the MED file is not readable.
7037 * \throw If there is no mesh in the MED file.
7038 * \throw If no field values of the given \a type.
7039 * \throw If no field values lying on the top level support.
7040 * \sa getFieldAtLevel()
7042 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
7044 if(getFileName().empty())
7045 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
7046 MCAuto<DataArray> arrOut;
7047 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
7048 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
7053 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
7054 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7055 * \param [in] type - a spatial discretization of the new field.
7056 * \param [in] mesh - the supporting mesh.
7057 * \param [in] renumPol - specifies how to permute values of the result field according to
7058 * the optional numbers of cells and nodes, if any. The valid values are
7059 * - 0 - do not permute.
7060 * - 1 - permute cells.
7061 * - 2 - permute nodes.
7062 * - 3 - permute cells and nodes.
7064 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
7065 * caller is to delete this field using decrRef() as it is no more needed.
7066 * \throw If no field of \a this is lying on \a mesh.
7067 * \throw If the mesh is empty.
7068 * \throw If no field values of the given \a type are available.
7069 * \sa getFieldAtLevel()
7070 * \sa getFieldOnMeshAtLevel()
7072 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
7074 MCAuto<DataArray> arrOut;
7075 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
7076 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
7081 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
7082 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7083 * \param [in] type - a spatial discretization of interest.
7084 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7085 * \param [in] mesh - the supporting mesh.
7086 * \param [in] renumPol - specifies how to permute values of the result field according to
7087 * the optional numbers of cells and nodes, if any. The valid values are
7088 * - 0 - do not permute.
7089 * - 1 - permute cells.
7090 * - 2 - permute nodes.
7091 * - 3 - permute cells and nodes.
7093 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
7094 * caller is to delete this field using decrRef() as it is no more needed.
7095 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7096 * \throw If no field of \a this is lying on \a mesh.
7097 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7098 * \sa getFieldAtLevel()
7099 * \sa getFieldOnMeshAtLevel()
7101 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
7103 MCAuto<DataArray> arrOut;
7104 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
7105 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
7110 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
7111 * This method is called "Old" because in MED3 norm a field has only one meshName
7112 * attached, so this method is for readers of MED2 files. If \a this field
7113 * has not been constructed via file reading, an exception is thrown.
7114 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7115 * \param [in] type - a spatial discretization of interest.
7116 * \param [in] mName - a name of the supporting mesh.
7117 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7118 * \param [in] renumPol - specifies how to permute values of the result field according to
7119 * the optional numbers of cells and nodes, if any. The valid values are
7120 * - 0 - do not permute.
7121 * - 1 - permute cells.
7122 * - 2 - permute nodes.
7123 * - 3 - permute cells and nodes.
7125 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
7126 * caller is to delete this field using decrRef() as it is no more needed.
7127 * \throw If the MED file is not readable.
7128 * \throw If there is no mesh named \a mName in the MED file.
7129 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7130 * \throw If \a this field has not been constructed via file reading.
7131 * \throw If no field of \a this is lying on the mesh named \a mName.
7132 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7133 * \sa getFieldAtLevel()
7135 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
7137 if(getFileName().empty())
7138 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7139 MCAuto<DataArray> arrOut;
7140 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull()));
7141 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
7146 * Returns values and a profile of the field of a given type lying on a given support.
7147 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7148 * \param [in] type - a spatial discretization of the field.
7149 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7150 * \param [in] mesh - the supporting mesh.
7151 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
7152 * field of interest lies on. If the field lies on all entities of the given
7153 * dimension, all ids in \a pfl are zero. The caller is to delete this array
7154 * using decrRef() as it is no more needed.
7155 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
7156 * field. The caller is to delete this array using decrRef() as it is no more needed.
7157 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7158 * \throw If no field of \a this is lying on \a mesh.
7159 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7161 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
7163 MCAuto<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
7164 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
7168 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
7169 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
7170 * "Sort By Type"), if not, an exception is thrown.
7171 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7172 * \param [in] field - the field to add to \a this.
7173 * \throw If the name of \a field is empty.
7174 * \throw If the data array of \a field is not set.
7175 * \throw If the data array is already allocated but has different number of components
7177 * \throw If the underlying mesh of \a field has no name.
7178 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
7180 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
7183 contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
7187 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
7188 * can be an aggregation of several MEDCouplingFieldDouble instances.
7189 * The mesh support of input parameter \a field is ignored here, it can be NULL.
7190 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
7193 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
7194 * A new profile is added only if no equal profile is missing.
7195 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7196 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
7197 * \param [in] mesh - the supporting mesh of \a field.
7198 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
7199 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
7200 * \throw If either \a field or \a mesh or \a profile has an empty name.
7201 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7202 * \throw If the data array of \a field is not set.
7203 * \throw If the data array of \a this is already allocated but has different number of
7204 * components than \a field.
7205 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
7206 * \sa setFieldNoProfileSBT()
7208 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
7211 contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
7214 MEDFileField1TS *MEDFileField1TS::shallowCpy() const
7216 return new MEDFileField1TS(*this);
7219 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const
7221 return contentNotNull()->getUndergroundDataArrayTemplate();
7224 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7226 return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
7229 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
7230 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
7232 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
7235 //= MEDFileIntField1TS
7237 MEDFileIntField1TS *MEDFileIntField1TS::New()
7239 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS);
7240 ret->contentNotNull();
7244 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll)
7246 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
7247 return MEDFileIntField1TS::New(fid,loadAll);
7250 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, bool loadAll)
7252 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,loadAll,0));
7253 ret->contentNotNull();
7257 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
7259 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
7260 return MEDFileIntField1TS::New(fid,fieldName,loadAll);
7263 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
7265 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,loadAll,0));
7266 ret->contentNotNull();
7270 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
7272 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
7273 return MEDFileIntField1TS::New(fid,fieldName,iteration,order,loadAll);
7276 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
7278 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,iteration,order,loadAll,0));
7279 ret->contentNotNull();
7283 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
7285 MCAuto<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
7286 ret->contentNotNull();
7290 MEDFileIntField1TS::MEDFileIntField1TS()
7292 _content=new MEDFileIntField1TSWithoutSDA;
7295 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
7296 try:MEDFileAnyTypeField1TS(fid,loadAll,ms)
7299 catch(INTERP_KERNEL::Exception& e)
7302 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
7303 try:MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms)
7306 catch(INTERP_KERNEL::Exception& e)
7309 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
7310 try:MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms)
7313 catch(INTERP_KERNEL::Exception& e)
7317 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
7318 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
7320 * \warning this is a shallow copy constructor
7322 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
7326 MEDFileIntField1TS *MEDFileIntField1TS::shallowCpy() const
7328 return new MEDFileIntField1TS(*this);
7332 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
7333 * following the given input policy.
7335 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
7336 * By default (true) the globals are deeply copied.
7337 * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
7339 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const
7341 MCAuto<MEDFileField1TS> ret;
7342 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
7345 const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
7347 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
7348 MCAuto<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
7349 ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc));
7352 ret=MEDFileField1TS::New();
7354 ret->deepCpyGlobs(*this);
7356 ret->shallowCpyGlobs(*this);
7361 * Adds a MEDCouplingFieldInt to \a this. The underlying mesh of the given field is
7362 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
7363 * "Sort By Type"), if not, an exception is thrown.
7364 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7365 * \param [in] field - the field to add to \a this.
7366 * \throw If the name of \a field is empty.
7367 * \throw If the data array of \a field is not set.
7368 * \throw If the data array is already allocated but has different number of components
7370 * \throw If the underlying mesh of \a field has no name.
7371 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
7373 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldInt *field)
7375 MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
7377 contentNotNull()->setFieldNoProfileSBT(field2,field->getArray(),*this,*contentNotNull());
7381 * Adds a MEDCouplingFieldInt to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
7382 * can be an aggregation of several MEDCouplingFieldDouble instances.
7383 * The mesh support of input parameter \a field is ignored here, it can be NULL.
7384 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
7387 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
7388 * A new profile is added only if no equal profile is missing.
7389 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7390 * \param [in] field - the field to add to \a this.
7391 * \param [in] mesh - the supporting mesh of \a field.
7392 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
7393 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
7394 * \throw If either \a field or \a mesh or \a profile has an empty name.
7395 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7396 * \throw If the data array of \a field is not set.
7397 * \throw If the data array of \a this is already allocated but has different number of
7398 * components than \a field.
7399 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
7400 * \sa setFieldNoProfileSBT()
7402 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
7404 MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
7406 contentNotNull()->setFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
7409 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const
7411 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7413 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
7414 const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
7416 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 !");
7420 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
7422 if(getFileName().empty())
7423 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7424 MCAuto<DataArray> arrOut;
7425 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
7426 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7430 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MCAuto<DataArray>& arr)
7433 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
7434 DataArrayInt *arrC(dynamic_cast<DataArrayInt *>((DataArray *)arr));
7436 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
7441 MCAuto<MEDCouplingFieldInt> MEDFileIntField1TS::SetDataArrayDoubleInIntField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
7444 double t0(f->getTime(t1,t2));
7445 MCAuto<DataArrayInt> arr2(DynamicCastSafe<DataArray,DataArrayInt>(arr));
7446 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
7447 MCAuto<MEDCouplingFieldInt> ret(MEDCouplingFieldInt::New(*ft));
7448 ret->setTime(t0,t1,t2); ret->setArray(arr2);
7452 MCAuto<MEDCouplingFieldDouble> MEDFileIntField1TS::ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f)
7455 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ConvertFieldIntToFieldDouble : null input field !");
7457 double t0(f->getTime(t1,t2));
7458 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
7459 MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(*ft));
7460 ret->setTime(t0,t1,t2);
7464 MEDFileIntField1TS *MEDFileIntField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
7466 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::extractPart : not implemented yet !");
7470 * 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
7471 * method should be called (getFieldOnMeshAtLevel for example).
7472 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
7474 * \param [in] mesh - the mesh the field is lying on
7475 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
7476 * caller is to delete this field using decrRef() as it is no more needed.
7478 MEDCouplingFieldInt *MEDFileIntField1TS::field(const MEDFileMesh *mesh) const
7480 MCAuto<DataArray> arrOut;
7481 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
7482 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7487 * Returns a new MEDCouplingFieldInt of a given type lying on
7488 * the top level cells of the first mesh in MED file. If \a this field
7489 * has not been constructed via file reading, an exception is thrown.
7490 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7491 * \param [in] type - a spatial discretization of interest.
7492 * \param [in] renumPol - specifies how to permute values of the result field according to
7493 * the optional numbers of cells and nodes, if any. The valid values are
7494 * - 0 - do not permute.
7495 * - 1 - permute cells.
7496 * - 2 - permute nodes.
7497 * - 3 - permute cells and nodes.
7499 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7500 * caller is to delete this field using decrRef() as it is no more needed.
7501 * \throw If \a this field has not been constructed via file reading.
7502 * \throw If the MED file is not readable.
7503 * \throw If there is no mesh in the MED file.
7504 * \throw If no field values of the given \a type.
7505 * \throw If no field values lying on the top level support.
7506 * \sa getFieldAtLevel()
7508 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
7510 if(getFileName().empty())
7511 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
7512 MCAuto<DataArray> arrOut;
7513 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
7514 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7519 * Returns a new MEDCouplingFieldInt of given type lying on a given mesh.
7520 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7521 * \param [in] type - a spatial discretization of the new field.
7522 * \param [in] mesh - the supporting mesh.
7523 * \param [in] renumPol - specifies how to permute values of the result field according to
7524 * the optional numbers of cells and nodes, if any. The valid values are
7525 * - 0 - do not permute.
7526 * - 1 - permute cells.
7527 * - 2 - permute nodes.
7528 * - 3 - permute cells and nodes.
7530 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7531 * caller is to delete this field using decrRef() as it is no more needed.
7532 * \throw If no field of \a this is lying on \a mesh.
7533 * \throw If the mesh is empty.
7534 * \throw If no field values of the given \a type are available.
7535 * \sa getFieldAtLevel()
7536 * \sa getFieldOnMeshAtLevel()
7538 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
7540 MCAuto<DataArray> arrOut;
7541 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
7542 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7547 * Returns a new MEDCouplingFieldInt of a given type lying on a given support.
7548 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7549 * \param [in] type - a spatial discretization of interest.
7550 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7551 * \param [in] mesh - the supporting mesh.
7552 * \param [in] renumPol - specifies how to permute values of the result field according to
7553 * the optional numbers of cells and nodes, if any. The valid values are
7554 * - 0 - do not permute.
7555 * - 1 - permute cells.
7556 * - 2 - permute nodes.
7557 * - 3 - permute cells and nodes.
7559 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7560 * caller is to delete this field using decrRef() as it is no more needed.
7561 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7562 * \throw If no field of \a this is lying on \a mesh.
7563 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7564 * \sa getFieldAtLevel()
7565 * \sa getFieldOnMeshAtLevel()
7567 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
7569 MCAuto<DataArray> arrOut;
7570 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
7571 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7576 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
7577 * This method is called "Old" because in MED3 norm a field has only one meshName
7578 * attached, so this method is for readers of MED2 files. If \a this field
7579 * has not been constructed via file reading, an exception is thrown.
7580 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7581 * \param [in] type - a spatial discretization of interest.
7582 * \param [in] mName - a name of the supporting mesh.
7583 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7584 * \param [in] renumPol - specifies how to permute values of the result field according to
7585 * the optional numbers of cells and nodes, if any. The valid values are
7586 * - 0 - do not permute.
7587 * - 1 - permute cells.
7588 * - 2 - permute nodes.
7589 * - 3 - permute cells and nodes.
7591 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7592 * caller is to delete this field using decrRef() as it is no more needed.
7593 * \throw If the MED file is not readable.
7594 * \throw If there is no mesh named \a mName in the MED file.
7595 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7596 * \throw If \a this field has not been constructed via file reading.
7597 * \throw If no field of \a this is lying on the mesh named \a mName.
7598 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7599 * \sa getFieldAtLevel()
7601 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
7603 if(getFileName().empty())
7604 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7605 MCAuto<DataArray> arrOut;
7606 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
7607 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7612 * Returns values and a profile of the field of a given type lying on a given support.
7613 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7614 * \param [in] type - a spatial discretization of the field.
7615 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7616 * \param [in] mesh - the supporting mesh.
7617 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
7618 * field of interest lies on. If the field lies on all entities of the given
7619 * dimension, all ids in \a pfl are zero. The caller is to delete this array
7620 * using decrRef() as it is no more needed.
7621 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
7622 * field. The caller is to delete this array using decrRef() as it is no more needed.
7623 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7624 * \throw If no field of \a this is lying on \a mesh.
7625 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7627 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
7629 MCAuto<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
7630 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
7633 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull()
7635 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7637 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
7638 MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
7640 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 !");
7644 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const
7646 return contentNotNull()->getUndergroundDataArrayTemplate();
7649 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
7651 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
7655 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileFieldNameScope(fieldName)
7660 * \param [in] fieldId field id in C mode
7662 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7664 med_field_type typcha;
7665 std::string dtunitOut;
7666 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fieldId,false,_name,typcha,_infos,dtunitOut));
7667 setDtUnit(dtunitOut.c_str());
7668 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities);
7671 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)
7672 try:MEDFileFieldNameScope(fieldName),_infos(infos)
7674 setDtUnit(dtunit.c_str());
7675 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities);
7677 catch(INTERP_KERNEL::Exception& e)
7682 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
7684 std::size_t ret(_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MCAuto<MEDFileField1TSWithoutSDA>));
7685 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7686 ret+=(*it).capacity();
7690 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
7692 std::vector<const BigMemoryObject *> ret;
7693 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7694 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
7699 * 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
7702 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
7704 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7705 ret->setInfo(_infos);
7706 int sz=(int)_time_steps.size();
7707 for(const int *id=startIds;id!=endIds;id++)
7709 if(*id>=0 && *id<sz)
7711 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
7712 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7716 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7718 ret->pushBackTimeStep(tse2);
7722 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
7723 oss << " ! Should be in [0," << sz << ") !";
7724 throw INTERP_KERNEL::Exception(oss.str());
7727 if(ret->getNumberOfTS()>0)
7728 ret->synchronizeNameScope();
7729 ret->copyNameScope(*this);
7734 * 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
7737 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
7739 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
7740 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7741 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7742 ret->setInfo(_infos);
7743 int sz=(int)_time_steps.size();
7745 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
7749 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
7750 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7754 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7756 ret->pushBackTimeStep(tse2);
7760 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
7761 oss << " ! Should be in [0," << sz << ") !";
7762 throw INTERP_KERNEL::Exception(oss.str());
7765 if(ret->getNumberOfTS()>0)
7766 ret->synchronizeNameScope();
7767 ret->copyNameScope(*this);
7771 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7774 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7775 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7777 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7780 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7781 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
7782 ids->pushBackSilent(id);
7784 return buildFromTimeStepIds(ids->begin(),ids->end());
7787 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7790 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7791 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7793 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7796 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7797 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
7798 ids->pushBackSilent(id);
7800 return buildFromTimeStepIds(ids->begin(),ids->end());
7803 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfStructureElements() const
7805 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7806 if((*it).isNotNull())
7807 if((*it)->presenceOfStructureElements())
7812 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::onlyStructureElements() const
7814 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7815 if((*it).isNotNull())
7816 if(!(*it)->onlyStructureElements())
7821 void MEDFileAnyTypeFieldMultiTSWithoutSDA::killStructureElements()
7823 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
7824 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7825 if((*it).isNotNull())
7827 if((*it)->presenceOfStructureElements())
7829 if(!(*it)->onlyStructureElements())
7831 (*it)->killStructureElements();
7843 void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyStructureElements()
7845 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
7846 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7847 if((*it).isNotNull())
7849 if((*it)->presenceOfStructureElements())
7851 if(!(*it)->onlyStructureElements())
7852 (*it)->keepOnlyStructureElements();
7859 void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyOnSE(const std::string& seName)
7861 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
7862 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7863 if((*it).isNotNull())
7864 (*it)->keepOnlyOnSE(seName);
7867 void MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
7869 std::vector< std::pair<std::string,std::string> > ps2;
7870 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7871 if((*it).isNotNull())
7873 (*it)->getMeshSENames(ps2);
7877 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames : this appears to not contain SE only !");
7878 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7879 if((*it).isNotNull())
7881 std::vector< std::pair<std::string,std::string> > ps3;
7882 (*it)->getMeshSENames(ps3);
7884 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames : For the moment only homogeneous SE def through time managed !");
7886 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=ps2.begin();it!=ps2.end();it++)
7888 std::vector< std::pair<std::string,std::string> >::iterator it2(std::find(ps.begin(),ps.end(),*it));
7894 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
7896 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7898 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7901 if(cur->presenceOfMultiDiscPerGeoType())
7907 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
7912 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
7917 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
7920 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7922 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
7923 if(pt->isDealingTS(iteration,order))
7926 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
7927 std::vector< std::pair<int,int> > vp=getIterations();
7928 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
7929 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
7930 throw INTERP_KERNEL::Exception(oss.str());
7933 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
7935 return *_time_steps[getTimeStepPos(iteration,order)];
7938 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
7940 return *_time_steps[getTimeStepPos(iteration,order)];
7943 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const
7945 if(_time_steps.empty())
7946 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
7947 return _time_steps[0]->getMeshName();
7950 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const std::string& newMeshName)
7952 std::string oldName(getMeshName());
7953 std::vector< std::pair<std::string,std::string> > v(1);
7954 v[0].first=oldName; v[0].second=newMeshName;
7958 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
7961 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7963 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7965 ret=cur->changeMeshNames(modifTab) || ret;
7971 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
7973 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
7975 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
7979 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
7981 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7983 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
7986 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
7987 MEDFileFieldGlobsReal& glob)
7990 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7992 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
7994 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
7999 void MEDFileAnyTypeFieldMultiTSWithoutSDA::accept(MEDFileFieldVisitor& visitor) const
8001 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8002 if((*it).isNotNull())
8004 visitor.newTimeStepEntry(*it);
8005 (*it)->accept(visitor);
8006 visitor.endTimeStepEntry(*it);
8010 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8012 std::string startLine(bkOffset,' ');
8013 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
8015 oss << " (" << fmtsId << ")";
8016 oss << " has the following name: \"" << _name << "\"." << std::endl;
8017 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
8018 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
8020 oss << startLine << " - \"" << *it << "\"" << std::endl;
8023 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8025 std::string chapter(17,'0'+i);
8026 oss << startLine << chapter << std::endl;
8027 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
8029 cur->simpleRepr(bkOffset+2,oss,i);
8031 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
8032 oss << startLine << chapter << std::endl;
8036 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
8038 std::size_t sz=_time_steps.size();
8039 std::vector< std::pair<int,int> > ret(sz);
8041 for(std::size_t i=0;i<sz;i++)
8043 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
8046 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
8050 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
8051 throw INTERP_KERNEL::Exception(oss.str());
8057 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MCAuto<MEDFileAnyTypeField1TSWithoutSDA>& tse)
8059 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
8061 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
8062 checkCoherencyOfType(tse2);
8063 if(_time_steps.empty())
8065 setName(tse2->getName().c_str());
8066 setInfo(tse2->getInfo());
8068 checkThatComponentsMatch(tse2->getInfo());
8069 if(getDtUnit().empty() && !tse->getDtUnit().empty())
8070 setDtUnit(tse->getDtUnit());
8071 _time_steps.push_back(tse);
8074 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
8076 std::size_t nbOfCompo=_infos.size();
8077 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8079 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
8082 if((cur->getInfo()).size()!=nbOfCompo)
8084 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
8085 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
8086 throw INTERP_KERNEL::Exception(oss.str());
8088 cur->copyNameScope(*this);
8093 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8095 _time_steps.resize(nbPdt);
8096 for(int i=0;i<nbPdt;i++)
8098 std::vector< std::pair<int,int> > ts;
8099 med_int numdt=0,numo=0;
8101 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt));
8106 _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
8111 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
8115 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
8118 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities);
8120 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entities);
8121 synchronizeNameScope();
8125 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
8127 if(_time_steps.empty())
8128 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
8129 checkThatNbOfCompoOfTSMatchThis();
8130 std::vector<std::string> infos(getInfo());
8131 int nbComp=infos.size();
8132 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
8133 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
8134 for(int i=0;i<nbComp;i++)
8136 std::string info=infos[i];
8138 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
8139 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
8140 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
8143 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
8144 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
8145 int nbOfTS=_time_steps.size();
8146 for(int i=0;i<nbOfTS;i++)
8147 _time_steps[i]->writeLL(fid,opts,*this);
8150 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
8152 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8154 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
8156 elt->loadBigArraysRecursively(fid,nasc);
8160 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
8162 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8164 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
8166 elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
8170 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
8172 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8174 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
8176 elt->unloadArrays();
8180 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
8182 return _time_steps.size();
8185 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
8187 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
8188 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8190 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
8192 newTS.push_back(*it);
8197 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
8199 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
8200 int maxId=(int)_time_steps.size();
8202 std::set<int> idsToDel;
8203 for(const int *id=startIds;id!=endIds;id++,ii++)
8205 if(*id>=0 && *id<maxId)
8207 idsToDel.insert(*id);
8211 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
8212 throw INTERP_KERNEL::Exception(oss.str());
8215 for(int iii=0;iii<maxId;iii++)
8216 if(idsToDel.find(iii)==idsToDel.end())
8217 newTS.push_back(_time_steps[iii]);
8221 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
8223 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
8224 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
8225 if(nbOfEntriesToKill==0)
8227 std::size_t sz=_time_steps.size();
8228 std::vector<bool> b(sz,true);
8230 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
8232 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
8233 for(std::size_t i=0;i<sz;i++)
8235 newTS.push_back(_time_steps[i]);
8239 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
8242 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
8243 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
8245 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
8249 tmp->getTime(it2,ord);
8250 if(it2==iteration && order==ord)
8253 oss << "(" << it2 << "," << ord << "), ";
8256 throw INTERP_KERNEL::Exception(oss.str());
8259 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
8262 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
8264 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
8266 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
8270 double ti=tmp->getTime(it2,ord);
8271 if(fabs(time-ti)<eps)
8277 throw INTERP_KERNEL::Exception(oss.str());
8280 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
8282 int lgth=_time_steps.size();
8283 std::vector< std::pair<int,int> > ret(lgth);
8284 for(int i=0;i<lgth;i++)
8285 _time_steps[i]->fillIteration(ret[i]);
8290 * 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'
8291 * This method returns two things.
8292 * - The absolute dimension of 'this' in first parameter.
8293 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
8294 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
8296 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
8297 * Only these 3 discretizations will be taken into account here.
8299 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
8300 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
8301 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
8303 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
8304 * 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'.
8306 * Let's consider the typical following case :
8307 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
8308 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
8309 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
8311 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
8313 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
8315 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
8316 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
8317 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
8318 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
8320 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8322 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
8325 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
8327 if(pos<0 || pos>=(int)_time_steps.size())
8329 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
8330 throw INTERP_KERNEL::Exception(oss.str());
8332 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
8335 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
8336 oss << "\nTry to use following method eraseEmptyTS !";
8337 throw INTERP_KERNEL::Exception(oss.str());
8342 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
8344 if(pos<0 || pos>=(int)_time_steps.size())
8346 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
8347 throw INTERP_KERNEL::Exception(oss.str());
8349 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
8352 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
8353 oss << "\nTry to use following method eraseEmptyTS !";
8354 throw INTERP_KERNEL::Exception(oss.str());
8359 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
8361 std::vector<std::string> ret;
8362 std::set<std::string> ret2;
8363 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8365 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
8366 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
8367 if(ret2.find(*it2)==ret2.end())
8369 ret.push_back(*it2);
8376 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
8378 std::vector<std::string> ret;
8379 std::set<std::string> ret2;
8380 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8382 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
8383 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
8384 if(ret2.find(*it2)==ret2.end())
8386 ret.push_back(*it2);
8393 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
8395 std::vector<std::string> ret;
8396 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8398 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
8399 ret.insert(ret.end(),tmp.begin(),tmp.end());
8404 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
8406 std::vector<std::string> ret;
8407 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8409 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
8410 ret.insert(ret.end(),tmp.begin(),tmp.end());
8415 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8417 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8418 (*it)->changePflsRefsNamesGen2(mapOfModif);
8421 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8423 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8424 (*it)->changeLocsRefsNamesGen2(mapOfModif);
8427 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
8429 int lgth=_time_steps.size();
8430 std::vector< std::vector<TypeOfField> > ret(lgth);
8431 for(int i=0;i<lgth;i++)
8432 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
8437 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
8439 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
8441 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
8444 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCopy() const
8446 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
8448 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8450 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
8451 ret->_time_steps[i]=(*it)->deepCopy();
8456 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
8458 std::size_t sz(_infos.size()),sz2(_time_steps.size());
8459 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
8460 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
8461 for(std::size_t i=0;i<sz;i++)
8463 ret[i]=shallowCpy();
8464 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
8466 for(std::size_t i=0;i<sz2;i++)
8468 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
8471 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
8472 throw INTERP_KERNEL::Exception(oss.str());
8476 for(std::size_t i=0;i<sz;i++)
8477 for(std::size_t j=0;j<sz2;j++)
8478 ret[i]->_time_steps[j]=ts[j][i];
8483 * This method splits into discretization each time steps in \a this.
8484 * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
8486 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
8488 std::size_t sz(_time_steps.size());
8489 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
8490 for(std::size_t i=0;i<sz;i++)
8492 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
8495 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
8496 throw INTERP_KERNEL::Exception(oss.str());
8498 items[i]=timeStep->splitDiscretizations();
8501 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
8502 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
8503 std::vector< TypeOfField > types;
8504 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
8505 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
8507 std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
8509 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
8510 std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
8511 if(it2==types.end())
8512 types.push_back(ts[0]);
8514 ret.resize(types.size()); ret2.resize(types.size());
8515 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
8516 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
8518 TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
8519 std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
8520 ret2[pos].push_back(*it1);
8522 for(std::size_t i=0;i<types.size();i++)
8524 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
8525 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
8526 elt->pushBackTimeStep(*it1);//also updates infos in elt
8528 elt->MEDFileFieldNameScope::operator=(*this);
8534 * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
8536 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
8538 std::size_t sz(_time_steps.size());
8539 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
8540 std::size_t szOut(std::numeric_limits<std::size_t>::max());
8541 for(std::size_t i=0;i<sz;i++)
8543 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
8546 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
8547 throw INTERP_KERNEL::Exception(oss.str());
8549 items[i]=timeStep->splitMultiDiscrPerGeoTypes();
8550 if(szOut==std::numeric_limits<std::size_t>::max())
8551 szOut=items[i].size();
8553 if(items[i].size()!=szOut)
8554 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
8556 if(szOut==std::numeric_limits<std::size_t>::max())
8557 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
8558 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
8559 for(std::size_t i=0;i<szOut;i++)
8561 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
8562 for(std::size_t j=0;j<sz;j++)
8563 elt->pushBackTimeStep(items[j][i]);
8565 elt->MEDFileFieldNameScope::operator=(*this);
8570 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
8572 _name=field->getName();
8574 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
8576 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
8577 _infos=arr->getInfoOnComponents();
8580 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
8582 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
8583 if(_name!=field->getName())
8585 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
8586 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
8587 throw INTERP_KERNEL::Exception(oss.str());
8590 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
8591 checkThatComponentsMatch(arr->getInfoOnComponents());
8594 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
8596 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
8597 if(getInfo().size()!=compos.size())
8599 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
8600 oss << " number of components of element to append (" << compos.size() << ") !";
8601 throw INTERP_KERNEL::Exception(oss.str());
8605 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
8606 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
8607 oss << " But compo in input fields are : ";
8608 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
8610 throw INTERP_KERNEL::Exception(oss.str());
8614 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
8616 std::size_t sz=_infos.size();
8618 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
8620 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
8622 if(elt->getInfo().size()!=sz)
8624 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
8625 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
8626 throw INTERP_KERNEL::Exception(oss.str());
8631 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
8634 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8635 if(!_time_steps.empty())
8636 checkCoherencyOfTinyInfo(field,arr);
8637 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8638 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8639 objC->setFieldNoProfileSBT(field,arr,glob,*this);
8640 copyTinyInfoFrom(field,arr);
8641 _time_steps.push_back(obj);
8644 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
8647 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8648 if(!_time_steps.empty())
8649 checkCoherencyOfTinyInfo(field,arr);
8650 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8651 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8652 objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
8653 copyTinyInfoFrom(field,arr);
8654 _time_steps.push_back(obj);
8657 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ts)
8659 int sz=(int)_time_steps.size();
8662 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
8663 throw INTERP_KERNEL::Exception(oss.str());
8665 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
8668 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
8670 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
8671 throw INTERP_KERNEL::Exception(oss.str());
8677 //= MEDFileFieldMultiTSWithoutSDA
8679 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)
8681 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8684 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
8688 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8693 * \param [in] fieldId field id in C mode
8695 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8696 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8699 catch(INTERP_KERNEL::Exception& e)
8702 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)
8703 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8706 catch(INTERP_KERNEL::Exception& e)
8709 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8711 return new MEDFileField1TSWithoutSDA;
8714 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8717 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8718 const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
8720 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8723 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const
8725 return MEDFileField1TSWithoutSDA::TYPE_STR;
8728 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const
8730 return new MEDFileFieldMultiTSWithoutSDA(*this);
8733 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const
8735 return new MEDFileFieldMultiTSWithoutSDA;
8739 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
8740 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
8742 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
8744 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
8745 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8747 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
8748 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
8751 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
8753 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
8754 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8756 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8758 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8761 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
8763 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
8764 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
8765 ret->setIteration(i,elt);
8771 //= MEDFileAnyTypeFieldMultiTS
8773 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
8777 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8778 try:MEDFileFieldGlobsReal(fid)
8780 _content=BuildContentFrom(fid,loadAll,ms);
8783 catch(INTERP_KERNEL::Exception& e)
8788 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8790 med_field_type typcha;
8791 std::vector<std::string> infos;
8794 MEDFileAnyTypeField1TS::LocateField(fid,fieldName,i,typcha,infos,dtunit);
8795 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8800 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8805 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8810 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] !";
8811 throw INTERP_KERNEL::Exception(oss.str());
8814 ret->setDtUnit(dtunit.c_str());
8818 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8820 med_field_type typcha;
8822 std::vector<std::string> infos;
8823 std::string dtunit,fieldName;
8824 MEDFileAnyTypeField1TS::LocateField2(fid,0,true,fieldName,typcha,infos,dtunit);
8825 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8830 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8835 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8840 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] !";
8841 throw INTERP_KERNEL::Exception(oss.str());
8844 ret->setDtUnit(dtunit.c_str());
8848 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c)
8851 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
8852 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
8854 MCAuto<MEDFileFieldMultiTS> ret(MEDFileFieldMultiTS::New());
8855 ret->_content=c; c->incrRef();
8858 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
8860 MCAuto<MEDFileIntFieldMultiTS> ret(MEDFileIntFieldMultiTS::New());
8861 ret->_content=c; c->incrRef();
8864 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
8867 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, med_idt fid)
8869 MEDFileAnyTypeFieldMultiTS *ret(BuildNewInstanceFromContent(c));
8870 std::string fileName(FileNameFromFID(fid));
8871 ret->setFileName(fileName);
8875 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8876 try:MEDFileFieldGlobsReal(fid)
8878 _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
8881 catch(INTERP_KERNEL::Exception& e)
8886 //= MEDFileIntFieldMultiTSWithoutSDA
8888 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)
8890 return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8893 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
8897 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8901 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)
8902 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8905 catch(INTERP_KERNEL::Exception& e)
8909 * \param [in] fieldId field id in C mode
8911 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8912 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8915 catch(INTERP_KERNEL::Exception& e)
8918 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8920 return new MEDFileIntField1TSWithoutSDA;
8923 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8926 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8927 const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
8929 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8932 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const
8934 return MEDFileIntField1TSWithoutSDA::TYPE_STR;
8937 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const
8939 return new MEDFileIntFieldMultiTSWithoutSDA(*this);
8942 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const
8944 return new MEDFileIntFieldMultiTSWithoutSDA;
8947 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const
8949 MCAuto<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
8950 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8952 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8954 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8957 const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
8959 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
8960 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
8961 ret->setIteration(i,elt);
8967 //= MEDFileAnyTypeFieldMultiTS
8970 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
8971 * that has been read from a specified MED file.
8972 * \param [in] fileName - the name of the MED file to read.
8973 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8974 * is to delete this field using decrRef() as it is no more needed.
8975 * \throw If reading the file fails.
8977 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
8979 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8980 return New(fid,loadAll);
8983 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, bool loadAll)
8985 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
8986 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8987 ret->loadGlobals(fid);
8992 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
8993 * that has been read from a specified MED file.
8994 * \param [in] fileName - the name of the MED file to read.
8995 * \param [in] fieldName - the name of the field to read.
8996 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8997 * is to delete this field using decrRef() as it is no more needed.
8998 * \throw If reading the file fails.
8999 * \throw If there is no field named \a fieldName in the file.
9001 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9003 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9004 return New(fid,fieldName,loadAll);
9007 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
9009 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
9010 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
9011 ret->loadGlobals(fid);
9016 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9017 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9019 * \warning this is a shallow copy constructor
9021 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9023 if(!shallowCopyOfContent)
9025 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
9026 otherPtr->incrRef();
9027 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
9031 _content=other.shallowCpy();
9035 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
9037 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
9039 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
9043 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
9045 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
9047 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
9051 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
9053 return contentNotNullBase()->getPflsReallyUsed2();
9056 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
9058 return contentNotNullBase()->getLocsReallyUsed2();
9061 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
9063 return contentNotNullBase()->getPflsReallyUsedMulti2();
9066 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
9068 return contentNotNullBase()->getLocsReallyUsedMulti2();
9071 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
9073 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
9076 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
9078 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
9081 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
9083 return contentNotNullBase()->getNumberOfTS();
9086 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
9088 contentNotNullBase()->eraseEmptyTS();
9091 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
9093 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
9096 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
9098 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
9101 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
9103 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
9104 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
9109 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
9111 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
9112 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
9117 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
9119 return contentNotNullBase()->getIterations();
9122 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
9124 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
9125 pushBackTimeStep(*it);
9128 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
9131 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
9132 int nbOfTS(fmts->getNumberOfTS());
9133 for(int i=0;i<nbOfTS;i++)
9135 MCAuto<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
9136 pushBackTimeStep(elt);
9140 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
9143 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
9144 checkCoherencyOfType(f1ts);
9146 MCAuto<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
9147 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
9149 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
9150 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
9151 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
9152 _content->pushBackTimeStep(cSafe);
9153 appendGlobs(*f1ts,1e-12);
9156 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
9158 contentNotNullBase()->synchronizeNameScope();
9161 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
9163 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
9166 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
9168 return contentNotNullBase()->getPosGivenTime(time,eps);
9171 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
9173 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
9176 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
9178 return contentNotNullBase()->getTypesOfFieldAvailable();
9181 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
9183 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
9186 std::string MEDFileAnyTypeFieldMultiTS::getName() const
9188 return contentNotNullBase()->getName();
9191 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
9193 contentNotNullBase()->setName(name);
9196 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
9198 return contentNotNullBase()->getDtUnit();
9201 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
9203 contentNotNullBase()->setDtUnit(dtUnit);
9206 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
9208 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
9211 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
9213 return contentNotNullBase()->getTimeSteps(ret1);
9216 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
9218 return contentNotNullBase()->getMeshName();
9221 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
9223 contentNotNullBase()->setMeshName(newMeshName);
9226 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
9228 return contentNotNullBase()->changeMeshNames(modifTab);
9231 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
9233 return contentNotNullBase()->getInfo();
9236 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
9238 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
9241 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
9243 return contentNotNullBase()->setInfo(info);
9246 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
9248 const std::vector<std::string> ret=getInfo();
9249 return (int)ret.size();
9252 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
9254 writeGlobals(fid,*this);
9255 contentNotNullBase()->writeLL(fid,*this);
9259 * This method alloc the arrays and load potentially huge arrays contained in this field.
9260 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
9261 * This method can be also called to refresh or reinit values from a file.
9263 * \throw If the fileName is not set or points to a non readable MED file.
9265 void MEDFileAnyTypeFieldMultiTS::loadArrays()
9267 if(getFileName().empty())
9268 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
9269 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
9270 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
9274 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
9275 * But once data loaded once, this method does nothing.
9277 * \throw If the fileName is not set or points to a non readable MED file.
9278 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
9280 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
9282 if(!getFileName().empty())
9284 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
9285 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
9290 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
9291 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
9292 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
9294 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
9296 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
9298 contentNotNullBase()->unloadArrays();
9302 * 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.
9303 * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
9304 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
9306 * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
9308 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
9310 if(!getFileName().empty())
9311 contentNotNullBase()->unloadArrays();
9314 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
9316 std::ostringstream oss;
9317 contentNotNullBase()->simpleRepr(0,oss,-1);
9318 simpleReprGlobs(oss);
9322 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
9324 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
9327 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
9329 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
9330 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
9335 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
9336 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
9337 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
9339 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
9341 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9343 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
9344 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
9345 std::size_t sz(contentsSplit.size());
9346 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
9347 for(std::size_t i=0;i<sz;i++)
9349 ret[i]=shallowCpy();
9350 ret[i]->_content=contentsSplit[i];
9356 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
9357 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
9359 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
9361 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9363 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
9364 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
9365 std::size_t sz(contentsSplit.size());
9366 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
9367 for(std::size_t i=0;i<sz;i++)
9369 ret[i]=shallowCpy();
9370 ret[i]->_content=contentsSplit[i];
9376 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
9377 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
9379 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
9381 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9383 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
9384 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
9385 std::size_t sz(contentsSplit.size());
9386 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
9387 for(std::size_t i=0;i<sz;i++)
9389 ret[i]=shallowCpy();
9390 ret[i]->_content=contentsSplit[i];
9395 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCopy() const
9397 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
9398 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
9399 ret->_content=_content->deepCopy();
9400 ret->deepCpyGlobs(*this);
9404 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
9410 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
9411 * \param [in] iteration - the iteration number of a required time step.
9412 * \param [in] order - the iteration order number of required time step.
9413 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. 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::getTimeStep(int iteration, int order) const
9419 int pos=getPosOfTimeStep(iteration,order);
9420 return getTimeStepAtPos(pos);
9424 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
9425 * \param [in] time - the time of the time step of interest.
9426 * \param [in] eps - a precision used to compare time values.
9427 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9428 * delete this field using decrRef() as it is no more needed.
9429 * \throw If there is no required time step in \a this field.
9431 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
9433 int pos=getPosGivenTime(time,eps);
9434 return getTimeStepAtPos(pos);
9438 * 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.
9439 * The float64 value of time attached to the pair of integers are not considered here.
9440 * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
9442 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
9443 * \throw If there is a null pointer in \a vectFMTS.
9445 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
9447 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
9448 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9449 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
9450 while(!lstFMTS.empty())
9452 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
9453 MEDFileAnyTypeFieldMultiTS *curIt(*it);
9455 throw INTERP_KERNEL::Exception(msg);
9456 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
9457 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
9458 elt.push_back(curIt); it=lstFMTS.erase(it);
9459 while(it!=lstFMTS.end())
9463 throw INTERP_KERNEL::Exception(msg);
9464 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
9466 { elt.push_back(curIt); it=lstFMTS.erase(it); }
9476 * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
9477 * All returned instances in a subvector can be safely loaded, rendered along time
9478 * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
9479 * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
9480 * 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).
9481 * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
9482 * 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.
9484 * \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().
9485 * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
9486 * \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.
9487 * \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.
9489 * \throw If an element in \a vectFMTS has not only one spatial discretization set.
9490 * \throw If an element in \a vectFMTS change of spatial discretization along time.
9491 * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
9492 * \thorw If some elements in \a vectFMTS do not have the same times steps.
9493 * \throw If mesh is null.
9494 * \throw If an element in \a vectFMTS is null.
9495 * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
9497 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& fsc)
9499 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
9501 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
9502 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9503 if(vectFMTS.empty())
9505 std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
9506 MEDFileAnyTypeFieldMultiTS *frstElt(*it);
9508 throw INTERP_KERNEL::Exception(msg);
9510 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
9511 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
9512 for(;it!=vectFMTS.end();it++,i++)
9515 throw INTERP_KERNEL::Exception(msg);
9516 TypeOfField tof0,tof1;
9517 if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
9520 vectFMTSNotNodes.push_back(*it);
9522 vectFMTSNodes.push_back(*it);
9525 vectFMTSNotNodes.push_back(*it);
9527 std::vector< MCAuto<MEDFileFastCellSupportComparator> > cmps;
9528 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
9530 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
9533 bool isFetched(false);
9534 for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
9537 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
9538 if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
9539 { ret[i].push_back(*it2); isFetched=true; }
9543 std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
9544 MCAuto<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
9545 ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
9553 * 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.
9554 * \param [out] cmps - same size than the returned vector.
9556 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& cmps)
9558 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9559 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
9560 while(!lstFMTS.empty())
9562 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
9563 MEDFileAnyTypeFieldMultiTS *ref(*it);
9564 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
9565 elt.push_back(ref); it=lstFMTS.erase(it);
9566 MCAuto<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
9567 MCAuto<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
9568 while(it!=lstFMTS.end())
9570 MEDFileAnyTypeFieldMultiTS *curIt(*it);
9571 if(cmp->isEqual(curIt))
9572 { elt.push_back(curIt); it=lstFMTS.erase(it); }
9576 ret.push_back(elt); cmps.push_back(cmp);
9582 * 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.
9583 * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
9585 * \throw If \a f0 or \a f1 has not only one spatial discretization set.
9586 * \throw If \a f0 or \a f1 change of spatial discretization along time.
9587 * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
9588 * \thorw If \a f0 and \a f1 do not have the same times steps.
9589 * \throw If mesh is null.
9590 * \throw If \a f0 or \a f1 is null.
9591 * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
9593 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
9596 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
9598 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
9599 if(f0->getMeshName()!=mesh->getName())
9601 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9602 throw INTERP_KERNEL::Exception(oss.str());
9604 if(f1->getMeshName()!=mesh->getName())
9606 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9607 throw INTERP_KERNEL::Exception(oss.str());
9609 int nts=f0->getNumberOfTS();
9610 if(nts!=f1->getNumberOfTS())
9611 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
9614 for(int i=0;i<nts;i++)
9616 MCAuto<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
9617 MCAuto<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
9618 std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
9619 if(tofs0.size()!=1 || tofs1.size()!=1)
9620 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
9623 if(tof0!=tofs0[0] || tof1!=tofs1[0])
9624 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
9627 { tof0=tofs0[0]; tof1=tofs1[0]; }
9628 if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
9630 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() << ") !";
9631 throw INTERP_KERNEL::Exception(oss.str());
9633 if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
9635 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() << ") !";
9636 throw INTERP_KERNEL::Exception(oss.str());
9638 if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
9640 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() << ") !";
9641 throw INTERP_KERNEL::Exception(oss.str());
9648 * Return an extraction of \a this using \a extractDef map to specify the extraction.
9649 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
9651 * \return A new object that the caller is responsible to deallocate.
9653 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
9656 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::extractPart : mesh is null !");
9657 MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(buildNewEmpty());
9658 int nbTS(getNumberOfTS());
9659 for(int i=0;i<nbTS;i++)
9661 MCAuto<MEDFileAnyTypeField1TS> f1ts(getTimeStepAtPos(i));
9662 MCAuto<MEDFileAnyTypeField1TS> f1tsOut(f1ts->extractPart(extractDef,mm));
9663 fmtsOut->pushBackTimeStep(f1tsOut);
9665 return fmtsOut.retn();
9669 MCAuto<MEDFileAnyTypeField1TS> AggregateHelperF1TS(const std::vector< typename MLFieldTraits<T>::F1TSType const *>& f1tss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9671 MCAuto< typename MLFieldTraits<T>::F1TSType > ret(MLFieldTraits<T>::F1TSType::New());
9673 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : empty vector !");
9674 std::size_t sz(f1tss.size()),i(0);
9675 std::vector< typename MLFieldTraits<T>::F1TSWSDAType const *> f1tsw(sz);
9676 for(typename std::vector< typename MLFieldTraits<T>::F1TSType const *>::const_iterator it=f1tss.begin();it!=f1tss.end();it++,i++)
9678 typename MLFieldTraits<T>::F1TSType const *elt(*it);
9680 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : presence of a null pointer !");
9681 f1tsw[i]=dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType const *>(elt->contentNotNullBase());
9683 typename MLFieldTraits<T>::F1TSWSDAType *retc(dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType *>(ret->contentNotNullBase()));
9685 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : internal error 1 !");
9686 retc->aggregate(f1tsw,dts);
9687 ret->setDtUnit(f1tss[0]->getDtUnit());
9688 return DynamicCast<typename MLFieldTraits<T>::F1TSType , MEDFileAnyTypeField1TS>(ret);
9692 MCAuto< MEDFileAnyTypeFieldMultiTS > AggregateHelperFMTS(const std::vector< typename MLFieldTraits<T>::FMTSType const *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9694 MCAuto< typename MLFieldTraits<T>::FMTSType > ret(MLFieldTraits<T>::FMTSType::New());
9696 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : empty vector !");
9697 std::size_t sz(fmtss.size());
9698 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9700 typename MLFieldTraits<T>::FMTSType const *elt(*it);
9702 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : presence of null pointer !");
9704 int nbTS(fmtss[0]->getNumberOfTS());
9705 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9706 if((*it)->getNumberOfTS()!=nbTS)
9707 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : all fields must have the same number of TS !");
9708 for(int iterTS=0;iterTS<nbTS;iterTS++)
9711 std::vector< typename MLFieldTraits<T>::F1TSType const *> f1tss(sz);
9712 std::vector< MCAuto<typename MLFieldTraits<T>::F1TSType> > f1tss2(sz);
9713 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++,i++)
9714 { f1tss2[i]=(*it)->getTimeStepAtPos(iterTS); f1tss[i]=f1tss2[i]; }
9715 MCAuto<MEDFileAnyTypeField1TS> f1ts(AggregateHelperF1TS<T>(f1tss,dts));
9716 ret->pushBackTimeStep(f1ts);
9717 ret->setDtUnit(f1ts->getDtUnit());
9719 return DynamicCast<typename MLFieldTraits<T>::FMTSType , MEDFileAnyTypeFieldMultiTS>(ret);
9723 * \a dts and \a ftmss are expected to have same size.
9725 MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileAnyTypeFieldMultiTS::Aggregate(const std::vector<const MEDFileAnyTypeFieldMultiTS *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9728 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : input vector is empty !");
9729 std::size_t sz(fmtss.size());
9730 std::vector<const MEDFileFieldMultiTS *> fmtss1;
9731 std::vector<const MEDFileIntFieldMultiTS *> fmtss2;
9732 for(std::vector<const MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9735 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : presence of null instance in input vector !");
9736 const MEDFileFieldMultiTS *elt1(dynamic_cast<const MEDFileFieldMultiTS *>(*it));
9739 fmtss1.push_back(elt1);
9742 const MEDFileIntFieldMultiTS *elt2(dynamic_cast<const MEDFileIntFieldMultiTS *>(*it));
9745 fmtss2.push_back(elt2);
9748 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not recognized type !");
9750 if(fmtss1.size()!=sz && fmtss2.size()!=sz)
9751 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : type of data is not homogeneous !");
9752 if(fmtss1.size()==sz)
9753 return AggregateHelperFMTS<double>(fmtss1,dts);
9754 if(fmtss2.size()!=sz)
9755 return AggregateHelperFMTS<int>(fmtss2,dts);
9756 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not implemented yet !");
9759 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
9761 return new MEDFileAnyTypeFieldMultiTSIterator(this);
9764 //= MEDFileFieldMultiTS
9767 * Returns a new empty instance of MEDFileFieldMultiTS.
9768 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9769 * is to delete this field using decrRef() as it is no more needed.
9771 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
9773 return new MEDFileFieldMultiTS;
9777 * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
9778 * that has been read from a specified MED file.
9779 * \param [in] fileName - the name of the MED file to read.
9780 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9781 * is to delete this field using decrRef() as it is no more needed.
9782 * \throw If reading the file fails.
9784 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll)
9786 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9787 return New(fid,loadAll);
9790 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, bool loadAll)
9792 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,loadAll,0));
9793 ret->contentNotNull();//to check that content type matches with \a this type.
9798 * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
9799 * that has been read from a specified MED file.
9800 * \param [in] fileName - the name of the MED file to read.
9801 * \param [in] fieldName - the name of the field to read.
9802 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9803 * is to delete this field using decrRef() as it is no more needed.
9804 * \throw If reading the file fails.
9805 * \throw If there is no field named \a fieldName in the file.
9807 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9809 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9810 return New(fid,fieldName,loadAll);
9813 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
9815 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0));
9816 ret->contentNotNull();//to check that content type matches with \a this type.
9821 * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9822 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9824 * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
9825 * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9826 * \warning this is a shallow copy constructor
9827 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
9828 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9829 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9830 * is to delete this field using decrRef() as it is no more needed.
9832 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9834 return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
9837 MEDFileFieldMultiTS *MEDFileFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9839 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9840 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
9841 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0,ent));
9842 ret->contentNotNull();//to check that content type matches with \a this type.
9846 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
9848 return new MEDFileFieldMultiTS(*this);
9851 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9854 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9855 const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
9857 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
9861 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
9862 * following the given input policy.
9864 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9865 * By default (true) the globals are deeply copied.
9866 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
9868 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
9870 MCAuto<MEDFileIntFieldMultiTS> ret;
9871 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9874 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
9876 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
9877 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
9878 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc));
9881 ret=MEDFileIntFieldMultiTS::New();
9883 ret->deepCpyGlobs(*this);
9885 ret->shallowCpyGlobs(*this);
9890 * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
9891 * \param [in] pos - a time step id.
9892 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9893 * delete this field using decrRef() as it is no more needed.
9894 * \throw If \a pos is not a valid time step id.
9896 MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const
9898 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9901 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9902 throw INTERP_KERNEL::Exception(oss.str());
9904 const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
9907 MCAuto<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
9908 ret->shallowCpyGlobs(*this);
9911 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
9912 throw INTERP_KERNEL::Exception(oss.str());
9916 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9917 * mesh entities of a given dimension of the first mesh in MED file.
9918 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9919 * \param [in] type - a spatial discretization of interest.
9920 * \param [in] iteration - the iteration number of a required time step.
9921 * \param [in] order - the iteration order number of required time step.
9922 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9923 * \param [in] renumPol - specifies how to permute values of the result field according to
9924 * the optional numbers of cells and nodes, if any. The valid values are
9925 * - 0 - do not permute.
9926 * - 1 - permute cells.
9927 * - 2 - permute nodes.
9928 * - 3 - permute cells and nodes.
9930 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9931 * caller is to delete this field using decrRef() as it is no more needed.
9932 * \throw If the MED file is not readable.
9933 * \throw If there is no mesh in the MED file.
9934 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9935 * \throw If no field values of the required parameters are available.
9937 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9939 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9940 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9942 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
9943 MCAuto<DataArray> arrOut;
9944 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9945 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9950 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9951 * the top level cells of the first mesh in MED file.
9952 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9953 * \param [in] type - a spatial discretization of interest.
9954 * \param [in] iteration - the iteration number of a required time step.
9955 * \param [in] order - the iteration order number of required time step.
9956 * \param [in] renumPol - specifies how to permute values of the result field according to
9957 * the optional numbers of cells and nodes, if any. The valid values are
9958 * - 0 - do not permute.
9959 * - 1 - permute cells.
9960 * - 2 - permute nodes.
9961 * - 3 - permute cells and nodes.
9963 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9964 * caller is to delete this field using decrRef() as it is no more needed.
9965 * \throw If the MED file is not readable.
9966 * \throw If there is no mesh in the MED file.
9967 * \throw If no field values of the required parameters are available.
9969 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9971 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9972 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9974 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
9975 MCAuto<DataArray> arrOut;
9976 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9977 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9982 * 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
9983 * method should be called (getFieldOnMeshAtLevel for example).
9984 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
9986 * \param [in] iteration - the iteration number of a required time step.
9987 * \param [in] order - the iteration order number of required time step.
9988 * \param [in] mesh - the mesh the field is lying on
9989 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9990 * caller is to delete this field using decrRef() as it is no more needed.
9992 MEDCouplingFieldDouble *MEDFileFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
9994 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9995 MCAuto<DataArray> arrOut;
9996 MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
9997 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
10002 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
10004 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10005 * \param [in] type - a spatial discretization of interest.
10006 * \param [in] iteration - the iteration number of a required time step.
10007 * \param [in] order - the iteration order number of required time step.
10008 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10009 * \param [in] mesh - the supporting mesh.
10010 * \param [in] renumPol - specifies how to permute values of the result field according to
10011 * the optional numbers of cells and nodes, if any. The valid values are
10012 * - 0 - do not permute.
10013 * - 1 - permute cells.
10014 * - 2 - permute nodes.
10015 * - 3 - permute cells and nodes.
10017 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
10018 * caller is to delete this field using decrRef() as it is no more needed.
10019 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
10020 * \throw If no field of \a this is lying on \a mesh.
10021 * \throw If no field values of the required parameters are available.
10023 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
10025 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10026 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
10028 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
10029 MCAuto<DataArray> arrOut;
10030 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
10031 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
10036 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
10038 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10039 * \param [in] type - a spatial discretization of the new field.
10040 * \param [in] iteration - the iteration number of a required time step.
10041 * \param [in] order - the iteration order number of required time step.
10042 * \param [in] mesh - the supporting mesh.
10043 * \param [in] renumPol - specifies how to permute values of the result field according to
10044 * the optional numbers of cells and nodes, if any. The valid values are
10045 * - 0 - do not permute.
10046 * - 1 - permute cells.
10047 * - 2 - permute nodes.
10048 * - 3 - permute cells and nodes.
10050 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
10051 * caller is to delete this field using decrRef() as it is no more needed.
10052 * \throw If no field of \a this is lying on \a mesh.
10053 * \throw If no field values of the required parameters are available.
10055 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
10057 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
10058 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
10060 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
10061 MCAuto<DataArray> arrOut;
10062 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
10063 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
10068 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
10069 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
10070 * This method is useful for MED2 file format when field on different mesh was autorized.
10072 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
10074 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
10075 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
10077 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
10078 MCAuto<DataArray> arrOut;
10079 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
10080 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
10085 * Returns values and a profile of the field of a given type, of a given time step,
10086 * lying on a given support.
10087 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10088 * \param [in] type - a spatial discretization of the field.
10089 * \param [in] iteration - the iteration number of a required time step.
10090 * \param [in] order - the iteration order number of required time step.
10091 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10092 * \param [in] mesh - the supporting mesh.
10093 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
10094 * field of interest lies on. If the field lies on all entities of the given
10095 * dimension, all ids in \a pfl are zero. The caller is to delete this array
10096 * using decrRef() as it is no more needed.
10097 * \param [in] glob - the global data storing profiles and localization.
10098 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
10099 * field. The caller is to delete this array using decrRef() as it is no more needed.
10100 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10101 * \throw If no field of \a this is lying on \a mesh.
10102 * \throw If no field values of the required parameters are available.
10104 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
10106 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
10107 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
10109 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
10110 MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
10111 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
10114 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const
10116 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10118 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
10119 const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
10121 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 !");
10125 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull()
10127 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10129 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
10130 MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
10132 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 !");
10137 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
10138 * the given field is checked if its elements are sorted suitable for writing to MED file
10139 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
10140 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10141 * \param [in] field - the field to add to \a this.
10142 * \throw If the name of \a field is empty.
10143 * \throw If the data array of \a field is not set.
10144 * \throw If existing time steps have different name or number of components than \a field.
10145 * \throw If the underlying mesh of \a field has no name.
10146 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
10148 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
10150 const DataArrayDouble *arr=0;
10152 arr=field->getArray();
10153 contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
10157 * Adds a MEDCouplingFieldDouble to \a this as another time step.
10158 * The mesh support of input parameter \a field is ignored here, it can be NULL.
10159 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
10162 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
10163 * A new profile is added only if no equal profile is missing.
10164 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10165 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
10166 * \param [in] mesh - the supporting mesh of \a field.
10167 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
10168 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
10169 * \throw If either \a field or \a mesh or \a profile has an empty name.
10170 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10171 * \throw If the data array of \a field is not set.
10172 * \throw If the data array of \a this is already allocated but has different number of
10173 * components than \a field.
10174 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
10175 * \sa setFieldNoProfileSBT()
10177 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
10179 const DataArrayDouble *arr=0;
10181 arr=field->getArray();
10182 contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
10185 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
10187 _content=new MEDFileFieldMultiTSWithoutSDA;
10190 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
10191 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
10194 catch(INTERP_KERNEL::Exception& e)
10197 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10198 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
10201 catch(INTERP_KERNEL::Exception& e)
10204 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
10208 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
10210 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
10213 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
10215 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
10218 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
10220 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
10223 MEDFileFieldMultiTS *MEDFileFieldMultiTS::buildNewEmpty() const
10225 return MEDFileFieldMultiTS::New();
10228 //= MEDFileAnyTypeFieldMultiTSIterator
10230 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
10235 _nb_iter=fmts->getNumberOfTS();
10239 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
10243 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
10245 if(_iter_id<_nb_iter)
10247 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
10249 return fmts->getTimeStepAtPos(_iter_id++);
10257 //= MEDFileIntFieldMultiTS
10260 * Returns a new empty instance of MEDFileFieldMultiTS.
10261 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
10262 * is to delete this field using decrRef() as it is no more needed.
10264 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
10266 return new MEDFileIntFieldMultiTS;
10270 * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
10271 * that has been read from a specified MED file.
10272 * \param [in] fileName - the name of the MED file to read.
10273 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
10274 * is to delete this field using decrRef() as it is no more needed.
10275 * \throw If reading the file fails.
10277 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll)
10279 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10280 return New(fid,loadAll);
10283 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, bool loadAll)
10285 MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,loadAll,0));
10286 ret->contentNotNull();//to check that content type matches with \a this type.
10291 * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
10292 * that has been read from a specified MED file.
10293 * \param [in] fileName - the name of the MED file to read.
10294 * \param [in] fieldName - the name of the field to read.
10295 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
10296 * is to delete this field using decrRef() as it is no more needed.
10297 * \throw If reading the file fails.
10298 * \throw If there is no field named \a fieldName in the file.
10300 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
10302 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10303 return New(fid,fieldName,loadAll);
10306 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
10308 MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0));
10309 ret->contentNotNull();//to check that content type matches with \a this type.
10314 * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
10315 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
10317 * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
10318 * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
10319 * \warning this is a shallow copy constructor
10320 * \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
10321 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
10322 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
10323 * is to delete this field using decrRef() as it is no more needed.
10325 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
10327 return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
10330 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
10332 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10333 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
10334 MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0,ent));
10335 ret->contentNotNull();//to check that content type matches with \a this type.
10340 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
10341 * following the given input policy.
10343 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
10344 * By default (true) the globals are deeply copied.
10345 * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
10347 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const
10349 MCAuto<MEDFileFieldMultiTS> ret;
10350 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
10353 const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
10355 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
10356 MCAuto<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
10357 ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc));
10360 ret=MEDFileFieldMultiTS::New();
10362 ret->deepCpyGlobs(*this);
10364 ret->shallowCpyGlobs(*this);
10368 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const
10370 return new MEDFileIntFieldMultiTS(*this);
10373 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
10376 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
10377 const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
10379 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
10383 * 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
10384 * method should be called (getFieldOnMeshAtLevel for example).
10385 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
10387 * \param [in] iteration - the iteration number of a required time step.
10388 * \param [in] order - the iteration order number of required time step.
10389 * \param [in] mesh - the mesh the field is lying on
10390 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
10391 * caller is to delete this field using decrRef() as it is no more needed.
10393 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
10395 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10396 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10398 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::field : mismatch of type of field expecting INT32 !");
10399 MCAuto<DataArray> arrOut;
10400 MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
10401 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arrOut));
10402 return ret2.retn();
10406 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
10407 * mesh entities of a given dimension of the first mesh in MED file.
10408 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10409 * \param [in] type - a spatial discretization of interest.
10410 * \param [in] iteration - the iteration number of a required time step.
10411 * \param [in] order - the iteration order number of required time step.
10412 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10413 * \param [in] renumPol - specifies how to permute values of the result field according to
10414 * the optional numbers of cells and nodes, if any. The valid values are
10415 * - 0 - do not permute.
10416 * - 1 - permute cells.
10417 * - 2 - permute nodes.
10418 * - 3 - permute cells and nodes.
10420 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10421 * caller is to delete this field using decrRef() as it is no more needed.
10422 * \throw If the MED file is not readable.
10423 * \throw If there is no mesh in the MED file.
10424 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
10425 * \throw If no field values of the required parameters are available.
10427 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
10429 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10430 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10432 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
10433 MCAuto<DataArray> arr;
10434 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase()));
10435 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10436 return ret2.retn();
10440 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
10441 * the top level cells of the first mesh in MED file.
10442 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10443 * \param [in] type - a spatial discretization of interest.
10444 * \param [in] iteration - the iteration number of a required time step.
10445 * \param [in] order - the iteration order number of required time step.
10446 * \param [in] renumPol - specifies how to permute values of the result field according to
10447 * the optional numbers of cells and nodes, if any. The valid values are
10448 * - 0 - do not permute.
10449 * - 1 - permute cells.
10450 * - 2 - permute nodes.
10451 * - 3 - permute cells and nodes.
10453 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10454 * caller is to delete this field using decrRef() as it is no more needed.
10455 * \throw If the MED file is not readable.
10456 * \throw If there is no mesh in the MED file.
10457 * \throw If no field values of the required parameters are available.
10459 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
10461 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10462 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10464 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
10465 MCAuto<DataArray> arr;
10466 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase()));
10467 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10468 return ret2.retn();
10472 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
10474 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10475 * \param [in] type - a spatial discretization of interest.
10476 * \param [in] iteration - the iteration number of a required time step.
10477 * \param [in] order - the iteration order number of required time step.
10478 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10479 * \param [in] mesh - the supporting mesh.
10480 * \param [in] renumPol - specifies how to permute values of the result field according to
10481 * the optional numbers of cells and nodes, if any. The valid values are
10482 * - 0 - do not permute.
10483 * - 1 - permute cells.
10484 * - 2 - permute nodes.
10485 * - 3 - permute cells and nodes.
10487 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10488 * caller is to delete this field using decrRef() as it is no more needed.
10489 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
10490 * \throw If no field of \a this is lying on \a mesh.
10491 * \throw If no field values of the required parameters are available.
10493 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
10495 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10496 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10498 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10499 MCAuto<DataArray> arr;
10500 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase()));
10501 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10502 return ret2.retn();
10506 * Returns a new MEDCouplingFieldInt of given type, of a given time step, lying on a
10508 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10509 * \param [in] type - a spatial discretization of the new field.
10510 * \param [in] iteration - the iteration number of a required time step.
10511 * \param [in] order - the iteration order number of required time step.
10512 * \param [in] mesh - the supporting mesh.
10513 * \param [out] arrOut - the DataArrayInt containing values of field.
10514 * \param [in] renumPol - specifies how to permute values of the result field according to
10515 * the optional numbers of cells and nodes, if any. The valid values are
10516 * - 0 - do not permute.
10517 * - 1 - permute cells.
10518 * - 2 - permute nodes.
10519 * - 3 - permute cells and nodes.
10521 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10522 * caller is to delete this field using decrRef() as it is no more needed.
10523 * \throw If no field of \a this is lying on \a mesh.
10524 * \throw If no field values of the required parameters are available.
10526 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
10528 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10529 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10531 throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10532 MCAuto<DataArray> arr;
10533 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase()));
10534 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10535 return ret2.retn();
10539 * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
10540 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
10541 * This method is useful for MED2 file format when field on different mesh was autorized.
10543 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol) const
10545 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10546 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10548 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10549 MCAuto<DataArray> arr;
10550 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase()));
10551 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10552 return ret2.retn();
10556 * Returns values and a profile of the field of a given type, of a given time step,
10557 * lying on a given support.
10558 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10559 * \param [in] type - a spatial discretization of the field.
10560 * \param [in] iteration - the iteration number of a required time step.
10561 * \param [in] order - the iteration order number of required time step.
10562 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10563 * \param [in] mesh - the supporting mesh.
10564 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
10565 * field of interest lies on. If the field lies on all entities of the given
10566 * dimension, all ids in \a pfl are zero. The caller is to delete this array
10567 * using decrRef() as it is no more needed.
10568 * \param [in] glob - the global data storing profiles and localization.
10569 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
10570 * field. The caller is to delete this array using decrRef() as it is no more needed.
10571 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10572 * \throw If no field of \a this is lying on \a mesh.
10573 * \throw If no field values of the required parameters are available.
10575 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
10577 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
10578 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
10580 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
10581 MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
10582 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
10586 * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
10587 * \param [in] pos - a time step id.
10588 * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
10589 * delete this field using decrRef() as it is no more needed.
10590 * \throw If \a pos is not a valid time step id.
10592 MEDFileIntField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
10594 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
10597 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
10598 throw INTERP_KERNEL::Exception(oss.str());
10600 const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
10603 MCAuto<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
10604 ret->shallowCpyGlobs(*this);
10607 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
10608 throw INTERP_KERNEL::Exception(oss.str());
10612 * Adds a MEDCouplingFieldInt to \a this as another time step. The underlying mesh of
10613 * the given field is checked if its elements are sorted suitable for writing to MED file
10614 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
10615 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10616 * \param [in] field - the field to add to \a this.
10617 * \throw If the name of \a field is empty.
10618 * \throw If the data array of \a field is not set.
10619 * \throw If existing time steps have different name or number of components than \a field.
10620 * \throw If the underlying mesh of \a field has no name.
10621 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
10623 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldInt *field)
10625 MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
10626 contentNotNull()->appendFieldNoProfileSBT(field2,field->getArray(),*this);
10630 * Adds a MEDCouplingFieldDouble to \a this as another time step.
10631 * The mesh support of input parameter \a field is ignored here, it can be NULL.
10632 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
10635 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
10636 * A new profile is added only if no equal profile is missing.
10637 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10638 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
10639 * \param [in] arrOfVals - the values of the field \a field used.
10640 * \param [in] mesh - the supporting mesh of \a field.
10641 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
10642 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
10643 * \throw If either \a field or \a mesh or \a profile has an empty name.
10644 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10645 * \throw If the data array of \a field is not set.
10646 * \throw If the data array of \a this is already allocated but has different number of
10647 * components than \a field.
10648 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
10649 * \sa setFieldNoProfileSBT()
10651 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
10653 MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
10654 contentNotNull()->appendFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this);
10657 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const
10659 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10661 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
10662 const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10664 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 !");
10668 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull()
10670 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10672 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
10673 MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10675 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 !");
10679 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
10681 _content=new MEDFileIntFieldMultiTSWithoutSDA;
10684 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
10688 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
10689 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
10692 catch(INTERP_KERNEL::Exception& e)
10695 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10696 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
10699 catch(INTERP_KERNEL::Exception& e)
10702 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
10704 return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
10707 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::buildNewEmpty() const
10709 return MEDFileIntFieldMultiTS::New();
10714 MEDFileFields *MEDFileFields::New()
10716 return new MEDFileFields;
10719 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
10721 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10722 return New(fid,loadAll);
10725 MEDFileFields *MEDFileFields::NewAdv(const std::string& fileName, bool loadAll, const MEDFileEntities *entities)
10727 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10728 return NewAdv(fid,loadAll,entities);
10731 MEDFileFields *MEDFileFields::NewAdv(med_idt fid, bool loadAll, const MEDFileEntities *entities)
10733 return new MEDFileFields(fid,loadAll,0,entities);
10736 MEDFileFields *MEDFileFields::NewWithDynGT(const std::string& fileName, const MEDFileStructureElements *se, bool loadAll)
10738 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10739 return NewWithDynGT(fid,se,loadAll);
10742 MEDFileFields *MEDFileFields::NewWithDynGT(med_idt fid, const MEDFileStructureElements *se, bool loadAll)
10745 throw INTERP_KERNEL::Exception("MEDFileFields::NewWithDynGT : null struct element pointer !");
10746 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> entities(MEDFileEntities::BuildFrom(*se));
10747 return new MEDFileFields(fid,loadAll,0,entities);
10750 MEDFileFields *MEDFileFields::New(med_idt fid, bool loadAll)
10752 return new MEDFileFields(fid,loadAll,0,0);
10755 MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
10757 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10758 return new MEDFileFields(fid,loadAll,ms,0);
10761 MEDFileFields *MEDFileFields::LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
10763 MEDFileUtilities::CheckFileForRead(fileName);
10764 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
10765 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10766 return new MEDFileFields(fid,loadAll,0,ent);
10769 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
10771 std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
10772 ret+=_fields.capacity()*sizeof(MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
10776 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
10778 std::vector<const BigMemoryObject *> ret;
10779 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10780 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
10784 MEDFileFields *MEDFileFields::deepCopy() const
10786 MCAuto<MEDFileFields> ret(shallowCpy());
10788 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10790 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10791 ret->_fields[i]=(*it)->deepCopy();
10793 ret->deepCpyGlobs(*this);
10797 MEDFileFields *MEDFileFields::shallowCpy() const
10799 return new MEDFileFields(*this);
10803 * 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
10804 * 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.
10805 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
10807 * \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.
10808 * \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.
10810 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10812 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
10814 std::set< std::pair<int,int> > s;
10815 bool firstShot=true;
10816 areThereSomeForgottenTS=false;
10817 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10819 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10821 std::vector< std::pair<int,int> > v=(*it)->getIterations();
10822 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
10824 { s=s1; firstShot=false; }
10827 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
10829 areThereSomeForgottenTS=true;
10833 std::vector< std::pair<int,int> > ret;
10834 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
10838 int MEDFileFields::getNumberOfFields() const
10840 return _fields.size();
10843 std::vector<std::string> MEDFileFields::getFieldsNames() const
10845 std::vector<std::string> ret(_fields.size());
10847 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10849 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
10852 ret[i]=f->getName();
10856 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
10857 throw INTERP_KERNEL::Exception(oss.str());
10863 std::vector<std::string> MEDFileFields::getMeshesNames() const
10865 std::vector<std::string> ret;
10866 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10868 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10870 ret.push_back(cur->getMeshName());
10875 std::string MEDFileFields::simpleRepr() const
10877 std::ostringstream oss;
10878 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
10883 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
10885 int nbOfFields(getNumberOfFields());
10886 std::string startLine(bkOffset,' ');
10887 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
10889 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10891 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10894 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
10898 oss << startLine << " - not defined !" << std::endl;
10902 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10904 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10905 std::string chapter(17,'0'+i);
10906 oss << startLine << chapter << std::endl;
10909 cur->simpleRepr(bkOffset+2,oss,i);
10913 oss << startLine << " - not defined !" << std::endl;
10915 oss << startLine << chapter << std::endl;
10917 simpleReprGlobs(oss);
10920 MEDFileFields::MEDFileFields()
10924 MEDFileFields::MEDFileFields(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10925 try:MEDFileFieldGlobsReal(fid)
10927 int nbFields(MEDnField(fid));
10928 _fields.resize(nbFields);
10929 med_field_type typcha;
10930 for(int i=0;i<nbFields;i++)
10932 std::vector<std::string> infos;
10933 std::string fieldName,dtunit;
10934 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,i,false,fieldName,typcha,infos,dtunit));
10939 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10944 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10949 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] !";
10950 throw INTERP_KERNEL::Exception(oss.str());
10954 loadAllGlobals(fid,entities);
10956 catch(INTERP_KERNEL::Exception& e)
10961 void MEDFileFields::writeLL(med_idt fid) const
10964 writeGlobals(fid,*this);
10965 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10967 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
10970 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
10971 throw INTERP_KERNEL::Exception(oss.str());
10973 elt->writeLL(fid,*this);
10978 * This method alloc the arrays and load potentially huge arrays contained in this field.
10979 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
10980 * This method can be also called to refresh or reinit values from a file.
10982 * \throw If the fileName is not set or points to a non readable MED file.
10984 void MEDFileFields::loadArrays()
10986 if(getFileName().empty())
10987 throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
10988 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
10989 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10991 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10993 elt->loadBigArraysRecursively(fid,*elt);
10998 * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
10999 * But once data loaded once, this method does nothing.
11001 * \throw If the fileName is not set or points to a non readable MED file.
11002 * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
11004 void MEDFileFields::loadArraysIfNecessary()
11006 if(!getFileName().empty())
11008 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
11009 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11011 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
11013 elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
11019 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
11020 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
11021 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
11023 * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
11025 void MEDFileFields::unloadArrays()
11027 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11029 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
11031 elt->unloadArrays();
11036 * 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.
11037 * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
11038 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
11040 * \sa MEDFileFields::loadArraysIfNecessary
11042 void MEDFileFields::unloadArraysWithoutDataLoss()
11044 if(!getFileName().empty())
11048 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
11050 std::vector<std::string> ret;
11051 std::set<std::string> ret2;
11052 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11054 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
11055 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
11056 if(ret2.find(*it2)==ret2.end())
11058 ret.push_back(*it2);
11065 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
11067 std::vector<std::string> ret;
11068 std::set<std::string> ret2;
11069 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11071 std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
11072 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
11073 if(ret2.find(*it2)==ret2.end())
11075 ret.push_back(*it2);
11082 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
11084 std::vector<std::string> ret;
11085 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11087 std::vector<std::string> tmp((*it)->getPflsReallyUsedMulti2());
11088 ret.insert(ret.end(),tmp.begin(),tmp.end());
11093 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
11095 std::vector<std::string> ret;
11096 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11098 std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
11099 ret.insert(ret.end(),tmp.begin(),tmp.end());
11104 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
11106 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
11107 (*it)->changePflsRefsNamesGen2(mapOfModif);
11110 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
11112 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
11113 (*it)->changeLocsRefsNamesGen2(mapOfModif);
11116 void MEDFileFields::resize(int newSize)
11118 _fields.resize(newSize);
11121 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
11123 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
11127 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
11130 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
11131 _fields.push_back(field->getContent());
11132 appendGlobs(*field,1e-12);
11135 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
11138 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
11139 if(i>=(int)_fields.size())
11140 _fields.resize(i+1);
11141 _fields[i]=field->getContent();
11142 appendGlobs(*field,1e-12);
11145 void MEDFileFields::destroyFieldAtPos(int i)
11147 destroyFieldsAtPos(&i,&i+1);
11150 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
11152 std::vector<bool> b(_fields.size(),true);
11153 for(const int *i=startIds;i!=endIds;i++)
11155 if(*i<0 || *i>=(int)_fields.size())
11157 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
11158 throw INTERP_KERNEL::Exception(oss.str());
11162 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
11164 for(std::size_t i=0;i<_fields.size();i++)
11166 fields[j++]=_fields[i];
11170 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
11172 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
11173 int nbOfEntriesToKill(DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg));
11174 std::vector<bool> b(_fields.size(),true);
11176 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
11178 if(k<0 || k>=(int)_fields.size())
11180 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
11181 throw INTERP_KERNEL::Exception(oss.str());
11185 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
11187 for(std::size_t i=0;i<_fields.size();i++)
11189 fields[j++]=_fields[i];
11193 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
11196 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11198 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
11200 ret=cur->changeMeshNames(modifTab) || ret;
11206 * \param [in] meshName the name of the mesh that will be renumbered.
11207 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
11208 * This code corresponds to the distribution of types in the corresponding mesh.
11209 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
11210 * \param [in] renumO2N the old to new renumber array.
11211 * \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
11212 * field in \a this.
11214 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
11217 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11219 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
11222 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
11229 * Return an extraction of \a this using \a extractDef map to specify the extraction.
11230 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
11232 * \return A new object that the caller is responsible to deallocate.
11234 MEDFileFields *MEDFileFields::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
11237 throw INTERP_KERNEL::Exception("MEDFileFields::extractPart : input mesh is NULL !");
11238 MCAuto<MEDFileFields> fsOut(MEDFileFields::New());
11239 int nbFields(getNumberOfFields());
11240 for(int i=0;i<nbFields;i++)
11242 MCAuto<MEDFileAnyTypeFieldMultiTS> fmts(getFieldAtPos(i));
11245 std::ostringstream oss; oss << "MEDFileFields::extractPart : at pos #" << i << " field is null !";
11246 throw INTERP_KERNEL::Exception(oss.str());
11248 MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(fmts->extractPart(extractDef,mm));
11249 fsOut->pushField(fmtsOut);
11251 return fsOut.retn();
11254 void MEDFileFields::accept(MEDFileFieldVisitor& visitor) const
11256 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11257 if((*it).isNotNull())
11259 visitor.newFieldEntry(*it);
11260 (*it)->accept(visitor);
11261 visitor.endFieldEntry(*it);
11265 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
11267 if(i<0 || i>=(int)_fields.size())
11269 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
11270 throw INTERP_KERNEL::Exception(oss.str());
11272 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
11275 MCAuto<MEDFileAnyTypeFieldMultiTS> ret;
11276 const MEDFileFieldMultiTSWithoutSDA *fmtsC(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts));
11277 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts));
11279 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
11281 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
11284 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
11285 throw INTERP_KERNEL::Exception(oss.str());
11287 ret->shallowCpyGlobs(*this);
11292 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
11293 * This method is accessible in python using __getitem__ with a list in input.
11294 * \return a new object that the caller should deal with.
11296 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
11298 MCAuto<MEDFileFields> ret=shallowCpy();
11299 std::size_t sz=std::distance(startIds,endIds);
11300 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
11302 for(const int *i=startIds;i!=endIds;i++,j++)
11304 if(*i<0 || *i>=(int)_fields.size())
11306 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
11307 throw INTERP_KERNEL::Exception(oss.str());
11309 fields[j]=_fields[*i];
11311 ret->_fields=fields;
11315 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
11317 return getFieldAtPos(getPosFromFieldName(fieldName));
11321 * This method removes, if any, fields in \a this having no time steps.
11322 * 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.
11324 * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
11326 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
11328 std::vector<MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
11329 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11331 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
11334 if(elt->getNumberOfTS()>0)
11335 newFields.push_back(*it);
11338 if(_fields.size()==newFields.size())
11345 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
11346 * This method can be seen as a filter applied on \a this, that returns an object containing
11347 * 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
11348 * shallow copied from \a this.
11350 * \param [in] meshName - the name of the mesh on w
11351 * \return a new object that the caller should deal with.
11353 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
11355 MCAuto<MEDFileFields> ret(MEDFileFields::New());
11356 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11358 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
11361 if(cur->getMeshName()==meshName)
11364 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
11365 ret->_fields.push_back(cur2);
11368 ret->shallowCpyOnlyUsedGlobs(*this);
11373 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
11374 * Input time steps are specified using a pair of integer (iteration, order).
11375 * 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,
11376 * but for each multitimestep only the time steps in \a timeSteps are kept.
11377 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
11379 * The returned object points to shallow copy of elements in \a this.
11381 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
11382 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
11383 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
11385 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
11387 MCAuto<MEDFileFields> ret(MEDFileFields::New());
11388 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11390 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
11393 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
11394 ret->_fields.push_back(elt);
11396 ret->shallowCpyOnlyUsedGlobs(*this);
11401 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
11403 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
11405 MCAuto<MEDFileFields> ret=MEDFileFields::New();
11406 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11408 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
11411 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
11412 if(elt->getNumberOfTS()!=0)
11413 ret->_fields.push_back(elt);
11415 ret->shallowCpyOnlyUsedGlobs(*this);
11419 bool MEDFileFields::presenceOfStructureElements() const
11421 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11422 if((*it).isNotNull())
11423 if((*it)->presenceOfStructureElements())
11428 void MEDFileFields::killStructureElements()
11430 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
11431 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11432 if((*it).isNotNull())
11434 if((*it)->presenceOfStructureElements())
11436 if(!(*it)->onlyStructureElements())
11438 (*it)->killStructureElements();
11439 ret.push_back(*it);
11444 ret.push_back(*it);
11450 void MEDFileFields::keepOnlyStructureElements()
11452 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
11453 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11454 if((*it).isNotNull())
11456 if((*it)->presenceOfStructureElements())
11458 if(!(*it)->onlyStructureElements())
11459 (*it)->keepOnlyStructureElements();
11460 ret.push_back(*it);
11466 void MEDFileFields::keepOnlyOnMeshSE(const std::string& meshName, const std::string& seName)
11468 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
11469 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11470 if((*it).isNotNull())
11472 if((*it)->getMeshName()!=meshName)
11474 std::vector< std::pair<std::string,std::string> > ps;
11475 (*it)->getMeshSENames(ps);
11476 std::pair<std::string,std::string> p(meshName,seName);
11477 if(std::find(ps.begin(),ps.end(),p)!=ps.end())
11478 (*it)->keepOnlyOnSE(seName);
11479 ret.push_back(*it);
11484 void MEDFileFields::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
11486 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11487 if((*it).isNotNull())
11488 (*it)->getMeshSENames(ps);
11491 void MEDFileFields::blowUpSE(MEDFileMeshes *ms, const MEDFileStructureElements *ses)
11493 MEDFileBlowStrEltUp::DealWithSE(this,ms,ses);
11496 MCAuto<MEDFileFields> MEDFileFields::partOfThisOnStructureElements() const
11498 MCAuto<MEDFileFields> ret(deepCopy());
11499 ret->keepOnlyStructureElements();
11503 MCAuto<MEDFileFields> MEDFileFields::partOfThisLyingOnSpecifiedMeshSEName(const std::string& meshName, const std::string& seName) const
11505 MCAuto<MEDFileFields> ret(deepCopy());
11506 ret->keepOnlyOnMeshSE(meshName,seName);
11510 void MEDFileFields::aggregate(const MEDFileFields& other)
11512 int nbFieldsToAdd(other.getNumberOfFields());
11513 std::vector<std::string> fsn(getFieldsNames());
11514 for(int i=0;i<nbFieldsToAdd;i++)
11516 MCAuto<MEDFileAnyTypeFieldMultiTS> elt(other.getFieldAtPos(i));
11517 std::string name(elt->getName());
11518 if(std::find(fsn.begin(),fsn.end(),name)!=fsn.end())
11520 std::ostringstream oss; oss << "MEDFileFields::aggregate : name \"" << name << "\" already appears !";
11521 throw INTERP_KERNEL::Exception(oss.str());
11527 MEDFileFieldsIterator *MEDFileFields::iterator()
11529 return new MEDFileFieldsIterator(this);
11532 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
11534 std::string tmp(fieldName);
11535 std::vector<std::string> poss;
11536 for(std::size_t i=0;i<_fields.size();i++)
11538 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f(_fields[i]);
11541 std::string fname(f->getName());
11545 poss.push_back(fname);
11548 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
11549 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
11551 throw INTERP_KERNEL::Exception(oss.str());
11554 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
11559 _nb_iter=fs->getNumberOfFields();
11563 MEDFileFieldsIterator::~MEDFileFieldsIterator()
11567 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
11569 if(_iter_id<_nb_iter)
11571 MEDFileFields *fs(_fs);
11573 return fs->getFieldAtPos(_iter_id++);