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 MEDCoupling::MEDFileField1TSTemplateWithoutSDA<int>;
48 template class MEDCoupling::MEDFileField1TSTemplateWithoutSDA<float>;
49 template class MEDCoupling::MEDFileField1TSTemplateWithoutSDA<double>;
50 template class MEDCoupling::MEDFileTemplateField1TS<int>;
51 template class MEDCoupling::MEDFileTemplateField1TS<double>;
53 const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64";
54 const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32";
55 const char MEDFileFloatField1TSWithoutSDA::TYPE_STR[]="FLOAT32";
57 MEDFileGTKeeper::~MEDFileGTKeeper()
61 MEDFileGTKeeper *MEDFileGTKeeperSta::deepCopy() const
63 return new MEDFileGTKeeperSta(_geo_type);
66 INTERP_KERNEL::NormalizedCellType MEDFileGTKeeperSta::getGeoType() const
71 std::string MEDFileGTKeeperSta::getRepr() const
73 return INTERP_KERNEL::CellModel::GetCellModel(_geo_type).getRepr();
76 bool MEDFileGTKeeperSta::isEqual(const MEDFileGTKeeper *other) const
78 const MEDFileGTKeeperSta *otherC(dynamic_cast<const MEDFileGTKeeperSta *>(other));
81 return _geo_type==otherC->_geo_type;
84 MEDFileGTKeeperDyn::MEDFileGTKeeperDyn(const MEDFileUMesh *mesh, const MEDFileUMesh *section, const MEDFileStructureElement *se):_mesh(mesh),_section(section),_se(se)
92 if(_mesh.isNull() || _section.isNull() || _se.isNull())
93 throw INTERP_KERNEL::Exception("MEDFileGTKeeperDyn constructor : null pointer not allowed !");
96 MEDFileGTKeeper *MEDFileGTKeeperDyn::deepCopy() const
98 return new MEDFileGTKeeperDyn(_mesh,_section,_se);
101 INTERP_KERNEL::NormalizedCellType MEDFileGTKeeperDyn::getGeoType() const
103 throw INTERP_KERNEL::Exception("MEDFileGTKeeperDyn::getGeoType : not valid !");
106 std::string MEDFileGTKeeperDyn::getRepr() const
108 std::ostringstream oss;
109 oss << _se->getDynGT();
113 bool MEDFileGTKeeperDyn::isEqual(const MEDFileGTKeeper *other) const
115 const MEDFileGTKeeperDyn *otherC(dynamic_cast<const MEDFileGTKeeperDyn *>(other));
121 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const std::string& locName)
123 return new MEDFileFieldLoc(fid,locName);
126 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, int id, const MEDFileEntities *entities)
128 return new MEDFileFieldLoc(fid,id,entities);
131 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)
133 return new MEDFileFieldLoc(locName,geoType,refCoo,gsCoo,w);
136 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, const std::string& locName):_name(locName)
138 med_geometry_type geotype;
139 med_geometry_type sectiongeotype;
140 int nsectionmeshcell;
141 INTERP_KERNEL::AutoPtr<char> geointerpname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
142 INTERP_KERNEL::AutoPtr<char> sectionmeshname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
143 MEDlocalizationInfoByName(fid,locName.c_str(),&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
144 _gt=new MEDFileGTKeeperSta((INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype))));
145 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
146 _nb_node_per_cell=cm.getNumberOfNodes();
147 _ref_coo.resize(_dim*_nb_node_per_cell);
148 _gs_coo.resize(_dim*_nb_gauss_pt);
149 _w.resize(_nb_gauss_pt);
150 MEDlocalizationRd(fid,locName.c_str(),MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
153 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id, const MEDFileEntities *entities)
155 med_geometry_type geotype;
156 med_geometry_type sectiongeotype;
157 int nsectionmeshcell;
158 INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
159 INTERP_KERNEL::AutoPtr<char> geointerpname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
160 INTERP_KERNEL::AutoPtr<char> sectionmeshname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
161 MEDlocalizationInfo(fid,id+1,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
163 std::string sectionName(MEDLoaderBase::buildStringFromFortran(sectionmeshname,MED_NAME_SIZE));
164 if(sectionName.empty())
166 _gt=new MEDFileGTKeeperSta((INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype))));
167 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
168 _nb_node_per_cell=cm.getNumberOfNodes();
172 const MEDFileAllStaticEntitiesPlusDyn *entities2(dynamic_cast<const MEDFileAllStaticEntitiesPlusDyn *>(entities));
175 std::ostringstream oss; oss << "MEDFileFieldLoc cstr : for loc \"" << _name << "\" presence of non static type ! Expect entities !";
176 throw INTERP_KERNEL::Exception(oss.str());
178 const MEDFileStructureElement *se(entities2->getWithGT(geotype));
179 const MEDFileUMesh *um(entities2->getSupMeshWithName(se->getMeshName()));
180 const MEDFileUMesh *section(entities2->getSupMeshWithName(sectionName));
181 _gt=new MEDFileGTKeeperDyn(um,section,se);
184 MEDFILESAFECALLERWR0(MEDmeshGeotypeParameter,(fid,geotype,&dummy,&_nb_node_per_cell));
187 _ref_coo.resize(_dim*_nb_node_per_cell);
188 _gs_coo.resize(_dim*_nb_gauss_pt);
189 _w.resize(_nb_gauss_pt);
190 MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
193 MEDFileFieldLoc::MEDFileFieldLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType,
194 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)
196 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
197 _dim=cm.getDimension();
198 _nb_node_per_cell=cm.getNumberOfNodes();
199 _nb_gauss_pt=_w.size();
203 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)
207 MEDFileFieldLoc *MEDFileFieldLoc::deepCopy() const
209 return new MEDFileFieldLoc(*this);
212 bool MEDFileFieldLoc::isOnStructureElement() const
214 const MEDFileGTKeeper *gt(_gt);
216 throw INTERP_KERNEL::Exception("MEDFileFieldLoc::isOnStructureElement : null pointer !");
217 const MEDFileGTKeeperDyn *gt2(dynamic_cast<const MEDFileGTKeeperDyn *>(gt));
221 std::size_t MEDFileFieldLoc::getHeapMemorySizeWithoutChildren() const
223 return (_ref_coo.capacity()+_gs_coo.capacity()+_w.capacity())*sizeof(double)+_name.capacity();
226 std::vector<const BigMemoryObject *> MEDFileFieldLoc::getDirectChildrenWithNull() const
228 return std::vector<const BigMemoryObject *>();
231 void MEDFileFieldLoc::simpleRepr(std::ostream& oss) const
233 static const char OFF7[]="\n ";
234 oss << "\"" << _name << "\"" << OFF7;
235 oss << "GeoType=" << _gt->getRepr() << OFF7;
236 oss << "Dimension=" << _dim << OFF7;
237 oss << "Number of Gauss points=" << _nb_gauss_pt << OFF7;
238 oss << "Number of nodes per cell=" << _nb_node_per_cell << OFF7;
239 oss << "RefCoords="; std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
240 oss << "Weights="; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
241 oss << "GaussPtsCoords="; std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," ")); oss << std::endl;
244 void MEDFileFieldLoc::setName(const std::string& name)
249 bool MEDFileFieldLoc::isEqual(const MEDFileFieldLoc& other, double eps) const
251 if(_name!=other._name)
255 if(_nb_gauss_pt!=other._nb_gauss_pt)
257 if(_nb_node_per_cell!=other._nb_node_per_cell)
259 if(!_gt->isEqual(other._gt))
261 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_ref_coo,other._ref_coo,eps))
263 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_gs_coo,other._gs_coo,eps))
265 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_w,other._w,eps))
271 void MEDFileFieldLoc::writeLL(med_idt fid) const
273 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);
276 std::string MEDFileFieldLoc::repr() const
278 std::ostringstream oss; oss.precision(15);
279 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
280 oss << "Localization \"" << _name << "\" :\n" << " - Geometric Type : " << cm.getRepr();
281 oss << "\n - Dimension : " << _dim << "\n - Number of gauss points : ";
282 oss << _nb_gauss_pt << "\n - Number of nodes in cell : " << _nb_node_per_cell;
283 oss << "\n - Ref coords are : ";
284 int sz=_ref_coo.size();
287 int nbOfTuples=sz/_dim;
288 for(int i=0;i<nbOfTuples;i++)
291 for(int j=0;j<_dim;j++)
292 { oss << _ref_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
297 std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," "));
298 oss << "\n - Gauss coords in reference element : ";
302 int nbOfTuples=sz/_dim;
303 for(int i=0;i<nbOfTuples;i++)
306 for(int j=0;j<_dim;j++)
307 { oss << _gs_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
312 std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," "));
313 oss << "\n - Weights of Gauss coords are : "; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," "));
317 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
319 _type=field->getTypeOfField();
325 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,offset,offset+nbOfCells,1);
326 _end=_start+nbOfCells;
332 MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
333 const int *arrPtr=arr->getConstPointer();
334 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,arrPtr[offset],arrPtr[offset+nbOfCells],1);
335 _end=_start+(arrPtr[offset+nbOfCells]-arrPtr[offset]);
341 const MEDCouplingFieldDiscretization *disc(field->getDiscretization());
342 const MEDCouplingGaussLocalization& gsLoc(field->getGaussLocalization(_loc_id));
343 const MEDCouplingFieldDiscretizationGauss *disc2(dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc));
345 throw INTERP_KERNEL::Exception("assignFieldNoProfile : invalid call to this method ! Internal Error !");
346 const DataArrayInt *dai(disc2->getArrayOfDiscIds());
347 MCAuto<DataArrayInt> dai2(disc2->getOffsetArr(field->getMesh()));
348 const int *dai2Ptr(dai2->getConstPointer());
349 int nbi(gsLoc.getWeights().size());
350 MCAuto<DataArrayInt> da2(dai->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1));
351 MCAuto<DataArrayInt> da3(da2->findIdsEqual(_loc_id));
352 const int *da3Ptr(da3->getConstPointer());
353 if(da3->getNumberOfTuples()!=nbOfCells)
354 {//profile : for gauss even in NoProfile !!!
355 std::ostringstream oss; oss << "Pfl_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
357 da3->setName(_profile.c_str());
358 glob.appendProfile(da3);
360 MCAuto<DataArrayInt> da4(DataArrayInt::New());
361 _nval=da3->getNbOfElems();
362 da4->alloc(_nval*nbi,1);
363 int *da4Ptr(da4->getPointer());
364 for(int i=0;i<_nval;i++)
366 int ref=dai2Ptr[offset+da3Ptr[i]];
367 for(int j=0;j<nbi;j++)
370 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
371 _localization=oss2.str();
372 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,da4);
373 _end=_start+_nval*nbi;
374 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
378 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile : not implemented yet for such discretization type of field !");
384 * Leaf method of field with profile assignement. This method is the most general one. No optimization is done here.
385 * \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).
386 * \param [in] multiTypePfl is the end user profile specified in high level API
387 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
388 * \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.
389 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
390 * \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.
392 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)
395 _type=field->getTypeOfField();
396 std::string pflName(multiTypePfl->getName());
397 std::ostringstream oss; oss << pflName;
401 { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType()); oss << "_" << cm.getRepr(); }
408 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : existing profile with empty name !");
409 if(_type!=ON_GAUSS_PT)
411 locIds->setName(oss.str());
412 glob.appendProfile(locIds);
421 _nval=idsInPfl->getNumberOfTuples();
422 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,0,arrr->getNumberOfTuples(),1);
428 _nval=idsInPfl->getNumberOfTuples();
429 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,idsInPfl);
435 MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
436 MCAuto<DataArrayInt> arr2=arr->deltaShiftIndex();
437 MCAuto<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->begin(),multiTypePfl->end());
438 arr3->computeOffsetsFull();
439 MCAuto<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
440 int trueNval=tmp->getNumberOfTuples();
441 _nval=idsInPfl->getNumberOfTuples();
442 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
443 _end=_start+trueNval;
448 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(field->getDiscretization());
450 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
451 const DataArrayInt *da1=disc2->getArrayOfDiscIds();
452 const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
453 MCAuto<DataArrayInt> da2=da1->selectByTupleId(idsInPfl->begin(),idsInPfl->end());
454 MCAuto<DataArrayInt> da3=da2->findIdsEqual(_loc_id);
455 MCAuto<DataArrayInt> da4=idsInPfl->selectByTupleId(da3->begin(),da3->end());
457 MCAuto<MEDCouplingMesh> mesh2=mesh->buildPart(multiTypePfl->begin(),multiTypePfl->end());
458 MCAuto<DataArrayInt> arr=disc2->getOffsetArr(mesh2);
460 MCAuto<DataArrayInt> tmp=DataArrayInt::New();
462 for(const int *pt=da4->begin();pt!=da4->end();pt++)
463 trueNval+=arr->getIJ(*pt+1,0)-arr->getIJ(*pt,0);
464 tmp->alloc(trueNval,1);
465 int *tmpPtr=tmp->getPointer();
466 for(const int *pt=da4->begin();pt!=da4->end();pt++)
467 for(int j=arr->getIJ(*pt,0);j<arr->getIJ(*pt+1,0);j++)
470 _nval=da4->getNumberOfTuples();
471 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
472 _end=_start+trueNval;
473 oss << "_loc_" << _loc_id;
476 MCAuto<DataArrayInt> da5=locIds->selectByTupleId(da3->begin(),da3->end());
477 da5->setName(oss.str());
478 glob.appendProfile(da5);
483 if(!da3->isIota(nbOfEltsInWholeMesh))
485 da3->setName(oss.str());
486 glob.appendProfile(da3);
490 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
491 _localization=oss2.str();
492 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
496 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for such discretization type of field !");
501 void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob)
504 _nval=arrr->getNumberOfTuples();
505 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,0,_nval,1);
510 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int profileIt, const PartDefinition *pd)
512 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt,pd);
515 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int locId)
517 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string());
520 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(const MEDFileFieldPerMeshPerTypePerDisc& other)
522 return new MEDFileFieldPerMeshPerTypePerDisc(other);
525 std::size_t MEDFileFieldPerMeshPerTypePerDisc::getHeapMemorySizeWithoutChildren() const
527 return _profile.capacity()+_localization.capacity()+sizeof(MEDFileFieldPerMeshPerTypePerDisc);
530 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypePerDisc::getDirectChildrenWithNull() const
532 std::vector<const BigMemoryObject *> ret(1);
533 ret[0]=(const PartDefinition*)_pd;
537 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCopy(MEDFileFieldPerMeshPerTypeCommon *father) const
539 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret(new MEDFileFieldPerMeshPerTypePerDisc(*this));
544 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField atype, int profileIt, const PartDefinition *pd)
545 try:_type(atype),_father(fath),_profile_it(profileIt),_pd(const_cast<PartDefinition *>(pd))
550 catch(INTERP_KERNEL::Exception& e)
555 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
559 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)
563 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(0),_start(-std::numeric_limits<int>::max()),_end(-std::numeric_limits<int>::max()),
564 _nval(-std::numeric_limits<int>::max()),_loc_id(-std::numeric_limits<int>::max())
568 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)
570 const PartDefinition *pd(_pd);
573 INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
575 med_int nbValsInFile(MEDfieldnValueWithProfileByName(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile.c_str(),MED_COMPACT_PFLMODE,&tmp1,locname,&nbi));
576 if(_end-_start!=nbValsInFile*nbi)
578 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 !";
579 throw INTERP_KERNEL::Exception(oss.str());
581 MEDFILESAFECALLERRD0(MEDfieldValueWithProfileRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,_profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,startFeedingPtr));
585 if(!_profile.empty())
586 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : not implemented !");
587 INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)),locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
589 int overallNval(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
590 const SlicePartDefinition *spd(dynamic_cast<const SlicePartDefinition *>(pd));
594 spd->getSlice(start,stop,step);
595 int nbOfEltsToLoad(DataArray::GetNumberOfItemGivenBES(start,stop,step,"MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile"));
596 med_filter filter=MED_FILTER_INIT;
597 MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
598 MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
599 /*start*/start+1,/*stride*/step,/*count*/1,/*blocksize*/nbOfEltsToLoad,
600 /*lastblocksize=useless because count=1*/0,&filter);
601 MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,startFeedingPtr));
602 MEDfilterClose(&filter);
605 const DataArrayPartDefinition *dpd(dynamic_cast<const DataArrayPartDefinition *>(pd));
608 dpd->checkConsistencyLight();
609 MCAuto<DataArrayInt> myIds(dpd->toDAI());
610 int a(myIds->getMinValueInArray()),b(myIds->getMaxValueInArray());
611 myIds=myIds->deepCopy();// WARNING deep copy here because _pd is modified by applyLin !!!
612 myIds->applyLin(1,-a);
613 int nbOfEltsToLoad(b-a+1);
614 med_filter filter=MED_FILTER_INIT;
615 {//TODO : manage int32 !
616 MCAuto<DataArrayDouble> tmp(DataArrayDouble::New());
617 tmp->alloc(nbOfEltsToLoad,nbOfCompo);
618 MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
619 MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
620 /*start*/a+1,/*stride*/1,/*count*/1,/*blocksize*/nbOfEltsToLoad,
621 /*lastblocksize=useless because count=1*/0,&filter);
622 MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,reinterpret_cast<unsigned char *>(tmp->getPointer())));
623 MCAuto<DataArrayDouble> feeder(DataArrayDouble::New());
624 feeder->useExternalArrayWithRWAccess(reinterpret_cast<double *>(startFeedingPtr),_nval,nbOfCompo);
625 feeder->setContigPartOfSelectedValues(0,tmp,myIds);
627 MEDfilterClose(&filter);
630 throw INTERP_KERNEL::Exception("Not implemented yet for not slices!");
634 const MEDFileFieldPerMeshPerTypeCommon *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
639 void MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
641 INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
642 INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
643 std::string fieldName(nasc.getName()),meshName(getMeshName());
644 int iteration(getIteration()),order(getOrder()),profilesize,nbi;
645 TypeOfField type(getType());
646 med_geometry_type mgeoti;
647 med_entity_type menti;
648 _father->entriesForMEDfile(type,mgeoti,menti);
649 int zeNVal(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
650 _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
651 _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
652 const PartDefinition *pd(_pd);
659 if(!_profile.empty())
660 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively : profiles are not managed yet with part of def !");
661 _nval=pd->getNumberOfElems();
664 _end=start+_nval*nbi;
666 if(type==ON_CELLS && !_localization.empty())
668 if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
669 setType(ON_GAUSS_PT);
672 setType(ON_GAUSS_NE);
673 _localization.clear();
678 void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, const MEDFileFieldNameScope& nasc)
680 std::string fieldName(nasc.getName()),meshName(getMeshName());
681 int iteration(getIteration()),order(getOrder());
682 TypeOfField type(getType());
683 med_geometry_type mgeoti;
684 med_entity_type menti;
685 _father->entriesForMEDfile(type,mgeoti,menti);
687 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !");
690 DataArray *arr(getOrCreateAndGetArray());//arr is not null due to the spec of getOrCreateAndGetArray
691 if(_start<0 || _start>=arr->getNumberOfTuples())
693 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << ") !";
694 throw INTERP_KERNEL::Exception(oss.str());
696 if(_end<0 || _end>arr->getNumberOfTuples())
698 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !";
699 throw INTERP_KERNEL::Exception(oss.str());
701 int nbOfCompo(arr->getNumberOfComponents());
702 DataArrayDouble *arrD(dynamic_cast<DataArrayDouble *>(arr));
705 double *startFeeding(arrD->getPointer()+_start*nbOfCompo);
706 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
709 DataArrayInt *arrI(dynamic_cast<DataArrayInt *>(arr));
712 int *startFeeding(arrI->getPointer()+_start*nbOfCompo);
713 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
716 throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
720 * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
722 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart)
724 int delta=_end-_start;
725 _start=newValueOfStart;
729 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
731 return _father->getIteration();
734 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
736 return _father->getOrder();
739 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
741 return _father->getTime();
744 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
746 return _father->getMeshName();
749 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
751 const char startLine[]=" ## ";
752 std::string startLine2(bkOffset,' ');
753 startLine2+=startLine;
754 INTERP_KERNEL::AutoCppPtr<MEDCouplingFieldDiscretization> tmp(MEDCouplingFieldDiscretization::New(_type));
755 oss << startLine2 << "Localization #" << id << "." << std::endl;
756 oss << startLine2 << " Type=" << tmp->getRepr() << "." << std::endl;
757 oss << startLine2 << " This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
758 oss << startLine2 << " This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
759 oss << startLine2 << " This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
762 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
767 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
769 return _father->getGeoType();
772 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
777 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
782 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
784 return _father->getNumberOfComponents();
787 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
792 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray()
794 return _father->getOrCreateAndGetArray();
797 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const
799 const MEDFileFieldPerMeshPerTypeCommon *fath=_father;
800 return fath->getOrCreateAndGetArray();
803 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
805 return _father->getInfo();
808 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
813 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const std::string& newPflName)
818 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
820 return _localization;
823 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const std::string& newLocName)
825 _localization=newLocName;
828 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
830 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
832 if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
834 _profile=(*it2).second;
840 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
842 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
844 if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
846 _localization=(*it2).second;
852 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
856 dads.push_back(std::pair<int,int>(_start,_end));
857 geoTypes.push_back(getGeoType());
862 pfls.push_back(glob->getProfile(_profile.c_str()));
864 if(_localization.empty())
868 locs.push_back(glob->getLocalizationId(_localization.c_str()));
872 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
874 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));
878 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
880 TypeOfField type=getType();
881 INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
882 med_geometry_type mgeoti;
883 med_entity_type menti;
884 _father->entriesForMEDfile(getType(),mgeoti,menti);
885 const DataArray *arr(getOrCreateAndGetArray());
887 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
888 if(!arr->isAllocated())
889 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : the array to be written is not allocated !");
890 const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
891 const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
892 const unsigned char *locToWrite=0;
894 locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
896 locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
898 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
899 MEDFILESAFECALLERWR0(MEDfieldValueWithProfileWr,(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
900 MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
904 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const
909 dad.first=_start; dad.second=_end;
913 * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
914 * This code corresponds to the distribution of types in the corresponding mesh.
915 * \param [out] ptToFill memory zone where the output will be stored.
916 * \return the size of data pushed into output param \a ptToFill
918 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const
921 std::ostringstream oss;
922 std::size_t nbOfType=codeOfMesh.size()/3;
924 for(std::size_t i=0;i<nbOfType && found==-1;i++)
925 if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
929 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
930 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
931 throw INTERP_KERNEL::Exception(oss.str());
936 if(_nval!=codeOfMesh[3*found+1])
938 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
939 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
940 oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
941 throw INTERP_KERNEL::Exception(oss.str());
943 for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
948 const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
949 if(pfl->getNumberOfTuples()!=_nval)
951 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
952 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
954 oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
955 throw INTERP_KERNEL::Exception(oss.str());
957 int offset2=codeOfMesh[3*found+2];
958 for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
960 if(*pflId<codeOfMesh[3*found+1])
961 *work++=offset2+*pflId;
967 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const
969 for(int i=_start;i<_end;i++)
974 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId)
985 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
989 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
992 std::map<std::pair<std::string,TypeOfField>,int> m;
993 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
994 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
995 if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
996 m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
998 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
999 ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
1004 * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
1006 * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
1007 * \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.
1008 * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
1009 * \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)
1010 * \param [in,out] glob if necessary by the method, new profiles can be added to it
1011 * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
1012 * \param [out] result All new entries will be appended on it.
1013 * \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 !)
1015 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
1016 const DataArrayInt *explicitIdsInMesh,
1017 const std::vector<int>& newCode,
1018 MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
1019 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >& result)
1021 if(entriesOnSameDisc.empty())
1023 TypeOfField type=entriesOnSameDisc[0]->getType();
1024 int szEntities=0,szTuples=0;
1025 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
1026 { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
1027 int nbi=szTuples/szEntities;
1028 if(szTuples%szEntities!=0)
1029 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
1030 MCAuto<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
1031 MCAuto<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
1032 std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
1033 std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
1034 std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
1035 std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
1036 MCAuto<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
1038 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
1040 int startOfEltIdOfChunk=(*it)->_start;
1041 MCAuto<DataArrayInt> newEltIds=explicitIdsInMesh->subArray(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
1042 MCAuto<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
1043 MCAuto<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
1045 MCAuto<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
1046 newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
1048 newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
1049 newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
1051 MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
1052 MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
1053 MCAuto<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
1054 MCAuto<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
1056 MCAuto<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
1058 MCAuto<DataArrayDouble> arrPart=arr->subArray(offset,offset+szTuples);
1059 arrPart->renumberInPlace(renumTupleIds->begin());
1060 arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
1062 const int *idIt=diffVals->begin();
1063 std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
1065 for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
1067 MCAuto<DataArrayInt> ids=newGeoTypesEltIdsAllGather->findIdsEqual(*idIt);
1068 MCAuto<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
1069 int nbEntityElts=subIds->getNumberOfTuples();
1071 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
1072 NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIota(newCode[3*(*idIt)+1]),nbi,
1076 result.push_back(eltToAdd);
1077 offset2+=nbEntityElts*nbi;
1079 ret=ret || li.empty();
1084 * \param [in] typeF type of field of new chunk
1085 * \param [in] geoType the geometric type of the chunk
1086 * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
1087 * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
1088 * \param [in] nbi number of integration points
1089 * \param [in] offset The offset in the **global array of data**.
1090 * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
1091 * to the new chunk to create.
1092 * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
1093 * \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
1094 * and corresponding entry erased from \a entriesOnSameDisc.
1095 * \return a newly allocated chunk
1097 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
1098 bool isPfl, int nbi, int offset,
1099 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
1100 MEDFileFieldGlobsReal& glob,
1101 bool ¬InExisting)
1103 int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
1104 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
1105 for(;it!=entriesOnSameDisc.end();it++)
1107 if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
1111 if((*it)->_profile.empty())
1114 if(!(*it)->_profile.empty())
1116 const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
1117 if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
1123 if(it==entriesOnSameDisc.end())
1126 MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
1128 ret->_loc_id=(int)geoType;
1129 ret->_nval=nbMeshEntities;
1131 ret->_end=ret->_start+ret->_nval*nbi;
1134 idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
1135 glob.appendProfile(idsOfMeshElt);
1136 ret->_profile=idsOfMeshElt->getName();
1138 //tony treatment of localization
1143 notInExisting=false;
1144 MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1145 ret->_loc_id=(int)geoType;
1146 ret->setNewStart(offset);
1147 entriesOnSameDisc.erase(it);
1153 ////////////////////////////////////
1155 MEDFileFieldPerMeshPerTypeCommon::~MEDFileFieldPerMeshPerTypeCommon()
1159 void MEDFileFieldPerMeshPerTypeCommon::setFather(MEDFileFieldPerMesh *father)
1164 void MEDFileFieldPerMeshPerTypeCommon::accept(MEDFileFieldVisitor& visitor) const
1166 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1167 if((*it).isNotNull())
1169 visitor.newPerMeshPerTypePerDisc(*it);
1173 void MEDFileFieldPerMeshPerTypeCommon::deepCopyElements()
1176 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1178 if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
1179 _field_pm_pt_pd[i]=(*it)->deepCopy(this);
1183 std::size_t MEDFileFieldPerMeshPerTypeCommon::getHeapMemorySizeWithoutChildren() const
1185 return _field_pm_pt_pd.capacity()*sizeof(MCAuto<MEDFileFieldPerMeshPerTypePerDisc>);
1188 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypeCommon::getDirectChildrenWithNull() const
1190 std::vector<const BigMemoryObject *> ret;
1191 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1192 ret.push_back((const MEDFileFieldPerMeshPerTypePerDisc *)*it);
1196 void MEDFileFieldPerMeshPerTypeCommon::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1198 std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
1199 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1200 _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1204 * This method is the most general one. No optimization is done here.
1205 * \param [in] multiTypePfl is the end user profile specified in high level API
1206 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1207 * \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.
1208 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1209 * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1210 * \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.
1212 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)
1214 std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1215 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1216 _field_pm_pt_pd[*it]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1219 void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1221 _field_pm_pt_pd.resize(1);
1222 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1223 _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1226 void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1228 MCAuto<DataArrayInt> pfl2=pfl->deepCopy();
1229 if(!arr || !arr->isAllocated())
1230 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile : input array is null, or not allocated !");
1231 _field_pm_pt_pd.resize(1);
1232 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1233 _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.
1236 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1238 TypeOfField type=field->getTypeOfField();
1239 if(type!=ON_GAUSS_PT)
1241 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1242 int sz=_field_pm_pt_pd.size();
1244 for(int j=0;j<sz && !found;j++)
1246 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1248 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1254 _field_pm_pt_pd.resize(sz+1);
1255 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1257 std::vector<int> ret(1,(int)sz);
1262 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1263 int sz2=ret2.size();
1264 std::vector<int> ret3(sz2);
1266 for(int i=0;i<sz2;i++)
1268 int sz=_field_pm_pt_pd.size();
1269 int locIdToFind=ret2[i];
1271 for(int j=0;j<sz && !found;j++)
1273 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1275 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1282 _field_pm_pt_pd.resize(sz+1);
1283 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1291 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1293 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1294 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1296 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1297 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1299 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1300 MCAuto<DataArrayInt> da2=da->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1);
1301 MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1302 if(retTmp->presenceOfValue(-1))
1303 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1304 std::vector<int> ret(retTmp->begin(),retTmp->end());
1308 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1310 TypeOfField type=field->getTypeOfField();
1311 if(type!=ON_GAUSS_PT)
1313 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1314 int sz=_field_pm_pt_pd.size();
1316 for(int j=0;j<sz && !found;j++)
1318 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1320 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1326 _field_pm_pt_pd.resize(sz+1);
1327 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1329 std::vector<int> ret(1,0);
1334 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1335 int sz2=ret2.size();
1336 std::vector<int> ret3(sz2);
1338 for(int i=0;i<sz2;i++)
1340 int sz=_field_pm_pt_pd.size();
1341 int locIdToFind=ret2[i];
1343 for(int j=0;j<sz && !found;j++)
1345 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1347 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1354 _field_pm_pt_pd.resize(sz+1);
1355 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1363 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1365 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1366 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1368 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1369 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1371 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1372 MCAuto<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1373 MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1374 if(retTmp->presenceOfValue(-1))
1375 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1376 std::vector<int> ret(retTmp->begin(),retTmp->end());
1380 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerTypeCommon::getFather() const
1385 bool MEDFileFieldPerMeshPerTypeCommon::isUniqueLevel(int& dim) const
1387 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
1388 int curDim((int)cm.getDimension());
1389 if(dim!=std::numeric_limits<int>::max())
1399 void MEDFileFieldPerMeshPerTypeCommon::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1401 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1403 (*it)->fillTypesOfFieldAvailable(types);
1407 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
1409 int sz=_field_pm_pt_pd.size();
1410 dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1411 for(int i=0;i<sz;i++)
1413 _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1417 int MEDFileFieldPerMeshPerTypeCommon::getIteration() const
1419 return _father->getIteration();
1422 int MEDFileFieldPerMeshPerTypeCommon::getOrder() const
1424 return _father->getOrder();
1427 double MEDFileFieldPerMeshPerTypeCommon::getTime() const
1429 return _father->getTime();
1432 std::string MEDFileFieldPerMeshPerTypeCommon::getMeshName() const
1434 return _father->getMeshName();
1437 void MEDFileFieldPerMeshPerTypeCommon::getSizes(int& globalSz, int& nbOfEntries) const
1439 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1441 globalSz+=(*it)->getNumberOfTuples();
1443 nbOfEntries+=(int)_field_pm_pt_pd.size();
1446 int MEDFileFieldPerMeshPerTypeCommon::getNumberOfComponents() const
1448 return _father->getNumberOfComponents();
1451 bool MEDFileFieldPerMeshPerTypeCommon::presenceOfMultiDiscPerGeoType() const
1454 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1456 const MEDFileFieldPerMeshPerTypePerDisc *fmtd(*it);
1463 void MEDFileFieldPerMeshPerTypeCommon::pushDiscretization(MEDFileFieldPerMeshPerTypePerDisc *disc)
1465 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt;
1467 _field_pm_pt_pd.push_back(elt);
1470 DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray()
1472 return _father->getOrCreateAndGetArray();
1475 const DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray() const
1477 const MEDFileFieldPerMesh *fath=_father;
1478 return fath->getOrCreateAndGetArray();
1481 const std::vector<std::string>& MEDFileFieldPerMeshPerTypeCommon::getInfo() const
1483 return _father->getInfo();
1486 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsed() const
1488 std::vector<std::string> ret;
1489 std::set<std::string> ret2;
1490 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1492 std::string tmp=(*it1)->getProfile();
1494 if(ret2.find(tmp)==ret2.end())
1503 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsed() const
1505 std::vector<std::string> ret;
1506 std::set<std::string> ret2;
1507 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1509 std::string tmp=(*it1)->getLocalization();
1510 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1511 if(ret2.find(tmp)==ret2.end())
1520 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsedMulti() const
1522 std::vector<std::string> ret;
1523 std::set<std::string> ret2;
1524 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1526 std::string tmp=(*it1)->getProfile();
1533 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsedMulti() const
1535 std::vector<std::string> ret;
1536 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1538 std::string tmp=(*it1)->getLocalization();
1539 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1545 void MEDFileFieldPerMeshPerTypeCommon::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1547 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1548 (*it1)->changePflsRefsNamesGen(mapOfModif);
1551 void MEDFileFieldPerMeshPerTypeCommon::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1553 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1554 (*it1)->changeLocsRefsNamesGen(mapOfModif);
1557 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId)
1559 if(_field_pm_pt_pd.empty())
1561 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << getGeoTypeRepr() << "\" !";
1562 throw INTERP_KERNEL::Exception(oss.str());
1564 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1565 return _field_pm_pt_pd[locId];
1566 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
1567 oss2 << ") for geometric type \"" << getGeoTypeRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1568 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1569 return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1572 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId) const
1574 if(_field_pm_pt_pd.empty())
1576 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << getGeoTypeRepr() << "\" !";
1577 throw INTERP_KERNEL::Exception(oss.str());
1579 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1580 return _field_pm_pt_pd[locId];
1581 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
1582 oss2 << ") for geometric type \"" << getGeoTypeRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1583 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1584 return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1587 void MEDFileFieldPerMeshPerTypeCommon::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1590 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1592 (*it)->fillValues(i,startEntryId,entries);
1596 void MEDFileFieldPerMeshPerTypeCommon::setLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
1598 _field_pm_pt_pd=leaves;
1599 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1600 (*it)->setFather(this);
1604 * \param [in,out] globalNum a global numbering counter for the renumbering.
1605 * \param [out] its - list of pair (start,stop) kept
1606 * \return bool - false if the type of field \a tof is not contained in \a this.
1608 bool MEDFileFieldPerMeshPerTypeCommon::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
1611 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1612 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1613 if((*it)->getType()==tof)
1615 newPmPtPd.push_back(*it);
1616 std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1617 (*it)->setNewStart(globalNum);
1618 globalNum=(*it)->getEnd();
1619 its.push_back(bgEnd);
1623 _field_pm_pt_pd=newPmPtPd;
1628 * \param [in,out] globalNum a global numbering counter for the renumbering.
1629 * \param [out] its - list of pair (start,stop) kept
1630 * \return bool - false if the type of field \a tof is not contained in \a this.
1632 bool MEDFileFieldPerMeshPerTypeCommon::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
1634 if(_field_pm_pt_pd.size()<=idOfDisc)
1636 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt(_field_pm_pt_pd[idOfDisc]);
1637 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd(1,elt);
1638 std::pair<int,int> bgEnd; bgEnd.first=_field_pm_pt_pd[idOfDisc]->getStart(); bgEnd.second=_field_pm_pt_pd[idOfDisc]->getEnd();
1639 elt->setNewStart(globalNum);
1640 globalNum=elt->getEnd();
1641 its.push_back(bgEnd);
1642 _field_pm_pt_pd=newPmPtPd;
1646 void MEDFileFieldPerMeshPerTypeCommon::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
1648 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1649 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1652 void MEDFileFieldPerMeshPerTypeCommon::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1654 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1655 (*it)->loadBigArray(fid,nasc);
1658 void MEDFileFieldPerMeshPerTypeCommon::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1660 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1662 (*it)->copyOptionsFrom(*this);
1663 (*it)->writeLL(fid,nasc);
1667 med_entity_type MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1672 medfGeoType=typmai3[(int)ikGeoType];
1675 medfGeoType=MED_NONE;
1678 medfGeoType=typmai3[(int)ikGeoType];
1679 return MED_NODE_ELEMENT;
1681 medfGeoType=typmai3[(int)ikGeoType];
1684 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1686 return MED_UNDEF_ENTITY_TYPE;
1689 //////////////////////////////////////////////////
1691 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd)
1693 return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc,pd);
1696 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType)
1698 return new MEDFileFieldPerMeshPerType(fath,geoType);
1701 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCopy(MEDFileFieldPerMesh *father) const
1703 MCAuto<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
1704 ret->setFather(father);
1705 ret->deepCopyElements();
1709 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
1711 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1713 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1714 if(meshDim!=(int)cm.getDimension())
1717 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1718 (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1721 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1726 void MEDFileFieldPerMeshPerType::entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const
1728 ent=MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(mct,_geo_type,gt);
1731 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1733 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1734 int curDim((int)cm.getDimension());
1735 dim=std::max(dim,curDim);
1738 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1740 const char startLine[]=" ## ";
1741 std::string startLine2(bkOffset,' ');
1742 std::string startLine3(startLine2);
1743 startLine3+=startLine;
1744 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1746 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1747 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1750 oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1751 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1753 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1755 const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1757 cur->simpleRepr(bkOffset,oss,i);
1760 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1765 std::string MEDFileFieldPerMeshPerType::getGeoTypeRepr() const
1767 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1768 return std::string(cm.getRepr());
1771 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *father, INTERP_KERNEL::NormalizedCellType gt):MEDFileFieldPerMeshPerTypeCommon(father),_geo_type(gt)
1775 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):MEDFileFieldPerMeshPerTypeCommon(fath),_geo_type(geoType)
1777 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1778 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1779 med_geometry_type mgeoti;
1780 med_entity_type menti(ConvertIntoMEDFileType(type,geoType,mgeoti));
1781 int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName));
1782 _field_pm_pt_pd.resize(nbProfiles);
1783 for(int i=0;i<nbProfiles;i++)
1785 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i,pd);
1789 int nbProfiles2(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName));
1790 for(int i=0;i<nbProfiles2;i++)
1791 _field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i,pd));
1795 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)
1797 MCAuto<MEDFileFieldPerMeshPerType> ret(MEDFileFieldPerMeshPerType::New(father,gt));
1798 std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > > m;
1799 for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerType *> >::const_iterator it=pms.begin();it!=pms.end();it++)
1801 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it2=(*it).second->_field_pm_pt_pd.begin();it2!=(*it).second->_field_pm_pt_pd.end();it2++)
1802 m[(*it2)->getType()].push_back(std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * >((*it).first,*it2));
1804 for(std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > >::const_iterator it=m.begin();it!=m.end();it++)
1806 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> agg(MEDFileFieldPerMeshPerTypePerDisc::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
1807 ret->_field_pm_pt_pd.push_back(agg);
1812 //////////////////////////////////////////////////
1814 MEDFileFieldPerMeshPerTypeDyn *MEDFileFieldPerMeshPerTypeDyn::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileEntities *entities, int idGT, const MEDFileFieldNameScope& nasc)
1817 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeDyn::NewOnRead : null pointer !");
1818 const MEDFileAllStaticEntitiesPlusDyn *entities2(dynamic_cast<const MEDFileAllStaticEntitiesPlusDyn *>(entities));
1820 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeDyn::NewOnRead : invalid type of entities !");
1821 const MEDFileStructureElement *se(entities2->getWithGT(idGT));
1822 return new MEDFileFieldPerMeshPerTypeDyn(fid,fath,se,nasc);
1825 MEDFileFieldPerMeshPerTypeDyn::MEDFileFieldPerMeshPerTypeDyn(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileStructureElement *se, const MEDFileFieldNameScope& nasc):MEDFileFieldPerMeshPerTypeCommon(fath)
1828 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1829 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1830 int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,_se->getDynGT(),pflName,locName));
1831 _field_pm_pt_pd.resize(nbProfiles);
1832 for(int i=0;i<nbProfiles;i++)
1834 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,_se->getEntity(),i,NULL);
1838 int MEDFileFieldPerMeshPerTypeDyn::getDynGT() const
1840 return _se->getDynGT();
1843 std::string MEDFileFieldPerMeshPerTypeDyn::getModelName() const
1845 return _se->getName();
1848 void MEDFileFieldPerMeshPerTypeDyn::getDimension(int& dim) const
1850 throw INTERP_KERNEL::Exception("not implemented yet !");
1853 void MEDFileFieldPerMeshPerTypeDyn::entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const
1856 ent=MED_STRUCT_ELEMENT;
1859 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypeDyn::getGeoType() const
1861 throw INTERP_KERNEL::Exception("not implemented yet !");
1864 void MEDFileFieldPerMeshPerTypeDyn::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1866 const char startLine[]=" ## ";
1867 std::string startLine2(bkOffset,' ');
1868 std::string startLine3(startLine2);
1869 startLine3+=startLine;
1870 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry STRUCTURE_ELEMENT type " << getDynGT() << "." << std::endl;
1871 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1873 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1875 if((*it).isNotNull())
1876 (*it)->simpleRepr(bkOffset,oss,i);
1879 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1884 std::string MEDFileFieldPerMeshPerTypeDyn::getGeoTypeRepr() const
1886 throw INTERP_KERNEL::Exception("not implemented yet !");
1889 MEDFileFieldPerMeshPerTypeDyn *MEDFileFieldPerMeshPerTypeDyn::deepCopy(MEDFileFieldPerMesh *father) const
1891 MCAuto<MEDFileFieldPerMeshPerTypeDyn> ret(new MEDFileFieldPerMeshPerTypeDyn(*this));
1892 ret->setFather(father);
1893 ret->deepCopyElements();
1897 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
1899 throw INTERP_KERNEL::Exception("not implemented yet !");
1902 //////////////////////////////////////////////////
1904 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const MEDFileEntities *entities)
1906 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm,entities);
1909 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1911 return new MEDFileFieldPerMesh(fath,mesh);
1914 std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
1916 return _field_pm_pt.capacity()*sizeof(MCAuto< MEDFileFieldPerMeshPerType >);
1919 std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildrenWithNull() const
1921 std::vector<const BigMemoryObject *> ret;
1922 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1927 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCopy(MEDFileAnyTypeField1TSWithoutSDA *father) const
1929 MCAuto< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1930 ret->_father=father;
1932 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1934 if((*it).isNotNull())
1935 ret->_field_pm_pt[i]=(*it)->deepCopy((MEDFileFieldPerMesh *)(ret));
1940 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1942 std::string startLine(bkOffset,' ');
1943 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << getMeshName() << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1944 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1946 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1948 if((*it).isNotNull())
1949 (*it)->simpleRepr(bkOffset,oss,i);
1952 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1957 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh)
1959 mesh->getTime(_mesh_iteration,_mesh_order);
1962 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1964 int nbOfTypes=code.size()/3;
1966 for(int i=0;i<nbOfTypes;i++)
1968 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1969 int nbOfCells=code[3*i+1];
1970 int pos=addNewEntryIfNecessary(type);
1971 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1977 * This method is the most general one. No optimization is done here.
1978 * \param [in] multiTypePfl is the end user profile specified in high level API
1979 * \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].
1980 * \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.
1981 * \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.
1982 * \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.
1983 * \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.
1985 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)
1987 int nbOfTypes(code.size()/3);
1988 for(int i=0;i<nbOfTypes;i++)
1990 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1991 int pos=addNewEntryIfNecessary(type);
1992 DataArrayInt *pfl=0;
1994 pfl=idsPerType[code[3*i+2]];
1995 int nbOfTupes2=code2.size()/3;
1997 for(;found<nbOfTupes2;found++)
1998 if(code[3*i]==code2[3*found])
2000 if(found==nbOfTupes2)
2001 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
2002 _field_pm_pt[pos]->assignFieldProfile(nbOfTypes==1,start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
2006 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
2008 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
2009 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
2012 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
2014 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
2015 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
2018 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
2020 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2021 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
2024 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
2026 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2027 (*it)->loadBigArraysRecursively(fid,nasc);
2030 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
2032 int nbOfTypes=_field_pm_pt.size();
2033 for(int i=0;i<nbOfTypes;i++)
2035 _field_pm_pt[i]->copyOptionsFrom(*this);
2036 _field_pm_pt[i]->writeLL(fid,nasc);
2040 void MEDFileFieldPerMesh::getDimension(int& dim) const
2042 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2043 (*it)->getDimension(dim);
2046 bool MEDFileFieldPerMesh::isUniqueLevel(int& dim) const
2048 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2049 if(!(*it)->isUniqueLevel(dim))
2054 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
2056 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2057 (*it)->fillTypesOfFieldAvailable(types);
2060 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
2062 int sz=_field_pm_pt.size();
2063 std::vector< std::vector<std::pair<int,int> > > ret(sz);
2064 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
2065 for(int i=0;i<sz;i++)
2067 types[i]=_field_pm_pt[i]->getGeoType();
2068 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
2073 double MEDFileFieldPerMesh::getTime() const
2076 return _father->getTime(tmp1,tmp2);
2079 int MEDFileFieldPerMesh::getIteration() const
2081 return _father->getIteration();
2084 int MEDFileFieldPerMesh::getOrder() const
2086 return _father->getOrder();
2089 int MEDFileFieldPerMesh::getNumberOfComponents() const
2091 return _father->getNumberOfComponents();
2094 std::string MEDFileFieldPerMesh::getMeshName() const
2096 return _father->getMeshName();
2099 void MEDFileFieldPerMesh::setMeshName(const std::string& meshName)
2101 _father->setMeshName(meshName);
2104 bool MEDFileFieldPerMesh::presenceOfMultiDiscPerGeoType() const
2106 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2110 if((*it)->presenceOfMultiDiscPerGeoType())
2116 bool MEDFileFieldPerMesh::presenceOfStructureElements() const
2118 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2119 if((*it).isNotNull())
2121 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2128 bool MEDFileFieldPerMesh::onlyStructureElements() const
2130 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2131 if((*it).isNotNull())
2133 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2140 void MEDFileFieldPerMesh::killStructureElements()
2142 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
2143 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2145 if((*it).isNotNull())
2147 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2155 void MEDFileFieldPerMesh::keepOnlyStructureElements()
2157 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
2158 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2160 if((*it).isNotNull())
2162 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2170 void MEDFileFieldPerMesh::keepOnlyOnSE(const std::string& seName)
2172 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
2173 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2175 if((*it).isNotNull())
2177 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2179 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::keepOnlyOnSE : presence of non SE !");
2180 if(pt->getModelName()==seName)
2187 void MEDFileFieldPerMesh::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
2189 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2191 if((*it).isNotNull())
2193 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2196 ps.push_back(std::pair<std::string,std::string>(getMeshName(),pt->getModelName()));
2199 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getMeshSENames : presence of a non structure element part !");
2204 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
2207 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
2208 return _father->getOrCreateAndGetArray();
2211 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
2214 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
2215 return _father->getOrCreateAndGetArray();
2218 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
2220 return _father->getInfo();
2224 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
2225 * 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.
2226 * It returns 2 output vectors :
2227 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
2228 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
2229 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
2231 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)
2233 int notNullPflsSz=0;
2234 int nbOfArrs=geoTypes.size();
2235 for(int i=0;i<nbOfArrs;i++)
2238 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
2239 int nbOfDiffGeoTypes=geoTypes3.size();
2240 code.resize(3*nbOfDiffGeoTypes);
2241 notNullPfls.resize(notNullPflsSz);
2244 for(int i=0;i<nbOfDiffGeoTypes;i++)
2247 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
2248 std::vector<const DataArrayInt *> notNullTmp;
2250 notNullTmp.push_back(pfls[j]);
2252 for(;j<nbOfArrs;j++)
2253 if(geoTypes[j]==refType)
2256 notNullTmp.push_back(pfls[j]);
2260 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
2261 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
2262 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
2263 code[3*i]=(int)refType;
2264 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
2265 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
2266 if(notNullTmp.empty())
2270 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
2271 code[3*i+2]=notNullPflsSz++;
2277 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
2279 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)
2283 for(int i=0;i<sz;i++)
2287 if(type!=ON_GAUSS_NE)
2288 ret+=dads[i].second-dads[i].first;
2291 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
2292 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
2297 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
2298 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
2304 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
2306 std::vector<std::string> ret;
2307 std::set<std::string> ret2;
2308 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2310 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
2311 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
2312 if(ret2.find(*it2)==ret2.end())
2314 ret.push_back(*it2);
2321 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
2323 std::vector<std::string> ret;
2324 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2326 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
2327 ret.insert(ret.end(),tmp.begin(),tmp.end());
2332 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
2334 std::vector<std::string> ret;
2335 std::set<std::string> ret2;
2336 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2338 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
2339 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
2340 if(ret2.find(*it2)==ret2.end())
2342 ret.push_back(*it2);
2349 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
2351 std::vector<std::string> ret;
2352 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2354 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
2355 ret.insert(ret.end(),tmp.begin(),tmp.end());
2360 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
2362 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
2364 if((*it).first==getMeshName())
2366 setMeshName((*it).second);
2373 void MEDFileFieldPerMesh::convertMedBallIntoClassic()
2375 if(_field_pm_pt.size()!=1)
2376 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : Only managed for single mesh !");
2377 if(_field_pm_pt[0].isNull())
2378 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : null pointer !");
2379 MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<MEDFileFieldPerMeshPerTypeDyn *>((MEDFileFieldPerMeshPerTypeCommon *)_field_pm_pt[0]));
2381 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : this is expected to be marked as structure element !");
2382 if(pt->getNumberOfLoc()!=1)
2383 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : only one loc managed !");
2384 const MEDFileFieldPerMeshPerTypePerDisc *disc(pt->getLeafGivenLocId(0));
2386 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : internal error !");
2387 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> disc2(MEDFileFieldPerMeshPerTypePerDisc::New(*disc));
2388 disc2->setType(ON_NODES);
2389 MCAuto<MEDFileFieldPerMeshPerType> pt2(MEDFileFieldPerMeshPerType::New(this,INTERP_KERNEL::NORM_ERROR));
2390 disc2->setFather(pt2);
2391 pt2->setFather(this);
2392 pt2->pushDiscretization(disc2);
2393 _field_pm_pt[0]=DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(pt2);
2396 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
2397 MEDFileFieldGlobsReal& glob)
2399 if(getMeshName()!=meshName)
2401 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
2402 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
2403 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
2404 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
2405 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
2406 getUndergroundDataArrayExt(entries);
2407 DataArray *arr0(getOrCreateAndGetArray());//tony
2409 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
2410 DataArrayDouble *arr(dynamic_cast<DataArrayDouble *>(arr0));//tony
2412 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
2415 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
2416 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
2418 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
2420 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2421 sz+=(*it).second.second-(*it).second.first;
2424 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2426 MCAuto<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
2427 ////////////////////
2428 MCAuto<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
2429 int *workI2=explicitIdsOldInMesh->getPointer();
2430 int sz1=0,sz2=0,sid=1;
2431 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
2432 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
2433 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
2435 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
2436 MCAuto<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
2437 int *workI=explicitIdsOldInArr->getPointer();
2438 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
2440 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
2441 (*itL2)->setLocId(sz2);
2442 (*itL2)->_tmp_work1=(*itL2)->getStart();
2443 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
2445 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
2447 explicitIdsOldInMesh->reAlloc(sz2);
2448 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
2449 ////////////////////
2450 MCAuto<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
2451 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
2452 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
2453 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
2455 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
2456 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
2457 otherEntriesNew.back()->setLocId((*it)->getGeoType());
2459 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
2460 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
2461 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
2463 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
2464 int newStart=elt->getLocId();
2465 elt->setLocId((*it)->getGeoType());
2466 elt->setNewStart(newStart);
2467 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
2468 entriesKeptNew.push_back(elt);
2469 entriesKeptNew2.push_back(elt);
2471 MCAuto<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
2472 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
2473 MCAuto<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
2474 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
2476 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
2479 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
2481 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
2482 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
2484 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
2485 glob,arr2,otherEntriesNew) || ret;
2489 // Assign new dispatching
2490 assignNewLeaves(otherEntriesNew);
2491 arr->deepCopyFrom(*arr2);
2496 * \param [in,out] globalNum a global numbering counter for the renumbering.
2497 * \param [out] its - list of pair (start,stop) kept
2499 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
2501 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > ret;
2502 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2504 std::vector< std::pair<int,int> > its2;
2505 if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
2508 its.insert(its.end(),its2.begin(),its2.end());
2515 * \param [in,out] globalNum a global numbering counter for the renumbering.
2516 * \param [out] its - list of pair (start,stop) kept
2518 void MEDFileFieldPerMesh::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
2520 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > ret;
2521 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2523 std::vector< std::pair<int,int> > its2;
2524 if((*it)->keepOnlyGaussDiscretization(idOfDisc,globalNum,its2))
2527 its.insert(its.end(),its2.begin(),its2.end());
2533 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
2535 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > > types;
2536 for( std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
2537 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
2539 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > fieldPmPt(types.size());
2540 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
2541 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it2=fieldPmPt.begin();
2542 for(;it1!=types.end();it1++,it2++)
2544 MCAuto<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
2545 elt->setLeaves((*it1).second);
2546 MCAuto<MEDFileFieldPerMeshPerTypeCommon> elt2(DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(elt));
2549 _field_pm_pt=fieldPmPt;
2552 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2554 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2555 (*it)->changePflsRefsNamesGen(mapOfModif);
2558 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2560 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2561 (*it)->changeLocsRefsNamesGen(mapOfModif);
2565 * \param [in] mesh is the whole mesh
2567 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2569 if(_field_pm_pt.empty())
2570 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2572 std::vector< std::pair<int,int> > dads;
2573 std::vector<const DataArrayInt *> pfls;
2574 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2575 std::vector<int> locs,code;
2576 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2577 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2578 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2580 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2583 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2584 throw INTERP_KERNEL::Exception(oss.str());
2587 std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2588 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2591 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2593 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2596 MCAuto<DataArrayInt> arr2(arr);
2597 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2603 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2607 if(nb!=mesh->getNumberOfNodes())
2609 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2610 oss << " nodes in mesh !";
2611 throw INTERP_KERNEL::Exception(oss.str());
2613 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2616 return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2620 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
2622 if(_field_pm_pt.empty())
2623 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2625 std::vector<std::pair<int,int> > dads;
2626 std::vector<const DataArrayInt *> pfls;
2627 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2628 std::vector<int> locs,code;
2629 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2630 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2631 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2633 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2636 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2637 throw INTERP_KERNEL::Exception(oss.str());
2639 std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2640 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2643 MCAuto<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2644 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2649 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2653 if(nb!=mesh->getNumberOfNodes())
2655 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2656 oss << " nodes in mesh !";
2657 throw INTERP_KERNEL::Exception(oss.str());
2660 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2666 void MEDFileFieldPerMesh::accept(MEDFileFieldVisitor& visitor) const
2668 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2669 if((*it).isNotNull())
2671 visitor.newPerMeshPerTypeEntry(*it);
2672 (*it)->accept(visitor);
2673 visitor.endPerMeshPerTypeEntry(*it);
2677 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
2681 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2683 (*it)->getSizes(globalSz,nbOfEntries);
2685 entries.resize(nbOfEntries);
2687 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2689 (*it)->fillValues(nbOfEntries,entries);
2693 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
2695 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2697 if((*it)->getGeoType()==typ)
2698 return (*it)->getLeafGivenLocId(locId);
2700 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2701 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2702 oss << "Possiblities are : ";
2703 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2705 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2706 oss << "\"" << cm2.getRepr() << "\", ";
2708 throw INTERP_KERNEL::Exception(oss.str());
2711 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
2713 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2715 if((*it)->getGeoType()==typ)
2716 return (*it)->getLeafGivenLocId(locId);
2718 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2719 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2720 oss << "Possiblities are : ";
2721 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2723 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2724 oss << "\"" << cm2.getRepr() << "\", ";
2726 throw INTERP_KERNEL::Exception(oss.str());
2730 * \param [in,out] start - Integer that gives the current position in the final aggregated array
2731 * \param [in] pms - list of elements to aggregate. integer gives the mesh id
2732 * \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.
2733 * \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.
2735 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)
2737 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret(new MEDFileFieldPerMeshPerTypePerDisc(father,tof));
2739 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : empty input vector !");
2740 for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it=pms.begin();it!=pms.end();it++)
2743 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : presence of null pointer !");
2744 if(!(*it).second->getProfile().empty())
2745 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for profiles !");
2746 if(!(*it).second->getLocalization().empty())
2747 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for gauss pts !");
2749 INTERP_KERNEL::NormalizedCellType gt(pms[0].second->getGeoType());
2751 std::vector< std::pair<int,int> > filteredDTS;
2752 for(std::vector< std::vector< std::pair<int,int> > >::const_iterator it=dts.begin();it!=dts.end();it++,i++)
2753 for(std::vector< std::pair<int,int> >::const_iterator it2=(*it).begin();it2!=(*it).end();it2++)
2754 if((*it2).first==gt)
2755 filteredDTS.push_back(std::pair<int,int>(i,(*it2).second));
2756 if(pms.size()!=filteredDTS.size())
2757 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles !");
2758 std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it1(pms.begin());
2759 std::vector< std::pair<int,int> >::const_iterator it2(filteredDTS.begin());
2760 int zeStart(start),nval(0);
2761 for(;it1!=pms.end();it1++,it2++)
2763 if((*it1).first!=(*it2).first)
2764 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles 2 !");
2765 int s1((*it1).second->getStart()),e1((*it1).second->getEnd());
2766 extractInfo.push_back(std::pair<int, std::pair<int,int> >((*it1).first,std::pair<int,int>(s1,e1)));
2768 nval+=((*it1).second)->getNumberOfVals();
2770 ret->_start=zeStart; ret->_end=start; ret->_nval=nval;
2774 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)
2776 MCAuto<MEDFileFieldPerMesh> ret(new MEDFileFieldPerMesh(father,pms[0]->getMeshName(),pms[0]->getMeshIteration(),pms[0]->getMeshOrder()));
2777 std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > > m;
2779 for(std::vector<const MEDFileFieldPerMesh *>::const_iterator it=pms.begin();it!=pms.end();it++,i++)
2781 const std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >& v((*it)->_field_pm_pt);
2782 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it2=v.begin();it2!=v.end();it2++)
2784 INTERP_KERNEL::NormalizedCellType gt((*it2)->getGeoType());
2785 const MEDFileFieldPerMeshPerType *elt(dynamic_cast<const MEDFileFieldPerMeshPerType *>((const MEDFileFieldPerMeshPerTypeCommon *)(*it2)));
2787 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::Aggregate : not managed for structelement !");
2788 m[gt].push_back(std::pair<int,const MEDFileFieldPerMeshPerType *>(i,elt));
2791 for(std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > >::const_iterator it=m.begin();it!=m.end();it++)
2793 MCAuto<MEDFileFieldPerMeshPerType> agg(MEDFileFieldPerMeshPerType::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
2794 MCAuto<MEDFileFieldPerMeshPerTypeCommon> agg2(DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(agg));
2795 ret->_field_pm_pt.push_back(agg2);
2800 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2803 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2804 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it2=_field_pm_pt.begin();
2805 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2807 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2812 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2817 int ret=std::distance(_field_pm_pt.begin(),it2);
2818 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2823 * 'dads' and 'locs' input parameters have the same number of elements
2824 * \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
2826 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2827 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2828 const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2831 MCAuto<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2832 ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2833 MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2834 const std::vector<std::string>& infos=getInfo();
2835 da->setInfoOnComponents(infos);
2837 if(type==ON_GAUSS_PT)
2840 int nbOfArrs=dads.size();
2841 for(int i=0;i<nbOfArrs;i++)
2843 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2844 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2845 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2846 MCAuto<DataArrayInt> di=DataArrayInt::New();
2847 di->alloc(nbOfElems,1);
2849 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2850 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2859 * 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.
2860 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2861 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2862 * The order of cells in the returned field is those imposed by the profile.
2863 * \param [in] mesh is the global mesh.
2865 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2866 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2867 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2868 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2870 if(da->isIota(mesh->getNumberOfCells()))
2871 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2872 MCAuto<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2873 m2->setName(mesh->getName().c_str());
2874 MCAuto<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2880 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2882 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2883 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2884 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2886 if(da->isIota(mesh->getNumberOfNodes()))
2887 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2888 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2889 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2892 if(meshu->getNodalConnectivity()==0)
2894 MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2895 int nb=da->getNbOfElems();
2896 const int *ptr=da->getConstPointer();
2897 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2898 meshuc->allocateCells(nb);
2899 for(int i=0;i<nb;i++)
2900 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2901 meshuc->finishInsertingCells();
2902 ret->setMesh(meshuc);
2903 const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2904 if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2905 disc->checkCoherencyBetween(meshuc,arrOut);
2910 MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2912 DataArrayInt *arr2=0;
2913 MCAuto<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2914 MCAuto<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2915 MCAuto<DataArrayInt> arr3(arr2);
2916 int nnodes=mesh2->getNumberOfNodes();
2917 if(nnodes==(int)da->getNbOfElems())
2919 MCAuto<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2920 arrOut->renumberInPlace(da3->getConstPointer());
2921 mesh2->setName(mesh->getName().c_str());
2922 ret->setMesh(mesh2);
2927 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 !!!";
2928 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2929 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2930 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2931 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2932 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2933 throw INTERP_KERNEL::Exception(oss.str());
2939 * This method is the most light method of field retrieving.
2941 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
2945 pflOut=DataArrayInt::New();
2946 pflOut->alloc(nbOfElems,1);
2951 pflOut=const_cast<DataArrayInt*>(pflIn);
2954 MCAuto<DataArrayInt> safePfl(pflOut);
2955 MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2956 const std::vector<std::string>& infos=getInfo();
2957 int nbOfComp=infos.size();
2958 for(int i=0;i<nbOfComp;i++)
2959 da->setInfoOnComponent(i,infos[i].c_str());
2970 static MFFPMIter *NewCell(const MEDFileEntities *entities);
2971 static bool IsPresenceOfNode(const MEDFileEntities *entities);
2972 virtual ~MFFPMIter() { }
2973 virtual void begin() = 0;
2974 virtual bool finished() const = 0;
2975 virtual void next() = 0;
2976 virtual int current() const = 0;
2979 class MFFPMIterSimple : public MFFPMIter
2982 MFFPMIterSimple():_pos(0) { }
2983 void begin() { _pos=0; }
2984 bool finished() const { return _pos>=MED_N_CELL_FIXED_GEO; }
2985 void next() { _pos++; }
2986 int current() const { return _pos; }
2991 class MFFPMIter2 : public MFFPMIter
2994 MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts);
2995 void begin() { _it=_ids.begin(); }
2996 bool finished() const { return _it==_ids.end(); }
2997 void next() { _it++; }
2998 int current() const { return *_it; }
3000 std::vector<int> _ids;
3001 std::vector<int>::const_iterator _it;
3004 MFFPMIter *MFFPMIter::NewCell(const MEDFileEntities *entities)
3007 return new MFFPMIterSimple;
3010 const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
3013 std::vector<INTERP_KERNEL::NormalizedCellType> tmp;
3014 const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
3015 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
3017 if((*it).first==ON_CELLS || (*it).first==ON_GAUSS_NE || (*it).first==ON_GAUSS_PT)
3018 tmp.push_back((*it).second);
3020 return new MFFPMIter2(tmp);
3022 return new MFFPMIterSimple;// for MEDFileAllStaticEntites and MEDFileAllStaticEntitiesPlusDyn cells are in
3026 bool MFFPMIter::IsPresenceOfNode(const MEDFileEntities *entities)
3032 const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
3035 const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
3036 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
3037 if((*it).first==ON_NODES)
3041 return true;// for MEDFileAllStaticEntites and MEDFileAllStaticEntitiesPlusDyn nodes are in
3045 MFFPMIter2::MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts)
3047 std::size_t sz(cts.size());
3049 for(std::size_t i=0;i<sz;i++)
3051 INTERP_KERNEL::NormalizedCellType *loc(std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,cts[i]));
3052 if(loc!=typmai2+MED_N_CELL_FIXED_GEO)
3053 _ids[i]=(int)std::distance(typmai2,loc);
3055 throw INTERP_KERNEL::Exception("MFFPMIter2 : The specified geo type does not exists !");
3061 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),
3064 INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
3065 INTERP_KERNEL::AutoPtr<char> pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
3066 INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
3067 const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
3068 INTERP_KERNEL::AutoCppPtr<MFFPMIter> iter0(MFFPMIter::NewCell(entities));
3069 for(iter0->begin();!iter0->finished();iter0->next())
3071 int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL ,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
3072 std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
3073 int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
3074 std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
3075 if(nbProfile>0 || nbProfile2>0)
3077 const PartDefinition *pd(0);
3079 pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[iter0->current()]),typmai2[iter0->current()]);
3080 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nasc,pd));
3087 if(MFFPMIter::IsPresenceOfNode(entities))
3089 int nbProfile(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName));
3092 const PartDefinition *pd(0);
3094 pd=mmu->getPartDefAtLevel(1,INTERP_KERNEL::NORM_ERROR);
3095 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd));
3096 setMeshName(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE));
3101 std::vector<int> dynGT(entities->getDynGTAvail());
3102 for(std::vector<int>::const_iterator it=dynGT.begin();it!=dynGT.end();it++)
3104 int nbPfl(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,*it,pflName,locName));
3107 _field_pm_pt.push_back(MEDFileFieldPerMeshPerTypeDyn::NewOnRead(fid,this,entities,*it,nasc));
3108 setMeshName(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE));
3113 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
3115 copyTinyInfoFrom(mesh);
3118 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3120 if(id>=(int)_pfls.size())
3122 _pfls[id]=DataArrayInt::New();
3123 int lgth(MEDprofileSizeByName(fid,pflName.c_str()));
3124 _pfls[id]->setName(pflName);
3125 _pfls[id]->alloc(lgth,1);
3126 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName.c_str(),_pfls[id]->getPointer()));
3127 _pfls[id]->applyLin(1,-1,0);//Converting into C format
3130 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
3132 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
3134 MEDFILESAFECALLERRD0(MEDprofileInfo,(fid,i+1,pflName,&sz));
3135 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
3136 if(i>=(int)_pfls.size())
3138 _pfls[i]=DataArrayInt::New();
3139 _pfls[i]->alloc(sz,1);
3140 _pfls[i]->setName(pflCpp.c_str());
3141 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName,_pfls[i]->getPointer()));
3142 _pfls[i]->applyLin(1,-1,0);//Converting into C format
3145 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3147 int nbOfPfls=_pfls.size();
3148 for(int i=0;i<nbOfPfls;i++)
3150 MCAuto<DataArrayInt> cpy=_pfls[i]->deepCopy();
3151 cpy->applyLin(1,1,0);
3152 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
3153 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
3154 MEDFILESAFECALLERWR0(MEDprofileWr,(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer()));
3157 int nbOfLocs=_locs.size();
3158 for(int i=0;i<nbOfLocs;i++)
3159 _locs[i]->writeLL(fid);
3162 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
3164 std::vector<std::string> pfls=getPfls();
3165 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
3167 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
3170 _pfls.push_back(*it);
3174 int id=std::distance(pfls.begin(),it2);
3175 if(!(*it)->isEqual(*_pfls[id]))
3177 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
3178 throw INTERP_KERNEL::Exception(oss.str());
3182 std::vector<std::string> locs=getLocs();
3183 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
3185 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
3188 _locs.push_back(*it);
3192 int id=std::distance(locs.begin(),it2);
3193 if(!(*it)->isEqual(*_locs[id],eps))
3195 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
3196 throw INTERP_KERNEL::Exception(oss.str());
3202 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
3204 for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
3205 getProfile((*it).c_str());
3208 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
3210 for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
3211 getLocalization((*it).c_str());
3214 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
3216 std::vector<std::string> profiles=real.getPflsReallyUsed();
3217 int sz=profiles.size();
3219 for(int i=0;i<sz;i++)
3220 loadProfileInFile(fid,i,profiles[i].c_str());
3222 std::vector<std::string> locs=real.getLocsReallyUsed();
3225 for(int i=0;i<sz;i++)
3226 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
3229 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid, const MEDFileEntities *entities)
3231 int nProfil=MEDnProfile(fid);
3232 for(int i=0;i<nProfil;i++)
3233 loadProfileInFile(fid,i);
3234 int sz=MEDnLocalization(fid);
3236 for(int i=0;i<sz;i++)
3238 _locs[i]=MEDFileFieldLoc::New(fid,i,entities);
3242 MEDFileFieldGlobs *MEDFileFieldGlobs::New(med_idt fid)
3244 return new MEDFileFieldGlobs(fid);
3247 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
3249 return new MEDFileFieldGlobs;
3252 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
3254 return _file_name.capacity()+_pfls.capacity()*sizeof(MCAuto<DataArrayInt>)+_locs.capacity()*sizeof(MCAuto<MEDFileFieldLoc>);
3257 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildrenWithNull() const
3259 std::vector<const BigMemoryObject *> ret;
3260 for(std::vector< MCAuto< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3261 ret.push_back((const DataArrayInt *)*it);
3262 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3263 ret.push_back((const MEDFileFieldLoc *)*it);
3267 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCopy() const
3269 MCAuto<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
3271 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3273 if((const DataArrayInt *)*it)
3274 ret->_pfls[i]=(*it)->deepCopy();
3277 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3279 if((const MEDFileFieldLoc*)*it)
3280 ret->_locs[i]=(*it)->deepCopy();
3286 * \throw if a profile in \a pfls in not in \a this.
3287 * \throw if a localization in \a locs in not in \a this.
3288 * \sa MEDFileFieldGlobs::deepCpyPart
3290 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
3292 MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
3293 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
3295 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
3297 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
3299 MCAuto<DataArrayInt> pfl2(pfl);
3300 ret->_pfls.push_back(pfl2);
3302 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
3304 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
3306 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
3308 MCAuto<MEDFileFieldLoc> loc2(loc);
3309 ret->_locs.push_back(loc2);
3311 ret->setFileName(getFileName());
3316 * \throw if a profile in \a pfls in not in \a this.
3317 * \throw if a localization in \a locs in not in \a this.
3318 * \sa MEDFileFieldGlobs::shallowCpyPart
3320 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
3322 MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
3323 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
3325 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
3327 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
3328 ret->_pfls.push_back(pfl->deepCopy());
3330 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
3332 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
3334 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
3335 ret->_locs.push_back(loc->deepCopy());
3337 ret->setFileName(getFileName());
3341 MEDFileFieldGlobs::MEDFileFieldGlobs(med_idt fid):_file_name(MEDFileWritable::FileNameFromFID(fid))
3345 MEDFileFieldGlobs::MEDFileFieldGlobs()
3349 MEDFileFieldGlobs::~MEDFileFieldGlobs()
3353 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
3355 oss << "Profiles :\n";
3356 std::size_t n=_pfls.size();
3357 for(std::size_t i=0;i<n;i++)
3359 oss << " - #" << i << " ";
3360 const DataArrayInt *pfl=_pfls[i];
3362 oss << "\"" << pfl->getName() << "\"\n";
3367 oss << "Localizations :\n";
3368 for(std::size_t i=0;i<n;i++)
3370 oss << " - #" << i << " ";
3371 const MEDFileFieldLoc *loc=_locs[i];
3373 loc->simpleRepr(oss);
3379 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3381 for(std::vector< MCAuto<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
3383 DataArrayInt *elt(*it);
3386 std::string name(elt->getName());
3387 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3389 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3391 elt->setName((*it2).second.c_str());
3399 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3401 for(std::vector< MCAuto<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
3403 MEDFileFieldLoc *elt(*it);
3406 std::string name(elt->getName());
3407 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3409 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3411 elt->setName((*it2).second.c_str());
3419 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
3421 if(locId<0 || locId>=(int)_locs.size())
3422 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
3423 return _locs[locId]->getNbOfGaussPtPerCell();
3426 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
3428 return getLocalizationFromId(getLocalizationId(locName));
3431 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
3433 if(locId<0 || locId>=(int)_locs.size())
3434 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3435 return *_locs[locId];
3439 namespace MEDCouplingImpl
3444 LocFinder(const std::string& loc):_loc(loc) { }
3445 bool operator() (const MCAuto<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
3447 const std::string &_loc;
3453 PflFinder(const std::string& pfl):_pfl(pfl) { }
3454 bool operator() (const MCAuto<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
3456 const std::string& _pfl;
3461 int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
3463 std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),MEDCouplingImpl::LocFinder(loc));
3466 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
3467 for(it=_locs.begin();it!=_locs.end();it++)
3468 oss << "\"" << (*it)->getName() << "\", ";
3469 throw INTERP_KERNEL::Exception(oss.str());
3471 return std::distance(_locs.begin(),it);
3475 * The returned value is never null.
3477 const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
3479 std::string pflNameCpp(pflName);
3480 std::vector< MCAuto<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3483 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3484 for(it=_pfls.begin();it!=_pfls.end();it++)
3485 oss << "\"" << (*it)->getName() << "\", ";
3486 throw INTERP_KERNEL::Exception(oss.str());
3491 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
3493 if(pflId<0 || pflId>=(int)_pfls.size())
3494 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3495 return _pfls[pflId];
3498 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
3500 if(locId<0 || locId>=(int)_locs.size())
3501 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3502 return *_locs[locId];
3505 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
3507 return getLocalizationFromId(getLocalizationId(locName));
3511 * The returned value is never null.
3513 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
3515 std::string pflNameCpp(pflName);
3516 std::vector< MCAuto<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3519 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3520 for(it=_pfls.begin();it!=_pfls.end();it++)
3521 oss << "\"" << (*it)->getName() << "\", ";
3522 throw INTERP_KERNEL::Exception(oss.str());
3527 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
3529 if(pflId<0 || pflId>=(int)_pfls.size())
3530 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3531 return _pfls[pflId];
3534 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
3536 std::vector< MCAuto<DataArrayInt> > newPfls;
3538 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3540 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
3541 newPfls.push_back(*it);
3546 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
3548 std::vector< MCAuto<MEDFileFieldLoc> > newLocs;
3550 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3552 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
3553 newLocs.push_back(*it);
3558 void MEDFileFieldGlobs::killStructureElementsInGlobs()
3560 std::vector< MCAuto<MEDFileFieldLoc> > newLocs;
3561 for(std::vector< MCAuto<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
3565 if(!(*it)->isOnStructureElement())
3566 newLocs.push_back(*it);
3571 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
3573 int sz=_pfls.size();
3574 std::vector<std::string> ret(sz);
3575 for(int i=0;i<sz;i++)
3576 ret[i]=_pfls[i]->getName();
3580 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
3582 int sz=_locs.size();
3583 std::vector<std::string> ret(sz);
3584 for(int i=0;i<sz;i++)
3585 ret[i]=_locs[i]->getName();
3589 bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
3591 std::vector<std::string> v=getPfls();
3592 std::string s(pflName);
3593 return std::find(v.begin(),v.end(),s)!=v.end();
3596 bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
3598 std::vector<std::string> v=getLocs();
3599 std::string s(locName);
3600 return std::find(v.begin(),v.end(),s)!=v.end();
3603 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
3605 std::map<int,std::vector<int> > m;
3607 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3609 const DataArrayInt *tmp=(*it);
3612 m[tmp->getHashCode()].push_back(i);
3615 std::vector< std::vector<int> > ret;
3616 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
3618 if((*it2).second.size()>1)
3620 std::vector<int> ret0;
3621 bool equalityOrNot=false;
3622 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
3624 std::vector<int>::const_iterator it4=it3; it4++;
3625 for(;it4!=(*it2).second.end();it4++)
3627 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
3630 ret0.push_back(*it3);
3631 ret0.push_back(*it4);
3637 ret.push_back(ret0);
3643 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
3645 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
3648 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
3650 std::string name(pfl->getName());
3652 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
3653 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3654 if(name==(*it)->getName())
3656 if(!pfl->isEqual(*(*it)))
3658 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
3659 throw INTERP_KERNEL::Exception(oss.str());
3663 _pfls.push_back(pfl);
3666 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)
3668 std::string name(locName);
3670 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
3671 MCAuto<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
3672 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3673 if((*it)->isName(locName))
3675 if(!(*it)->isEqual(*obj,1e-12))
3677 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
3678 throw INTERP_KERNEL::Exception(oss.str());
3681 _locs.push_back(obj);
3684 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
3686 std::vector<std::string> names=getPfls();
3687 return CreateNewNameNotIn("NewPfl_",names);
3690 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
3692 std::vector<std::string> names=getLocs();
3693 return CreateNewNameNotIn("NewLoc_",names);
3696 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
3698 for(std::size_t sz=0;sz<100000;sz++)
3700 std::ostringstream tryName;
3701 tryName << prefix << sz;
3702 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
3703 return tryName.str();
3705 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
3709 * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
3710 * \param [in] fname - the file name.
3712 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(med_idt fid):_globals(MEDFileFieldGlobs::New(fid))
3717 * Creates an empty MEDFileFieldGlobsReal.
3719 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
3723 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
3728 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildrenWithNull() const
3730 std::vector<const BigMemoryObject *> ret;
3731 ret.push_back((const MEDFileFieldGlobs *)_globals);
3736 * Returns a string describing profiles and Gauss points held in \a this.
3737 * \return std::string - the description string.
3739 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
3741 const MEDFileFieldGlobs *glob=_globals;
3742 std::ostringstream oss2; oss2 << glob;
3743 std::string stars(oss2.str().length(),'*');
3744 oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n";
3746 glob->simpleRepr(oss);
3748 oss << "NO GLOBAL INFORMATION !\n";
3751 void MEDFileFieldGlobsReal::resetContent()
3753 _globals=MEDFileFieldGlobs::New();
3756 void MEDFileFieldGlobsReal::killStructureElementsInGlobs()
3758 contentNotNull()->killStructureElementsInGlobs();
3761 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
3766 * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
3767 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3769 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3771 _globals=other._globals;
3775 * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3776 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3778 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3780 const MEDFileFieldGlobs *otherg(other._globals);
3783 _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3787 * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3788 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3790 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3792 const MEDFileFieldGlobs *otherg(other._globals);
3795 _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3798 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3800 _globals=other._globals;
3801 if((const MEDFileFieldGlobs *)_globals)
3802 _globals=other._globals->deepCopy();
3806 * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3807 * \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3808 * \param [in] eps - a precision used to compare Gauss points with same name held by
3809 * \a this and \a other MEDFileFieldGlobsReal.
3810 * \throw If \a this and \a other hold profiles with equal names but different ids.
3811 * \throw If \a this and \a other hold different Gauss points with equal names.
3813 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
3815 const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3816 if(thisGlobals==otherGlobals)
3820 _globals=other._globals;
3823 _globals->appendGlobs(*other._globals,eps);
3826 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
3828 checkGlobsPflsPartCoherency();
3829 checkGlobsLocsPartCoherency();
3832 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
3834 contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3837 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
3839 contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3842 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3844 contentNotNull()->loadProfileInFile(fid,id,pflName);
3847 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3849 contentNotNull()->loadProfileInFile(fid,id);
3852 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
3854 contentNotNull()->loadGlobals(fid,*this);
3857 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid, const MEDFileEntities *entities)
3859 contentNotNull()->loadAllGlobals(fid,entities);
3862 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3864 contentNotNull()->writeGlobals(fid,opt);
3868 * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3869 * or getPflsReallyUsedMulti().
3870 * \return std::vector<std::string> - a sequence of names of all profiles.
3872 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3874 return contentNotNull()->getPfls();
3878 * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3879 * or getLocsReallyUsedMulti().
3880 * \return std::vector<std::string> - a sequence of names of all localizations.
3882 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3884 return contentNotNull()->getLocs();
3888 * Checks if the profile with a given name exists.
3889 * \param [in] pflName - the profile name of interest.
3890 * \return bool - \c true if the profile named \a pflName exists.
3892 bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
3894 return contentNotNull()->existsPfl(pflName);
3898 * Checks if the localization with a given name exists.
3899 * \param [in] locName - the localization name of interest.
3900 * \return bool - \c true if the localization named \a locName exists.
3902 bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
3904 return contentNotNull()->existsLoc(locName);
3907 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
3909 return contentNotNull()->createNewNameOfPfl();
3912 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
3914 return contentNotNull()->createNewNameOfLoc();
3918 * Sets the name of a MED file.
3919 * \param [inout] fileName - the file name.
3921 void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
3923 contentNotNull()->setFileName(fileName);
3927 * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3928 * in the same order.
3929 * \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3930 * Each item of this sequence is a vector containing ids of equal profiles.
3932 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3934 return contentNotNull()->whichAreEqualProfiles();
3938 * Finds equal localizations.
3939 * \param [in] eps - a precision used to compare real values of the localizations.
3940 * \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3941 * Each item of this sequence is a vector containing ids of equal localizations.
3943 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3945 return contentNotNull()->whichAreEqualLocs(eps);
3949 * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3950 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3951 * this sequence is a pair whose
3952 * - the first item is a vector of profile names to replace by the second item,
3953 * - the second item is a profile name to replace every profile name of the first item.
3955 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3957 contentNotNull()->changePflsNamesInStruct(mapOfModif);
3961 * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3962 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3963 * this sequence is a pair whose
3964 * - the first item is a vector of localization names to replace by the second item,
3965 * - the second item is a localization name to replace every localization name of the first item.
3967 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3969 contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3973 * Replaces references to some profiles (a reference is a profile name) by references
3974 * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3975 * them-selves accordingly. <br>
3976 * This method is a generalization of changePflName().
3977 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3978 * this sequence is a pair whose
3979 * - the first item is a vector of profile names to replace by the second item,
3980 * - the second item is a profile name to replace every profile of the first item.
3981 * \sa changePflsRefsNamesGen()
3982 * \sa changePflName()
3984 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3986 changePflsRefsNamesGen(mapOfModif);
3987 changePflsNamesInStruct(mapOfModif);
3991 * Replaces references to some localizations (a reference is a localization name) by references
3992 * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3993 * them-selves accordingly. <br>
3994 * This method is a generalization of changeLocName().
3995 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3996 * this sequence is a pair whose
3997 * - the first item is a vector of localization names to replace by the second item,
3998 * - the second item is a localization name to replace every localization of the first item.
3999 * \sa changeLocsRefsNamesGen()
4000 * \sa changeLocName()
4002 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4004 changeLocsRefsNamesGen(mapOfModif);
4005 changeLocsNamesInStruct(mapOfModif);
4009 * Renames the profile having a given name and updates references to this profile.
4010 * \param [in] oldName - the name of the profile to rename.
4011 * \param [in] newName - a new name of the profile.
4012 * \sa changePflsNames().
4014 void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
4016 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
4017 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
4019 changePflsNames(mapOfModif);
4023 * Renames the localization having a given name and updates references to this localization.
4024 * \param [in] oldName - the name of the localization to rename.
4025 * \param [in] newName - a new name of the localization.
4026 * \sa changeLocsNames().
4028 void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
4030 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
4031 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
4033 changeLocsNames(mapOfModif);
4037 * Removes duplicated profiles. Returns a map used to update references to removed
4038 * profiles via changePflsRefsNamesGen().
4039 * Equal profiles are found using whichAreEqualProfiles().
4040 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
4041 * a sequence describing the performed replacements of profiles. Each element of
4042 * this sequence is a pair whose
4043 * - the first item is a vector of profile names replaced by the second item,
4044 * - the second item is a profile name replacing every profile of the first item.
4046 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
4048 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
4049 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
4051 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
4053 std::vector< std::string > tmp((*it).size());
4055 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
4056 tmp[j]=std::string(getProfileFromId(*it2)->getName());
4057 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
4059 std::vector<int> tmp2((*it).begin()+1,(*it).end());
4060 killProfileIds(tmp2);
4062 changePflsRefsNamesGen(ret);
4067 * Removes duplicated localizations. Returns a map used to update references to removed
4068 * localizations via changeLocsRefsNamesGen().
4069 * Equal localizations are found using whichAreEqualLocs().
4070 * \param [in] eps - a precision used to compare real values of the localizations.
4071 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
4072 * a sequence describing the performed replacements of localizations. Each element of
4073 * this sequence is a pair whose
4074 * - the first item is a vector of localization names replaced by the second item,
4075 * - the second item is a localization name replacing every localization of the first item.
4077 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
4079 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
4080 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
4082 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
4084 std::vector< std::string > tmp((*it).size());
4086 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
4087 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
4088 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
4090 std::vector<int> tmp2((*it).begin()+1,(*it).end());
4091 killLocalizationIds(tmp2);
4093 changeLocsRefsNamesGen(ret);
4098 * Returns number of Gauss points per cell in a given localization.
4099 * \param [in] locId - an id of the localization of interest.
4100 * \return int - the number of the Gauss points per cell.
4102 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
4104 return contentNotNull()->getNbOfGaussPtPerCell(locId);
4108 * Returns an id of a localization by its name.
4109 * \param [in] loc - the localization name of interest.
4110 * \return int - the id of the localization.
4111 * \throw If there is no a localization named \a loc.
4113 int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
4115 return contentNotNull()->getLocalizationId(loc);
4119 * Returns the name of the MED file.
4120 * \return const std::string& - the MED file name.
4122 std::string MEDFileFieldGlobsReal::getFileName() const
4124 return contentNotNull()->getFileName();
4128 * Returns a localization object by its name.
4129 * \param [in] locName - the name of the localization of interest.
4130 * \return const MEDFileFieldLoc& - the localization object having the name \a locName.
4131 * \throw If there is no a localization named \a locName.
4133 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
4135 return contentNotNull()->getLocalization(locName);
4139 * Returns a localization object by its id.
4140 * \param [in] locId - the id of the localization of interest.
4141 * \return const MEDFileFieldLoc& - the localization object having the id \a locId.
4142 * \throw If there is no a localization with id \a locId.
4144 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
4146 return contentNotNull()->getLocalizationFromId(locId);
4150 * Returns a profile array by its name.
4151 * \param [in] pflName - the name of the profile of interest.
4152 * \return const DataArrayInt * - the profile array having the name \a pflName.
4153 * \throw If there is no a profile named \a pflName.
4155 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
4157 return contentNotNull()->getProfile(pflName);
4161 * Returns a profile array by its id.
4162 * \param [in] pflId - the id of the profile of interest.
4163 * \return const DataArrayInt * - the profile array having the id \a pflId.
4164 * \throw If there is no a profile with id \a pflId.
4166 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
4168 return contentNotNull()->getProfileFromId(pflId);
4172 * Returns a localization object, apt for modification, by its id.
4173 * \param [in] locId - the id of the localization of interest.
4174 * \return MEDFileFieldLoc& - a non-const reference to the localization object
4175 * having the id \a locId.
4176 * \throw If there is no a localization with id \a locId.
4178 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
4180 return contentNotNull()->getLocalizationFromId(locId);
4184 * Returns a localization object, apt for modification, by its name.
4185 * \param [in] locName - the name of the localization of interest.
4186 * \return MEDFileFieldLoc& - a non-const reference to the localization object
4187 * having the name \a locName.
4188 * \throw If there is no a localization named \a locName.
4190 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
4192 return contentNotNull()->getLocalization(locName);
4196 * Returns a profile array, apt for modification, by its name.
4197 * \param [in] pflName - the name of the profile of interest.
4198 * \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
4199 * \throw If there is no a profile named \a pflName.
4201 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
4203 return contentNotNull()->getProfile(pflName);
4207 * Returns a profile array, apt for modification, by its id.
4208 * \param [in] pflId - the id of the profile of interest.
4209 * \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
4210 * \throw If there is no a profile with id \a pflId.
4212 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
4214 return contentNotNull()->getProfileFromId(pflId);
4218 * Removes profiles given by their ids. No data is updated to track this removal.
4219 * \param [in] pflIds - a sequence of ids of the profiles to remove.
4221 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
4223 contentNotNull()->killProfileIds(pflIds);
4227 * Removes localizations given by their ids. No data is updated to track this removal.
4228 * \param [in] locIds - a sequence of ids of the localizations to remove.
4230 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
4232 contentNotNull()->killLocalizationIds(locIds);
4236 * Stores a profile array.
4237 * \param [in] pfl - the profile array to store.
4238 * \throw If the name of \a pfl is empty.
4239 * \throw If a profile with the same name as that of \a pfl already exists but contains
4242 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
4244 contentNotNull()->appendProfile(pfl);
4248 * Adds a new localization of Gauss points.
4249 * \param [in] locName - the name of the new localization.
4250 * \param [in] geoType - a geometrical type of the reference cell.
4251 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
4252 * must be \c nbOfNodesPerCell * \c dimOfType.
4253 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
4254 * must be _wg_.size() * \c dimOfType.
4255 * \param [in] w - the weights of Gauss points.
4256 * \throw If \a locName is empty.
4257 * \throw If a localization with the name \a locName already exists but is
4258 * different form the new one.
4260 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)
4262 contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
4265 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
4267 MEDFileFieldGlobs *g(_globals);
4269 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
4273 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
4275 const MEDFileFieldGlobs *g(_globals);
4277 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
4281 //= MEDFileFieldNameScope
4283 MEDFileFieldNameScope::MEDFileFieldNameScope()
4287 MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName, const std::string& meshName):_name(fieldName),_mesh_name(meshName)
4292 * Returns the name of \a this field.
4293 * \return std::string - a string containing the field name.
4295 std::string MEDFileFieldNameScope::getName() const
4301 * Sets name of \a this field
4302 * \param [in] name - the new field name.
4304 void MEDFileFieldNameScope::setName(const std::string& fieldName)
4309 std::string MEDFileFieldNameScope::getDtUnit() const
4314 void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
4319 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
4322 _mesh_name=other._mesh_name;
4323 _dt_unit=other._dt_unit;
4327 * Returns the mesh name.
4328 * \return std::string - a string holding the mesh name.
4329 * \throw If \c _field_per_mesh.empty()
4331 std::string MEDFileFieldNameScope::getMeshName() const
4336 void MEDFileFieldNameScope::setMeshName(const std::string& meshName)
4338 _mesh_name=meshName;
4341 //= MEDFileAnyTypeField1TSWithoutSDA
4343 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
4345 _field_per_mesh.resize(other._field_per_mesh.size());
4347 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
4349 if((const MEDFileFieldPerMesh *)*it)
4350 _field_per_mesh[i]=(*it)->deepCopy(this);
4354 void MEDFileAnyTypeField1TSWithoutSDA::accept(MEDFileFieldVisitor& visitor) const
4356 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4357 if((*it).isNotNull())
4359 visitor.newMeshEntry(*it);
4360 (*it)->accept(visitor);
4361 visitor.endMeshEntry(*it);
4366 * Prints a string describing \a this field into a stream. This string is outputted
4367 * by \c print Python command.
4368 * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
4369 * \param [in,out] oss - the out stream.
4370 * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
4371 * info id printed, else, not.
4373 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
4375 std::string startOfLine(bkOffset,' ');
4376 oss << startOfLine << "Field ";
4378 oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
4379 oss << "on one time Step ";
4381 oss << "(" << f1tsId << ") ";
4382 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
4383 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
4384 const DataArray *arr=getUndergroundDataArray();
4387 const std::vector<std::string> &comps=arr->getInfoOnComponents();
4390 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
4391 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
4392 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
4394 if(arr->isAllocated())
4396 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
4399 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
4403 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
4405 oss << startOfLine << "----------------------" << std::endl;
4406 if(!_field_per_mesh.empty())
4409 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
4411 const MEDFileFieldPerMesh *cur=(*it2);
4413 cur->simpleRepr(bkOffset,oss,i);
4415 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
4420 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
4422 oss << startOfLine << "----------------------" << std::endl;
4425 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
4427 const DataArray *arr(getUndergroundDataArray());
4429 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
4430 int nbOfCompo=arr->getNumberOfComponents();
4431 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
4432 for(int i=0;i<nbOfCompo;i++)
4435 std::vector<int> v(1,i);
4436 MCAuto<DataArray> arr2=arr->keepSelectedComponents(v);
4437 ret[i]->setArray(arr2);
4442 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order):MEDFileFieldNameScope(fieldName,meshName),_iteration(iteration),_order(order),_csit(csit),_nb_of_tuples_to_be_allocated(-2)
4446 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
4451 * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
4452 * empty. Returns -1 if this in on nodes.
4453 * \return int - the dimension of \a this.
4455 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
4458 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4459 (*it)->getDimension(ret);
4463 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
4466 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4468 MEDFileFieldPerMesh *cur(*it);
4470 ret=cur->changeMeshNames(modifTab) || ret;
4476 * Returns the number of iteration of the state of underlying mesh.
4477 * \return int - the iteration number.
4478 * \throw If \c _field_per_mesh.empty()
4480 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
4482 if(_field_per_mesh.empty())
4483 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
4484 return _field_per_mesh[0]->getMeshIteration();
4488 * Returns the order number of iteration of the state of underlying mesh.
4489 * \return int - the order number.
4490 * \throw If \c _field_per_mesh.empty()
4492 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
4494 if(_field_per_mesh.empty())
4495 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
4496 return _field_per_mesh[0]->getMeshOrder();
4500 * Checks if \a this field is tagged by a given iteration number and a given
4501 * iteration order number.
4502 * \param [in] iteration - the iteration number of interest.
4503 * \param [in] order - the iteration order number of interest.
4504 * \return bool - \c true if \a this->getIteration() == \a iteration &&
4505 * \a this->getOrder() == \a order.
4507 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
4509 return iteration==_iteration && order==_order;
4513 * Returns number of iteration and order number of iteration when
4514 * \a this field has been calculated.
4515 * \return std::pair<int,int> - a pair of the iteration number and the iteration
4518 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
4520 std::pair<int,int> p;
4526 * Returns number of iteration and order number of iteration when
4527 * \a this field has been calculated.
4528 * \param [in,out] p - a pair returning the iteration number and the iteration
4531 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
4538 * Returns all types of spatial discretization of \a this field.
4539 * \param [in,out] types - a sequence of types of \a this field.
4541 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
4543 std::set<TypeOfField> types2;
4544 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4546 (*it)->fillTypesOfFieldAvailable(types2);
4548 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
4549 std::copy(types2.begin(),types2.end(),bi);
4553 * Returns all types of spatial discretization of \a this field.
4554 * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
4557 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
4559 std::vector<TypeOfField> ret;
4560 fillTypesOfFieldAvailable(ret);
4564 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
4566 std::vector<std::string> ret;
4567 std::set<std::string> ret2;
4568 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4570 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
4571 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4572 if(ret2.find(*it2)==ret2.end())
4574 ret.push_back(*it2);
4581 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
4583 std::vector<std::string> ret;
4584 std::set<std::string> ret2;
4585 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4587 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
4588 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4589 if(ret2.find(*it2)==ret2.end())
4591 ret.push_back(*it2);
4598 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
4600 std::vector<std::string> ret;
4601 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4603 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
4604 ret.insert(ret.end(),tmp.begin(),tmp.end());
4609 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
4611 std::vector<std::string> ret;
4612 std::set<std::string> ret2;
4613 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4615 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
4616 ret.insert(ret.end(),tmp.begin(),tmp.end());
4621 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4623 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4624 (*it)->changePflsRefsNamesGen(mapOfModif);
4627 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4629 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4630 (*it)->changeLocsRefsNamesGen(mapOfModif);
4634 * Returns all attributes of parts of \a this field lying on a given mesh.
4635 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4636 * item of every of returned sequences refers to the _i_-th part of \a this field.
4637 * Thus all sequences returned by this method are of the same length equal to number
4638 * of different types of supporting entities.<br>
4639 * A field part can include sub-parts with several different spatial discretizations,
4640 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
4641 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4642 * of a nested sequence corresponds to a type of spatial discretization.<br>
4643 * This method allows for iteration over MEDFile DataStructure without any overhead.
4644 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4645 * for the case with only one underlying mesh. (Actually, the number of meshes is
4646 * not checked if \a mname == \c NULL).
4647 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4648 * a field part is returned.
4649 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4650 * This sequence is of the same length as \a types.
4651 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4652 * discretization. A profile name can be empty.
4653 * Length of this and of nested sequences is the same as that of \a typesF.
4654 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4655 * discretization. A localization name can be empty.
4656 * Length of this and of nested sequences is the same as that of \a typesF.
4657 * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
4658 * of ids of tuples within the data array, per each type of spatial
4659 * discretization within one mesh entity type.
4660 * Length of this and of nested sequences is the same as that of \a typesF.
4661 * \throw If no field is lying on \a mname.
4663 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
4665 if(_field_per_mesh.empty())
4666 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4667 return _field_per_mesh[0]->getFieldSplitedByType(types,typesF,pfls,locs);
4671 * Returns dimensions of mesh elements \a this field lies on. The returned value is a
4672 * maximal absolute dimension and values returned via the out parameter \a levs are
4673 * dimensions relative to the maximal absolute dimension. <br>
4674 * This method is designed for MEDFileField1TS instances that have a discretization
4675 * \ref MEDCoupling::ON_CELLS "ON_CELLS",
4676 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT",
4677 * \ref MEDCoupling::ON_GAUSS_NE "ON_GAUSS_NE".
4678 * Only these 3 discretizations will be taken into account here. If \a this is
4679 * \ref MEDCoupling::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
4680 * This method is useful to make the link between the dimension of the underlying mesh
4681 * and the levels of \a this, because it is possible that the highest dimension of \a this
4682 * field is not equal to the dimension of the underlying mesh.
4684 * Let's consider the following case:
4685 * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
4686 * TETRA4, HEXA8, TRI3 and SEG2.
4687 * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
4688 * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
4690 * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
4691 * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
4692 * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
4693 * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
4694 * parameter of getFieldAtLevel() is computed basing on the returned values as this:
4695 * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
4697 * to retrieve the highest level of
4698 * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br>
4699 * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
4700 * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
4701 * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
4702 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4703 * for the case with only one underlying mesh. (Actually, the number of meshes is
4704 * not checked if \a mname == \c NULL).
4705 * \param [in,out] levs - a sequence returning the dimensions relative to the maximal
4706 * absolute one. They are in decreasing order. This sequence is cleared before
4708 * \return int - the maximal absolute dimension of elements \a this fields lies on.
4709 * \throw If no field is lying on \a mname.
4711 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
4714 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4715 std::vector< std::vector<TypeOfField> > typesF;
4716 std::vector< std::vector<std::string> > pfls, locs;
4717 if(_field_per_mesh.empty())
4718 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels : This is empty !");
4719 _field_per_mesh[0]->getFieldSplitedByType(types,typesF,pfls,locs);
4721 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
4722 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
4723 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
4725 st.erase(INTERP_KERNEL::NORM_ERROR);
4727 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
4729 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
4730 ret1.insert((int)cm.getDimension());
4732 int ret=*std::max_element(ret1.begin(),ret1.end());
4733 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
4734 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
4738 void MEDFileAnyTypeField1TSWithoutSDA::convertMedBallIntoClassic()
4740 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it<_field_per_mesh.end();it++)
4741 if((*it).isNotNull())
4742 (*it)->convertMedBallIntoClassic();
4745 void MEDFileAnyTypeField1TSWithoutSDA::makeReduction(INTERP_KERNEL::NormalizedCellType ct, TypeOfField tof, const DataArrayInt *pfl)
4748 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : null pfl !");
4749 std::string name(pfl->getName());
4750 pfl->checkAllocated();
4751 if(pfl->getNumberOfComponents()!=1)
4752 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : non mono compo array !");
4754 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : empty pfl name !");
4755 if(_field_per_mesh.size()!=1)
4756 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : only single mesh supported !");
4757 MCAuto<MEDFileFieldPerMesh> fpm(_field_per_mesh[0]);
4759 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : only single not null mesh supported !");
4760 MEDFileFieldPerMeshPerTypePerDisc *disc(fpm->getLeafGivenTypeAndLocId(ct,0));
4761 if(disc->getType()!=tof)
4762 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : error !");
4763 int s(disc->getStart()),e(disc->getEnd()),nt(pfl->getNumberOfTuples());
4764 DataArray *arr(getUndergroundDataArray());
4765 int nt2(arr->getNumberOfTuples()),delta((e-s)-nt);
4767 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : internal error !");
4768 MCAuto<DataArray> arr0(arr->selectByTupleIdSafeSlice(0,s,1)),arr1(arr->selectByTupleIdSafeSlice(s,e,1)),arr2(arr->selectByTupleIdSafeSlice(e,nt2,1));
4769 MCAuto<DataArray> arr11(arr1->selectByTupleIdSafe(pfl->begin(),pfl->end()));
4770 MCAuto<DataArray> arrOut(arr->buildNewEmptyInstance());
4771 arrOut->alloc(nt2-delta,arr->getNumberOfComponents());
4772 arrOut->copyStringInfoFrom(*arr);
4773 arrOut->setContigPartOfSelectedValuesSlice(0,arr0,0,s,1);
4774 arrOut->setContigPartOfSelectedValuesSlice(s,arr11,0,nt,1);
4775 arrOut->setContigPartOfSelectedValuesSlice(e-delta,arr2,0,nt2-e,1);
4777 disc->setEnd(e-delta);
4778 disc->setProfile(name);
4782 * \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.
4783 * \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.
4784 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4785 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4787 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
4789 if(_field_per_mesh.empty())
4790 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId : This is empty !");
4791 return _field_per_mesh[0]->getLeafGivenTypeAndLocId(typ,locId);
4795 * \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.
4796 * \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.
4797 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4798 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4800 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
4802 if(_field_per_mesh.empty())
4803 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId : This is empty !");
4804 return _field_per_mesh[0]->getLeafGivenTypeAndLocId(typ,locId);
4808 * \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.
4810 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
4812 if(_field_per_mesh.empty())
4813 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4816 std::string mName2(mName);
4818 std::vector<std::string> msg;
4819 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4820 if(mName2==(*it)->getMeshName())
4823 msg.push_back((*it)->getMeshName());
4824 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4825 oss << "Possible meshes are : ";
4826 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4827 oss << "\"" << (*it2) << "\" ";
4828 throw INTERP_KERNEL::Exception(oss.str());
4831 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
4834 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4835 std::string tmp(mesh->getName());
4837 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4839 std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4841 for(;it!=_field_per_mesh.end();it++,i++)
4843 if((*it)->getMeshName()==tmp)
4846 int sz=_field_per_mesh.size();
4847 _field_per_mesh.resize(sz+1);
4848 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4852 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4853 MEDFileFieldGlobsReal& glob)
4856 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4858 MEDFileFieldPerMesh *fpm(*it);
4860 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4866 * This method splits \a this into several sub-parts so that each sub parts have exactly one spatial discretization. This method implements the minimal
4867 * splitting that leads to single spatial discretization of this.
4869 * \sa splitMultiDiscrPerGeoTypes
4871 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
4873 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4874 std::vector< std::vector<TypeOfField> > typesF;
4875 std::vector< std::vector<std::string> > pfls,locs;
4876 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4877 std::set<TypeOfField> allEnt;
4878 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4879 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4880 allEnt.insert(*it2);
4881 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4882 std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4883 for(std::size_t i=0;i<allEnt.size();i++,it3++)
4885 std::vector< std::pair<int,int> > its;
4886 ret[i]=shallowCpy();
4887 int newLgth(ret[i]->keepOnlySpatialDiscretization(*it3,its));
4888 ret[i]->updateData(newLgth,its);
4894 * This method performs a sub splitting as splitDiscretizations does but finer. This is the finest spliting level that can be done.
4895 * This method implements the minimal splitting so that each returned elements are mono Gauss discretization per geometric type.
4897 * \sa splitDiscretizations
4899 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes() const
4901 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4902 std::vector< std::vector<TypeOfField> > typesF;
4903 std::vector< std::vector<std::string> > pfls,locs;
4904 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4905 std::set<TypeOfField> allEnt;
4906 std::size_t nbOfMDPGT(0),ii(0);
4907 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++,ii++)
4909 nbOfMDPGT=std::max(nbOfMDPGT,locs[ii].size());
4910 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4911 allEnt.insert(*it2);
4913 if(allEnt.size()!=1)
4914 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : this field is expected to be defined only on one spatial discretization !");
4916 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
4919 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret0(1);
4920 ret0[0]=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(this); this->incrRef();
4923 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfMDPGT);
4924 for(std::size_t i=0;i<nbOfMDPGT;i++)
4926 std::vector< std::pair<int,int> > its;
4927 ret[i]=shallowCpy();
4928 int newLgth(ret[i]->keepOnlyGaussDiscretization(i,its));
4929 ret[i]->updateData(newLgth,its);
4934 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
4936 int globalCounter(0);
4937 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4938 (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4939 return globalCounter;
4942 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlyGaussDiscretization(std::size_t idOfDisc, std::vector< std::pair<int,int> >& its)
4944 int globalCounter(0);
4945 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4946 (*it)->keepOnlyGaussDiscretization(idOfDisc,globalCounter,its);
4947 return globalCounter;
4950 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
4952 if(_nb_of_tuples_to_be_allocated>=0)
4954 _nb_of_tuples_to_be_allocated=newLgth;
4955 const DataArray *oldArr(getUndergroundDataArray());
4958 MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4959 newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
4961 _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
4965 if(_nb_of_tuples_to_be_allocated==-1)
4967 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4969 const DataArray *oldArr(getUndergroundDataArray());
4970 if(!oldArr || !oldArr->isAllocated())
4971 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4972 MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4973 newArr->alloc(newLgth,getNumberOfComponents());
4975 newArr->copyStringInfoFrom(*oldArr);
4977 for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4979 if((*it).second<(*it).first)
4980 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4981 newArr->setContigPartOfSelectedValuesSlice(pos,oldArr,(*it).first,(*it).second,1);
4982 pos+=(*it).second-(*it).first;
4987 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4990 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
4992 if(_field_per_mesh.empty())
4993 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4994 if(_field_per_mesh.size()>1)
4995 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4996 _field_per_mesh[0]->copyOptionsFrom(opts);
4997 _field_per_mesh[0]->writeLL(fid,nasc);
5001 * 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.
5002 * If false is returned the memory allocation is not required.
5004 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
5006 if(_nb_of_tuples_to_be_allocated>=0)
5008 getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
5009 _nb_of_tuples_to_be_allocated=-2;
5012 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
5014 if(_nb_of_tuples_to_be_allocated==-1)
5015 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
5016 if(_nb_of_tuples_to_be_allocated<-3)
5017 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
5018 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
5021 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
5023 med_int numdt,numit;
5025 med_int meshnumdt,meshnumit;
5026 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt));
5030 INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
5031 MEDFILESAFECALLERRD0(MEDfield23ComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit)); // to check with Adrien for legacy MED files
5033 //MEDFILESAFECALLERRD0(MEDfieldComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt,&meshnumdt,&meshnumit));
5034 if(_iteration!=numdt || _order!=numit)
5035 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
5036 _field_per_mesh.resize(1);
5041 mm=ms->getMeshWithName(getMeshName());
5044 _field_per_mesh[0]=MEDFileFieldPerMesh::NewOnRead(fid,this,0,meshnumdt,meshnumit,nasc,mm,entities);
5045 _nb_of_tuples_to_be_allocated=0;
5046 _field_per_mesh[0]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
5049 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
5051 allocIfNecessaryTheArrayToReceiveDataFromFile();
5052 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5053 (*it)->loadBigArraysRecursively(fid,nasc);
5056 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
5058 if(allocIfNecessaryTheArrayToReceiveDataFromFile())
5059 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5060 (*it)->loadBigArraysRecursively(fid,nasc);
5063 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
5065 loadOnlyStructureOfDataRecursively(fid,nasc,ms,entities);
5066 loadBigArraysRecursively(fid,nasc);
5069 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
5071 DataArray *thisArr(getUndergroundDataArray());
5072 if(thisArr && thisArr->isAllocated())
5074 _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
5075 thisArr->desallocate();
5079 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
5081 return _mesh_name.capacity()+_dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MCAuto< MEDFileFieldPerMesh >);
5084 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
5086 std::vector<const BigMemoryObject *> ret;
5087 if(getUndergroundDataArray())
5088 ret.push_back(getUndergroundDataArray());
5089 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5090 ret.push_back((const MEDFileFieldPerMesh *)*it);
5095 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
5096 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
5097 * "Sort By Type"), if not, an exception is thrown.
5098 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
5099 * \param [in] arr - the array of values.
5100 * \param [in,out] glob - the global data where profiles and localization present in
5101 * \a field, if any, are added.
5102 * \throw If the name of \a field is empty.
5103 * \throw If the data array of \a field is not set.
5104 * \throw If \a this->_arr is already allocated but has different number of components
5106 * \throw If the underlying mesh of \a field has no name.
5107 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
5109 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
5111 const MEDCouplingMesh *mesh=field->getMesh();
5113 TypeOfField type=field->getTypeOfField();
5114 std::vector<DataArrayInt *> dummy;
5116 setMeshName(mesh->getName());
5117 int start=copyTinyInfoFrom(field,arr);
5118 int pos=addNewEntryIfNecessary(mesh);
5121 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
5122 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
5125 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
5129 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
5130 * of a given mesh are used as the support of the given field (a real support is not used).
5131 * Elements of the given mesh must be sorted suitable for writing to MED file.
5132 * Order of underlying mesh entities of the given field specified by \a profile parameter
5133 * is not prescribed; this method permutes field values to have them sorted by element
5134 * type as required for writing to MED file. A new profile is added only if no equal
5135 * profile is missing.
5136 * \param [in] field - the field to add to \a this. The field double values are ignored.
5137 * \param [in] arrOfVals - the values of the field \a field used.
5138 * \param [in] mesh - the supporting mesh of \a field.
5139 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
5140 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
5141 * \param [in,out] glob - the global data where profiles and localization present in
5142 * \a field, if any, are added.
5143 * \throw If either \a field or \a mesh or \a profile has an empty name.
5144 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
5145 * \throw If the data array of \a field is not set.
5146 * \throw If \a this->_arr is already allocated but has different number of components
5148 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
5149 * \sa setFieldNoProfileSBT()
5151 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
5154 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
5155 if(!arrOfVals || !arrOfVals->isAllocated())
5156 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
5157 TypeOfField type=field->getTypeOfField();
5158 std::vector<DataArrayInt *> idsInPflPerType;
5159 std::vector<DataArrayInt *> idsPerType;
5160 std::vector<int> code,code2;
5161 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
5164 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
5165 std::vector< MCAuto<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
5166 std::vector< MCAuto<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin());
5167 std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
5169 MCAuto<MEDCouplingFieldDouble> field2=field->clone(false);
5170 int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
5171 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
5173 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
5174 throw INTERP_KERNEL::Exception(oss.str());
5177 int start=copyTinyInfoFrom(field,arrOfVals);
5178 code2=m->getDistributionOfTypes();
5180 int pos=addNewEntryIfNecessary(m);
5181 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
5185 if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
5186 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
5187 std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
5188 std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
5189 int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
5190 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
5192 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
5193 throw INTERP_KERNEL::Exception(oss.str());
5195 int start=copyTinyInfoFrom(field,arrOfVals);
5196 int pos=addNewEntryIfNecessary(m);
5197 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
5202 * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
5204 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
5206 if(_nb_of_tuples_to_be_allocated>=0)
5207 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 !");
5208 DataArray *arr(getOrCreateAndGetArray());
5209 arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
5210 _nb_of_tuples_to_be_allocated=-3;
5214 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
5215 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
5216 * larger by the size of \a field. Returns an id of the first not filled
5217 * tuple of \a this->_arr.
5218 * \param [in] field - the field to copy the info on components and the name from.
5219 * \return int - the id of first not initialized tuple of \a this->_arr.
5220 * \throw If the name of \a field is empty.
5221 * \throw If the data array of \a field is not set.
5222 * \throw If \a this->_arr is already allocated but has different number of components
5225 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
5228 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
5229 std::string name(field->getName());
5230 setName(name.c_str());
5231 if(field->getMesh())
5232 setMeshName(field->getMesh()->getName());
5233 setDtUnit(field->getTimeUnit());
5235 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
5237 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
5238 if(!arr->isAllocated())
5239 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
5240 _dt=field->getTime(_iteration,_order);
5241 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
5242 if(!getOrCreateAndGetArray()->isAllocated())
5244 allocNotFromFile(arr->getNumberOfTuples());
5249 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
5250 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
5251 getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
5252 _nb_of_tuples_to_be_allocated=-3;
5253 return oldNbOfTuples;
5258 * Returns number of components in \a this field
5259 * \return int - the number of components.
5261 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
5263 return getOrCreateAndGetArray()->getNumberOfComponents();
5267 * Change info on components in \a this.
5268 * \throw If size of \a infos is not equal to the number of components already in \a this.
5270 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
5272 DataArray *arr=getOrCreateAndGetArray();
5273 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
5277 * Returns info on components of \a this field.
5278 * \return const std::vector<std::string>& - a sequence of strings each being an
5279 * information on _i_-th component.
5281 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
5283 const DataArray *arr=getOrCreateAndGetArray();
5284 return arr->getInfoOnComponents();
5288 * Returns a mutable info on components of \a this field.
5289 * \return std::vector<std::string>& - a sequence of strings each being an
5290 * information on _i_-th component.
5292 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
5294 DataArray *arr=getOrCreateAndGetArray();
5295 return arr->getInfoOnComponents();
5298 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const
5300 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5302 const MEDFileFieldPerMesh *fpm(*it);
5305 if(fpm->presenceOfMultiDiscPerGeoType())
5311 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfStructureElements() const
5313 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5314 if((*it).isNotNull())
5315 if((*it)->presenceOfStructureElements())
5320 bool MEDFileAnyTypeField1TSWithoutSDA::onlyStructureElements() const
5322 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5323 if((*it).isNotNull())
5324 if(!(*it)->onlyStructureElements())
5329 void MEDFileAnyTypeField1TSWithoutSDA::killStructureElements()
5331 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5332 if((*it).isNotNull())
5333 (*it)->killStructureElements();
5336 void MEDFileAnyTypeField1TSWithoutSDA::keepOnlyStructureElements()
5338 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5339 if((*it).isNotNull())
5340 (*it)->keepOnlyStructureElements();
5343 void MEDFileAnyTypeField1TSWithoutSDA::keepOnlyOnSE(const std::string& seName)
5345 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5346 if((*it).isNotNull())
5347 (*it)->keepOnlyOnSE(seName);
5350 void MEDFileAnyTypeField1TSWithoutSDA::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
5352 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5353 if((*it).isNotNull())
5354 (*it)->getMeshSENames(ps);
5357 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh(const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5359 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 !";
5360 if(_field_per_mesh.empty())
5361 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is empty ! Nothing to extract !");
5362 if(_field_per_mesh.size()>1)
5363 throw INTERP_KERNEL::Exception(MSG0);
5364 if(_field_per_mesh[0].isNull())
5365 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is inconsistent !");
5366 const MEDFileFieldPerMesh *pm(_field_per_mesh[0]);
5367 std::set<TypeOfField> types;
5368 pm->fillTypesOfFieldAvailable(types);
5370 throw INTERP_KERNEL::Exception(MSG0);
5371 TypeOfField type(*types.begin());
5372 int meshDimRelToMax(0);
5377 int myDim(std::numeric_limits<int>::max());
5378 bool isUnique(pm->isUniqueLevel(myDim));
5380 throw INTERP_KERNEL::Exception(MSG0);
5381 meshDimRelToMax=myDim-mesh->getMeshDimension();
5382 if(meshDimRelToMax>0)
5383 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the mesh attached to field is not compatible with the field !");
5385 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,0/*renumPol*/,glob,mesh,arrOut,nasc);
5389 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5390 * \param [in] type - a spatial discretization of the new field.
5391 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5392 * \param [in] mName - a name of the supporting mesh.
5393 * \param [in] renumPol - specifies how to permute values of the result field according to
5394 * the optional numbers of cells and nodes, if any. The valid values are
5395 * - 0 - do not permute.
5396 * - 1 - permute cells.
5397 * - 2 - permute nodes.
5398 * - 3 - permute cells and nodes.
5400 * \param [in] glob - the global data storing profiles and localization.
5401 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5402 * caller is to delete this field using decrRef() as it is no more needed.
5403 * \throw If the MED file is not readable.
5404 * \throw If there is no mesh named \a mName in the MED file.
5405 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5406 * \throw If no field of \a this is lying on the mesh \a mName.
5407 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5409 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5411 MCAuto<MEDFileMesh> mm;
5413 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
5415 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
5416 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
5420 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5421 * \param [in] type - a spatial discretization of the new field.
5422 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5423 * \param [in] renumPol - specifies how to permute values of the result field according to
5424 * the optional numbers of cells and nodes, if any. The valid values are
5425 * - 0 - do not permute.
5426 * - 1 - permute cells.
5427 * - 2 - permute nodes.
5428 * - 3 - permute cells and nodes.
5430 * \param [in] glob - the global data storing profiles and localization.
5431 * \param [in] mesh - the supporting mesh.
5432 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5433 * caller is to delete this field using decrRef() as it is no more needed.
5434 * \throw If the MED file is not readable.
5435 * \throw If no field of \a this is lying on \a mesh.
5436 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5437 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5439 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5441 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax,false));
5442 const DataArrayInt *d(mesh->getNumberFieldAtLevel(meshDimRelToMax)),*e(mesh->getNumberFieldAtLevel(1));
5443 if(meshDimRelToMax==1)
5444 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
5445 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
5449 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
5451 * \param [in] type - a spatial discretization of the new field.
5452 * \param [in] mName - a name of the supporting mesh.
5453 * \param [in] renumPol - specifies how to permute values of the result field according to
5454 * the optional numbers of cells and nodes, if any. The valid values are
5455 * - 0 - do not permute.
5456 * - 1 - permute cells.
5457 * - 2 - permute nodes.
5458 * - 3 - permute cells and nodes.
5460 * \param [in] glob - the global data storing profiles and localization.
5461 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5462 * caller is to delete this field using decrRef() as it is no more needed.
5463 * \throw If the MED file is not readable.
5464 * \throw If there is no mesh named \a mName in the MED file.
5465 * \throw If there are no mesh entities in the mesh.
5466 * \throw If no field values of the given \a type are available.
5468 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5470 MCAuto<MEDFileMesh> mm;
5472 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
5474 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
5475 int absDim=getDimension();
5476 int meshDimRelToMax=absDim-mm->getMeshDimension();
5477 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
5481 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5482 * \param [in] type - a spatial discretization of the new field.
5483 * \param [in] renumPol - specifies how to permute values of the result field according to
5484 * the optional numbers of cells and nodes, if any. The valid values are
5485 * - 0 - do not permute.
5486 * - 1 - permute cells.
5487 * - 2 - permute nodes.
5488 * - 3 - permute cells and nodes.
5490 * \param [in] glob - the global data storing profiles and localization.
5491 * \param [in] mesh - the supporting mesh.
5492 * \param [in] cellRenum - the cell numbers array used for permutation of the result
5493 * field according to \a renumPol.
5494 * \param [in] nodeRenum - the node numbers array used for permutation of the result
5495 * field according to \a renumPol.
5496 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5497 * caller is to delete this field using decrRef() as it is no more needed.
5498 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5499 * \throw If no field of \a this is lying on \a mesh.
5500 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5502 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
5504 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
5506 MCAuto<MEDCouplingFieldDouble> ret=_field_per_mesh[0]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
5511 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5518 throw INTERP_KERNEL::Exception(msg1);
5519 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5522 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
5524 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5525 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
5526 throw INTERP_KERNEL::Exception(oss.str());
5528 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
5529 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
5530 std::vector<DataArray *> arrOut2(1,arrOut);
5531 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
5532 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
5533 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
5540 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5542 throw INTERP_KERNEL::Exception(msg1);
5545 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
5547 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5548 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
5549 throw INTERP_KERNEL::Exception(oss.str());
5551 MCAuto<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
5552 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
5553 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
5554 ret->renumberNodes(nodeRenumSafe->getConstPointer());
5559 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
5564 * Returns values and a profile of the field of a given type lying on a given support.
5565 * \param [in] type - a spatial discretization of the field.
5566 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5567 * \param [in] mesh - the supporting mesh.
5568 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
5569 * field of interest lies on. If the field lies on all entities of the given
5570 * dimension, all ids in \a pfl are zero. The caller is to delete this array
5571 * using decrRef() as it is no more needed.
5572 * \param [in] glob - the global data storing profiles and localization.
5573 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
5574 * field. The caller is to delete this array using decrRef() as it is no more needed.
5575 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
5576 * \throw If no field of \a this is lying on \a mesh.
5577 * \throw If no field values of the given \a type are available.
5579 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
5581 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
5582 MCAuto<DataArray> ret=_field_per_mesh[0]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
5583 ret->setName(nasc.getName().c_str());
5587 //= MEDFileField1TSWithoutSDA
5590 * Throws if a given value is not a valid (non-extended) relative dimension.
5591 * \param [in] meshDimRelToMax - the relative dimension value.
5592 * \throw If \a meshDimRelToMax > 0.
5594 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
5596 if(meshDimRelToMax>0)
5597 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
5601 * Checks if elements of a given mesh are in the order suitable for writing
5602 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
5603 * vector describing types of elements and their number.
5604 * \param [in] mesh - the mesh to check.
5605 * \return std::vector<int> - a vector holding for each element type (1) item of
5606 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
5607 * These values are in full-interlace mode.
5608 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
5610 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
5613 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
5614 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
5615 int nbOfTypes=geoTypes.size();
5616 std::vector<int> code(3*nbOfTypes);
5617 MCAuto<DataArrayInt> arr1=DataArrayInt::New();
5618 arr1->alloc(nbOfTypes,1);
5619 int *arrPtr=arr1->getPointer();
5620 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
5621 for(int i=0;i<nbOfTypes;i++,it++)
5622 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
5623 MCAuto<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
5624 const int *arrPtr2=arr2->getConstPointer();
5626 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
5629 int nbCells=mesh->getNumberOfCellsWithType(*it);
5630 code[3*pos]=(int)(*it);
5631 code[3*pos+1]=nbCells;
5632 code[3*pos+2]=-1;//no profiles
5634 std::vector<const DataArrayInt *> idsPerType;//no profiles
5635 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
5639 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
5644 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5646 return new MEDFileField1TSWithoutSDA(fieldName,meshName,csit,iteration,order,infos);
5650 * Returns all attributes and values of parts of \a this field lying on a given mesh.
5651 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
5652 * item of every of returned sequences refers to the _i_-th part of \a this field.
5653 * Thus all sequences returned by this method are of the same length equal to number
5654 * of different types of supporting entities.<br>
5655 * A field part can include sub-parts with several different spatial discretizations,
5656 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
5657 * for example. Hence, some of the returned sequences contains nested sequences, and an item
5658 * of a nested sequence corresponds to a type of spatial discretization.<br>
5659 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
5660 * The overhead is due to selecting values into new instances of DataArrayDouble.
5661 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
5662 * for the case with only one underlying mesh. (Actually, the number of meshes is
5663 * not checked if \a mname == \c NULL).
5664 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
5665 * a field part is returned.
5666 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
5667 * A field part can include sub-parts with several different spatial discretizations,
5668 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and
5669 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT" for example.
5670 * This sequence is of the same length as \a types.
5671 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
5672 * discretization. A profile name can be empty.
5673 * Length of this and of nested sequences is the same as that of \a typesF.
5674 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
5675 * discretization. A localization name can be empty.
5676 * Length of this and of nested sequences is the same as that of \a typesF.
5677 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
5678 * per each type of spatial discretization within one mesh entity type.
5679 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
5680 * Length of this and of nested sequences is the same as that of \a typesF.
5681 * \throw If no field is lying on \a mname.
5683 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
5686 if(_field_per_mesh.empty())
5687 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
5688 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[0]->getFieldSplitedByType(types,typesF,pfls,locs);
5689 int nbOfRet=ret0.size();
5690 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
5691 for(int i=0;i<nbOfRet;i++)
5693 const std::vector< std::pair<int,int> >& p=ret0[i];
5694 int nbOfRet1=p.size();
5695 ret[i].resize(nbOfRet1);
5696 for(int j=0;j<nbOfRet1;j++)
5698 DataArrayDouble *tmp=_arr->selectByTupleIdSafeSlice(p[j].first,p[j].second,1);
5705 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
5710 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
5712 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
5713 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5714 ret->deepCpyLeavesFrom(*this);
5715 const DataArrayDouble *arr(_arr);
5718 MCAuto<DataArrayInt> arr2(arr->convertToIntArr());
5719 ret->setArray(arr2);
5725 * Returns a pointer to the underground DataArrayDouble instance and a
5726 * sequence describing parameters of a support of each part of \a this field. The
5727 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5728 * direct access to the field values. This method is intended for the field lying on one
5730 * \param [in,out] entries - the sequence describing parameters of a support of each
5731 * part of \a this field. Each item of this sequence consists of two parts. The
5732 * first part describes a type of mesh entity and an id of discretization of a
5733 * current field part. The second part describes a range of values [begin,end)
5734 * within the returned array relating to the current field part.
5735 * \return DataArrayDouble * - the pointer to the field values array.
5736 * \throw If the number of underlying meshes is not equal to 1.
5737 * \throw If no field values are available.
5738 * \sa getUndergroundDataArray()
5740 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5742 return getUndergroundDataArrayTemplateExt(entries);
5745 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<double>(fieldName,meshName,csit,iteration,order)
5747 DataArrayDouble *arr(getOrCreateAndGetArrayTemplate());
5748 arr->setInfoAndChangeNbOfCompo(infos);
5751 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<double>()
5755 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
5757 MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
5758 ret->deepCpyLeavesFrom(*this);
5762 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCopy() const
5764 MCAuto<MEDFileField1TSWithoutSDA> ret(shallowCpy());
5765 if(_arr.isNotNull())
5766 ret->_arr=_arr->deepCopy();
5770 //= MEDFileIntField1TSWithoutSDA
5772 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5774 return new MEDFileIntField1TSWithoutSDA(fieldName,meshName,csit,iteration,order,infos);
5777 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA()
5781 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order,
5782 const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<int>(fieldName,meshName,csit,iteration,order)
5784 DataArrayInt *arr(getOrCreateAndGetArrayTemplate());
5785 arr->setInfoAndChangeNbOfCompo(infos);
5788 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
5793 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const
5795 MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
5796 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5797 ret->deepCpyLeavesFrom(*this);
5798 if(_arr.isNotNull())
5800 MCAuto<DataArrayDouble> arr2(_arr->convertToDblArr());
5801 ret->setArray(arr2);
5807 * Returns a pointer to the underground DataArrayInt instance and a
5808 * sequence describing parameters of a support of each part of \a this field. The
5809 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5810 * direct access to the field values. This method is intended for the field lying on one
5812 * \param [in,out] entries - the sequence describing parameters of a support of each
5813 * part of \a this field. Each item of this sequence consists of two parts. The
5814 * first part describes a type of mesh entity and an id of discretization of a
5815 * current field part. The second part describes a range of values [begin,end)
5816 * within the returned array relating to the current field part.
5817 * \return DataArrayInt * - the pointer to the field values array.
5818 * \throw If the number of underlying meshes is not equal to 1.
5819 * \throw If no field values are available.
5820 * \sa getUndergroundDataArray()
5822 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5824 return getUndergroundDataArrayIntExt(entries);
5828 * Returns a pointer to the underground DataArrayInt instance and a
5829 * sequence describing parameters of a support of each part of \a this field. The
5830 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5831 * direct access to the field values. This method is intended for the field lying on one
5833 * \param [in,out] entries - the sequence describing parameters of a support of each
5834 * part of \a this field. Each item of this sequence consists of two parts. The
5835 * first part describes a type of mesh entity and an id of discretization of a
5836 * current field part. The second part describes a range of values [begin,end)
5837 * within the returned array relating to the current field part.
5838 * \return DataArrayInt * - the pointer to the field values array.
5839 * \throw If the number of underlying meshes is not equal to 1.
5840 * \throw If no field values are available.
5841 * \sa getUndergroundDataArray()
5843 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5845 if(_field_per_mesh.size()!=1)
5846 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5847 if(_field_per_mesh[0]==0)
5848 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5849 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5850 return getUndergroundDataArrayTemplate();
5853 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5855 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5856 ret->deepCpyLeavesFrom(*this);
5860 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCopy() const
5862 MCAuto<MEDFileIntField1TSWithoutSDA> ret(shallowCpy());
5863 if(_arr.isNotNull())
5864 ret->_arr=_arr->deepCopy();
5868 //= MEDFileFloatField1TSWithoutSDA
5870 MEDFileFloatField1TSWithoutSDA *MEDFileFloatField1TSWithoutSDA::New(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5872 return new MEDFileFloatField1TSWithoutSDA(fieldName,meshName,csit,iteration,order,infos);
5875 MEDFileFloatField1TSWithoutSDA::MEDFileFloatField1TSWithoutSDA()
5879 MEDFileFloatField1TSWithoutSDA::MEDFileFloatField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order,
5880 const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<float>(fieldName,meshName,csit,iteration,order)
5882 DataArrayFloat *arr(getOrCreateAndGetArrayTemplate());
5883 arr->setInfoAndChangeNbOfCompo(infos);
5886 const char *MEDFileFloatField1TSWithoutSDA::getTypeStr() const
5891 MEDFileField1TSWithoutSDA *MEDFileFloatField1TSWithoutSDA::convertToDouble() const
5893 MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
5894 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5895 ret->deepCpyLeavesFrom(*this);
5896 if(_arr.isNotNull())
5898 MCAuto<DataArrayDouble> arr2(_arr->convertToDblArr());
5899 ret->setArray(arr2);
5905 * Returns a pointer to the underground DataArrayFloat instance and a
5906 * sequence describing parameters of a support of each part of \a this field. The
5907 * caller should not decrRef() the returned DataArrayFloat. This method allows for a
5908 * direct access to the field values. This method is intended for the field lying on one
5910 * \param [in,out] entries - the sequence describing parameters of a support of each
5911 * part of \a this field. Each item of this sequence consists of two parts. The
5912 * first part describes a type of mesh entity and an id of discretization of a
5913 * current field part. The second part describes a range of values [begin,end)
5914 * within the returned array relating to the current field part.
5915 * \return DataArrayFloat * - the pointer to the field values array.
5916 * \throw If the number of underlying meshes is not equal to 1.
5917 * \throw If no field values are available.
5918 * \sa getUndergroundDataArray()
5920 DataArray *MEDFileFloatField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5922 return getUndergroundDataArrayFloatExt(entries);
5926 * Returns a pointer to the underground DataArrayFloat instance and a
5927 * sequence describing parameters of a support of each part of \a this field. The
5928 * caller should not decrRef() the returned DataArrayFloat. This method allows for a
5929 * direct access to the field values. This method is intended for the field lying on one
5931 * \param [in,out] entries - the sequence describing parameters of a support of each
5932 * part of \a this field. Each item of this sequence consists of two parts. The
5933 * first part describes a type of mesh entity and an id of discretization of a
5934 * current field part. The second part describes a range of values [begin,end)
5935 * within the returned array relating to the current field part.
5936 * \return DataArrayFloat * - the pointer to the field values array.
5937 * \throw If the number of underlying meshes is not equal to 1.
5938 * \throw If no field values are available.
5939 * \sa getUndergroundDataArray()
5941 DataArrayFloat *MEDFileFloatField1TSWithoutSDA::getUndergroundDataArrayFloatExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5943 if(_field_per_mesh.size()!=1)
5944 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5945 if(_field_per_mesh[0]==0)
5946 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5947 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5948 return getUndergroundDataArrayTemplate();
5951 MEDFileFloatField1TSWithoutSDA *MEDFileFloatField1TSWithoutSDA::shallowCpy() const
5953 MCAuto<MEDFileFloatField1TSWithoutSDA> ret(new MEDFileFloatField1TSWithoutSDA(*this));
5954 ret->deepCpyLeavesFrom(*this);
5958 MEDFileFloatField1TSWithoutSDA *MEDFileFloatField1TSWithoutSDA::deepCopy() const
5960 MCAuto<MEDFileFloatField1TSWithoutSDA> ret(shallowCpy());
5961 if(_arr.isNotNull())
5962 ret->_arr=_arr->deepCopy();
5966 //= MEDFileAnyTypeField1TS
5968 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5972 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
5974 med_field_type typcha;
5976 std::vector<std::string> infos;
5977 std::string dtunit,fieldName,meshName;
5978 LocateField2(fid,0,true,fieldName,typcha,infos,dtunit,meshName);
5979 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5984 ret=MEDFileField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5989 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5992 case MED_NODE://6432
5994 ret=MEDFileFloatField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5999 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] !";
6000 throw INTERP_KERNEL::Exception(oss.str());
6003 ret->setDtUnit(dtunit.c_str());
6004 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
6006 med_int numdt,numit;
6008 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
6009 ret->setTime(numdt,numit,dt);
6012 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
6014 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
6018 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
6019 try:MEDFileFieldGlobsReal(fid)
6021 _content=BuildContentFrom(fid,loadAll,ms,entities);
6024 catch(INTERP_KERNEL::Exception& e)
6029 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
6031 med_field_type typcha;
6032 std::vector<std::string> infos;
6033 std::string dtunit,meshName;
6037 nbSteps=LocateField(fid,fieldName,iii,typcha,infos,dtunit,meshName);
6039 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
6044 ret=MEDFileField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
6049 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
6052 case MED_NODE://6432
6054 ret=MEDFileFloatField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
6059 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] !";
6060 throw INTERP_KERNEL::Exception(oss.str());
6063 ret->setMeshName(meshName);
6064 ret->setDtUnit(dtunit.c_str());
6065 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
6069 std::ostringstream oss; oss << "MEDFileField1TS(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
6070 throw INTERP_KERNEL::Exception(oss.str());
6073 med_int numdt,numit;
6075 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
6076 ret->setTime(numdt,numit,dt);
6079 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
6081 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
6085 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
6086 try:MEDFileFieldGlobsReal(fid)
6088 _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
6091 catch(INTERP_KERNEL::Exception& e)
6096 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c)
6099 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
6100 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
6102 MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
6103 ret->_content=c; c->incrRef();
6106 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
6108 MCAuto<MEDFileIntField1TS> ret(MEDFileIntField1TS::New());
6109 ret->_content=c; c->incrRef();
6112 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
6115 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, med_idt fid)
6117 MEDFileAnyTypeField1TS *ret(BuildNewInstanceFromContent(c));
6118 ret->setFileName(FileNameFromFID(fid));
6122 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
6124 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6125 return New(fid,loadAll);
6128 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, bool loadAll)
6130 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,loadAll,0,0));
6131 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
6132 ret->loadGlobals(fid);
6136 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6138 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6139 return New(fid,fieldName,loadAll);
6142 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
6144 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
6145 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
6146 ret->loadGlobals(fid);
6150 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6152 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6153 return New(fid,fieldName,iteration,order,loadAll);
6156 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
6158 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0,0));
6159 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
6160 ret->loadGlobals(fid);
6164 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::NewAdv(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileEntities *entities)
6166 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6167 return NewAdv(fid,fieldName,iteration,order,loadAll,entities);
6170 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::NewAdv(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileEntities *entities)
6172 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0,entities));
6173 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
6174 ret->loadGlobals(fid);
6178 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
6180 med_field_type typcha;
6181 std::vector<std::string> infos;
6182 std::string dtunit,meshName;
6184 int nbOfStep2(LocateField(fid,fieldName,iii,typcha,infos,dtunit,meshName));
6185 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
6190 ret=MEDFileField1TSWithoutSDA::New(fieldName,meshName,-1,iteration,order,std::vector<std::string>());
6195 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,meshName,-1,iteration,order,std::vector<std::string>());
6200 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] !";
6201 throw INTERP_KERNEL::Exception(oss.str());
6204 ret->setDtUnit(dtunit.c_str());
6205 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
6208 std::vector< std::pair<int,int> > dtits(nbOfStep2);
6209 for(int i=0;i<nbOfStep2 && !found;i++)
6211 med_int numdt,numit;
6213 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt));
6214 if(numdt==iteration && numit==order)
6220 dtits[i]=std::pair<int,int>(numdt,numit);
6224 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available iterations are : ";
6225 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
6226 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
6227 throw INTERP_KERNEL::Exception(oss.str());
6230 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
6232 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
6236 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
6237 try:MEDFileFieldGlobsReal(fid)
6239 _content=BuildContentFrom(fid,fieldName,iteration,order,loadAll,ms,entities);
6242 catch(INTERP_KERNEL::Exception& e)
6248 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6249 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6251 * \warning this is a shallow copy constructor
6253 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
6255 if(!shallowCopyOfContent)
6257 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
6258 otherPtr->incrRef();
6259 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
6263 _content=other.shallowCpy();
6267 int MEDFileAnyTypeField1TS::LocateField2(med_idt fid, int fieldIdCFormat, bool checkFieldId, std::string& fieldName, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut, std::string& meshName)
6271 int nbFields=MEDnField(fid);
6272 if(fieldIdCFormat>=nbFields)
6274 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << FileNameFromFID(fid) << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
6275 throw INTERP_KERNEL::Exception(oss.str());
6278 int ncomp(MEDfieldnComponent(fid,fieldIdCFormat+1));
6279 INTERP_KERNEL::AutoPtr<char> comp(MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE));
6280 INTERP_KERNEL::AutoPtr<char> unit(MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE));
6281 INTERP_KERNEL::AutoPtr<char> dtunit(MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE));
6282 INTERP_KERNEL::AutoPtr<char> nomcha(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
6283 INTERP_KERNEL::AutoPtr<char> nomMaa(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
6286 MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep));
6287 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
6288 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
6289 meshName=MEDLoaderBase::buildStringFromFortran(nomMaa,MED_NAME_SIZE);
6290 infos.clear(); infos.resize(ncomp);
6291 for(int j=0;j<ncomp;j++)
6292 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
6297 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
6300 * \return in case of success the number of time steps available for the field with name \a fieldName.
6302 int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const std::string& fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut, std::string& meshName)
6304 int nbFields=MEDnField(fid);
6306 std::vector<std::string> fns(nbFields);
6308 for(int i=0;i<nbFields && !found;i++)
6310 std::string tmp,tmp2;
6311 nbOfStep2=LocateField2(fid,i,false,tmp,typcha,infos,dtunitOut,tmp2);
6313 found=(tmp==fieldName);
6322 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available fields are : ";
6323 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
6324 oss << "\"" << *it << "\" ";
6325 throw INTERP_KERNEL::Exception(oss.str());
6331 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
6332 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
6333 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
6334 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
6335 * to keep a valid instance.
6336 * 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.
6337 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
6338 * 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.
6340 * \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.
6341 * \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.
6342 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
6343 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
6344 * \param [in] newLocName is the new localization name.
6345 * \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.
6346 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
6348 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
6350 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6351 std::string oldPflName=disc->getProfile();
6352 std::vector<std::string> vv=getPflsReallyUsedMulti();
6353 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
6354 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
6356 disc->setProfile(newPflName);
6357 DataArrayInt *pfl=getProfile(oldPflName.c_str());
6358 pfl->setName(newPflName);
6362 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
6363 throw INTERP_KERNEL::Exception(oss.str());
6368 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
6369 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
6370 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
6371 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
6372 * to keep a valid instance.
6373 * 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.
6374 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
6375 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
6376 * 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.
6378 * \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.
6379 * \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.
6380 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
6381 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
6382 * \param [in] newLocName is the new localization name.
6383 * \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.
6384 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
6386 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
6388 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6389 std::string oldLocName=disc->getLocalization();
6390 std::vector<std::string> vv=getLocsReallyUsedMulti();
6391 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
6392 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
6394 disc->setLocalization(newLocName);
6395 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
6396 loc.setName(newLocName);
6400 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
6401 throw INTERP_KERNEL::Exception(oss.str());
6405 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
6407 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
6409 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
6413 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
6415 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
6417 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
6422 * This method alloc the arrays and load potentially huge arrays contained in this field.
6423 * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
6424 * This method can be also called to refresh or reinit values from a file.
6426 * \throw If the fileName is not set or points to a non readable MED file.
6427 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
6429 void MEDFileAnyTypeField1TS::loadArrays()
6431 if(getFileName().empty())
6432 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
6433 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
6434 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
6438 * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
6439 * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
6440 * this method does not throw if \a this does not come from file read.
6442 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
6444 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
6446 if(!getFileName().empty())
6448 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
6449 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
6454 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
6455 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
6456 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
6458 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
6460 void MEDFileAnyTypeField1TS::unloadArrays()
6462 contentNotNullBase()->unloadArrays();
6466 * 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.
6467 * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
6468 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
6470 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
6472 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
6474 if(!getFileName().empty())
6475 contentNotNullBase()->unloadArrays();
6478 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
6480 int nbComp(getNumberOfComponents());
6481 INTERP_KERNEL::AutoPtr<char> comp(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
6482 INTERP_KERNEL::AutoPtr<char> unit(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
6483 for(int i=0;i<nbComp;i++)
6485 std::string info=getInfo()[i];
6487 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
6488 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
6489 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
6491 if(getName().empty())
6492 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
6493 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
6494 writeGlobals(fid,*this);
6495 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
6498 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
6500 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
6503 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
6505 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
6506 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
6511 * Returns a string describing \a this field. This string is outputted
6512 * by \c print Python command.
6514 std::string MEDFileAnyTypeField1TS::simpleRepr() const
6516 std::ostringstream oss;
6517 contentNotNullBase()->simpleRepr(0,oss,-1);
6518 simpleReprGlobs(oss);
6523 * This method returns all profiles whose name is non empty used.
6524 * \b WARNING If profile is used several times it will be reported \b only \b once.
6525 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
6527 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
6529 return contentNotNullBase()->getPflsReallyUsed2();
6533 * This method returns all localizations whose name is non empty used.
6534 * \b WARNING If localization is used several times it will be reported \b only \b once.
6536 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
6538 return contentNotNullBase()->getLocsReallyUsed2();
6542 * This method returns all profiles whose name is non empty used.
6543 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
6545 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
6547 return contentNotNullBase()->getPflsReallyUsedMulti2();
6551 * This method returns all localizations whose name is non empty used.
6552 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
6554 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
6556 return contentNotNullBase()->getLocsReallyUsedMulti2();
6559 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6561 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
6564 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6566 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
6569 int MEDFileAnyTypeField1TS::getDimension() const
6571 return contentNotNullBase()->getDimension();
6574 int MEDFileAnyTypeField1TS::getIteration() const
6576 return contentNotNullBase()->getIteration();
6579 int MEDFileAnyTypeField1TS::getOrder() const
6581 return contentNotNullBase()->getOrder();
6584 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
6586 return contentNotNullBase()->getTime(iteration,order);
6589 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
6591 contentNotNullBase()->setTime(iteration,order,val);
6594 std::string MEDFileAnyTypeField1TS::getName() const
6596 return contentNotNullBase()->getName();
6599 void MEDFileAnyTypeField1TS::setName(const std::string& name)
6601 contentNotNullBase()->setName(name);
6604 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
6606 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
6609 std::string MEDFileAnyTypeField1TS::getDtUnit() const
6611 return contentNotNullBase()->getDtUnit();
6614 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
6616 contentNotNullBase()->setDtUnit(dtUnit);
6619 std::string MEDFileAnyTypeField1TS::getMeshName() const
6621 return contentNotNullBase()->getMeshName();
6624 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
6626 contentNotNullBase()->setMeshName(newMeshName);
6629 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
6631 return contentNotNullBase()->changeMeshNames(modifTab);
6634 int MEDFileAnyTypeField1TS::getMeshIteration() const
6636 return contentNotNullBase()->getMeshIteration();
6639 int MEDFileAnyTypeField1TS::getMeshOrder() const
6641 return contentNotNullBase()->getMeshOrder();
6644 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
6646 return contentNotNullBase()->getNumberOfComponents();
6649 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
6651 return contentNotNullBase()->isDealingTS(iteration,order);
6654 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
6656 return contentNotNullBase()->getDtIt();
6659 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
6661 contentNotNullBase()->fillIteration(p);
6664 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
6666 contentNotNullBase()->fillTypesOfFieldAvailable(types);
6669 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
6671 contentNotNullBase()->setInfo(infos);
6674 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
6676 return contentNotNullBase()->getInfo();
6678 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
6680 return contentNotNullBase()->getInfo();
6683 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
6685 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
6688 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
6690 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6693 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
6695 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6698 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
6700 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
6703 void MEDFileAnyTypeField1TS::convertMedBallIntoClassic()
6705 return contentNotNullBase()->convertMedBallIntoClassic();
6708 void MEDFileAnyTypeField1TS::makeReduction(INTERP_KERNEL::NormalizedCellType ct, TypeOfField tof, const DataArrayInt *pfl)
6710 return contentNotNullBase()->makeReduction(ct,tof,pfl);
6713 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
6715 return contentNotNullBase()->getTypesOfFieldAvailable();
6718 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,
6719 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6721 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
6725 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
6726 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
6727 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
6729 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
6731 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6733 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
6734 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
6735 std::size_t sz(contentsSplit.size());
6736 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6737 for(std::size_t i=0;i<sz;i++)
6739 ret[i]=shallowCpy();
6740 ret[i]->_content=contentsSplit[i];
6746 * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
6747 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6749 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
6751 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6753 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
6754 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
6755 std::size_t sz(contentsSplit.size());
6756 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6757 for(std::size_t i=0;i<sz;i++)
6759 ret[i]=shallowCpy();
6760 ret[i]->_content=contentsSplit[i];
6766 * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this.
6767 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6769 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const
6771 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6773 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !");
6774 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
6775 std::size_t sz(contentsSplit.size());
6776 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6777 for(std::size_t i=0;i<sz;i++)
6779 ret[i]=shallowCpy();
6780 ret[i]->_content=contentsSplit[i];
6785 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCopy() const
6787 MCAuto<MEDFileAnyTypeField1TS> ret=shallowCpy();
6788 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
6789 ret->_content=_content->deepCopy();
6790 ret->deepCpyGlobs(*this);
6794 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
6796 return contentNotNullBase()->copyTinyInfoFrom(field,arr);
6802 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
6803 * following the given input policy.
6805 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6806 * By default (true) the globals are deeply copied.
6807 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
6809 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
6811 MCAuto<MEDFileIntField1TS> ret;
6812 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6815 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
6817 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
6818 MCAuto<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
6819 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc));
6822 ret=MEDFileIntField1TS::New();
6824 ret->deepCpyGlobs(*this);
6826 ret->shallowCpyGlobs(*this);
6830 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
6833 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
6835 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
6836 DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6838 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6839 f->setArray(arrOutC);
6843 * Return an extraction of \a this using \a extractDef map to specify the extraction.
6844 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
6846 * \return A new object that the caller is responsible to deallocate.
6847 * \sa MEDFileUMesh::deduceNodeSubPartFromCellSubPart , MEDFileUMesh::extractPart
6849 MEDFileField1TS *MEDFileField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
6852 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : input mesh is NULL !");
6853 MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
6854 std::vector<TypeOfField> tof(getTypesOfFieldAvailable());
6855 for(std::vector<TypeOfField>::const_iterator it0=tof.begin();it0!=tof.end();it0++)
6857 if((*it0)!=ON_NODES)
6859 std::vector<int> levs;
6860 getNonEmptyLevels(mm->getName(),levs);
6861 for(std::vector<int>::const_iterator lev=levs.begin();lev!=levs.end();lev++)
6863 std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(*lev));
6864 if(it2!=extractDef.end())
6866 MCAuto<DataArrayInt> t((*it2).second);
6868 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6869 MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_CELLS,(*lev),mm));
6870 MCAuto<MEDCouplingFieldDouble> fOut(f->buildSubPart(t));
6871 ret->setFieldNoProfileSBT(fOut);
6877 std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(1));
6878 if(it2==extractDef.end())
6879 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a NODE field and no extract array available for NODE !");
6880 MCAuto<DataArrayInt> t((*it2).second);
6882 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6883 MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_NODES,0,mm));
6884 MCAuto<MEDCouplingFieldDouble> fOut(f->deepCopy());
6885 DataArrayDouble *arr(f->getArray());
6886 MCAuto<DataArrayDouble> newArr(arr->selectByTupleIdSafe(t->begin(),t->end()));
6887 fOut->setArray(newArr);
6888 ret->setFieldNoProfileSBT(fOut);
6894 MEDFileField1TS::MEDFileField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
6895 try:MEDFileTemplateField1TS<double>(fid,loadAll,ms)
6898 catch(INTERP_KERNEL::Exception& e)
6901 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6902 try:MEDFileTemplateField1TS<double>(fid,fieldName,loadAll,ms)
6905 catch(INTERP_KERNEL::Exception& e)
6908 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6909 try:MEDFileTemplateField1TS<double>(fid,fieldName,iteration,order,loadAll,ms)
6912 catch(INTERP_KERNEL::Exception& e)
6916 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6917 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6919 * \warning this is a shallow copy constructor
6921 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6922 try:MEDFileTemplateField1TS<double>(other,shallowCopyOfContent)
6925 catch(INTERP_KERNEL::Exception& e)
6929 * 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
6930 * method should be called (getFieldOnMeshAtLevel for example).
6931 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
6933 * \param [in] mesh - the mesh the field is lying on
6934 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6935 * caller is to delete this field using decrRef() as it is no more needed.
6937 MEDCouplingFieldDouble *MEDFileField1TS::field(const MEDFileMesh *mesh) const
6939 MCAuto<DataArray> arrOut;
6940 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
6941 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6946 * Returns a new MEDCouplingFieldDouble of a given type lying on
6947 * mesh entities of a given dimension of the first mesh in MED file. If \a this field
6948 * has not been constructed via file reading, an exception is thrown.
6949 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6950 * \param [in] type - a spatial discretization of interest.
6951 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6952 * \param [in] renumPol - specifies how to permute values of the result field according to
6953 * the optional numbers of cells and nodes, if any. The valid values are
6954 * - 0 - do not permute.
6955 * - 1 - permute cells.
6956 * - 2 - permute nodes.
6957 * - 3 - permute cells and nodes.
6959 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6960 * caller is to delete this field using decrRef() as it is no more needed.
6961 * \throw If \a this field has not been constructed via file reading.
6962 * \throw If the MED file is not readable.
6963 * \throw If there is no mesh in the MED file.
6964 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6965 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6966 * \sa getFieldOnMeshAtLevel()
6968 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6970 if(getFileName().empty())
6971 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6972 MCAuto<DataArray> arrOut;
6973 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
6974 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6979 * Returns a new MEDCouplingFieldDouble of a given type lying on
6980 * the top level cells of the first mesh in MED file. If \a this field
6981 * has not been constructed via file reading, an exception is thrown.
6982 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6983 * \param [in] type - a spatial discretization of interest.
6984 * \param [in] renumPol - specifies how to permute values of the result field according to
6985 * the optional numbers of cells and nodes, if any. The valid values are
6986 * - 0 - do not permute.
6987 * - 1 - permute cells.
6988 * - 2 - permute nodes.
6989 * - 3 - permute cells and nodes.
6991 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6992 * caller is to delete this field using decrRef() as it is no more needed.
6993 * \throw If \a this field has not been constructed via file reading.
6994 * \throw If the MED file is not readable.
6995 * \throw If there is no mesh in the MED file.
6996 * \throw If no field values of the given \a type.
6997 * \throw If no field values lying on the top level support.
6998 * \sa getFieldAtLevel()
7000 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
7002 if(getFileName().empty())
7003 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
7004 MCAuto<DataArray> arrOut;
7005 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
7006 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
7011 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
7012 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7013 * \param [in] type - a spatial discretization of the new field.
7014 * \param [in] mesh - the supporting mesh.
7015 * \param [in] renumPol - specifies how to permute values of the result field according to
7016 * the optional numbers of cells and nodes, if any. The valid values are
7017 * - 0 - do not permute.
7018 * - 1 - permute cells.
7019 * - 2 - permute nodes.
7020 * - 3 - permute cells and nodes.
7022 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
7023 * caller is to delete this field using decrRef() as it is no more needed.
7024 * \throw If no field of \a this is lying on \a mesh.
7025 * \throw If the mesh is empty.
7026 * \throw If no field values of the given \a type are available.
7027 * \sa getFieldAtLevel()
7028 * \sa getFieldOnMeshAtLevel()
7030 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
7032 MCAuto<DataArray> arrOut;
7033 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
7034 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
7039 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
7040 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7041 * \param [in] type - a spatial discretization of interest.
7042 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7043 * \param [in] mesh - the supporting mesh.
7044 * \param [in] renumPol - specifies how to permute values of the result field according to
7045 * the optional numbers of cells and nodes, if any. The valid values are
7046 * - 0 - do not permute.
7047 * - 1 - permute cells.
7048 * - 2 - permute nodes.
7049 * - 3 - permute cells and nodes.
7051 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
7052 * caller is to delete this field using decrRef() as it is no more needed.
7053 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7054 * \throw If no field of \a this is lying on \a mesh.
7055 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7056 * \sa getFieldAtLevel()
7057 * \sa getFieldOnMeshAtLevel()
7059 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
7061 MCAuto<DataArray> arrOut;
7062 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
7063 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
7068 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
7069 * This method is called "Old" because in MED3 norm a field has only one meshName
7070 * attached, so this method is for readers of MED2 files. If \a this field
7071 * has not been constructed via file reading, an exception is thrown.
7072 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7073 * \param [in] type - a spatial discretization of interest.
7074 * \param [in] mName - a name of the supporting mesh.
7075 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7076 * \param [in] renumPol - specifies how to permute values of the result field according to
7077 * the optional numbers of cells and nodes, if any. The valid values are
7078 * - 0 - do not permute.
7079 * - 1 - permute cells.
7080 * - 2 - permute nodes.
7081 * - 3 - permute cells and nodes.
7083 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
7084 * caller is to delete this field using decrRef() as it is no more needed.
7085 * \throw If the MED file is not readable.
7086 * \throw If there is no mesh named \a mName in the MED file.
7087 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7088 * \throw If \a this field has not been constructed via file reading.
7089 * \throw If no field of \a this is lying on the mesh named \a mName.
7090 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7091 * \sa getFieldAtLevel()
7093 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
7095 if(getFileName().empty())
7096 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7097 MCAuto<DataArray> arrOut;
7098 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull()));
7099 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
7104 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
7105 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
7106 * "Sort By Type"), if not, an exception is thrown.
7107 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7108 * \param [in] field - the field to add to \a this.
7109 * \throw If the name of \a field is empty.
7110 * \throw If the data array of \a field is not set.
7111 * \throw If the data array is already allocated but has different number of components
7113 * \throw If the underlying mesh of \a field has no name.
7114 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
7116 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
7119 contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
7123 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
7124 * can be an aggregation of several MEDCouplingFieldDouble instances.
7125 * The mesh support of input parameter \a field is ignored here, it can be NULL.
7126 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
7129 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
7130 * A new profile is added only if no equal profile is missing.
7131 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7132 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
7133 * \param [in] mesh - the supporting mesh of \a field.
7134 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
7135 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
7136 * \throw If either \a field or \a mesh or \a profile has an empty name.
7137 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7138 * \throw If the data array of \a field is not set.
7139 * \throw If the data array of \a this is already allocated but has different number of
7140 * components than \a field.
7141 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
7142 * \sa setFieldNoProfileSBT()
7144 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
7147 contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
7150 MEDFileField1TS *MEDFileField1TS::shallowCpy() const
7152 return new MEDFileField1TS(*this);
7155 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
7156 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
7158 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
7161 //= MEDFileIntField1TS
7163 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
7164 try:MEDFileTemplateField1TS<int>(fid,loadAll,ms)
7167 catch(INTERP_KERNEL::Exception& e)
7170 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
7171 try:MEDFileTemplateField1TS<int>(fid,fieldName,loadAll,ms)
7174 catch(INTERP_KERNEL::Exception& e)
7177 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
7178 try:MEDFileTemplateField1TS<int>(fid,fieldName,iteration,order,loadAll,ms)
7181 catch(INTERP_KERNEL::Exception& e)
7185 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
7186 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
7188 * \warning this is a shallow copy constructor
7190 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileTemplateField1TS<int>(other,shallowCopyOfContent)
7194 MEDFileIntField1TS *MEDFileIntField1TS::shallowCpy() const
7196 return new MEDFileIntField1TS(*this);
7200 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
7201 * following the given input policy.
7203 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
7204 * By default (true) the globals are deeply copied.
7205 * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
7207 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const
7209 MCAuto<MEDFileField1TS> ret;
7210 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
7213 const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
7215 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
7216 MCAuto<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
7217 ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc));
7220 ret=MEDFileField1TS::New();
7222 ret->deepCpyGlobs(*this);
7224 ret->shallowCpyGlobs(*this);
7229 * Adds a MEDCouplingFieldInt to \a this. The underlying mesh of the given field is
7230 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
7231 * "Sort By Type"), if not, an exception is thrown.
7232 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7233 * \param [in] field - the field to add to \a this.
7234 * \throw If the name of \a field is empty.
7235 * \throw If the data array of \a field is not set.
7236 * \throw If the data array is already allocated but has different number of components
7238 * \throw If the underlying mesh of \a field has no name.
7239 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
7241 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldInt *field)
7243 MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
7245 contentNotNull()->setFieldNoProfileSBT(field2,field->getArray(),*this,*contentNotNull());
7249 * Adds a MEDCouplingFieldInt to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
7250 * can be an aggregation of several MEDCouplingFieldDouble instances.
7251 * The mesh support of input parameter \a field is ignored here, it can be NULL.
7252 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
7255 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
7256 * A new profile is added only if no equal profile is missing.
7257 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7258 * \param [in] field - the field to add to \a this.
7259 * \param [in] mesh - the supporting mesh of \a field.
7260 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
7261 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
7262 * \throw If either \a field or \a mesh or \a profile has an empty name.
7263 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7264 * \throw If the data array of \a field is not set.
7265 * \throw If the data array of \a this is already allocated but has different number of
7266 * components than \a field.
7267 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
7268 * \sa setFieldNoProfileSBT()
7270 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
7272 MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
7274 contentNotNull()->setFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
7277 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
7279 if(getFileName().empty())
7280 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7281 MCAuto<DataArray> arrOut;
7282 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
7283 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7287 MCAuto<MEDCouplingFieldInt> MEDFileIntField1TS::SetDataArrayDoubleInIntField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
7290 double t0(f->getTime(t1,t2));
7291 MCAuto<DataArrayInt> arr2(DynamicCastSafe<DataArray,DataArrayInt>(arr));
7292 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
7293 MCAuto<MEDCouplingFieldInt> ret(MEDCouplingFieldInt::New(*ft));
7294 ret->setTime(t0,t1,t2); ret->setArray(arr2);
7298 MCAuto<MEDCouplingFieldDouble> MEDFileIntField1TS::ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f)
7301 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ConvertFieldIntToFieldDouble : null input field !");
7303 double t0(f->getTime(t1,t2));
7304 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
7305 MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(*ft));
7306 ret->setTime(t0,t1,t2);
7310 MEDFileIntField1TS *MEDFileIntField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
7312 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::extractPart : not implemented yet !");
7316 * 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
7317 * method should be called (getFieldOnMeshAtLevel for example).
7318 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
7320 * \param [in] mesh - the mesh the field is lying on
7321 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
7322 * caller is to delete this field using decrRef() as it is no more needed.
7324 MEDCouplingFieldInt *MEDFileIntField1TS::field(const MEDFileMesh *mesh) const
7326 MCAuto<DataArray> arrOut;
7327 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
7328 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7333 * Returns a new MEDCouplingFieldInt of a given type lying on
7334 * the top level cells of the first mesh in MED file. If \a this field
7335 * has not been constructed via file reading, an exception is thrown.
7336 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7337 * \param [in] type - a spatial discretization of interest.
7338 * \param [in] renumPol - specifies how to permute values of the result field according to
7339 * the optional numbers of cells and nodes, if any. The valid values are
7340 * - 0 - do not permute.
7341 * - 1 - permute cells.
7342 * - 2 - permute nodes.
7343 * - 3 - permute cells and nodes.
7345 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7346 * caller is to delete this field using decrRef() as it is no more needed.
7347 * \throw If \a this field has not been constructed via file reading.
7348 * \throw If the MED file is not readable.
7349 * \throw If there is no mesh in the MED file.
7350 * \throw If no field values of the given \a type.
7351 * \throw If no field values lying on the top level support.
7352 * \sa getFieldAtLevel()
7354 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
7356 if(getFileName().empty())
7357 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
7358 MCAuto<DataArray> arrOut;
7359 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
7360 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7365 * Returns a new MEDCouplingFieldInt of given type lying on a given mesh.
7366 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7367 * \param [in] type - a spatial discretization of the new field.
7368 * \param [in] mesh - the supporting mesh.
7369 * \param [in] renumPol - specifies how to permute values of the result field according to
7370 * the optional numbers of cells and nodes, if any. The valid values are
7371 * - 0 - do not permute.
7372 * - 1 - permute cells.
7373 * - 2 - permute nodes.
7374 * - 3 - permute cells and nodes.
7376 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7377 * caller is to delete this field using decrRef() as it is no more needed.
7378 * \throw If no field of \a this is lying on \a mesh.
7379 * \throw If the mesh is empty.
7380 * \throw If no field values of the given \a type are available.
7381 * \sa getFieldAtLevel()
7382 * \sa getFieldOnMeshAtLevel()
7384 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
7386 MCAuto<DataArray> arrOut;
7387 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
7388 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7393 * Returns a new MEDCouplingFieldInt of a given type lying on a given support.
7394 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7395 * \param [in] type - a spatial discretization of interest.
7396 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7397 * \param [in] mesh - the supporting mesh.
7398 * \param [in] renumPol - specifies how to permute values of the result field according to
7399 * the optional numbers of cells and nodes, if any. The valid values are
7400 * - 0 - do not permute.
7401 * - 1 - permute cells.
7402 * - 2 - permute nodes.
7403 * - 3 - permute cells and nodes.
7405 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7406 * caller is to delete this field using decrRef() as it is no more needed.
7407 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7408 * \throw If no field of \a this is lying on \a mesh.
7409 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7410 * \sa getFieldAtLevel()
7411 * \sa getFieldOnMeshAtLevel()
7413 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
7415 MCAuto<DataArray> arrOut;
7416 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
7417 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7422 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
7423 * This method is called "Old" because in MED3 norm a field has only one meshName
7424 * attached, so this method is for readers of MED2 files. If \a this field
7425 * has not been constructed via file reading, an exception is thrown.
7426 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7427 * \param [in] type - a spatial discretization of interest.
7428 * \param [in] mName - a name of the supporting mesh.
7429 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7430 * \param [in] renumPol - specifies how to permute values of the result field according to
7431 * the optional numbers of cells and nodes, if any. The valid values are
7432 * - 0 - do not permute.
7433 * - 1 - permute cells.
7434 * - 2 - permute nodes.
7435 * - 3 - permute cells and nodes.
7437 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7438 * caller is to delete this field using decrRef() as it is no more needed.
7439 * \throw If the MED file is not readable.
7440 * \throw If there is no mesh named \a mName in the MED file.
7441 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7442 * \throw If \a this field has not been constructed via file reading.
7443 * \throw If no field of \a this is lying on the mesh named \a mName.
7444 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7445 * \sa getFieldAtLevel()
7447 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
7449 if(getFileName().empty())
7450 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7451 MCAuto<DataArray> arrOut;
7452 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
7453 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7457 //= MEDFileFloatField1TS
7459 MEDFileFloatField1TS::MEDFileFloatField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
7460 try:MEDFileTemplateField1TS<float>(fid,loadAll,ms)
7463 catch(INTERP_KERNEL::Exception& e)
7466 MEDFileFloatField1TS::MEDFileFloatField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
7467 try:MEDFileTemplateField1TS<float>(fid,fieldName,loadAll,ms)
7470 catch(INTERP_KERNEL::Exception& e)
7473 MEDFileFloatField1TS::MEDFileFloatField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
7474 try:MEDFileTemplateField1TS<float>(fid,fieldName,iteration,order,loadAll,ms)
7477 catch(INTERP_KERNEL::Exception& e)
7480 //= MEDFileFloatField1TS
7482 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
7484 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
7488 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName):MEDFileFieldNameScope(fieldName,meshName)
7493 * \param [in] fieldId field id in C mode
7495 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7497 med_field_type typcha;
7498 std::string dtunitOut,meshName;
7499 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fieldId,false,_name,typcha,_infos,dtunitOut,meshName));
7500 setMeshName(meshName);
7501 setDtUnit(dtunitOut.c_str());
7502 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities);
7505 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7506 try:MEDFileFieldNameScope(fieldName,meshName),_infos(infos)
7508 setDtUnit(dtunit.c_str());
7509 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities);
7511 catch(INTERP_KERNEL::Exception& e)
7516 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
7518 std::size_t ret(_mesh_name.capacity()+_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MCAuto<MEDFileField1TSWithoutSDA>));
7519 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7520 ret+=(*it).capacity();
7524 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
7526 std::vector<const BigMemoryObject *> ret;
7527 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7528 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
7533 * 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
7536 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
7538 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7539 ret->setInfo(_infos);
7540 int sz=(int)_time_steps.size();
7541 for(const int *id=startIds;id!=endIds;id++)
7543 if(*id>=0 && *id<sz)
7545 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
7546 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7550 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7552 ret->pushBackTimeStep(tse2);
7556 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
7557 oss << " ! Should be in [0," << sz << ") !";
7558 throw INTERP_KERNEL::Exception(oss.str());
7561 if(ret->getNumberOfTS()>0)
7562 ret->synchronizeNameScope();
7563 ret->copyNameScope(*this);
7568 * 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
7571 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
7573 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
7574 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7575 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7576 ret->setInfo(_infos);
7577 int sz=(int)_time_steps.size();
7579 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
7583 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
7584 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7588 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7590 ret->pushBackTimeStep(tse2);
7594 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
7595 oss << " ! Should be in [0," << sz << ") !";
7596 throw INTERP_KERNEL::Exception(oss.str());
7599 if(ret->getNumberOfTS()>0)
7600 ret->synchronizeNameScope();
7601 ret->copyNameScope(*this);
7605 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7608 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7609 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7611 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7614 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7615 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
7616 ids->pushBackSilent(id);
7618 return buildFromTimeStepIds(ids->begin(),ids->end());
7621 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7624 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7625 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7627 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7630 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7631 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
7632 ids->pushBackSilent(id);
7634 return buildFromTimeStepIds(ids->begin(),ids->end());
7637 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfStructureElements() const
7639 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7640 if((*it).isNotNull())
7641 if((*it)->presenceOfStructureElements())
7646 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::onlyStructureElements() const
7648 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7649 if((*it).isNotNull())
7650 if(!(*it)->onlyStructureElements())
7655 void MEDFileAnyTypeFieldMultiTSWithoutSDA::killStructureElements()
7657 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
7658 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7659 if((*it).isNotNull())
7661 if((*it)->presenceOfStructureElements())
7663 if(!(*it)->onlyStructureElements())
7665 (*it)->killStructureElements();
7677 void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyStructureElements()
7679 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
7680 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7681 if((*it).isNotNull())
7683 if((*it)->presenceOfStructureElements())
7685 if(!(*it)->onlyStructureElements())
7686 (*it)->keepOnlyStructureElements();
7693 void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyOnSE(const std::string& seName)
7695 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
7696 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7697 if((*it).isNotNull())
7698 (*it)->keepOnlyOnSE(seName);
7701 void MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
7703 std::vector< std::pair<std::string,std::string> > ps2;
7704 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7705 if((*it).isNotNull())
7707 (*it)->getMeshSENames(ps2);
7711 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames : this appears to not contain SE only !");
7712 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7713 if((*it).isNotNull())
7715 std::vector< std::pair<std::string,std::string> > ps3;
7716 (*it)->getMeshSENames(ps3);
7718 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames : For the moment only homogeneous SE def through time managed !");
7720 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=ps2.begin();it!=ps2.end();it++)
7722 std::vector< std::pair<std::string,std::string> >::iterator it2(std::find(ps.begin(),ps.end(),*it));
7728 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
7730 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7732 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7735 if(cur->presenceOfMultiDiscPerGeoType())
7741 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
7746 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
7751 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
7754 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7756 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
7757 if(pt->isDealingTS(iteration,order))
7760 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
7761 std::vector< std::pair<int,int> > vp=getIterations();
7762 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
7763 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
7764 throw INTERP_KERNEL::Exception(oss.str());
7767 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
7769 return *_time_steps[getTimeStepPos(iteration,order)];
7772 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
7774 return *_time_steps[getTimeStepPos(iteration,order)];
7777 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
7780 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
7782 if((*it).first==getMeshName())
7784 setMeshName((*it).second);
7788 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7790 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7792 ret=cur->changeMeshNames(modifTab) || ret;
7798 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
7800 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
7802 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
7806 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
7808 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7810 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
7813 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
7814 MEDFileFieldGlobsReal& glob)
7817 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7819 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
7821 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
7826 void MEDFileAnyTypeFieldMultiTSWithoutSDA::accept(MEDFileFieldVisitor& visitor) const
7828 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7829 if((*it).isNotNull())
7831 visitor.newTimeStepEntry(*it);
7832 (*it)->accept(visitor);
7833 visitor.endTimeStepEntry(*it);
7837 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7839 std::string startLine(bkOffset,' ');
7840 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
7842 oss << " (" << fmtsId << ")";
7843 oss << " has the following name: \"" << _name << "\"." << std::endl;
7844 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
7845 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7847 oss << startLine << " - \"" << *it << "\"" << std::endl;
7850 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7852 std::string chapter(17,'0'+i);
7853 oss << startLine << chapter << std::endl;
7854 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7856 cur->simpleRepr(bkOffset+2,oss,i);
7858 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
7859 oss << startLine << chapter << std::endl;
7863 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
7865 std::size_t sz=_time_steps.size();
7866 std::vector< std::pair<int,int> > ret(sz);
7868 for(std::size_t i=0;i<sz;i++)
7870 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
7873 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
7877 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
7878 throw INTERP_KERNEL::Exception(oss.str());
7884 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MCAuto<MEDFileAnyTypeField1TSWithoutSDA>& tse)
7886 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
7888 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
7889 checkCoherencyOfType(tse2);
7890 if(_time_steps.empty())
7892 setName(tse2->getName());
7893 setMeshName(tse2->getMeshName());
7894 setInfo(tse2->getInfo());
7896 checkThatComponentsMatch(tse2->getInfo());
7897 if(getDtUnit().empty() && !tse->getDtUnit().empty())
7898 setDtUnit(tse->getDtUnit());
7899 _time_steps.push_back(tse);
7902 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
7904 std::size_t nbOfCompo=_infos.size();
7905 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7907 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7910 if((cur->getInfo()).size()!=nbOfCompo)
7912 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
7913 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
7914 throw INTERP_KERNEL::Exception(oss.str());
7916 cur->copyNameScope(*this);
7921 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7923 _time_steps.resize(nbPdt);
7924 for(int i=0;i<nbPdt;i++)
7926 std::vector< std::pair<int,int> > ts;
7927 med_int numdt=0,numo=0;
7929 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt));
7934 _time_steps[i]=MEDFileField1TSWithoutSDA::New(getName(),getMeshName(),i+1,numdt,numo,_infos);
7939 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(getName(),getMeshName(),i+1,numdt,numo,_infos);
7943 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
7946 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities);
7948 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entities);
7949 synchronizeNameScope();
7953 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
7955 if(_time_steps.empty())
7956 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
7957 checkThatNbOfCompoOfTSMatchThis();
7958 std::vector<std::string> infos(getInfo());
7959 int nbComp=infos.size();
7960 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7961 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7962 for(int i=0;i<nbComp;i++)
7964 std::string info=infos[i];
7966 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7967 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7968 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7971 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7972 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
7973 int nbOfTS=_time_steps.size();
7974 for(int i=0;i<nbOfTS;i++)
7975 _time_steps[i]->writeLL(fid,opts,*this);
7978 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
7980 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7982 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7984 elt->loadBigArraysRecursively(fid,nasc);
7988 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
7990 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7992 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7994 elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7998 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
8000 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8002 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
8004 elt->unloadArrays();
8008 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
8010 return _time_steps.size();
8013 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
8015 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
8016 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8018 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
8020 newTS.push_back(*it);
8025 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
8027 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
8028 int maxId=(int)_time_steps.size();
8030 std::set<int> idsToDel;
8031 for(const int *id=startIds;id!=endIds;id++,ii++)
8033 if(*id>=0 && *id<maxId)
8035 idsToDel.insert(*id);
8039 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
8040 throw INTERP_KERNEL::Exception(oss.str());
8043 for(int iii=0;iii<maxId;iii++)
8044 if(idsToDel.find(iii)==idsToDel.end())
8045 newTS.push_back(_time_steps[iii]);
8049 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
8051 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
8052 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
8053 if(nbOfEntriesToKill==0)
8055 std::size_t sz=_time_steps.size();
8056 std::vector<bool> b(sz,true);
8058 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
8060 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
8061 for(std::size_t i=0;i<sz;i++)
8063 newTS.push_back(_time_steps[i]);
8067 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
8070 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
8071 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
8073 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
8077 tmp->getTime(it2,ord);
8078 if(it2==iteration && order==ord)
8081 oss << "(" << it2 << "," << ord << "), ";
8084 throw INTERP_KERNEL::Exception(oss.str());
8087 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
8090 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
8092 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
8094 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
8098 double ti=tmp->getTime(it2,ord);
8099 if(fabs(time-ti)<eps)
8105 throw INTERP_KERNEL::Exception(oss.str());
8108 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
8110 int lgth=_time_steps.size();
8111 std::vector< std::pair<int,int> > ret(lgth);
8112 for(int i=0;i<lgth;i++)
8113 _time_steps[i]->fillIteration(ret[i]);
8118 * 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'
8119 * This method returns two things.
8120 * - The absolute dimension of 'this' in first parameter.
8121 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
8122 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
8124 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
8125 * Only these 3 discretizations will be taken into account here.
8127 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
8128 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
8129 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
8131 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
8132 * 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'.
8134 * Let's consider the typical following case :
8135 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
8136 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
8137 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
8139 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
8141 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
8143 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
8144 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
8145 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
8146 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
8148 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8150 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
8153 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
8155 if(pos<0 || pos>=(int)_time_steps.size())
8157 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
8158 throw INTERP_KERNEL::Exception(oss.str());
8160 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
8163 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
8164 oss << "\nTry to use following method eraseEmptyTS !";
8165 throw INTERP_KERNEL::Exception(oss.str());
8170 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
8172 if(pos<0 || pos>=(int)_time_steps.size())
8174 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
8175 throw INTERP_KERNEL::Exception(oss.str());
8177 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
8180 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
8181 oss << "\nTry to use following method eraseEmptyTS !";
8182 throw INTERP_KERNEL::Exception(oss.str());
8187 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
8189 std::vector<std::string> ret;
8190 std::set<std::string> ret2;
8191 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8193 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
8194 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
8195 if(ret2.find(*it2)==ret2.end())
8197 ret.push_back(*it2);
8204 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
8206 std::vector<std::string> ret;
8207 std::set<std::string> ret2;
8208 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8210 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
8211 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
8212 if(ret2.find(*it2)==ret2.end())
8214 ret.push_back(*it2);
8221 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
8223 std::vector<std::string> ret;
8224 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8226 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
8227 ret.insert(ret.end(),tmp.begin(),tmp.end());
8232 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
8234 std::vector<std::string> ret;
8235 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8237 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
8238 ret.insert(ret.end(),tmp.begin(),tmp.end());
8243 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8245 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8246 (*it)->changePflsRefsNamesGen2(mapOfModif);
8249 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8251 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8252 (*it)->changeLocsRefsNamesGen2(mapOfModif);
8255 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
8257 int lgth=_time_steps.size();
8258 std::vector< std::vector<TypeOfField> > ret(lgth);
8259 for(int i=0;i<lgth;i++)
8260 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
8265 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
8267 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
8269 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
8272 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCopy() const
8274 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
8276 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8278 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
8279 ret->_time_steps[i]=(*it)->deepCopy();
8284 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
8286 std::size_t sz(_infos.size()),sz2(_time_steps.size());
8287 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
8288 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
8289 for(std::size_t i=0;i<sz;i++)
8291 ret[i]=shallowCpy();
8292 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
8294 for(std::size_t i=0;i<sz2;i++)
8296 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
8299 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
8300 throw INTERP_KERNEL::Exception(oss.str());
8304 for(std::size_t i=0;i<sz;i++)
8305 for(std::size_t j=0;j<sz2;j++)
8306 ret[i]->_time_steps[j]=ts[j][i];
8311 * This method splits into discretization each time steps in \a this.
8312 * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
8314 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
8316 std::size_t sz(_time_steps.size());
8317 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
8318 for(std::size_t i=0;i<sz;i++)
8320 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
8323 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
8324 throw INTERP_KERNEL::Exception(oss.str());
8326 items[i]=timeStep->splitDiscretizations();
8329 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
8330 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
8331 std::vector< TypeOfField > types;
8332 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
8333 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
8335 std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
8337 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
8338 std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
8339 if(it2==types.end())
8340 types.push_back(ts[0]);
8342 ret.resize(types.size()); ret2.resize(types.size());
8343 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
8344 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
8346 TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
8347 std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
8348 ret2[pos].push_back(*it1);
8350 for(std::size_t i=0;i<types.size();i++)
8352 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
8353 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
8354 elt->pushBackTimeStep(*it1);//also updates infos in elt
8356 elt->MEDFileFieldNameScope::operator=(*this);
8362 * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
8364 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
8366 std::size_t sz(_time_steps.size());
8367 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
8368 std::size_t szOut(std::numeric_limits<std::size_t>::max());
8369 for(std::size_t i=0;i<sz;i++)
8371 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
8374 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
8375 throw INTERP_KERNEL::Exception(oss.str());
8377 items[i]=timeStep->splitMultiDiscrPerGeoTypes();
8378 if(szOut==std::numeric_limits<std::size_t>::max())
8379 szOut=items[i].size();
8381 if(items[i].size()!=szOut)
8382 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
8384 if(szOut==std::numeric_limits<std::size_t>::max())
8385 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
8386 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
8387 for(std::size_t i=0;i<szOut;i++)
8389 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
8390 for(std::size_t j=0;j<sz;j++)
8391 elt->pushBackTimeStep(items[j][i]);
8393 elt->MEDFileFieldNameScope::operator=(*this);
8398 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
8400 setName(field->getName());
8401 if(field->getMesh())
8402 setMeshName(field->getMesh()->getName());
8404 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
8406 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
8407 _infos=arr->getInfoOnComponents();
8410 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
8412 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
8413 if(_name!=field->getName())
8415 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
8416 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
8417 throw INTERP_KERNEL::Exception(oss.str());
8420 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
8421 checkThatComponentsMatch(arr->getInfoOnComponents());
8424 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
8426 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
8427 if(getInfo().size()!=compos.size())
8429 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
8430 oss << " number of components of element to append (" << compos.size() << ") !";
8431 throw INTERP_KERNEL::Exception(oss.str());
8435 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
8436 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
8437 oss << " But compo in input fields are : ";
8438 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
8440 throw INTERP_KERNEL::Exception(oss.str());
8444 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
8446 std::size_t sz=_infos.size();
8448 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
8450 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
8452 if(elt->getInfo().size()!=sz)
8454 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
8455 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
8456 throw INTERP_KERNEL::Exception(oss.str());
8461 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
8464 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8465 if(!_time_steps.empty())
8466 checkCoherencyOfTinyInfo(field,arr);
8467 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8468 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8469 objC->setFieldNoProfileSBT(field,arr,glob,*this);
8470 copyTinyInfoFrom(field,arr);
8471 _time_steps.push_back(obj);
8474 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
8477 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8478 if(!_time_steps.empty())
8479 checkCoherencyOfTinyInfo(field,arr);
8480 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8481 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8482 objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
8483 copyTinyInfoFrom(field,arr);
8484 setMeshName(objC->getMeshName());
8485 _time_steps.push_back(obj);
8488 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ts)
8490 int sz=(int)_time_steps.size();
8493 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
8494 throw INTERP_KERNEL::Exception(oss.str());
8496 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
8499 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
8501 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
8502 throw INTERP_KERNEL::Exception(oss.str());
8508 //= MEDFileFieldMultiTSWithoutSDA
8510 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8512 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,meshName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8515 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
8519 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName,meshName)
8524 * \param [in] fieldId field id in C mode
8526 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8527 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8530 catch(INTERP_KERNEL::Exception& e)
8533 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8534 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,meshName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8537 catch(INTERP_KERNEL::Exception& e)
8540 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8542 return new MEDFileField1TSWithoutSDA;
8545 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8548 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8549 const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
8551 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8554 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const
8556 return MEDFileField1TSWithoutSDA::TYPE_STR;
8559 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const
8561 return new MEDFileFieldMultiTSWithoutSDA(*this);
8564 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const
8566 return new MEDFileFieldMultiTSWithoutSDA;
8570 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
8571 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
8573 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
8575 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
8576 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8578 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
8579 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
8582 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
8584 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
8585 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8587 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8589 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8592 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
8594 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
8595 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
8596 ret->setIteration(i,elt);
8602 //= MEDFileAnyTypeFieldMultiTS
8604 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
8608 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8609 try:MEDFileFieldGlobsReal(fid)
8611 _content=BuildContentFrom(fid,loadAll,ms);
8614 catch(INTERP_KERNEL::Exception& e)
8619 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8621 med_field_type typcha;
8622 std::vector<std::string> infos;
8624 std::string meshName;
8626 MEDFileAnyTypeField1TS::LocateField(fid,fieldName,i,typcha,infos,dtunit,meshName);
8627 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8632 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8637 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8642 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] !";
8643 throw INTERP_KERNEL::Exception(oss.str());
8646 ret->setMeshName(meshName);
8647 ret->setDtUnit(dtunit.c_str());
8651 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8653 med_field_type typcha;
8655 std::vector<std::string> infos;
8656 std::string dtunit,fieldName,meshName;
8657 MEDFileAnyTypeField1TS::LocateField2(fid,0,true,fieldName,typcha,infos,dtunit,meshName);
8658 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8663 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8668 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8673 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] !";
8674 throw INTERP_KERNEL::Exception(oss.str());
8677 ret->setMeshName(meshName);
8678 ret->setDtUnit(dtunit.c_str());
8682 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c)
8685 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
8686 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
8688 MCAuto<MEDFileFieldMultiTS> ret(MEDFileFieldMultiTS::New());
8689 ret->_content=c; c->incrRef();
8692 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
8694 MCAuto<MEDFileIntFieldMultiTS> ret(MEDFileIntFieldMultiTS::New());
8695 ret->_content=c; c->incrRef();
8698 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
8701 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, med_idt fid)
8703 MEDFileAnyTypeFieldMultiTS *ret(BuildNewInstanceFromContent(c));
8704 std::string fileName(FileNameFromFID(fid));
8705 ret->setFileName(fileName);
8709 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8710 try:MEDFileFieldGlobsReal(fid)
8712 _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
8715 catch(INTERP_KERNEL::Exception& e)
8720 //= MEDFileIntFieldMultiTSWithoutSDA
8722 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8724 return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,meshName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8727 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
8731 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName,meshName)
8735 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8736 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,meshName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8739 catch(INTERP_KERNEL::Exception& e)
8743 * \param [in] fieldId field id in C mode
8745 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8746 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8749 catch(INTERP_KERNEL::Exception& e)
8752 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8754 return new MEDFileIntField1TSWithoutSDA;
8757 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8760 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8761 const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
8763 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8766 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const
8768 return MEDFileIntField1TSWithoutSDA::TYPE_STR;
8771 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const
8773 return new MEDFileIntFieldMultiTSWithoutSDA(*this);
8776 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const
8778 return new MEDFileIntFieldMultiTSWithoutSDA;
8781 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const
8783 MCAuto<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
8784 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8786 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8788 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8791 const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
8793 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
8794 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
8795 ret->setIteration(i,elt);
8801 //= MEDFileAnyTypeFieldMultiTS
8804 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
8805 * that has been read from a specified MED file.
8806 * \param [in] fileName - the name of the MED file to read.
8807 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8808 * is to delete this field using decrRef() as it is no more needed.
8809 * \throw If reading the file fails.
8811 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
8813 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8814 return New(fid,loadAll);
8817 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, bool loadAll)
8819 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
8820 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8821 ret->loadGlobals(fid);
8826 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
8827 * that has been read from a specified MED file.
8828 * \param [in] fileName - the name of the MED file to read.
8829 * \param [in] fieldName - the name of the field to read.
8830 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8831 * is to delete this field using decrRef() as it is no more needed.
8832 * \throw If reading the file fails.
8833 * \throw If there is no field named \a fieldName in the file.
8835 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8837 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8838 return New(fid,fieldName,loadAll);
8841 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
8843 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
8844 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8845 ret->loadGlobals(fid);
8850 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8851 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8853 * \warning this is a shallow copy constructor
8855 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8857 if(!shallowCopyOfContent)
8859 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
8860 otherPtr->incrRef();
8861 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
8865 _content=other.shallowCpy();
8869 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
8871 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8873 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
8877 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
8879 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8881 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
8885 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
8887 return contentNotNullBase()->getPflsReallyUsed2();
8890 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
8892 return contentNotNullBase()->getLocsReallyUsed2();
8895 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
8897 return contentNotNullBase()->getPflsReallyUsedMulti2();
8900 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
8902 return contentNotNullBase()->getLocsReallyUsedMulti2();
8905 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8907 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
8910 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8912 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
8915 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
8917 return contentNotNullBase()->getNumberOfTS();
8920 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
8922 contentNotNullBase()->eraseEmptyTS();
8925 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
8927 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
8930 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
8932 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
8935 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
8937 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
8938 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8943 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
8945 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
8946 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8951 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
8953 return contentNotNullBase()->getIterations();
8956 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
8958 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
8959 pushBackTimeStep(*it);
8962 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
8965 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
8966 int nbOfTS(fmts->getNumberOfTS());
8967 for(int i=0;i<nbOfTS;i++)
8969 MCAuto<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
8970 pushBackTimeStep(elt);
8974 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
8977 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
8978 checkCoherencyOfType(f1ts);
8980 MCAuto<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
8981 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
8983 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
8984 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
8985 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
8986 _content->pushBackTimeStep(cSafe);
8987 appendGlobs(*f1ts,1e-12);
8990 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
8992 contentNotNullBase()->synchronizeNameScope();
8995 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
8997 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
9000 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
9002 return contentNotNullBase()->getPosGivenTime(time,eps);
9005 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
9007 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
9010 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
9012 return contentNotNullBase()->getTypesOfFieldAvailable();
9015 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
9017 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
9020 std::string MEDFileAnyTypeFieldMultiTS::getName() const
9022 return contentNotNullBase()->getName();
9025 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
9027 contentNotNullBase()->setName(name);
9030 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
9032 return contentNotNullBase()->getDtUnit();
9035 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
9037 contentNotNullBase()->setDtUnit(dtUnit);
9040 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
9042 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
9045 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
9047 return contentNotNullBase()->getTimeSteps(ret1);
9050 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
9052 return contentNotNullBase()->getMeshName();
9055 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
9057 contentNotNullBase()->setMeshName(newMeshName);
9060 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
9062 return contentNotNullBase()->changeMeshNames(modifTab);
9065 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
9067 return contentNotNullBase()->getInfo();
9070 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
9072 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
9075 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
9077 return contentNotNullBase()->setInfo(info);
9080 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
9082 const std::vector<std::string> ret=getInfo();
9083 return (int)ret.size();
9086 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
9088 writeGlobals(fid,*this);
9089 contentNotNullBase()->writeLL(fid,*this);
9093 * This method alloc the arrays and load potentially huge arrays contained in this field.
9094 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
9095 * This method can be also called to refresh or reinit values from a file.
9097 * \throw If the fileName is not set or points to a non readable MED file.
9099 void MEDFileAnyTypeFieldMultiTS::loadArrays()
9101 if(getFileName().empty())
9102 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
9103 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
9104 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
9108 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
9109 * But once data loaded once, this method does nothing.
9111 * \throw If the fileName is not set or points to a non readable MED file.
9112 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
9114 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
9116 if(!getFileName().empty())
9118 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
9119 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
9124 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
9125 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
9126 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
9128 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
9130 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
9132 contentNotNullBase()->unloadArrays();
9136 * 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.
9137 * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
9138 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
9140 * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
9142 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
9144 if(!getFileName().empty())
9145 contentNotNullBase()->unloadArrays();
9148 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
9150 std::ostringstream oss;
9151 contentNotNullBase()->simpleRepr(0,oss,-1);
9152 simpleReprGlobs(oss);
9156 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
9158 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
9161 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
9163 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
9164 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
9169 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
9170 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
9171 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
9173 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
9175 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9177 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
9178 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
9179 std::size_t sz(contentsSplit.size());
9180 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
9181 for(std::size_t i=0;i<sz;i++)
9183 ret[i]=shallowCpy();
9184 ret[i]->_content=contentsSplit[i];
9190 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
9191 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
9193 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
9195 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9197 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
9198 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
9199 std::size_t sz(contentsSplit.size());
9200 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
9201 for(std::size_t i=0;i<sz;i++)
9203 ret[i]=shallowCpy();
9204 ret[i]->_content=contentsSplit[i];
9210 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
9211 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
9213 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
9215 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9217 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
9218 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
9219 std::size_t sz(contentsSplit.size());
9220 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
9221 for(std::size_t i=0;i<sz;i++)
9223 ret[i]=shallowCpy();
9224 ret[i]->_content=contentsSplit[i];
9229 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCopy() const
9231 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
9232 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
9233 ret->_content=_content->deepCopy();
9234 ret->deepCpyGlobs(*this);
9238 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
9244 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
9245 * \param [in] iteration - the iteration number of a required time step.
9246 * \param [in] order - the iteration order number of required time step.
9247 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
9248 * delete this field using decrRef() as it is no more needed.
9249 * \throw If there is no required time step in \a this field.
9251 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
9253 int pos=getPosOfTimeStep(iteration,order);
9254 return getTimeStepAtPos(pos);
9258 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
9259 * \param [in] time - the time of the time step of interest.
9260 * \param [in] eps - a precision used to compare time values.
9261 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9262 * delete this field using decrRef() as it is no more needed.
9263 * \throw If there is no required time step in \a this field.
9265 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
9267 int pos=getPosGivenTime(time,eps);
9268 return getTimeStepAtPos(pos);
9272 * 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.
9273 * The float64 value of time attached to the pair of integers are not considered here.
9274 * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
9276 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
9277 * \throw If there is a null pointer in \a vectFMTS.
9279 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
9281 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
9282 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9283 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
9284 while(!lstFMTS.empty())
9286 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
9287 MEDFileAnyTypeFieldMultiTS *curIt(*it);
9289 throw INTERP_KERNEL::Exception(msg);
9290 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
9291 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
9292 elt.push_back(curIt); it=lstFMTS.erase(it);
9293 while(it!=lstFMTS.end())
9297 throw INTERP_KERNEL::Exception(msg);
9298 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
9300 { elt.push_back(curIt); it=lstFMTS.erase(it); }
9310 * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
9311 * All returned instances in a subvector can be safely loaded, rendered along time
9312 * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
9313 * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
9314 * 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).
9315 * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
9316 * 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.
9318 * \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().
9319 * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
9320 * \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.
9321 * \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.
9323 * \throw If an element in \a vectFMTS has not only one spatial discretization set.
9324 * \throw If an element in \a vectFMTS change of spatial discretization along time.
9325 * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
9326 * \thorw If some elements in \a vectFMTS do not have the same times steps.
9327 * \throw If mesh is null.
9328 * \throw If an element in \a vectFMTS is null.
9329 * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
9331 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& fsc)
9333 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
9335 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
9336 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9337 if(vectFMTS.empty())
9339 std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
9340 MEDFileAnyTypeFieldMultiTS *frstElt(*it);
9342 throw INTERP_KERNEL::Exception(msg);
9344 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
9345 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
9346 for(;it!=vectFMTS.end();it++,i++)
9349 throw INTERP_KERNEL::Exception(msg);
9350 TypeOfField tof0,tof1;
9351 if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
9354 vectFMTSNotNodes.push_back(*it);
9356 vectFMTSNodes.push_back(*it);
9359 vectFMTSNotNodes.push_back(*it);
9361 std::vector< MCAuto<MEDFileFastCellSupportComparator> > cmps;
9362 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
9364 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
9367 bool isFetched(false);
9368 for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
9371 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
9372 if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
9373 { ret[i].push_back(*it2); isFetched=true; }
9377 std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
9378 MCAuto<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
9379 ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
9387 * 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.
9388 * \param [out] cmps - same size than the returned vector.
9390 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& cmps)
9392 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9393 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
9394 while(!lstFMTS.empty())
9396 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
9397 MEDFileAnyTypeFieldMultiTS *ref(*it);
9398 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
9399 elt.push_back(ref); it=lstFMTS.erase(it);
9400 MCAuto<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
9401 MCAuto<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
9402 while(it!=lstFMTS.end())
9404 MEDFileAnyTypeFieldMultiTS *curIt(*it);
9405 if(cmp->isEqual(curIt))
9406 { elt.push_back(curIt); it=lstFMTS.erase(it); }
9410 ret.push_back(elt); cmps.push_back(cmp);
9416 * 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.
9417 * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
9419 * \throw If \a f0 or \a f1 has not only one spatial discretization set.
9420 * \throw If \a f0 or \a f1 change of spatial discretization along time.
9421 * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
9422 * \thorw If \a f0 and \a f1 do not have the same times steps.
9423 * \throw If mesh is null.
9424 * \throw If \a f0 or \a f1 is null.
9425 * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
9427 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
9430 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
9432 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
9433 if(f0->getMeshName()!=mesh->getName())
9435 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9436 throw INTERP_KERNEL::Exception(oss.str());
9438 if(f1->getMeshName()!=mesh->getName())
9440 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9441 throw INTERP_KERNEL::Exception(oss.str());
9443 int nts=f0->getNumberOfTS();
9444 if(nts!=f1->getNumberOfTS())
9445 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
9448 for(int i=0;i<nts;i++)
9450 MCAuto<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
9451 MCAuto<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
9452 std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
9453 if(tofs0.size()!=1 || tofs1.size()!=1)
9454 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
9457 if(tof0!=tofs0[0] || tof1!=tofs1[0])
9458 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
9461 { tof0=tofs0[0]; tof1=tofs1[0]; }
9462 if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
9464 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() << ") !";
9465 throw INTERP_KERNEL::Exception(oss.str());
9467 if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
9469 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() << ") !";
9470 throw INTERP_KERNEL::Exception(oss.str());
9472 if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
9474 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() << ") !";
9475 throw INTERP_KERNEL::Exception(oss.str());
9482 * Return an extraction of \a this using \a extractDef map to specify the extraction.
9483 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
9485 * \return A new object that the caller is responsible to deallocate.
9487 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
9490 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::extractPart : mesh is null !");
9491 MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(buildNewEmpty());
9492 int nbTS(getNumberOfTS());
9493 for(int i=0;i<nbTS;i++)
9495 MCAuto<MEDFileAnyTypeField1TS> f1ts(getTimeStepAtPos(i));
9496 MCAuto<MEDFileAnyTypeField1TS> f1tsOut(f1ts->extractPart(extractDef,mm));
9497 fmtsOut->pushBackTimeStep(f1tsOut);
9499 return fmtsOut.retn();
9503 MCAuto<MEDFileAnyTypeField1TS> AggregateHelperF1TS(const std::vector< typename MLFieldTraits<T>::F1TSType const *>& f1tss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9505 MCAuto< typename MLFieldTraits<T>::F1TSType > ret(MLFieldTraits<T>::F1TSType::New());
9507 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : empty vector !");
9508 std::size_t sz(f1tss.size()),i(0);
9509 std::vector< typename MLFieldTraits<T>::F1TSWSDAType const *> f1tsw(sz);
9510 for(typename std::vector< typename MLFieldTraits<T>::F1TSType const *>::const_iterator it=f1tss.begin();it!=f1tss.end();it++,i++)
9512 typename MLFieldTraits<T>::F1TSType const *elt(*it);
9514 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : presence of a null pointer !");
9515 f1tsw[i]=dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType const *>(elt->contentNotNullBase());
9517 typename MLFieldTraits<T>::F1TSWSDAType *retc(dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType *>(ret->contentNotNullBase()));
9519 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : internal error 1 !");
9520 retc->aggregate(f1tsw,dts);
9521 ret->setDtUnit(f1tss[0]->getDtUnit());
9522 return DynamicCast<typename MLFieldTraits<T>::F1TSType , MEDFileAnyTypeField1TS>(ret);
9526 MCAuto< MEDFileAnyTypeFieldMultiTS > AggregateHelperFMTS(const std::vector< typename MLFieldTraits<T>::FMTSType const *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9528 MCAuto< typename MLFieldTraits<T>::FMTSType > ret(MLFieldTraits<T>::FMTSType::New());
9530 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : empty vector !");
9531 std::size_t sz(fmtss.size());
9532 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9534 typename MLFieldTraits<T>::FMTSType const *elt(*it);
9536 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : presence of null pointer !");
9538 int nbTS(fmtss[0]->getNumberOfTS());
9539 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9540 if((*it)->getNumberOfTS()!=nbTS)
9541 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : all fields must have the same number of TS !");
9542 for(int iterTS=0;iterTS<nbTS;iterTS++)
9545 std::vector< typename MLFieldTraits<T>::F1TSType const *> f1tss(sz);
9546 std::vector< MCAuto<typename MLFieldTraits<T>::F1TSType> > f1tss2(sz);
9547 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++,i++)
9548 { f1tss2[i]=(*it)->getTimeStepAtPos(iterTS); f1tss[i]=f1tss2[i]; }
9549 MCAuto<MEDFileAnyTypeField1TS> f1ts(AggregateHelperF1TS<T>(f1tss,dts));
9550 ret->pushBackTimeStep(f1ts);
9551 ret->setDtUnit(f1ts->getDtUnit());
9553 return DynamicCast<typename MLFieldTraits<T>::FMTSType , MEDFileAnyTypeFieldMultiTS>(ret);
9557 * \a dts and \a ftmss are expected to have same size.
9559 MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileAnyTypeFieldMultiTS::Aggregate(const std::vector<const MEDFileAnyTypeFieldMultiTS *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9562 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : input vector is empty !");
9563 std::size_t sz(fmtss.size());
9564 std::vector<const MEDFileFieldMultiTS *> fmtss1;
9565 std::vector<const MEDFileIntFieldMultiTS *> fmtss2;
9566 for(std::vector<const MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9569 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : presence of null instance in input vector !");
9570 const MEDFileFieldMultiTS *elt1(dynamic_cast<const MEDFileFieldMultiTS *>(*it));
9573 fmtss1.push_back(elt1);
9576 const MEDFileIntFieldMultiTS *elt2(dynamic_cast<const MEDFileIntFieldMultiTS *>(*it));
9579 fmtss2.push_back(elt2);
9582 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not recognized type !");
9584 if(fmtss1.size()!=sz && fmtss2.size()!=sz)
9585 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : type of data is not homogeneous !");
9586 if(fmtss1.size()==sz)
9587 return AggregateHelperFMTS<double>(fmtss1,dts);
9588 if(fmtss2.size()!=sz)
9589 return AggregateHelperFMTS<int>(fmtss2,dts);
9590 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not implemented yet !");
9593 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
9595 return new MEDFileAnyTypeFieldMultiTSIterator(this);
9598 //= MEDFileFieldMultiTS
9601 * Returns a new empty instance of MEDFileFieldMultiTS.
9602 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9603 * is to delete this field using decrRef() as it is no more needed.
9605 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
9607 return new MEDFileFieldMultiTS;
9611 * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
9612 * that has been read from a specified MED file.
9613 * \param [in] fileName - the name of the MED file to read.
9614 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9615 * is to delete this field using decrRef() as it is no more needed.
9616 * \throw If reading the file fails.
9618 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll)
9620 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9621 return New(fid,loadAll);
9624 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, bool loadAll)
9626 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,loadAll,0));
9627 ret->contentNotNull();//to check that content type matches with \a this type.
9632 * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
9633 * that has been read from a specified MED file.
9634 * \param [in] fileName - the name of the MED file to read.
9635 * \param [in] fieldName - the name of the field to read.
9636 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9637 * is to delete this field using decrRef() as it is no more needed.
9638 * \throw If reading the file fails.
9639 * \throw If there is no field named \a fieldName in the file.
9641 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9643 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9644 return New(fid,fieldName,loadAll);
9647 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
9649 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0));
9650 ret->contentNotNull();//to check that content type matches with \a this type.
9655 * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9656 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9658 * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
9659 * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9660 * \warning this is a shallow copy constructor
9661 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
9662 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9663 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9664 * is to delete this field using decrRef() as it is no more needed.
9666 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9668 return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
9671 MEDFileFieldMultiTS *MEDFileFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9673 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9674 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
9675 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0,ent));
9676 ret->contentNotNull();//to check that content type matches with \a this type.
9680 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
9682 return new MEDFileFieldMultiTS(*this);
9685 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9688 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9689 const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
9691 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
9695 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
9696 * following the given input policy.
9698 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9699 * By default (true) the globals are deeply copied.
9700 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
9702 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
9704 MCAuto<MEDFileIntFieldMultiTS> ret;
9705 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9708 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
9710 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
9711 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
9712 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc));
9715 ret=MEDFileIntFieldMultiTS::New();
9717 ret->deepCpyGlobs(*this);
9719 ret->shallowCpyGlobs(*this);
9724 * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
9725 * \param [in] pos - a time step id.
9726 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9727 * delete this field using decrRef() as it is no more needed.
9728 * \throw If \a pos is not a valid time step id.
9730 MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const
9732 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9735 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9736 throw INTERP_KERNEL::Exception(oss.str());
9738 const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
9741 MCAuto<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
9742 ret->shallowCpyGlobs(*this);
9745 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
9746 throw INTERP_KERNEL::Exception(oss.str());
9750 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9751 * mesh entities of a given dimension of the first mesh in MED file.
9752 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9753 * \param [in] type - a spatial discretization of interest.
9754 * \param [in] iteration - the iteration number of a required time step.
9755 * \param [in] order - the iteration order number of required time step.
9756 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9757 * \param [in] renumPol - specifies how to permute values of the result field according to
9758 * the optional numbers of cells and nodes, if any. The valid values are
9759 * - 0 - do not permute.
9760 * - 1 - permute cells.
9761 * - 2 - permute nodes.
9762 * - 3 - permute cells and nodes.
9764 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9765 * caller is to delete this field using decrRef() as it is no more needed.
9766 * \throw If the MED file is not readable.
9767 * \throw If there is no mesh in the MED file.
9768 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9769 * \throw If no field values of the required parameters are available.
9771 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9773 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9774 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9776 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
9777 MCAuto<DataArray> arrOut;
9778 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9779 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9784 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9785 * the top level cells of the first mesh in MED file.
9786 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9787 * \param [in] type - a spatial discretization of interest.
9788 * \param [in] iteration - the iteration number of a required time step.
9789 * \param [in] order - the iteration order number of required time step.
9790 * \param [in] renumPol - specifies how to permute values of the result field according to
9791 * the optional numbers of cells and nodes, if any. The valid values are
9792 * - 0 - do not permute.
9793 * - 1 - permute cells.
9794 * - 2 - permute nodes.
9795 * - 3 - permute cells and nodes.
9797 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9798 * caller is to delete this field using decrRef() as it is no more needed.
9799 * \throw If the MED file is not readable.
9800 * \throw If there is no mesh in the MED file.
9801 * \throw If no field values of the required parameters are available.
9803 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9805 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9806 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9808 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
9809 MCAuto<DataArray> arrOut;
9810 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9811 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9816 * 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
9817 * method should be called (getFieldOnMeshAtLevel for example).
9818 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
9820 * \param [in] iteration - the iteration number of a required time step.
9821 * \param [in] order - the iteration order number of required time step.
9822 * \param [in] mesh - the mesh the field is lying on
9823 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9824 * caller is to delete this field using decrRef() as it is no more needed.
9826 MEDCouplingFieldDouble *MEDFileFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
9828 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9829 MCAuto<DataArray> arrOut;
9830 MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
9831 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9836 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9838 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9839 * \param [in] type - a spatial discretization of interest.
9840 * \param [in] iteration - the iteration number of a required time step.
9841 * \param [in] order - the iteration order number of required time step.
9842 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9843 * \param [in] mesh - the supporting mesh.
9844 * \param [in] renumPol - specifies how to permute values of the result field according to
9845 * the optional numbers of cells and nodes, if any. The valid values are
9846 * - 0 - do not permute.
9847 * - 1 - permute cells.
9848 * - 2 - permute nodes.
9849 * - 3 - permute cells and nodes.
9851 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9852 * caller is to delete this field using decrRef() as it is no more needed.
9853 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9854 * \throw If no field of \a this is lying on \a mesh.
9855 * \throw If no field values of the required parameters are available.
9857 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9859 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9860 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9862 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9863 MCAuto<DataArray> arrOut;
9864 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
9865 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9870 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9872 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9873 * \param [in] type - a spatial discretization of the new field.
9874 * \param [in] iteration - the iteration number of a required time step.
9875 * \param [in] order - the iteration order number of required time step.
9876 * \param [in] mesh - the supporting mesh.
9877 * \param [in] renumPol - specifies how to permute values of the result field according to
9878 * the optional numbers of cells and nodes, if any. The valid values are
9879 * - 0 - do not permute.
9880 * - 1 - permute cells.
9881 * - 2 - permute nodes.
9882 * - 3 - permute cells and nodes.
9884 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9885 * caller is to delete this field using decrRef() as it is no more needed.
9886 * \throw If no field of \a this is lying on \a mesh.
9887 * \throw If no field values of the required parameters are available.
9889 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
9891 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9892 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9894 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9895 MCAuto<DataArray> arrOut;
9896 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
9897 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9902 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
9903 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9904 * This method is useful for MED2 file format when field on different mesh was autorized.
9906 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
9908 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9909 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9911 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
9912 MCAuto<DataArray> arrOut;
9913 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
9914 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9919 * Returns values and a profile of the field of a given type, of a given time step,
9920 * lying on a given support.
9921 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9922 * \param [in] type - a spatial discretization of the field.
9923 * \param [in] iteration - the iteration number of a required time step.
9924 * \param [in] order - the iteration order number of required time step.
9925 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9926 * \param [in] mesh - the supporting mesh.
9927 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9928 * field of interest lies on. If the field lies on all entities of the given
9929 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9930 * using decrRef() as it is no more needed.
9931 * \param [in] glob - the global data storing profiles and localization.
9932 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
9933 * field. The caller is to delete this array using decrRef() as it is no more needed.
9934 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9935 * \throw If no field of \a this is lying on \a mesh.
9936 * \throw If no field values of the required parameters are available.
9938 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9940 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9941 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9943 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
9944 MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9945 return MEDFileField1TS::ReturnSafelyTypedDataArray(ret);
9948 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const
9950 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9952 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
9953 const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
9955 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 !");
9959 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull()
9961 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9963 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
9964 MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
9966 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 !");
9971 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9972 * the given field is checked if its elements are sorted suitable for writing to MED file
9973 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9974 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9975 * \param [in] field - the field to add to \a this.
9976 * \throw If the name of \a field is empty.
9977 * \throw If the data array of \a field is not set.
9978 * \throw If existing time steps have different name or number of components than \a field.
9979 * \throw If the underlying mesh of \a field has no name.
9980 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9982 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
9984 const DataArrayDouble *arr=0;
9986 arr=field->getArray();
9987 contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
9991 * Adds a MEDCouplingFieldDouble to \a this as another time step.
9992 * The mesh support of input parameter \a field is ignored here, it can be NULL.
9993 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9996 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9997 * A new profile is added only if no equal profile is missing.
9998 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9999 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
10000 * \param [in] mesh - the supporting mesh of \a field.
10001 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
10002 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
10003 * \throw If either \a field or \a mesh or \a profile has an empty name.
10004 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10005 * \throw If the data array of \a field is not set.
10006 * \throw If the data array of \a this is already allocated but has different number of
10007 * components than \a field.
10008 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
10009 * \sa setFieldNoProfileSBT()
10011 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
10013 const DataArrayDouble *arr=0;
10015 arr=field->getArray();
10016 contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
10019 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
10021 _content=new MEDFileFieldMultiTSWithoutSDA;
10024 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
10025 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
10028 catch(INTERP_KERNEL::Exception& e)
10031 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10032 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
10035 catch(INTERP_KERNEL::Exception& e)
10038 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
10042 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
10044 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
10047 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
10049 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
10052 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
10054 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
10057 MEDFileFieldMultiTS *MEDFileFieldMultiTS::buildNewEmpty() const
10059 return MEDFileFieldMultiTS::New();
10062 //= MEDFileAnyTypeFieldMultiTSIterator
10064 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
10069 _nb_iter=fmts->getNumberOfTS();
10073 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
10077 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
10079 if(_iter_id<_nb_iter)
10081 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
10083 return fmts->getTimeStepAtPos(_iter_id++);
10091 //= MEDFileIntFieldMultiTS
10094 * Returns a new empty instance of MEDFileFieldMultiTS.
10095 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
10096 * is to delete this field using decrRef() as it is no more needed.
10098 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
10100 return new MEDFileIntFieldMultiTS;
10104 * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
10105 * that has been read from a specified MED file.
10106 * \param [in] fileName - the name of the MED file to read.
10107 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
10108 * is to delete this field using decrRef() as it is no more needed.
10109 * \throw If reading the file fails.
10111 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll)
10113 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10114 return New(fid,loadAll);
10117 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, bool loadAll)
10119 MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,loadAll,0));
10120 ret->contentNotNull();//to check that content type matches with \a this type.
10125 * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
10126 * that has been read from a specified MED file.
10127 * \param [in] fileName - the name of the MED file to read.
10128 * \param [in] fieldName - the name of the field to read.
10129 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
10130 * is to delete this field using decrRef() as it is no more needed.
10131 * \throw If reading the file fails.
10132 * \throw If there is no field named \a fieldName in the file.
10134 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
10136 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10137 return New(fid,fieldName,loadAll);
10140 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
10142 MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0));
10143 ret->contentNotNull();//to check that content type matches with \a this type.
10148 * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
10149 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
10151 * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
10152 * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
10153 * \warning this is a shallow copy constructor
10154 * \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
10155 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
10156 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
10157 * is to delete this field using decrRef() as it is no more needed.
10159 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
10161 return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
10164 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
10166 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10167 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
10168 MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0,ent));
10169 ret->contentNotNull();//to check that content type matches with \a this type.
10174 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
10175 * following the given input policy.
10177 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
10178 * By default (true) the globals are deeply copied.
10179 * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
10181 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const
10183 MCAuto<MEDFileFieldMultiTS> ret;
10184 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
10187 const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
10189 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
10190 MCAuto<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
10191 ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc));
10194 ret=MEDFileFieldMultiTS::New();
10196 ret->deepCpyGlobs(*this);
10198 ret->shallowCpyGlobs(*this);
10202 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const
10204 return new MEDFileIntFieldMultiTS(*this);
10207 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
10210 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
10211 const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
10213 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
10217 * 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
10218 * method should be called (getFieldOnMeshAtLevel for example).
10219 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
10221 * \param [in] iteration - the iteration number of a required time step.
10222 * \param [in] order - the iteration order number of required time step.
10223 * \param [in] mesh - the mesh the field is lying on
10224 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
10225 * caller is to delete this field using decrRef() as it is no more needed.
10227 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
10229 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10230 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10232 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::field : mismatch of type of field expecting INT32 !");
10233 MCAuto<DataArray> arrOut;
10234 MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
10235 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arrOut));
10236 return ret2.retn();
10240 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
10241 * mesh entities of a given dimension of the first mesh in MED file.
10242 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10243 * \param [in] type - a spatial discretization of interest.
10244 * \param [in] iteration - the iteration number of a required time step.
10245 * \param [in] order - the iteration order number of required time step.
10246 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10247 * \param [in] renumPol - specifies how to permute values of the result field according to
10248 * the optional numbers of cells and nodes, if any. The valid values are
10249 * - 0 - do not permute.
10250 * - 1 - permute cells.
10251 * - 2 - permute nodes.
10252 * - 3 - permute cells and nodes.
10254 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10255 * caller is to delete this field using decrRef() as it is no more needed.
10256 * \throw If the MED file is not readable.
10257 * \throw If there is no mesh in the MED file.
10258 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
10259 * \throw If no field values of the required parameters are available.
10261 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
10263 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10264 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10266 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
10267 MCAuto<DataArray> arr;
10268 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase()));
10269 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10270 return ret2.retn();
10274 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
10275 * the top level cells of the first mesh in MED file.
10276 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10277 * \param [in] type - a spatial discretization of interest.
10278 * \param [in] iteration - the iteration number of a required time step.
10279 * \param [in] order - the iteration order number of required time step.
10280 * \param [in] renumPol - specifies how to permute values of the result field according to
10281 * the optional numbers of cells and nodes, if any. The valid values are
10282 * - 0 - do not permute.
10283 * - 1 - permute cells.
10284 * - 2 - permute nodes.
10285 * - 3 - permute cells and nodes.
10287 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10288 * caller is to delete this field using decrRef() as it is no more needed.
10289 * \throw If the MED file is not readable.
10290 * \throw If there is no mesh in the MED file.
10291 * \throw If no field values of the required parameters are available.
10293 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
10295 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10296 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10298 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
10299 MCAuto<DataArray> arr;
10300 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase()));
10301 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10302 return ret2.retn();
10306 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
10308 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10309 * \param [in] type - a spatial discretization of interest.
10310 * \param [in] iteration - the iteration number of a required time step.
10311 * \param [in] order - the iteration order number of required time step.
10312 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10313 * \param [in] mesh - the supporting mesh.
10314 * \param [in] renumPol - specifies how to permute values of the result field according to
10315 * the optional numbers of cells and nodes, if any. The valid values are
10316 * - 0 - do not permute.
10317 * - 1 - permute cells.
10318 * - 2 - permute nodes.
10319 * - 3 - permute cells and nodes.
10321 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10322 * caller is to delete this field using decrRef() as it is no more needed.
10323 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
10324 * \throw If no field of \a this is lying on \a mesh.
10325 * \throw If no field values of the required parameters are available.
10327 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
10329 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10330 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10332 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10333 MCAuto<DataArray> arr;
10334 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase()));
10335 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10336 return ret2.retn();
10340 * Returns a new MEDCouplingFieldInt of given type, of a given time step, lying on a
10342 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10343 * \param [in] type - a spatial discretization of the new field.
10344 * \param [in] iteration - the iteration number of a required time step.
10345 * \param [in] order - the iteration order number of required time step.
10346 * \param [in] mesh - the supporting mesh.
10347 * \param [out] arrOut - the DataArrayInt containing values of field.
10348 * \param [in] renumPol - specifies how to permute values of the result field according to
10349 * the optional numbers of cells and nodes, if any. The valid values are
10350 * - 0 - do not permute.
10351 * - 1 - permute cells.
10352 * - 2 - permute nodes.
10353 * - 3 - permute cells and nodes.
10355 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10356 * caller is to delete this field using decrRef() as it is no more needed.
10357 * \throw If no field of \a this is lying on \a mesh.
10358 * \throw If no field values of the required parameters are available.
10360 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
10362 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10363 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10365 throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10366 MCAuto<DataArray> arr;
10367 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase()));
10368 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10369 return ret2.retn();
10373 * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
10374 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
10375 * This method is useful for MED2 file format when field on different mesh was autorized.
10377 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol) const
10379 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10380 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10382 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10383 MCAuto<DataArray> arr;
10384 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase()));
10385 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10386 return ret2.retn();
10390 * Returns values and a profile of the field of a given type, of a given time step,
10391 * lying on a given support.
10392 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10393 * \param [in] type - a spatial discretization of the field.
10394 * \param [in] iteration - the iteration number of a required time step.
10395 * \param [in] order - the iteration order number of required time step.
10396 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10397 * \param [in] mesh - the supporting mesh.
10398 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
10399 * field of interest lies on. If the field lies on all entities of the given
10400 * dimension, all ids in \a pfl are zero. The caller is to delete this array
10401 * using decrRef() as it is no more needed.
10402 * \param [in] glob - the global data storing profiles and localization.
10403 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
10404 * field. The caller is to delete this array using decrRef() as it is no more needed.
10405 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10406 * \throw If no field of \a this is lying on \a mesh.
10407 * \throw If no field values of the required parameters are available.
10409 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
10411 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
10412 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
10414 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
10415 MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
10416 return MEDFileIntField1TS::ReturnSafelyTypedDataArray(ret);
10420 * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
10421 * \param [in] pos - a time step id.
10422 * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
10423 * delete this field using decrRef() as it is no more needed.
10424 * \throw If \a pos is not a valid time step id.
10426 MEDFileIntField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
10428 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
10431 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
10432 throw INTERP_KERNEL::Exception(oss.str());
10434 const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
10437 MCAuto<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
10438 ret->shallowCpyGlobs(*this);
10441 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
10442 throw INTERP_KERNEL::Exception(oss.str());
10446 * Adds a MEDCouplingFieldInt to \a this as another time step. The underlying mesh of
10447 * the given field is checked if its elements are sorted suitable for writing to MED file
10448 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
10449 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10450 * \param [in] field - the field to add to \a this.
10451 * \throw If the name of \a field is empty.
10452 * \throw If the data array of \a field is not set.
10453 * \throw If existing time steps have different name or number of components than \a field.
10454 * \throw If the underlying mesh of \a field has no name.
10455 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
10457 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldInt *field)
10459 MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
10460 contentNotNull()->appendFieldNoProfileSBT(field2,field->getArray(),*this);
10464 * Adds a MEDCouplingFieldDouble to \a this as another time step.
10465 * The mesh support of input parameter \a field is ignored here, it can be NULL.
10466 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
10469 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
10470 * A new profile is added only if no equal profile is missing.
10471 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10472 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
10473 * \param [in] arrOfVals - the values of the field \a field used.
10474 * \param [in] mesh - the supporting mesh of \a field.
10475 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
10476 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
10477 * \throw If either \a field or \a mesh or \a profile has an empty name.
10478 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10479 * \throw If the data array of \a field is not set.
10480 * \throw If the data array of \a this is already allocated but has different number of
10481 * components than \a field.
10482 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
10483 * \sa setFieldNoProfileSBT()
10485 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
10487 MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
10488 contentNotNull()->appendFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this);
10491 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const
10493 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10495 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
10496 const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10498 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 !");
10502 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull()
10504 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10506 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
10507 MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10509 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 !");
10513 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
10515 _content=new MEDFileIntFieldMultiTSWithoutSDA;
10518 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
10522 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
10523 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
10526 catch(INTERP_KERNEL::Exception& e)
10529 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10530 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
10533 catch(INTERP_KERNEL::Exception& e)
10536 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
10538 return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
10541 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::buildNewEmpty() const
10543 return MEDFileIntFieldMultiTS::New();
10548 MEDFileFields *MEDFileFields::New()
10550 return new MEDFileFields;
10553 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
10555 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10556 return New(fid,loadAll);
10559 MEDFileFields *MEDFileFields::NewAdv(const std::string& fileName, bool loadAll, const MEDFileEntities *entities)
10561 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10562 return NewAdv(fid,loadAll,entities);
10565 MEDFileFields *MEDFileFields::NewAdv(med_idt fid, bool loadAll, const MEDFileEntities *entities)
10567 return new MEDFileFields(fid,loadAll,0,entities);
10570 MEDFileFields *MEDFileFields::NewWithDynGT(const std::string& fileName, const MEDFileStructureElements *se, bool loadAll)
10572 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10573 return NewWithDynGT(fid,se,loadAll);
10576 MEDFileFields *MEDFileFields::NewWithDynGT(med_idt fid, const MEDFileStructureElements *se, bool loadAll)
10579 throw INTERP_KERNEL::Exception("MEDFileFields::NewWithDynGT : null struct element pointer !");
10580 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> entities(MEDFileEntities::BuildFrom(*se));
10581 return new MEDFileFields(fid,loadAll,0,entities);
10584 MEDFileFields *MEDFileFields::New(med_idt fid, bool loadAll)
10586 return new MEDFileFields(fid,loadAll,0,0);
10589 MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
10591 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10592 return new MEDFileFields(fid,loadAll,ms,0);
10595 MEDFileFields *MEDFileFields::LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
10597 MEDFileUtilities::CheckFileForRead(fileName);
10598 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
10599 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10600 return new MEDFileFields(fid,loadAll,0,ent);
10603 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
10605 std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
10606 ret+=_fields.capacity()*sizeof(MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
10610 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
10612 std::vector<const BigMemoryObject *> ret;
10613 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10614 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
10618 MEDFileFields *MEDFileFields::deepCopy() const
10620 MCAuto<MEDFileFields> ret(shallowCpy());
10622 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10624 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10625 ret->_fields[i]=(*it)->deepCopy();
10627 ret->deepCpyGlobs(*this);
10631 MEDFileFields *MEDFileFields::shallowCpy() const
10633 return new MEDFileFields(*this);
10637 * 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
10638 * 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.
10639 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
10641 * \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.
10642 * \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.
10644 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10646 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
10648 std::set< std::pair<int,int> > s;
10649 bool firstShot=true;
10650 areThereSomeForgottenTS=false;
10651 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10653 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10655 std::vector< std::pair<int,int> > v=(*it)->getIterations();
10656 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
10658 { s=s1; firstShot=false; }
10661 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
10663 areThereSomeForgottenTS=true;
10667 std::vector< std::pair<int,int> > ret;
10668 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
10672 int MEDFileFields::getNumberOfFields() const
10674 return _fields.size();
10677 std::vector<std::string> MEDFileFields::getFieldsNames() const
10679 std::vector<std::string> ret(_fields.size());
10681 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10683 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
10686 ret[i]=f->getName();
10690 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
10691 throw INTERP_KERNEL::Exception(oss.str());
10697 std::vector<std::string> MEDFileFields::getMeshesNames() const
10699 std::vector<std::string> ret;
10700 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10702 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10704 ret.push_back(cur->getMeshName());
10709 std::string MEDFileFields::simpleRepr() const
10711 std::ostringstream oss;
10712 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
10717 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
10719 int nbOfFields(getNumberOfFields());
10720 std::string startLine(bkOffset,' ');
10721 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
10723 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10725 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10728 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
10732 oss << startLine << " - not defined !" << std::endl;
10736 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10738 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10739 std::string chapter(17,'0'+i);
10740 oss << startLine << chapter << std::endl;
10743 cur->simpleRepr(bkOffset+2,oss,i);
10747 oss << startLine << " - not defined !" << std::endl;
10749 oss << startLine << chapter << std::endl;
10751 simpleReprGlobs(oss);
10754 MEDFileFields::MEDFileFields()
10758 MEDFileFields::MEDFileFields(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10759 try:MEDFileFieldGlobsReal(fid)
10761 int nbFields(MEDnField(fid));
10762 _fields.resize(nbFields);
10763 med_field_type typcha;
10764 for(int i=0;i<nbFields;i++)
10766 std::vector<std::string> infos;
10767 std::string fieldName,dtunit,meshName;
10768 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,i,false,fieldName,typcha,infos,dtunit,meshName));
10773 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName,meshName,typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10778 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName,meshName,typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10783 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] !";
10784 throw INTERP_KERNEL::Exception(oss.str());
10788 loadAllGlobals(fid,entities);
10790 catch(INTERP_KERNEL::Exception& e)
10795 void MEDFileFields::writeLL(med_idt fid) const
10798 writeGlobals(fid,*this);
10799 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10801 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
10804 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
10805 throw INTERP_KERNEL::Exception(oss.str());
10807 elt->writeLL(fid,*this);
10812 * This method alloc the arrays and load potentially huge arrays contained in this field.
10813 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
10814 * This method can be also called to refresh or reinit values from a file.
10816 * \throw If the fileName is not set or points to a non readable MED file.
10818 void MEDFileFields::loadArrays()
10820 if(getFileName().empty())
10821 throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
10822 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
10823 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10825 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10827 elt->loadBigArraysRecursively(fid,*elt);
10832 * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
10833 * But once data loaded once, this method does nothing.
10835 * \throw If the fileName is not set or points to a non readable MED file.
10836 * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
10838 void MEDFileFields::loadArraysIfNecessary()
10840 if(!getFileName().empty())
10842 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
10843 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10845 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10847 elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
10853 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
10854 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
10855 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
10857 * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
10859 void MEDFileFields::unloadArrays()
10861 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10863 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10865 elt->unloadArrays();
10870 * 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.
10871 * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
10872 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
10874 * \sa MEDFileFields::loadArraysIfNecessary
10876 void MEDFileFields::unloadArraysWithoutDataLoss()
10878 if(!getFileName().empty())
10882 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
10884 std::vector<std::string> ret;
10885 std::set<std::string> ret2;
10886 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10888 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
10889 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10890 if(ret2.find(*it2)==ret2.end())
10892 ret.push_back(*it2);
10899 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
10901 std::vector<std::string> ret;
10902 std::set<std::string> ret2;
10903 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10905 std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
10906 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10907 if(ret2.find(*it2)==ret2.end())
10909 ret.push_back(*it2);
10916 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
10918 std::vector<std::string> ret;
10919 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10921 std::vector<std::string> tmp((*it)->getPflsReallyUsedMulti2());
10922 ret.insert(ret.end(),tmp.begin(),tmp.end());
10927 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
10929 std::vector<std::string> ret;
10930 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10932 std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
10933 ret.insert(ret.end(),tmp.begin(),tmp.end());
10938 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10940 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10941 (*it)->changePflsRefsNamesGen2(mapOfModif);
10944 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10946 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10947 (*it)->changeLocsRefsNamesGen2(mapOfModif);
10950 void MEDFileFields::resize(int newSize)
10952 _fields.resize(newSize);
10955 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
10957 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
10961 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
10964 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
10965 _fields.push_back(field->getContent());
10966 appendGlobs(*field,1e-12);
10969 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
10972 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
10973 if(i>=(int)_fields.size())
10974 _fields.resize(i+1);
10975 _fields[i]=field->getContent();
10976 appendGlobs(*field,1e-12);
10979 void MEDFileFields::destroyFieldAtPos(int i)
10981 destroyFieldsAtPos(&i,&i+1);
10984 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
10986 std::vector<bool> b(_fields.size(),true);
10987 for(const int *i=startIds;i!=endIds;i++)
10989 if(*i<0 || *i>=(int)_fields.size())
10991 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10992 throw INTERP_KERNEL::Exception(oss.str());
10996 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10998 for(std::size_t i=0;i<_fields.size();i++)
11000 fields[j++]=_fields[i];
11004 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
11006 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
11007 int nbOfEntriesToKill(DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg));
11008 std::vector<bool> b(_fields.size(),true);
11010 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
11012 if(k<0 || k>=(int)_fields.size())
11014 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
11015 throw INTERP_KERNEL::Exception(oss.str());
11019 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
11021 for(std::size_t i=0;i<_fields.size();i++)
11023 fields[j++]=_fields[i];
11027 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
11030 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11032 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
11034 ret=cur->changeMeshNames(modifTab) || ret;
11040 * \param [in] meshName the name of the mesh that will be renumbered.
11041 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
11042 * This code corresponds to the distribution of types in the corresponding mesh.
11043 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
11044 * \param [in] renumO2N the old to new renumber array.
11045 * \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
11046 * field in \a this.
11048 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
11051 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11053 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
11056 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
11063 * Return an extraction of \a this using \a extractDef map to specify the extraction.
11064 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
11066 * \return A new object that the caller is responsible to deallocate.
11068 MEDFileFields *MEDFileFields::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
11071 throw INTERP_KERNEL::Exception("MEDFileFields::extractPart : input mesh is NULL !");
11072 MCAuto<MEDFileFields> fsOut(MEDFileFields::New());
11073 int nbFields(getNumberOfFields());
11074 for(int i=0;i<nbFields;i++)
11076 MCAuto<MEDFileAnyTypeFieldMultiTS> fmts(getFieldAtPos(i));
11079 std::ostringstream oss; oss << "MEDFileFields::extractPart : at pos #" << i << " field is null !";
11080 throw INTERP_KERNEL::Exception(oss.str());
11082 MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(fmts->extractPart(extractDef,mm));
11083 fsOut->pushField(fmtsOut);
11085 return fsOut.retn();
11088 void MEDFileFields::accept(MEDFileFieldVisitor& visitor) const
11090 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11091 if((*it).isNotNull())
11093 visitor.newFieldEntry(*it);
11094 (*it)->accept(visitor);
11095 visitor.endFieldEntry(*it);
11099 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
11101 if(i<0 || i>=(int)_fields.size())
11103 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
11104 throw INTERP_KERNEL::Exception(oss.str());
11106 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
11109 MCAuto<MEDFileAnyTypeFieldMultiTS> ret;
11110 const MEDFileFieldMultiTSWithoutSDA *fmtsC(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts));
11111 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts));
11113 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
11115 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
11118 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
11119 throw INTERP_KERNEL::Exception(oss.str());
11121 ret->shallowCpyGlobs(*this);
11126 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
11127 * This method is accessible in python using __getitem__ with a list in input.
11128 * \return a new object that the caller should deal with.
11130 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
11132 MCAuto<MEDFileFields> ret=shallowCpy();
11133 std::size_t sz=std::distance(startIds,endIds);
11134 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
11136 for(const int *i=startIds;i!=endIds;i++,j++)
11138 if(*i<0 || *i>=(int)_fields.size())
11140 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
11141 throw INTERP_KERNEL::Exception(oss.str());
11143 fields[j]=_fields[*i];
11145 ret->_fields=fields;
11149 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
11151 return getFieldAtPos(getPosFromFieldName(fieldName));
11155 * This method removes, if any, fields in \a this having no time steps.
11156 * 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.
11158 * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
11160 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
11162 std::vector<MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
11163 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11165 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
11168 if(elt->getNumberOfTS()>0)
11169 newFields.push_back(*it);
11172 if(_fields.size()==newFields.size())
11179 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
11180 * This method can be seen as a filter applied on \a this, that returns an object containing
11181 * 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
11182 * shallow copied from \a this.
11184 * \param [in] meshName - the name of the mesh on w
11185 * \return a new object that the caller should deal with.
11187 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
11189 MCAuto<MEDFileFields> ret(MEDFileFields::New());
11190 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11192 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
11195 if(cur->getMeshName()==meshName)
11198 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
11199 ret->_fields.push_back(cur2);
11202 ret->shallowCpyOnlyUsedGlobs(*this);
11207 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
11208 * Input time steps are specified using a pair of integer (iteration, order).
11209 * 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,
11210 * but for each multitimestep only the time steps in \a timeSteps are kept.
11211 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
11213 * The returned object points to shallow copy of elements in \a this.
11215 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
11216 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
11217 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
11219 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
11221 MCAuto<MEDFileFields> ret(MEDFileFields::New());
11222 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11224 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
11227 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
11228 ret->_fields.push_back(elt);
11230 ret->shallowCpyOnlyUsedGlobs(*this);
11235 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
11237 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
11239 MCAuto<MEDFileFields> ret=MEDFileFields::New();
11240 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11242 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
11245 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
11246 if(elt->getNumberOfTS()!=0)
11247 ret->_fields.push_back(elt);
11249 ret->shallowCpyOnlyUsedGlobs(*this);
11253 bool MEDFileFields::presenceOfStructureElements() const
11255 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11256 if((*it).isNotNull())
11257 if((*it)->presenceOfStructureElements())
11262 void MEDFileFields::killStructureElements()
11264 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
11265 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11266 if((*it).isNotNull())
11268 if((*it)->presenceOfStructureElements())
11270 if(!(*it)->onlyStructureElements())
11272 (*it)->killStructureElements();
11273 ret.push_back(*it);
11278 ret.push_back(*it);
11284 void MEDFileFields::keepOnlyStructureElements()
11286 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
11287 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11288 if((*it).isNotNull())
11290 if((*it)->presenceOfStructureElements())
11292 if(!(*it)->onlyStructureElements())
11293 (*it)->keepOnlyStructureElements();
11294 ret.push_back(*it);
11300 void MEDFileFields::keepOnlyOnMeshSE(const std::string& meshName, const std::string& seName)
11302 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
11303 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11304 if((*it).isNotNull())
11306 if((*it)->getMeshName()!=meshName)
11308 std::vector< std::pair<std::string,std::string> > ps;
11309 (*it)->getMeshSENames(ps);
11310 std::pair<std::string,std::string> p(meshName,seName);
11311 if(std::find(ps.begin(),ps.end(),p)!=ps.end())
11312 (*it)->keepOnlyOnSE(seName);
11313 ret.push_back(*it);
11318 void MEDFileFields::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
11320 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11321 if((*it).isNotNull())
11322 (*it)->getMeshSENames(ps);
11325 void MEDFileFields::blowUpSE(MEDFileMeshes *ms, const MEDFileStructureElements *ses)
11327 MEDFileBlowStrEltUp::DealWithSE(this,ms,ses);
11330 MCAuto<MEDFileFields> MEDFileFields::partOfThisOnStructureElements() const
11332 MCAuto<MEDFileFields> ret(deepCopy());
11333 ret->keepOnlyStructureElements();
11337 MCAuto<MEDFileFields> MEDFileFields::partOfThisLyingOnSpecifiedMeshSEName(const std::string& meshName, const std::string& seName) const
11339 MCAuto<MEDFileFields> ret(deepCopy());
11340 ret->keepOnlyOnMeshSE(meshName,seName);
11344 void MEDFileFields::aggregate(const MEDFileFields& other)
11346 int nbFieldsToAdd(other.getNumberOfFields());
11347 std::vector<std::string> fsn(getFieldsNames());
11348 for(int i=0;i<nbFieldsToAdd;i++)
11350 MCAuto<MEDFileAnyTypeFieldMultiTS> elt(other.getFieldAtPos(i));
11351 std::string name(elt->getName());
11352 if(std::find(fsn.begin(),fsn.end(),name)!=fsn.end())
11354 std::ostringstream oss; oss << "MEDFileFields::aggregate : name \"" << name << "\" already appears !";
11355 throw INTERP_KERNEL::Exception(oss.str());
11361 MEDFileFieldsIterator *MEDFileFields::iterator()
11363 return new MEDFileFieldsIterator(this);
11366 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
11368 std::string tmp(fieldName);
11369 std::vector<std::string> poss;
11370 for(std::size_t i=0;i<_fields.size();i++)
11372 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f(_fields[i]);
11375 std::string fname(f->getName());
11379 poss.push_back(fname);
11382 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
11383 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
11385 throw INTERP_KERNEL::Exception(oss.str());
11388 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
11393 _nb_iter=fs->getNumberOfFields();
11397 MEDFileFieldsIterator::~MEDFileFieldsIterator()
11401 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
11403 if(_iter_id<_nb_iter)
11405 MEDFileFields *fs(_fs);
11407 return fs->getFieldAtPos(_iter_id++);