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<double>;
50 const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64";
51 const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32";
53 MEDFileGTKeeper::~MEDFileGTKeeper()
57 MEDFileGTKeeper *MEDFileGTKeeperSta::deepCopy() const
59 return new MEDFileGTKeeperSta(_geo_type);
62 INTERP_KERNEL::NormalizedCellType MEDFileGTKeeperSta::getGeoType() const
67 std::string MEDFileGTKeeperSta::getRepr() const
69 return INTERP_KERNEL::CellModel::GetCellModel(_geo_type).getRepr();
72 bool MEDFileGTKeeperSta::isEqual(const MEDFileGTKeeper *other) const
74 const MEDFileGTKeeperSta *otherC(dynamic_cast<const MEDFileGTKeeperSta *>(other));
77 return _geo_type==otherC->_geo_type;
80 MEDFileGTKeeperDyn::MEDFileGTKeeperDyn(const MEDFileUMesh *mesh, const MEDFileUMesh *section, const MEDFileStructureElement *se):_mesh(mesh),_section(section),_se(se)
88 if(_mesh.isNull() || _section.isNull() || _se.isNull())
89 throw INTERP_KERNEL::Exception("MEDFileGTKeeperDyn constructor : null pointer not allowed !");
92 MEDFileGTKeeper *MEDFileGTKeeperDyn::deepCopy() const
94 return new MEDFileGTKeeperDyn(_mesh,_section,_se);
97 INTERP_KERNEL::NormalizedCellType MEDFileGTKeeperDyn::getGeoType() const
99 throw INTERP_KERNEL::Exception("MEDFileGTKeeperDyn::getGeoType : not valid !");
102 std::string MEDFileGTKeeperDyn::getRepr() const
104 std::ostringstream oss;
105 oss << _se->getDynGT();
109 bool MEDFileGTKeeperDyn::isEqual(const MEDFileGTKeeper *other) const
111 const MEDFileGTKeeperDyn *otherC(dynamic_cast<const MEDFileGTKeeperDyn *>(other));
117 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const std::string& locName)
119 return new MEDFileFieldLoc(fid,locName);
122 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, int id, const MEDFileEntities *entities)
124 return new MEDFileFieldLoc(fid,id,entities);
127 MEDFileFieldLoc *MEDFileFieldLoc::New(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
129 return new MEDFileFieldLoc(locName,geoType,refCoo,gsCoo,w);
132 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, const std::string& locName):_name(locName)
134 med_geometry_type geotype;
135 med_geometry_type sectiongeotype;
136 int nsectionmeshcell;
137 INTERP_KERNEL::AutoPtr<char> geointerpname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
138 INTERP_KERNEL::AutoPtr<char> sectionmeshname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
139 MEDlocalizationInfoByName(fid,locName.c_str(),&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
140 _gt=new MEDFileGTKeeperSta((INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype))));
141 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
142 _nb_node_per_cell=cm.getNumberOfNodes();
143 _ref_coo.resize(_dim*_nb_node_per_cell);
144 _gs_coo.resize(_dim*_nb_gauss_pt);
145 _w.resize(_nb_gauss_pt);
146 MEDlocalizationRd(fid,locName.c_str(),MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
149 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id, const MEDFileEntities *entities)
151 med_geometry_type geotype;
152 med_geometry_type sectiongeotype;
153 int nsectionmeshcell;
154 INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
155 INTERP_KERNEL::AutoPtr<char> geointerpname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
156 INTERP_KERNEL::AutoPtr<char> sectionmeshname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
157 MEDlocalizationInfo(fid,id+1,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
159 std::string sectionName(MEDLoaderBase::buildStringFromFortran(sectionmeshname,MED_NAME_SIZE));
160 if(sectionName.empty())
162 _gt=new MEDFileGTKeeperSta((INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype))));
163 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
164 _nb_node_per_cell=cm.getNumberOfNodes();
168 const MEDFileAllStaticEntitiesPlusDyn *entities2(dynamic_cast<const MEDFileAllStaticEntitiesPlusDyn *>(entities));
171 std::ostringstream oss; oss << "MEDFileFieldLoc cstr : for loc \"" << _name << "\" presence of non static type ! Expect entities !";
172 throw INTERP_KERNEL::Exception(oss.str());
174 const MEDFileStructureElement *se(entities2->getWithGT(geotype));
175 const MEDFileUMesh *um(entities2->getSupMeshWithName(se->getMeshName()));
176 const MEDFileUMesh *section(entities2->getSupMeshWithName(sectionName));
177 _gt=new MEDFileGTKeeperDyn(um,section,se);
180 MEDFILESAFECALLERWR0(MEDmeshGeotypeParameter,(fid,geotype,&dummy,&_nb_node_per_cell));
183 _ref_coo.resize(_dim*_nb_node_per_cell);
184 _gs_coo.resize(_dim*_nb_gauss_pt);
185 _w.resize(_nb_gauss_pt);
186 MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
189 MEDFileFieldLoc::MEDFileFieldLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType,
190 const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w):_name(locName),_gt(new MEDFileGTKeeperSta(geoType)),_ref_coo(refCoo),_gs_coo(gsCoo),_w(w)
192 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
193 _dim=cm.getDimension();
194 _nb_node_per_cell=cm.getNumberOfNodes();
195 _nb_gauss_pt=_w.size();
199 MEDFileFieldLoc::MEDFileFieldLoc(const MEDFileFieldLoc& other):_dim(other._dim),_nb_gauss_pt(other._nb_gauss_pt),_gt(other._gt->deepCopy()),_nb_node_per_cell(other._nb_node_per_cell),_name(other._name),_ref_coo(other._ref_coo),_gs_coo(other._gs_coo),_w(other._w)
203 MEDFileFieldLoc *MEDFileFieldLoc::deepCopy() const
205 return new MEDFileFieldLoc(*this);
208 bool MEDFileFieldLoc::isOnStructureElement() const
210 const MEDFileGTKeeper *gt(_gt);
212 throw INTERP_KERNEL::Exception("MEDFileFieldLoc::isOnStructureElement : null pointer !");
213 const MEDFileGTKeeperDyn *gt2(dynamic_cast<const MEDFileGTKeeperDyn *>(gt));
217 std::size_t MEDFileFieldLoc::getHeapMemorySizeWithoutChildren() const
219 return (_ref_coo.capacity()+_gs_coo.capacity()+_w.capacity())*sizeof(double)+_name.capacity();
222 std::vector<const BigMemoryObject *> MEDFileFieldLoc::getDirectChildrenWithNull() const
224 return std::vector<const BigMemoryObject *>();
227 void MEDFileFieldLoc::simpleRepr(std::ostream& oss) const
229 static const char OFF7[]="\n ";
230 oss << "\"" << _name << "\"" << OFF7;
231 oss << "GeoType=" << _gt->getRepr() << OFF7;
232 oss << "Dimension=" << _dim << OFF7;
233 oss << "Number of Gauss points=" << _nb_gauss_pt << OFF7;
234 oss << "Number of nodes per cell=" << _nb_node_per_cell << OFF7;
235 oss << "RefCoords="; std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
236 oss << "Weights="; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
237 oss << "GaussPtsCoords="; std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," ")); oss << std::endl;
240 void MEDFileFieldLoc::setName(const std::string& name)
245 bool MEDFileFieldLoc::isEqual(const MEDFileFieldLoc& other, double eps) const
247 if(_name!=other._name)
251 if(_nb_gauss_pt!=other._nb_gauss_pt)
253 if(_nb_node_per_cell!=other._nb_node_per_cell)
255 if(!_gt->isEqual(other._gt))
257 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_ref_coo,other._ref_coo,eps))
259 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_gs_coo,other._gs_coo,eps))
261 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_w,other._w,eps))
267 void MEDFileFieldLoc::writeLL(med_idt fid) const
269 MEDlocalizationWr(fid,_name.c_str(),typmai3[(int)getGeoType()],_dim,&_ref_coo[0],MED_FULL_INTERLACE,_nb_gauss_pt,&_gs_coo[0],&_w[0],MED_NO_INTERPOLATION,MED_NO_MESH_SUPPORT);
272 std::string MEDFileFieldLoc::repr() const
274 std::ostringstream oss; oss.precision(15);
275 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
276 oss << "Localization \"" << _name << "\" :\n" << " - Geometric Type : " << cm.getRepr();
277 oss << "\n - Dimension : " << _dim << "\n - Number of gauss points : ";
278 oss << _nb_gauss_pt << "\n - Number of nodes in cell : " << _nb_node_per_cell;
279 oss << "\n - Ref coords are : ";
280 int sz=_ref_coo.size();
283 int nbOfTuples=sz/_dim;
284 for(int i=0;i<nbOfTuples;i++)
287 for(int j=0;j<_dim;j++)
288 { oss << _ref_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
293 std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," "));
294 oss << "\n - Gauss coords in reference element : ";
298 int nbOfTuples=sz/_dim;
299 for(int i=0;i<nbOfTuples;i++)
302 for(int j=0;j<_dim;j++)
303 { oss << _gs_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
308 std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," "));
309 oss << "\n - Weights of Gauss coords are : "; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," "));
313 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
315 _type=field->getTypeOfField();
321 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,offset,offset+nbOfCells,1);
322 _end=_start+nbOfCells;
328 MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
329 const int *arrPtr=arr->getConstPointer();
330 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,arrPtr[offset],arrPtr[offset+nbOfCells],1);
331 _end=_start+(arrPtr[offset+nbOfCells]-arrPtr[offset]);
337 const MEDCouplingFieldDiscretization *disc(field->getDiscretization());
338 const MEDCouplingGaussLocalization& gsLoc(field->getGaussLocalization(_loc_id));
339 const MEDCouplingFieldDiscretizationGauss *disc2(dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc));
341 throw INTERP_KERNEL::Exception("assignFieldNoProfile : invalid call to this method ! Internal Error !");
342 const DataArrayInt *dai(disc2->getArrayOfDiscIds());
343 MCAuto<DataArrayInt> dai2(disc2->getOffsetArr(field->getMesh()));
344 const int *dai2Ptr(dai2->getConstPointer());
345 int nbi(gsLoc.getWeights().size());
346 MCAuto<DataArrayInt> da2(dai->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1));
347 MCAuto<DataArrayInt> da3(da2->findIdsEqual(_loc_id));
348 const int *da3Ptr(da3->getConstPointer());
349 if(da3->getNumberOfTuples()!=nbOfCells)
350 {//profile : for gauss even in NoProfile !!!
351 std::ostringstream oss; oss << "Pfl_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
353 da3->setName(_profile.c_str());
354 glob.appendProfile(da3);
356 MCAuto<DataArrayInt> da4(DataArrayInt::New());
357 _nval=da3->getNbOfElems();
358 da4->alloc(_nval*nbi,1);
359 int *da4Ptr(da4->getPointer());
360 for(int i=0;i<_nval;i++)
362 int ref=dai2Ptr[offset+da3Ptr[i]];
363 for(int j=0;j<nbi;j++)
366 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
367 _localization=oss2.str();
368 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,da4);
369 _end=_start+_nval*nbi;
370 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
374 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile : not implemented yet for such discretization type of field !");
380 * Leaf method of field with profile assignement. This method is the most general one. No optimization is done here.
381 * \param [in] pflName input containing name of profile if any. 0 if no profile (except for GAUSS_PT where a no profile can hide a profile when splitted by loc_id).
382 * \param [in] multiTypePfl is the end user profile specified in high level API
383 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
384 * \param [in] locIds is the profile needed to be created for MED file format. It can be null if all cells of current geometric type are fetched in \a multiTypePfl.
385 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
386 * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
388 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arrr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
391 _type=field->getTypeOfField();
392 std::string pflName(multiTypePfl->getName());
393 std::ostringstream oss; oss << pflName;
397 { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType()); oss << "_" << cm.getRepr(); }
404 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : existing profile with empty name !");
405 if(_type!=ON_GAUSS_PT)
407 locIds->setName(oss.str());
408 glob.appendProfile(locIds);
417 _nval=idsInPfl->getNumberOfTuples();
418 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,0,arrr->getNumberOfTuples(),1);
424 _nval=idsInPfl->getNumberOfTuples();
425 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,idsInPfl);
431 MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
432 MCAuto<DataArrayInt> arr2=arr->deltaShiftIndex();
433 MCAuto<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->begin(),multiTypePfl->end());
434 arr3->computeOffsetsFull();
435 MCAuto<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
436 int trueNval=tmp->getNumberOfTuples();
437 _nval=idsInPfl->getNumberOfTuples();
438 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
439 _end=_start+trueNval;
444 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(field->getDiscretization());
446 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
447 const DataArrayInt *da1=disc2->getArrayOfDiscIds();
448 const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
449 MCAuto<DataArrayInt> da2=da1->selectByTupleId(idsInPfl->begin(),idsInPfl->end());
450 MCAuto<DataArrayInt> da3=da2->findIdsEqual(_loc_id);
451 MCAuto<DataArrayInt> da4=idsInPfl->selectByTupleId(da3->begin(),da3->end());
453 MCAuto<MEDCouplingMesh> mesh2=mesh->buildPart(multiTypePfl->begin(),multiTypePfl->end());
454 MCAuto<DataArrayInt> arr=disc2->getOffsetArr(mesh2);
456 MCAuto<DataArrayInt> tmp=DataArrayInt::New();
458 for(const int *pt=da4->begin();pt!=da4->end();pt++)
459 trueNval+=arr->getIJ(*pt+1,0)-arr->getIJ(*pt,0);
460 tmp->alloc(trueNval,1);
461 int *tmpPtr=tmp->getPointer();
462 for(const int *pt=da4->begin();pt!=da4->end();pt++)
463 for(int j=arr->getIJ(*pt,0);j<arr->getIJ(*pt+1,0);j++)
466 _nval=da4->getNumberOfTuples();
467 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
468 _end=_start+trueNval;
469 oss << "_loc_" << _loc_id;
472 MCAuto<DataArrayInt> da5=locIds->selectByTupleId(da3->begin(),da3->end());
473 da5->setName(oss.str());
474 glob.appendProfile(da5);
479 if(!da3->isIota(nbOfEltsInWholeMesh))
481 da3->setName(oss.str());
482 glob.appendProfile(da3);
486 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
487 _localization=oss2.str();
488 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
492 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for such discretization type of field !");
497 void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob)
500 _nval=arrr->getNumberOfTuples();
501 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,0,_nval,1);
506 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int profileIt, const PartDefinition *pd)
508 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt,pd);
511 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int locId)
513 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string());
516 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(const MEDFileFieldPerMeshPerTypePerDisc& other)
518 return new MEDFileFieldPerMeshPerTypePerDisc(other);
521 std::size_t MEDFileFieldPerMeshPerTypePerDisc::getHeapMemorySizeWithoutChildren() const
523 return _profile.capacity()+_localization.capacity()+sizeof(MEDFileFieldPerMeshPerTypePerDisc);
526 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypePerDisc::getDirectChildrenWithNull() const
528 std::vector<const BigMemoryObject *> ret(1);
529 ret[0]=(const PartDefinition*)_pd;
533 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCopy(MEDFileFieldPerMeshPerTypeCommon *father) const
535 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret(new MEDFileFieldPerMeshPerTypePerDisc(*this));
540 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField atype, int profileIt, const PartDefinition *pd)
541 try:_type(atype),_father(fath),_profile_it(profileIt),_pd(const_cast<PartDefinition *>(pd))
546 catch(INTERP_KERNEL::Exception& e)
551 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
555 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(const MEDFileFieldPerMeshPerTypePerDisc& other):RefCountObject(other),_type(other._type),_father(0),_start(other._start),_end(other._end),_nval(other._nval),_profile(other._profile),_localization(other._localization),_loc_id(other._loc_id),_profile_it(other._profile_it),_pd(other._pd),_tmp_work1(other._tmp_work1)
559 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(0),_start(-std::numeric_limits<int>::max()),_end(-std::numeric_limits<int>::max()),
560 _nval(-std::numeric_limits<int>::max()),_loc_id(-std::numeric_limits<int>::max())
564 void MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile(med_idt fid, const std::string& fieldName, int nbOfCompo, int iteration, int order, med_entity_type menti, med_geometry_type mgeoti, unsigned char *startFeedingPtr)
566 const PartDefinition *pd(_pd);
569 INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
571 med_int nbValsInFile(MEDfieldnValueWithProfileByName(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile.c_str(),MED_COMPACT_PFLMODE,&tmp1,locname,&nbi));
572 if(_end-_start!=nbValsInFile*nbi)
574 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : The number of tuples to read is " << nbValsInFile << "*" << nbi << " (nb integration points) ! But in data structure it values " << _end-_start << " is expected !";
575 throw INTERP_KERNEL::Exception(oss.str());
577 MEDFILESAFECALLERRD0(MEDfieldValueWithProfileRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,_profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,startFeedingPtr));
581 if(!_profile.empty())
582 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : not implemented !");
583 INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)),locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
585 int overallNval(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
586 const SlicePartDefinition *spd(dynamic_cast<const SlicePartDefinition *>(pd));
590 spd->getSlice(start,stop,step);
591 int nbOfEltsToLoad(DataArray::GetNumberOfItemGivenBES(start,stop,step,"MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile"));
592 med_filter filter=MED_FILTER_INIT;
593 MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
594 MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
595 /*start*/start+1,/*stride*/step,/*count*/1,/*blocksize*/nbOfEltsToLoad,
596 /*lastblocksize=useless because count=1*/0,&filter);
597 MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,startFeedingPtr));
598 MEDfilterClose(&filter);
601 const DataArrayPartDefinition *dpd(dynamic_cast<const DataArrayPartDefinition *>(pd));
604 dpd->checkConsistencyLight();
605 MCAuto<DataArrayInt> myIds(dpd->toDAI());
606 int a(myIds->getMinValueInArray()),b(myIds->getMaxValueInArray());
607 myIds=myIds->deepCopy();// WARNING deep copy here because _pd is modified by applyLin !!!
608 myIds->applyLin(1,-a);
609 int nbOfEltsToLoad(b-a+1);
610 med_filter filter=MED_FILTER_INIT;
611 {//TODO : manage int32 !
612 MCAuto<DataArrayDouble> tmp(DataArrayDouble::New());
613 tmp->alloc(nbOfEltsToLoad,nbOfCompo);
614 MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
615 MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
616 /*start*/a+1,/*stride*/1,/*count*/1,/*blocksize*/nbOfEltsToLoad,
617 /*lastblocksize=useless because count=1*/0,&filter);
618 MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,reinterpret_cast<unsigned char *>(tmp->getPointer())));
619 MCAuto<DataArrayDouble> feeder(DataArrayDouble::New());
620 feeder->useExternalArrayWithRWAccess(reinterpret_cast<double *>(startFeedingPtr),_nval,nbOfCompo);
621 feeder->setContigPartOfSelectedValues(0,tmp,myIds);
623 MEDfilterClose(&filter);
626 throw INTERP_KERNEL::Exception("Not implemented yet for not slices!");
630 const MEDFileFieldPerMeshPerTypeCommon *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
635 void MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
637 INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
638 INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
639 std::string fieldName(nasc.getName()),meshName(getMeshName());
640 int iteration(getIteration()),order(getOrder()),profilesize,nbi;
641 TypeOfField type(getType());
642 med_geometry_type mgeoti;
643 med_entity_type menti;
644 _father->entriesForMEDfile(type,mgeoti,menti);
645 int zeNVal(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
646 _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
647 _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
648 const PartDefinition *pd(_pd);
655 if(!_profile.empty())
656 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively : profiles are not managed yet with part of def !");
657 _nval=pd->getNumberOfElems();
660 _end=start+_nval*nbi;
662 if(type==ON_CELLS && !_localization.empty())
664 if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
665 setType(ON_GAUSS_PT);
668 setType(ON_GAUSS_NE);
669 _localization.clear();
674 void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, const MEDFileFieldNameScope& nasc)
676 std::string fieldName(nasc.getName()),meshName(getMeshName());
677 int iteration(getIteration()),order(getOrder());
678 TypeOfField type(getType());
679 med_geometry_type mgeoti;
680 med_entity_type menti;
681 _father->entriesForMEDfile(type,mgeoti,menti);
683 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !");
686 DataArray *arr(getOrCreateAndGetArray());//arr is not null due to the spec of getOrCreateAndGetArray
687 if(_start<0 || _start>=arr->getNumberOfTuples())
689 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << ") !";
690 throw INTERP_KERNEL::Exception(oss.str());
692 if(_end<0 || _end>arr->getNumberOfTuples())
694 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !";
695 throw INTERP_KERNEL::Exception(oss.str());
697 int nbOfCompo(arr->getNumberOfComponents());
698 DataArrayDouble *arrD(dynamic_cast<DataArrayDouble *>(arr));
701 double *startFeeding(arrD->getPointer()+_start*nbOfCompo);
702 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
705 DataArrayInt *arrI(dynamic_cast<DataArrayInt *>(arr));
708 int *startFeeding(arrI->getPointer()+_start*nbOfCompo);
709 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
712 throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
716 * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
718 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart)
720 int delta=_end-_start;
721 _start=newValueOfStart;
725 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
727 return _father->getIteration();
730 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
732 return _father->getOrder();
735 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
737 return _father->getTime();
740 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
742 return _father->getMeshName();
745 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
747 const char startLine[]=" ## ";
748 std::string startLine2(bkOffset,' ');
749 startLine2+=startLine;
750 INTERP_KERNEL::AutoCppPtr<MEDCouplingFieldDiscretization> tmp(MEDCouplingFieldDiscretization::New(_type));
751 oss << startLine2 << "Localization #" << id << "." << std::endl;
752 oss << startLine2 << " Type=" << tmp->getRepr() << "." << std::endl;
753 oss << startLine2 << " This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
754 oss << startLine2 << " This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
755 oss << startLine2 << " This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
758 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
763 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
765 return _father->getGeoType();
768 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
773 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
778 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
780 return _father->getNumberOfComponents();
783 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
788 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray()
790 return _father->getOrCreateAndGetArray();
793 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const
795 const MEDFileFieldPerMeshPerTypeCommon *fath=_father;
796 return fath->getOrCreateAndGetArray();
799 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
801 return _father->getInfo();
804 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
809 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const std::string& newPflName)
814 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
816 return _localization;
819 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const std::string& newLocName)
821 _localization=newLocName;
824 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
826 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
828 if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
830 _profile=(*it2).second;
836 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
838 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
840 if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
842 _localization=(*it2).second;
848 void MEDFileFieldPerMeshPerTypePerDisc::getFieldAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
852 dads.push_back(std::pair<int,int>(_start,_end));
853 geoTypes.push_back(getGeoType());
858 pfls.push_back(glob->getProfile(_profile.c_str()));
860 if(_localization.empty())
864 locs.push_back(glob->getLocalizationId(_localization.c_str()));
868 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
870 entries[startEntryId]=std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int> ,std::pair<int,int> >(std::pair<INTERP_KERNEL::NormalizedCellType,int>(getGeoType(),discId),std::pair<int,int>(_start,_end));
874 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
876 TypeOfField type=getType();
877 INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
878 med_geometry_type mgeoti;
879 med_entity_type menti;
880 _father->entriesForMEDfile(getType(),mgeoti,menti);
881 const DataArray *arr(getOrCreateAndGetArray());
883 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
884 if(!arr->isAllocated())
885 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : the array to be written is not allocated !");
886 const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
887 const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
888 const unsigned char *locToWrite=0;
890 locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
892 locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
894 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
895 MEDFILESAFECALLERWR0(MEDfieldValueWithProfileWr,(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
896 MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
900 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const
905 dad.first=_start; dad.second=_end;
909 * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
910 * This code corresponds to the distribution of types in the corresponding mesh.
911 * \param [out] ptToFill memory zone where the output will be stored.
912 * \return the size of data pushed into output param \a ptToFill
914 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const
917 std::ostringstream oss;
918 std::size_t nbOfType=codeOfMesh.size()/3;
920 for(std::size_t i=0;i<nbOfType && found==-1;i++)
921 if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
925 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
926 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
927 throw INTERP_KERNEL::Exception(oss.str());
932 if(_nval!=codeOfMesh[3*found+1])
934 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
935 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
936 oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
937 throw INTERP_KERNEL::Exception(oss.str());
939 for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
944 const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
945 if(pfl->getNumberOfTuples()!=_nval)
947 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
948 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
950 oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
951 throw INTERP_KERNEL::Exception(oss.str());
953 int offset2=codeOfMesh[3*found+2];
954 for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
956 if(*pflId<codeOfMesh[3*found+1])
957 *work++=offset2+*pflId;
963 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const
965 for(int i=_start;i<_end;i++)
970 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId)
981 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
985 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
988 std::map<std::pair<std::string,TypeOfField>,int> m;
989 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
990 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
991 if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
992 m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
994 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
995 ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
1000 * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
1002 * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
1003 * \param [in] entriesOnSameDisc some entries **on same localization** if not the result can be invalid. The _start and _end on them are relative to \a arr parameter.
1004 * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
1005 * \param [in] newCode one of the input parameter to explicit the new geo type dispatch (in classical format same than those asked by MEDFileFields::renumberEntitiesLyingOnMesh)
1006 * \param [in,out] glob if necessary by the method, new profiles can be added to it
1007 * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
1008 * \param [out] result All new entries will be appended on it.
1009 * \return false if the configuration of renumbering leads to an unnecessary resplit of input \a entriesOnSameDisc. If not true is returned (the most general case !)
1011 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
1012 const DataArrayInt *explicitIdsInMesh,
1013 const std::vector<int>& newCode,
1014 MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
1015 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >& result)
1017 if(entriesOnSameDisc.empty())
1019 TypeOfField type=entriesOnSameDisc[0]->getType();
1020 int szEntities=0,szTuples=0;
1021 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
1022 { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
1023 int nbi=szTuples/szEntities;
1024 if(szTuples%szEntities!=0)
1025 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
1026 MCAuto<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
1027 MCAuto<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
1028 std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
1029 std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
1030 std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
1031 std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
1032 MCAuto<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
1034 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
1036 int startOfEltIdOfChunk=(*it)->_start;
1037 MCAuto<DataArrayInt> newEltIds=explicitIdsInMesh->subArray(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
1038 MCAuto<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
1039 MCAuto<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
1041 MCAuto<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
1042 newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
1044 newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
1045 newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
1047 MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
1048 MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
1049 MCAuto<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
1050 MCAuto<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
1052 MCAuto<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
1054 MCAuto<DataArrayDouble> arrPart=arr->subArray(offset,offset+szTuples);
1055 arrPart->renumberInPlace(renumTupleIds->begin());
1056 arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
1058 const int *idIt=diffVals->begin();
1059 std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
1061 for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
1063 MCAuto<DataArrayInt> ids=newGeoTypesEltIdsAllGather->findIdsEqual(*idIt);
1064 MCAuto<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
1065 int nbEntityElts=subIds->getNumberOfTuples();
1067 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
1068 NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIota(newCode[3*(*idIt)+1]),nbi,
1072 result.push_back(eltToAdd);
1073 offset2+=nbEntityElts*nbi;
1075 ret=ret || li.empty();
1080 * \param [in] typeF type of field of new chunk
1081 * \param [in] geoType the geometric type of the chunk
1082 * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
1083 * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
1084 * \param [in] nbi number of integration points
1085 * \param [in] offset The offset in the **global array of data**.
1086 * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
1087 * to the new chunk to create.
1088 * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
1089 * \param [out] notInExisting If false the return newly allocated entry is not coming from \a entriesOnSameDisc. If true the output comes from copy of \a entriesOnSameDisc
1090 * and corresponding entry erased from \a entriesOnSameDisc.
1091 * \return a newly allocated chunk
1093 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
1094 bool isPfl, int nbi, int offset,
1095 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
1096 MEDFileFieldGlobsReal& glob,
1097 bool ¬InExisting)
1099 int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
1100 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
1101 for(;it!=entriesOnSameDisc.end();it++)
1103 if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
1107 if((*it)->_profile.empty())
1110 if(!(*it)->_profile.empty())
1112 const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
1113 if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
1119 if(it==entriesOnSameDisc.end())
1122 MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
1124 ret->_loc_id=(int)geoType;
1125 ret->_nval=nbMeshEntities;
1127 ret->_end=ret->_start+ret->_nval*nbi;
1130 idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
1131 glob.appendProfile(idsOfMeshElt);
1132 ret->_profile=idsOfMeshElt->getName();
1134 //tony treatment of localization
1139 notInExisting=false;
1140 MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1141 ret->_loc_id=(int)geoType;
1142 ret->setNewStart(offset);
1143 entriesOnSameDisc.erase(it);
1149 ////////////////////////////////////
1151 MEDFileFieldPerMeshPerTypeCommon::~MEDFileFieldPerMeshPerTypeCommon()
1155 void MEDFileFieldPerMeshPerTypeCommon::setFather(MEDFileFieldPerMesh *father)
1160 void MEDFileFieldPerMeshPerTypeCommon::accept(MEDFileFieldVisitor& visitor) const
1162 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1163 if((*it).isNotNull())
1165 visitor.newPerMeshPerTypePerDisc(*it);
1169 void MEDFileFieldPerMeshPerTypeCommon::deepCopyElements()
1172 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1174 if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
1175 _field_pm_pt_pd[i]=(*it)->deepCopy(this);
1179 std::size_t MEDFileFieldPerMeshPerTypeCommon::getHeapMemorySizeWithoutChildren() const
1181 return _field_pm_pt_pd.capacity()*sizeof(MCAuto<MEDFileFieldPerMeshPerTypePerDisc>);
1184 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypeCommon::getDirectChildrenWithNull() const
1186 std::vector<const BigMemoryObject *> ret;
1187 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1188 ret.push_back((const MEDFileFieldPerMeshPerTypePerDisc *)*it);
1192 void MEDFileFieldPerMeshPerTypeCommon::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1194 std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
1195 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1196 _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1200 * This method is the most general one. No optimization is done here.
1201 * \param [in] multiTypePfl is the end user profile specified in high level API
1202 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1203 * \param [in] locIds is the profile needed to be created for MED file format. It can be null if all cells of current geometric type are fetched in \a multiTypePfl.
1204 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1205 * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1206 * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
1208 void MEDFileFieldPerMeshPerTypeCommon::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1210 std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1211 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1212 _field_pm_pt_pd[*it]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1215 void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1217 _field_pm_pt_pd.resize(1);
1218 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1219 _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1222 void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1224 MCAuto<DataArrayInt> pfl2=pfl->deepCopy();
1225 if(!arr || !arr->isAllocated())
1226 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile : input array is null, or not allocated !");
1227 _field_pm_pt_pd.resize(1);
1228 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1229 _field_pm_pt_pd[0]->assignFieldProfile(true,start,pfl,pfl2,pfl2,-1,field,arr,0,glob,nasc);//mesh is not requested so 0 is send.
1232 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1234 TypeOfField type=field->getTypeOfField();
1235 if(type!=ON_GAUSS_PT)
1237 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1238 int sz=_field_pm_pt_pd.size();
1240 for(int j=0;j<sz && !found;j++)
1242 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1244 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1250 _field_pm_pt_pd.resize(sz+1);
1251 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1253 std::vector<int> ret(1,(int)sz);
1258 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1259 int sz2=ret2.size();
1260 std::vector<int> ret3(sz2);
1262 for(int i=0;i<sz2;i++)
1264 int sz=_field_pm_pt_pd.size();
1265 int locIdToFind=ret2[i];
1267 for(int j=0;j<sz && !found;j++)
1269 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1271 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1278 _field_pm_pt_pd.resize(sz+1);
1279 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1287 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1289 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1290 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1292 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1293 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1295 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1296 MCAuto<DataArrayInt> da2=da->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1);
1297 MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1298 if(retTmp->presenceOfValue(-1))
1299 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1300 std::vector<int> ret(retTmp->begin(),retTmp->end());
1304 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1306 TypeOfField type=field->getTypeOfField();
1307 if(type!=ON_GAUSS_PT)
1309 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1310 int sz=_field_pm_pt_pd.size();
1312 for(int j=0;j<sz && !found;j++)
1314 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1316 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1322 _field_pm_pt_pd.resize(sz+1);
1323 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1325 std::vector<int> ret(1,0);
1330 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1331 int sz2=ret2.size();
1332 std::vector<int> ret3(sz2);
1334 for(int i=0;i<sz2;i++)
1336 int sz=_field_pm_pt_pd.size();
1337 int locIdToFind=ret2[i];
1339 for(int j=0;j<sz && !found;j++)
1341 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1343 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1350 _field_pm_pt_pd.resize(sz+1);
1351 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1359 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1361 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1362 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1364 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1365 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1367 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1368 MCAuto<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1369 MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1370 if(retTmp->presenceOfValue(-1))
1371 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1372 std::vector<int> ret(retTmp->begin(),retTmp->end());
1376 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerTypeCommon::getFather() const
1381 bool MEDFileFieldPerMeshPerTypeCommon::isUniqueLevel(int& dim) const
1383 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
1384 int curDim((int)cm.getDimension());
1385 if(dim!=std::numeric_limits<int>::max())
1395 void MEDFileFieldPerMeshPerTypeCommon::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1397 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1399 (*it)->fillTypesOfFieldAvailable(types);
1403 void MEDFileFieldPerMeshPerTypeCommon::fillFieldSplitedByType(std::vector< std::pair<int,int> >& dads, std::vector<TypeOfField>& types, std::vector<std::string>& pfls, std::vector<std::string>& locs) const
1405 int sz=_field_pm_pt_pd.size();
1406 dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1407 for(int i=0;i<sz;i++)
1409 _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1413 int MEDFileFieldPerMeshPerTypeCommon::getIteration() const
1415 return _father->getIteration();
1418 int MEDFileFieldPerMeshPerTypeCommon::getOrder() const
1420 return _father->getOrder();
1423 double MEDFileFieldPerMeshPerTypeCommon::getTime() const
1425 return _father->getTime();
1428 std::string MEDFileFieldPerMeshPerTypeCommon::getMeshName() const
1430 return _father->getMeshName();
1433 void MEDFileFieldPerMeshPerTypeCommon::getSizes(int& globalSz, int& nbOfEntries) const
1435 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1437 globalSz+=(*it)->getNumberOfTuples();
1439 nbOfEntries+=(int)_field_pm_pt_pd.size();
1442 int MEDFileFieldPerMeshPerTypeCommon::getNumberOfComponents() const
1444 return _father->getNumberOfComponents();
1447 bool MEDFileFieldPerMeshPerTypeCommon::presenceOfMultiDiscPerGeoType() const
1450 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1452 const MEDFileFieldPerMeshPerTypePerDisc *fmtd(*it);
1459 void MEDFileFieldPerMeshPerTypeCommon::pushDiscretization(MEDFileFieldPerMeshPerTypePerDisc *disc)
1461 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt;
1463 _field_pm_pt_pd.push_back(elt);
1466 DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray()
1468 return _father->getOrCreateAndGetArray();
1471 const DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray() const
1473 const MEDFileFieldPerMesh *fath=_father;
1474 return fath->getOrCreateAndGetArray();
1477 const std::vector<std::string>& MEDFileFieldPerMeshPerTypeCommon::getInfo() const
1479 return _father->getInfo();
1482 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsed() const
1484 std::vector<std::string> ret;
1485 std::set<std::string> ret2;
1486 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1488 std::string tmp=(*it1)->getProfile();
1490 if(ret2.find(tmp)==ret2.end())
1499 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsed() const
1501 std::vector<std::string> ret;
1502 std::set<std::string> ret2;
1503 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1505 std::string tmp=(*it1)->getLocalization();
1506 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1507 if(ret2.find(tmp)==ret2.end())
1516 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsedMulti() const
1518 std::vector<std::string> ret;
1519 std::set<std::string> ret2;
1520 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1522 std::string tmp=(*it1)->getProfile();
1529 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsedMulti() const
1531 std::vector<std::string> ret;
1532 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1534 std::string tmp=(*it1)->getLocalization();
1535 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1541 void MEDFileFieldPerMeshPerTypeCommon::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1543 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1544 (*it1)->changePflsRefsNamesGen(mapOfModif);
1547 void MEDFileFieldPerMeshPerTypeCommon::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1549 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1550 (*it1)->changeLocsRefsNamesGen(mapOfModif);
1553 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId)
1555 if(_field_pm_pt_pd.empty())
1557 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << getGeoTypeRepr() << "\" !";
1558 throw INTERP_KERNEL::Exception(oss.str());
1560 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1561 return _field_pm_pt_pd[locId];
1562 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
1563 oss2 << ") for geometric type \"" << getGeoTypeRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1564 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1565 return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1568 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId) const
1570 if(_field_pm_pt_pd.empty())
1572 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << getGeoTypeRepr() << "\" !";
1573 throw INTERP_KERNEL::Exception(oss.str());
1575 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1576 return _field_pm_pt_pd[locId];
1577 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
1578 oss2 << ") for geometric type \"" << getGeoTypeRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1579 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1580 return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1583 void MEDFileFieldPerMeshPerTypeCommon::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1586 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1588 (*it)->fillValues(i,startEntryId,entries);
1592 void MEDFileFieldPerMeshPerTypeCommon::setLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
1594 _field_pm_pt_pd=leaves;
1595 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1596 (*it)->setFather(this);
1600 * \param [in,out] globalNum a global numbering counter for the renumbering.
1601 * \param [out] its - list of pair (start,stop) kept
1602 * \return bool - false if the type of field \a tof is not contained in \a this.
1604 bool MEDFileFieldPerMeshPerTypeCommon::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
1607 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1608 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1609 if((*it)->getType()==tof)
1611 newPmPtPd.push_back(*it);
1612 std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1613 (*it)->setNewStart(globalNum);
1614 globalNum=(*it)->getEnd();
1615 its.push_back(bgEnd);
1619 _field_pm_pt_pd=newPmPtPd;
1624 * \param [in,out] globalNum a global numbering counter for the renumbering.
1625 * \param [out] its - list of pair (start,stop) kept
1626 * \return bool - false if the type of field \a tof is not contained in \a this.
1628 bool MEDFileFieldPerMeshPerTypeCommon::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
1630 if(_field_pm_pt_pd.size()<=idOfDisc)
1632 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt(_field_pm_pt_pd[idOfDisc]);
1633 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd(1,elt);
1634 std::pair<int,int> bgEnd; bgEnd.first=_field_pm_pt_pd[idOfDisc]->getStart(); bgEnd.second=_field_pm_pt_pd[idOfDisc]->getEnd();
1635 elt->setNewStart(globalNum);
1636 globalNum=elt->getEnd();
1637 its.push_back(bgEnd);
1638 _field_pm_pt_pd=newPmPtPd;
1642 void MEDFileFieldPerMeshPerTypeCommon::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
1644 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1645 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1648 void MEDFileFieldPerMeshPerTypeCommon::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1650 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1651 (*it)->loadBigArray(fid,nasc);
1654 void MEDFileFieldPerMeshPerTypeCommon::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1656 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1658 (*it)->copyOptionsFrom(*this);
1659 (*it)->writeLL(fid,nasc);
1663 med_entity_type MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1668 medfGeoType=typmai3[(int)ikGeoType];
1671 medfGeoType=MED_NONE;
1674 medfGeoType=typmai3[(int)ikGeoType];
1675 return MED_NODE_ELEMENT;
1677 medfGeoType=typmai3[(int)ikGeoType];
1680 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1682 return MED_UNDEF_ENTITY_TYPE;
1685 //////////////////////////////////////////////////
1687 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd)
1689 return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc,pd);
1692 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType)
1694 return new MEDFileFieldPerMeshPerType(fath,geoType);
1697 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCopy(MEDFileFieldPerMesh *father) const
1699 MCAuto<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
1700 ret->setFather(father);
1701 ret->deepCopyElements();
1705 void MEDFileFieldPerMeshPerType::getFieldAtLevel(int meshDim, TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
1707 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1709 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1710 if(meshDim!=(int)cm.getDimension())
1713 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1714 (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1717 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1722 void MEDFileFieldPerMeshPerType::entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const
1724 ent=MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(mct,_geo_type,gt);
1727 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1729 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1730 int curDim((int)cm.getDimension());
1731 dim=std::max(dim,curDim);
1734 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1736 const char startLine[]=" ## ";
1737 std::string startLine2(bkOffset,' ');
1738 std::string startLine3(startLine2);
1739 startLine3+=startLine;
1740 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1742 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1743 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1746 oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1747 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1749 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1751 const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1753 cur->simpleRepr(bkOffset,oss,i);
1756 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1761 std::string MEDFileFieldPerMeshPerType::getGeoTypeRepr() const
1763 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1764 return std::string(cm.getRepr());
1767 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *father, INTERP_KERNEL::NormalizedCellType gt):MEDFileFieldPerMeshPerTypeCommon(father),_geo_type(gt)
1771 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):MEDFileFieldPerMeshPerTypeCommon(fath),_geo_type(geoType)
1773 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1774 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1775 med_geometry_type mgeoti;
1776 med_entity_type menti(ConvertIntoMEDFileType(type,geoType,mgeoti));
1777 int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName));
1778 _field_pm_pt_pd.resize(nbProfiles);
1779 for(int i=0;i<nbProfiles;i++)
1781 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i,pd);
1785 int nbProfiles2(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName));
1786 for(int i=0;i<nbProfiles2;i++)
1787 _field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i,pd));
1791 MCAuto<MEDFileFieldPerMeshPerType> MEDFileFieldPerMeshPerType::Aggregate(int &start, const std::vector<std::pair<int,const MEDFileFieldPerMeshPerType *> >& pms, const std::vector< std::vector< std::pair<int,int> > >& dts, INTERP_KERNEL::NormalizedCellType gt, MEDFileFieldPerMesh *father, std::vector<std::pair< int, std::pair<int,int> > >& extractInfo)
1793 MCAuto<MEDFileFieldPerMeshPerType> ret(MEDFileFieldPerMeshPerType::New(father,gt));
1794 std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > > m;
1795 for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerType *> >::const_iterator it=pms.begin();it!=pms.end();it++)
1797 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it2=(*it).second->_field_pm_pt_pd.begin();it2!=(*it).second->_field_pm_pt_pd.end();it2++)
1798 m[(*it2)->getType()].push_back(std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * >((*it).first,*it2));
1800 for(std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > >::const_iterator it=m.begin();it!=m.end();it++)
1802 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> agg(MEDFileFieldPerMeshPerTypePerDisc::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
1803 ret->_field_pm_pt_pd.push_back(agg);
1808 //////////////////////////////////////////////////
1810 MEDFileFieldPerMeshPerTypeDyn *MEDFileFieldPerMeshPerTypeDyn::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileEntities *entities, int idGT, const MEDFileFieldNameScope& nasc)
1813 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeDyn::NewOnRead : null pointer !");
1814 const MEDFileAllStaticEntitiesPlusDyn *entities2(dynamic_cast<const MEDFileAllStaticEntitiesPlusDyn *>(entities));
1816 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeDyn::NewOnRead : invalid type of entities !");
1817 const MEDFileStructureElement *se(entities2->getWithGT(idGT));
1818 return new MEDFileFieldPerMeshPerTypeDyn(fid,fath,se,nasc);
1821 MEDFileFieldPerMeshPerTypeDyn::MEDFileFieldPerMeshPerTypeDyn(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileStructureElement *se, const MEDFileFieldNameScope& nasc):MEDFileFieldPerMeshPerTypeCommon(fath)
1824 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1825 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1826 int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,_se->getDynGT(),pflName,locName));
1827 _field_pm_pt_pd.resize(nbProfiles);
1828 for(int i=0;i<nbProfiles;i++)
1830 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,_se->getEntity(),i,NULL);
1834 int MEDFileFieldPerMeshPerTypeDyn::getDynGT() const
1836 return _se->getDynGT();
1839 std::string MEDFileFieldPerMeshPerTypeDyn::getModelName() const
1841 return _se->getName();
1844 void MEDFileFieldPerMeshPerTypeDyn::getDimension(int& dim) const
1846 throw INTERP_KERNEL::Exception("not implemented yet !");
1849 void MEDFileFieldPerMeshPerTypeDyn::entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const
1852 ent=MED_STRUCT_ELEMENT;
1855 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypeDyn::getGeoType() const
1857 throw INTERP_KERNEL::Exception("not implemented yet !");
1860 void MEDFileFieldPerMeshPerTypeDyn::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1862 const char startLine[]=" ## ";
1863 std::string startLine2(bkOffset,' ');
1864 std::string startLine3(startLine2);
1865 startLine3+=startLine;
1866 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry STRUCTURE_ELEMENT type " << getDynGT() << "." << std::endl;
1867 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1869 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1871 if((*it).isNotNull())
1872 (*it)->simpleRepr(bkOffset,oss,i);
1875 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1880 std::string MEDFileFieldPerMeshPerTypeDyn::getGeoTypeRepr() const
1882 throw INTERP_KERNEL::Exception("not implemented yet !");
1885 MEDFileFieldPerMeshPerTypeDyn *MEDFileFieldPerMeshPerTypeDyn::deepCopy(MEDFileFieldPerMesh *father) const
1887 MCAuto<MEDFileFieldPerMeshPerTypeDyn> ret(new MEDFileFieldPerMeshPerTypeDyn(*this));
1888 ret->setFather(father);
1889 ret->deepCopyElements();
1893 void MEDFileFieldPerMeshPerTypeDyn::getFieldAtLevel(int meshDim, TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
1895 throw INTERP_KERNEL::Exception("not implemented yet !");
1898 //////////////////////////////////////////////////
1900 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const MEDFileEntities *entities)
1902 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm,entities);
1905 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1907 return new MEDFileFieldPerMesh(fath,mesh);
1910 std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
1912 return _field_pm_pt.capacity()*sizeof(MCAuto< MEDFileFieldPerMeshPerType >);
1915 std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildrenWithNull() const
1917 std::vector<const BigMemoryObject *> ret;
1918 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1923 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCopy(MEDFileAnyTypeField1TSWithoutSDA *father) const
1925 MCAuto< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1926 ret->_father=father;
1928 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1930 if((*it).isNotNull())
1931 ret->_field_pm_pt[i]=(*it)->deepCopy((MEDFileFieldPerMesh *)(ret));
1936 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1938 std::string startLine(bkOffset,' ');
1939 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << getMeshName() << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1940 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1942 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1944 if((*it).isNotNull())
1945 (*it)->simpleRepr(bkOffset,oss,i);
1948 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1953 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh)
1955 mesh->getTime(_mesh_iteration,_mesh_order);
1958 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1960 int nbOfTypes=code.size()/3;
1962 for(int i=0;i<nbOfTypes;i++)
1964 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1965 int nbOfCells=code[3*i+1];
1966 int pos=addNewEntryIfNecessary(type);
1967 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1973 * This method is the most general one. No optimization is done here.
1974 * \param [in] multiTypePfl is the end user profile specified in high level API
1975 * \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].
1976 * \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.
1977 * \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.
1978 * \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.
1979 * \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.
1981 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)
1983 int nbOfTypes(code.size()/3);
1984 for(int i=0;i<nbOfTypes;i++)
1986 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1987 int pos=addNewEntryIfNecessary(type);
1988 DataArrayInt *pfl=0;
1990 pfl=idsPerType[code[3*i+2]];
1991 int nbOfTupes2=code2.size()/3;
1993 for(;found<nbOfTupes2;found++)
1994 if(code[3*i]==code2[3*found])
1996 if(found==nbOfTupes2)
1997 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1998 _field_pm_pt[pos]->assignFieldProfile(nbOfTypes==1,start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
2002 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
2004 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
2005 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
2008 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
2010 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
2011 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
2014 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
2016 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2017 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
2020 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
2022 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2023 (*it)->loadBigArraysRecursively(fid,nasc);
2026 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
2028 int nbOfTypes=_field_pm_pt.size();
2029 for(int i=0;i<nbOfTypes;i++)
2031 _field_pm_pt[i]->copyOptionsFrom(*this);
2032 _field_pm_pt[i]->writeLL(fid,nasc);
2036 void MEDFileFieldPerMesh::getDimension(int& dim) const
2038 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2039 (*it)->getDimension(dim);
2042 bool MEDFileFieldPerMesh::isUniqueLevel(int& dim) const
2044 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2045 if(!(*it)->isUniqueLevel(dim))
2050 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
2052 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2053 (*it)->fillTypesOfFieldAvailable(types);
2056 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
2058 int sz=_field_pm_pt.size();
2059 std::vector< std::vector<std::pair<int,int> > > ret(sz);
2060 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
2061 for(int i=0;i<sz;i++)
2063 types[i]=_field_pm_pt[i]->getGeoType();
2064 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
2069 double MEDFileFieldPerMesh::getTime() const
2072 return _father->getTime(tmp1,tmp2);
2075 int MEDFileFieldPerMesh::getIteration() const
2077 return _father->getIteration();
2080 int MEDFileFieldPerMesh::getOrder() const
2082 return _father->getOrder();
2085 int MEDFileFieldPerMesh::getNumberOfComponents() const
2087 return _father->getNumberOfComponents();
2090 std::string MEDFileFieldPerMesh::getMeshName() const
2092 return _father->getMeshName();
2095 void MEDFileFieldPerMesh::setMeshName(const std::string& meshName)
2097 _father->setMeshName(meshName);
2100 bool MEDFileFieldPerMesh::presenceOfMultiDiscPerGeoType() const
2102 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2106 if((*it)->presenceOfMultiDiscPerGeoType())
2112 bool MEDFileFieldPerMesh::presenceOfStructureElements() const
2114 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2115 if((*it).isNotNull())
2117 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2124 bool MEDFileFieldPerMesh::onlyStructureElements() const
2126 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2127 if((*it).isNotNull())
2129 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2136 void MEDFileFieldPerMesh::killStructureElements()
2138 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
2139 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2141 if((*it).isNotNull())
2143 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2151 void MEDFileFieldPerMesh::keepOnlyStructureElements()
2153 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
2154 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2156 if((*it).isNotNull())
2158 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2166 void MEDFileFieldPerMesh::keepOnlyOnSE(const std::string& seName)
2168 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
2169 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2171 if((*it).isNotNull())
2173 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2175 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::keepOnlyOnSE : presence of non SE !");
2176 if(pt->getModelName()==seName)
2183 void MEDFileFieldPerMesh::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
2185 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2187 if((*it).isNotNull())
2189 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2192 ps.push_back(std::pair<std::string,std::string>(getMeshName(),pt->getModelName()));
2195 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getMeshSENames : presence of a non structure element part !");
2200 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
2203 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
2204 return _father->getOrCreateAndGetArray();
2207 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
2210 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
2211 return _father->getOrCreateAndGetArray();
2214 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
2216 return _father->getInfo();
2220 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
2221 * 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.
2222 * It returns 2 output vectors :
2223 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
2224 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
2225 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
2227 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)
2229 int notNullPflsSz=0;
2230 int nbOfArrs=geoTypes.size();
2231 for(int i=0;i<nbOfArrs;i++)
2234 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
2235 int nbOfDiffGeoTypes=geoTypes3.size();
2236 code.resize(3*nbOfDiffGeoTypes);
2237 notNullPfls.resize(notNullPflsSz);
2240 for(int i=0;i<nbOfDiffGeoTypes;i++)
2243 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
2244 std::vector<const DataArrayInt *> notNullTmp;
2246 notNullTmp.push_back(pfls[j]);
2248 for(;j<nbOfArrs;j++)
2249 if(geoTypes[j]==refType)
2252 notNullTmp.push_back(pfls[j]);
2256 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
2257 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
2258 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
2259 code[3*i]=(int)refType;
2260 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
2261 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
2262 if(notNullTmp.empty())
2266 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
2267 code[3*i+2]=notNullPflsSz++;
2273 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
2275 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)
2279 for(int i=0;i<sz;i++)
2283 if(type!=ON_GAUSS_NE)
2284 ret+=dads[i].second-dads[i].first;
2287 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
2288 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
2293 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
2294 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
2300 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
2302 std::vector<std::string> ret;
2303 std::set<std::string> ret2;
2304 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2306 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
2307 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
2308 if(ret2.find(*it2)==ret2.end())
2310 ret.push_back(*it2);
2317 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
2319 std::vector<std::string> ret;
2320 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2322 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
2323 ret.insert(ret.end(),tmp.begin(),tmp.end());
2328 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
2330 std::vector<std::string> ret;
2331 std::set<std::string> ret2;
2332 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2334 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
2335 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
2336 if(ret2.find(*it2)==ret2.end())
2338 ret.push_back(*it2);
2345 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
2347 std::vector<std::string> ret;
2348 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2350 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
2351 ret.insert(ret.end(),tmp.begin(),tmp.end());
2356 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
2358 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
2360 if((*it).first==getMeshName())
2362 setMeshName((*it).second);
2369 void MEDFileFieldPerMesh::convertMedBallIntoClassic()
2371 if(_field_pm_pt.size()!=1)
2372 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : Only managed for single mesh !");
2373 if(_field_pm_pt[0].isNull())
2374 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : null pointer !");
2375 MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<MEDFileFieldPerMeshPerTypeDyn *>((MEDFileFieldPerMeshPerTypeCommon *)_field_pm_pt[0]));
2377 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : this is expected to be marked as structure element !");
2378 if(pt->getNumberOfLoc()!=1)
2379 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : only one loc managed !");
2380 const MEDFileFieldPerMeshPerTypePerDisc *disc(pt->getLeafGivenLocId(0));
2382 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : internal error !");
2383 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> disc2(MEDFileFieldPerMeshPerTypePerDisc::New(*disc));
2384 disc2->setType(ON_NODES);
2385 MCAuto<MEDFileFieldPerMeshPerType> pt2(MEDFileFieldPerMeshPerType::New(this,INTERP_KERNEL::NORM_ERROR));
2386 disc2->setFather(pt2);
2387 pt2->setFather(this);
2388 pt2->pushDiscretization(disc2);
2389 _field_pm_pt[0]=DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(pt2);
2392 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
2393 MEDFileFieldGlobsReal& glob)
2395 if(getMeshName()!=meshName)
2397 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
2398 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
2399 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
2400 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
2401 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
2402 getUndergroundDataArrayExt(entries);
2403 DataArray *arr0(getOrCreateAndGetArray());//tony
2405 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
2406 DataArrayDouble *arr(dynamic_cast<DataArrayDouble *>(arr0));//tony
2408 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
2411 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
2412 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
2414 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
2416 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2417 sz+=(*it).second.second-(*it).second.first;
2420 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2422 MCAuto<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
2423 ////////////////////
2424 MCAuto<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
2425 int *workI2=explicitIdsOldInMesh->getPointer();
2426 int sz1=0,sz2=0,sid=1;
2427 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
2428 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
2429 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
2431 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
2432 MCAuto<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
2433 int *workI=explicitIdsOldInArr->getPointer();
2434 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
2436 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
2437 (*itL2)->setLocId(sz2);
2438 (*itL2)->_tmp_work1=(*itL2)->getStart();
2439 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
2441 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
2443 explicitIdsOldInMesh->reAlloc(sz2);
2444 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
2445 ////////////////////
2446 MCAuto<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
2447 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
2448 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
2449 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
2451 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
2452 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
2453 otherEntriesNew.back()->setLocId((*it)->getGeoType());
2455 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
2456 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
2457 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
2459 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
2460 int newStart=elt->getLocId();
2461 elt->setLocId((*it)->getGeoType());
2462 elt->setNewStart(newStart);
2463 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
2464 entriesKeptNew.push_back(elt);
2465 entriesKeptNew2.push_back(elt);
2467 MCAuto<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
2468 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
2469 MCAuto<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
2470 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
2472 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
2475 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
2477 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
2478 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
2480 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
2481 glob,arr2,otherEntriesNew) || ret;
2485 // Assign new dispatching
2486 assignNewLeaves(otherEntriesNew);
2487 arr->deepCopyFrom(*arr2);
2492 * \param [in,out] globalNum a global numbering counter for the renumbering.
2493 * \param [out] its - list of pair (start,stop) kept
2495 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
2497 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > ret;
2498 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2500 std::vector< std::pair<int,int> > its2;
2501 if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
2504 its.insert(its.end(),its2.begin(),its2.end());
2511 * \param [in,out] globalNum a global numbering counter for the renumbering.
2512 * \param [out] its - list of pair (start,stop) kept
2514 void MEDFileFieldPerMesh::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
2516 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > ret;
2517 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2519 std::vector< std::pair<int,int> > its2;
2520 if((*it)->keepOnlyGaussDiscretization(idOfDisc,globalNum,its2))
2523 its.insert(its.end(),its2.begin(),its2.end());
2529 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
2531 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > > types;
2532 for( std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
2533 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
2535 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > fieldPmPt(types.size());
2536 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
2537 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it2=fieldPmPt.begin();
2538 for(;it1!=types.end();it1++,it2++)
2540 MCAuto<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
2541 elt->setLeaves((*it1).second);
2542 MCAuto<MEDFileFieldPerMeshPerTypeCommon> elt2(DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(elt));
2545 _field_pm_pt=fieldPmPt;
2548 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2550 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2551 (*it)->changePflsRefsNamesGen(mapOfModif);
2554 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2556 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2557 (*it)->changeLocsRefsNamesGen(mapOfModif);
2561 * \param [in] mesh is the whole mesh
2563 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2565 if(_field_pm_pt.empty())
2566 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2568 std::vector< std::pair<int,int> > dads;
2569 std::vector<const DataArrayInt *> pfls;
2570 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2571 std::vector<int> locs,code;
2572 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2573 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2574 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2576 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2579 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2580 throw INTERP_KERNEL::Exception(oss.str());
2583 std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2584 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2587 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2589 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2592 MCAuto<DataArrayInt> arr2(arr);
2593 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2599 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2603 if(nb!=mesh->getNumberOfNodes())
2605 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2606 oss << " nodes in mesh !";
2607 throw INTERP_KERNEL::Exception(oss.str());
2609 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2612 return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2616 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
2618 if(_field_pm_pt.empty())
2619 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2621 std::vector<std::pair<int,int> > dads;
2622 std::vector<const DataArrayInt *> pfls;
2623 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2624 std::vector<int> locs,code;
2625 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2626 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2627 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2629 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2632 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2633 throw INTERP_KERNEL::Exception(oss.str());
2635 std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2636 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2639 MCAuto<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2640 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2645 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2649 if(nb!=mesh->getNumberOfNodes())
2651 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2652 oss << " nodes in mesh !";
2653 throw INTERP_KERNEL::Exception(oss.str());
2656 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2662 void MEDFileFieldPerMesh::accept(MEDFileFieldVisitor& visitor) const
2664 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2665 if((*it).isNotNull())
2667 visitor.newPerMeshPerTypeEntry(*it);
2668 (*it)->accept(visitor);
2669 visitor.endPerMeshPerTypeEntry(*it);
2673 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
2677 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2679 (*it)->getSizes(globalSz,nbOfEntries);
2681 entries.resize(nbOfEntries);
2683 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2685 (*it)->fillValues(nbOfEntries,entries);
2689 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
2691 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2693 if((*it)->getGeoType()==typ)
2694 return (*it)->getLeafGivenLocId(locId);
2696 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2697 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2698 oss << "Possiblities are : ";
2699 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2701 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2702 oss << "\"" << cm2.getRepr() << "\", ";
2704 throw INTERP_KERNEL::Exception(oss.str());
2707 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
2709 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2711 if((*it)->getGeoType()==typ)
2712 return (*it)->getLeafGivenLocId(locId);
2714 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2715 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2716 oss << "Possiblities are : ";
2717 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2719 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2720 oss << "\"" << cm2.getRepr() << "\", ";
2722 throw INTERP_KERNEL::Exception(oss.str());
2726 * \param [in,out] start - Integer that gives the current position in the final aggregated array
2727 * \param [in] pms - list of elements to aggregate. integer gives the mesh id
2728 * \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.
2729 * \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.
2731 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)
2733 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret(new MEDFileFieldPerMeshPerTypePerDisc(father,tof));
2735 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : empty input vector !");
2736 for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it=pms.begin();it!=pms.end();it++)
2739 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : presence of null pointer !");
2740 if(!(*it).second->getProfile().empty())
2741 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for profiles !");
2742 if(!(*it).second->getLocalization().empty())
2743 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for gauss pts !");
2745 INTERP_KERNEL::NormalizedCellType gt(pms[0].second->getGeoType());
2747 std::vector< std::pair<int,int> > filteredDTS;
2748 for(std::vector< std::vector< std::pair<int,int> > >::const_iterator it=dts.begin();it!=dts.end();it++,i++)
2749 for(std::vector< std::pair<int,int> >::const_iterator it2=(*it).begin();it2!=(*it).end();it2++)
2750 if((*it2).first==gt)
2751 filteredDTS.push_back(std::pair<int,int>(i,(*it2).second));
2752 if(pms.size()!=filteredDTS.size())
2753 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles !");
2754 std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it1(pms.begin());
2755 std::vector< std::pair<int,int> >::const_iterator it2(filteredDTS.begin());
2756 int zeStart(start),nval(0);
2757 for(;it1!=pms.end();it1++,it2++)
2759 if((*it1).first!=(*it2).first)
2760 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles 2 !");
2761 int s1((*it1).second->getStart()),e1((*it1).second->getEnd());
2762 extractInfo.push_back(std::pair<int, std::pair<int,int> >((*it1).first,std::pair<int,int>(s1,e1)));
2764 nval+=((*it1).second)->getNumberOfVals();
2766 ret->_start=zeStart; ret->_end=start; ret->_nval=nval;
2770 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)
2772 MCAuto<MEDFileFieldPerMesh> ret(new MEDFileFieldPerMesh(father,pms[0]->getMeshName(),pms[0]->getMeshIteration(),pms[0]->getMeshOrder()));
2773 std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > > m;
2775 for(std::vector<const MEDFileFieldPerMesh *>::const_iterator it=pms.begin();it!=pms.end();it++,i++)
2777 const std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >& v((*it)->_field_pm_pt);
2778 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it2=v.begin();it2!=v.end();it2++)
2780 INTERP_KERNEL::NormalizedCellType gt((*it2)->getGeoType());
2781 const MEDFileFieldPerMeshPerType *elt(dynamic_cast<const MEDFileFieldPerMeshPerType *>((const MEDFileFieldPerMeshPerTypeCommon *)(*it2)));
2783 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::Aggregate : not managed for structelement !");
2784 m[gt].push_back(std::pair<int,const MEDFileFieldPerMeshPerType *>(i,elt));
2787 for(std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > >::const_iterator it=m.begin();it!=m.end();it++)
2789 MCAuto<MEDFileFieldPerMeshPerType> agg(MEDFileFieldPerMeshPerType::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
2790 MCAuto<MEDFileFieldPerMeshPerTypeCommon> agg2(DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(agg));
2791 ret->_field_pm_pt.push_back(agg2);
2796 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2799 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2800 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it2=_field_pm_pt.begin();
2801 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2803 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2808 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2813 int ret=std::distance(_field_pm_pt.begin(),it2);
2814 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2819 * 'dads' and 'locs' input parameters have the same number of elements
2820 * \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
2822 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2823 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2824 const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2827 MCAuto<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2828 ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2829 MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2830 const std::vector<std::string>& infos=getInfo();
2831 da->setInfoOnComponents(infos);
2833 if(type==ON_GAUSS_PT)
2836 int nbOfArrs=dads.size();
2837 for(int i=0;i<nbOfArrs;i++)
2839 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2840 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2841 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2842 MCAuto<DataArrayInt> di=DataArrayInt::New();
2843 di->alloc(nbOfElems,1);
2845 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2846 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2855 * 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.
2856 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2857 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2858 * The order of cells in the returned field is those imposed by the profile.
2859 * \param [in] mesh is the global mesh.
2861 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2862 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2863 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2864 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2866 if(da->isIota(mesh->getNumberOfCells()))
2867 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2868 MCAuto<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2869 m2->setName(mesh->getName().c_str());
2870 MCAuto<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2876 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2878 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2879 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2880 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2882 if(da->isIota(mesh->getNumberOfNodes()))
2883 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2884 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2885 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2888 if(meshu->getNodalConnectivity()==0)
2890 MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2891 int nb=da->getNbOfElems();
2892 const int *ptr=da->getConstPointer();
2893 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2894 meshuc->allocateCells(nb);
2895 for(int i=0;i<nb;i++)
2896 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2897 meshuc->finishInsertingCells();
2898 ret->setMesh(meshuc);
2899 const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2900 if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2901 disc->checkCoherencyBetween(meshuc,arrOut);
2906 MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2908 DataArrayInt *arr2=0;
2909 MCAuto<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2910 MCAuto<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2911 MCAuto<DataArrayInt> arr3(arr2);
2912 int nnodes=mesh2->getNumberOfNodes();
2913 if(nnodes==(int)da->getNbOfElems())
2915 MCAuto<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2916 arrOut->renumberInPlace(da3->getConstPointer());
2917 mesh2->setName(mesh->getName().c_str());
2918 ret->setMesh(mesh2);
2923 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 !!!";
2924 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2925 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2926 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2927 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2928 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2929 throw INTERP_KERNEL::Exception(oss.str());
2935 * This method is the most light method of field retrieving.
2937 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
2941 pflOut=DataArrayInt::New();
2942 pflOut->alloc(nbOfElems,1);
2947 pflOut=const_cast<DataArrayInt*>(pflIn);
2950 MCAuto<DataArrayInt> safePfl(pflOut);
2951 MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2952 const std::vector<std::string>& infos=getInfo();
2953 int nbOfComp=infos.size();
2954 for(int i=0;i<nbOfComp;i++)
2955 da->setInfoOnComponent(i,infos[i].c_str());
2966 static MFFPMIter *NewCell(const MEDFileEntities *entities);
2967 static bool IsPresenceOfNode(const MEDFileEntities *entities);
2968 virtual ~MFFPMIter() { }
2969 virtual void begin() = 0;
2970 virtual bool finished() const = 0;
2971 virtual void next() = 0;
2972 virtual int current() const = 0;
2975 class MFFPMIterSimple : public MFFPMIter
2978 MFFPMIterSimple():_pos(0) { }
2979 void begin() { _pos=0; }
2980 bool finished() const { return _pos>=MED_N_CELL_FIXED_GEO; }
2981 void next() { _pos++; }
2982 int current() const { return _pos; }
2987 class MFFPMIter2 : public MFFPMIter
2990 MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts);
2991 void begin() { _it=_ids.begin(); }
2992 bool finished() const { return _it==_ids.end(); }
2993 void next() { _it++; }
2994 int current() const { return *_it; }
2996 std::vector<int> _ids;
2997 std::vector<int>::const_iterator _it;
3000 MFFPMIter *MFFPMIter::NewCell(const MEDFileEntities *entities)
3003 return new MFFPMIterSimple;
3006 const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
3009 std::vector<INTERP_KERNEL::NormalizedCellType> tmp;
3010 const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
3011 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
3013 if((*it).first==ON_CELLS || (*it).first==ON_GAUSS_NE || (*it).first==ON_GAUSS_PT)
3014 tmp.push_back((*it).second);
3016 return new MFFPMIter2(tmp);
3018 return new MFFPMIterSimple;// for MEDFileAllStaticEntites and MEDFileAllStaticEntitiesPlusDyn cells are in
3022 bool MFFPMIter::IsPresenceOfNode(const MEDFileEntities *entities)
3028 const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
3031 const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
3032 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
3033 if((*it).first==ON_NODES)
3037 return true;// for MEDFileAllStaticEntites and MEDFileAllStaticEntitiesPlusDyn nodes are in
3041 MFFPMIter2::MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts)
3043 std::size_t sz(cts.size());
3045 for(std::size_t i=0;i<sz;i++)
3047 INTERP_KERNEL::NormalizedCellType *loc(std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,cts[i]));
3048 if(loc!=typmai2+MED_N_CELL_FIXED_GEO)
3049 _ids[i]=(int)std::distance(typmai2,loc);
3051 throw INTERP_KERNEL::Exception("MFFPMIter2 : The specified geo type does not exists !");
3057 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),
3060 INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
3061 INTERP_KERNEL::AutoPtr<char> pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
3062 INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
3063 const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
3064 INTERP_KERNEL::AutoCppPtr<MFFPMIter> iter0(MFFPMIter::NewCell(entities));
3065 for(iter0->begin();!iter0->finished();iter0->next())
3067 int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL ,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
3068 std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
3069 int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
3070 std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
3071 if(nbProfile>0 || nbProfile2>0)
3073 const PartDefinition *pd(0);
3075 pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[iter0->current()]),typmai2[iter0->current()]);
3076 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nasc,pd));
3083 if(MFFPMIter::IsPresenceOfNode(entities))
3085 int nbProfile(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName));
3088 const PartDefinition *pd(0);
3090 pd=mmu->getPartDefAtLevel(1,INTERP_KERNEL::NORM_ERROR);
3091 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd));
3092 setMeshName(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE));
3097 std::vector<int> dynGT(entities->getDynGTAvail());
3098 for(std::vector<int>::const_iterator it=dynGT.begin();it!=dynGT.end();it++)
3100 int nbPfl(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,*it,pflName,locName));
3103 _field_pm_pt.push_back(MEDFileFieldPerMeshPerTypeDyn::NewOnRead(fid,this,entities,*it,nasc));
3104 setMeshName(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE));
3109 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
3111 copyTinyInfoFrom(mesh);
3114 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3116 if(id>=(int)_pfls.size())
3118 _pfls[id]=DataArrayInt::New();
3119 int lgth(MEDprofileSizeByName(fid,pflName.c_str()));
3120 _pfls[id]->setName(pflName);
3121 _pfls[id]->alloc(lgth,1);
3122 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName.c_str(),_pfls[id]->getPointer()));
3123 _pfls[id]->applyLin(1,-1,0);//Converting into C format
3126 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
3128 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
3130 MEDFILESAFECALLERRD0(MEDprofileInfo,(fid,i+1,pflName,&sz));
3131 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
3132 if(i>=(int)_pfls.size())
3134 _pfls[i]=DataArrayInt::New();
3135 _pfls[i]->alloc(sz,1);
3136 _pfls[i]->setName(pflCpp.c_str());
3137 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName,_pfls[i]->getPointer()));
3138 _pfls[i]->applyLin(1,-1,0);//Converting into C format
3141 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3143 int nbOfPfls=_pfls.size();
3144 for(int i=0;i<nbOfPfls;i++)
3146 MCAuto<DataArrayInt> cpy=_pfls[i]->deepCopy();
3147 cpy->applyLin(1,1,0);
3148 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
3149 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
3150 MEDFILESAFECALLERWR0(MEDprofileWr,(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer()));
3153 int nbOfLocs=_locs.size();
3154 for(int i=0;i<nbOfLocs;i++)
3155 _locs[i]->writeLL(fid);
3158 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
3160 std::vector<std::string> pfls=getPfls();
3161 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
3163 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
3166 _pfls.push_back(*it);
3170 int id=std::distance(pfls.begin(),it2);
3171 if(!(*it)->isEqual(*_pfls[id]))
3173 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
3174 throw INTERP_KERNEL::Exception(oss.str());
3178 std::vector<std::string> locs=getLocs();
3179 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
3181 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
3184 _locs.push_back(*it);
3188 int id=std::distance(locs.begin(),it2);
3189 if(!(*it)->isEqual(*_locs[id],eps))
3191 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
3192 throw INTERP_KERNEL::Exception(oss.str());
3198 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
3200 for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
3201 getProfile((*it).c_str());
3204 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
3206 for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
3207 getLocalization((*it).c_str());
3210 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
3212 std::vector<std::string> profiles=real.getPflsReallyUsed();
3213 int sz=profiles.size();
3215 for(int i=0;i<sz;i++)
3216 loadProfileInFile(fid,i,profiles[i].c_str());
3218 std::vector<std::string> locs=real.getLocsReallyUsed();
3221 for(int i=0;i<sz;i++)
3222 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
3225 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid, const MEDFileEntities *entities)
3227 int nProfil=MEDnProfile(fid);
3228 for(int i=0;i<nProfil;i++)
3229 loadProfileInFile(fid,i);
3230 int sz=MEDnLocalization(fid);
3232 for(int i=0;i<sz;i++)
3234 _locs[i]=MEDFileFieldLoc::New(fid,i,entities);
3238 MEDFileFieldGlobs *MEDFileFieldGlobs::New(med_idt fid)
3240 return new MEDFileFieldGlobs(fid);
3243 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
3245 return new MEDFileFieldGlobs;
3248 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
3250 return _file_name.capacity()+_pfls.capacity()*sizeof(MCAuto<DataArrayInt>)+_locs.capacity()*sizeof(MCAuto<MEDFileFieldLoc>);
3253 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildrenWithNull() const
3255 std::vector<const BigMemoryObject *> ret;
3256 for(std::vector< MCAuto< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3257 ret.push_back((const DataArrayInt *)*it);
3258 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3259 ret.push_back((const MEDFileFieldLoc *)*it);
3263 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCopy() const
3265 MCAuto<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
3267 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3269 if((const DataArrayInt *)*it)
3270 ret->_pfls[i]=(*it)->deepCopy();
3273 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3275 if((const MEDFileFieldLoc*)*it)
3276 ret->_locs[i]=(*it)->deepCopy();
3282 * \throw if a profile in \a pfls in not in \a this.
3283 * \throw if a localization in \a locs in not in \a this.
3284 * \sa MEDFileFieldGlobs::deepCpyPart
3286 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
3288 MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
3289 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
3291 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
3293 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
3295 MCAuto<DataArrayInt> pfl2(pfl);
3296 ret->_pfls.push_back(pfl2);
3298 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
3300 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
3302 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
3304 MCAuto<MEDFileFieldLoc> loc2(loc);
3305 ret->_locs.push_back(loc2);
3307 ret->setFileName(getFileName());
3312 * \throw if a profile in \a pfls in not in \a this.
3313 * \throw if a localization in \a locs in not in \a this.
3314 * \sa MEDFileFieldGlobs::shallowCpyPart
3316 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
3318 MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
3319 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
3321 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
3323 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
3324 ret->_pfls.push_back(pfl->deepCopy());
3326 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
3328 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
3330 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
3331 ret->_locs.push_back(loc->deepCopy());
3333 ret->setFileName(getFileName());
3337 MEDFileFieldGlobs::MEDFileFieldGlobs(med_idt fid):_file_name(MEDFileWritable::FileNameFromFID(fid))
3341 MEDFileFieldGlobs::MEDFileFieldGlobs()
3345 MEDFileFieldGlobs::~MEDFileFieldGlobs()
3349 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
3351 oss << "Profiles :\n";
3352 std::size_t n=_pfls.size();
3353 for(std::size_t i=0;i<n;i++)
3355 oss << " - #" << i << " ";
3356 const DataArrayInt *pfl=_pfls[i];
3358 oss << "\"" << pfl->getName() << "\"\n";
3363 oss << "Localizations :\n";
3364 for(std::size_t i=0;i<n;i++)
3366 oss << " - #" << i << " ";
3367 const MEDFileFieldLoc *loc=_locs[i];
3369 loc->simpleRepr(oss);
3375 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3377 for(std::vector< MCAuto<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
3379 DataArrayInt *elt(*it);
3382 std::string name(elt->getName());
3383 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3385 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3387 elt->setName((*it2).second.c_str());
3395 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3397 for(std::vector< MCAuto<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
3399 MEDFileFieldLoc *elt(*it);
3402 std::string name(elt->getName());
3403 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3405 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3407 elt->setName((*it2).second.c_str());
3415 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
3417 if(locId<0 || locId>=(int)_locs.size())
3418 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
3419 return _locs[locId]->getNbOfGaussPtPerCell();
3422 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
3424 return getLocalizationFromId(getLocalizationId(locName));
3427 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
3429 if(locId<0 || locId>=(int)_locs.size())
3430 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3431 return *_locs[locId];
3435 namespace MEDCouplingImpl
3440 LocFinder(const std::string& loc):_loc(loc) { }
3441 bool operator() (const MCAuto<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
3443 const std::string &_loc;
3449 PflFinder(const std::string& pfl):_pfl(pfl) { }
3450 bool operator() (const MCAuto<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
3452 const std::string& _pfl;
3457 int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
3459 std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),MEDCouplingImpl::LocFinder(loc));
3462 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
3463 for(it=_locs.begin();it!=_locs.end();it++)
3464 oss << "\"" << (*it)->getName() << "\", ";
3465 throw INTERP_KERNEL::Exception(oss.str());
3467 return std::distance(_locs.begin(),it);
3471 * The returned value is never null.
3473 const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
3475 std::string pflNameCpp(pflName);
3476 std::vector< MCAuto<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3479 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3480 for(it=_pfls.begin();it!=_pfls.end();it++)
3481 oss << "\"" << (*it)->getName() << "\", ";
3482 throw INTERP_KERNEL::Exception(oss.str());
3487 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
3489 if(pflId<0 || pflId>=(int)_pfls.size())
3490 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3491 return _pfls[pflId];
3494 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
3496 if(locId<0 || locId>=(int)_locs.size())
3497 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3498 return *_locs[locId];
3501 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
3503 return getLocalizationFromId(getLocalizationId(locName));
3507 * The returned value is never null.
3509 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
3511 std::string pflNameCpp(pflName);
3512 std::vector< MCAuto<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3515 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3516 for(it=_pfls.begin();it!=_pfls.end();it++)
3517 oss << "\"" << (*it)->getName() << "\", ";
3518 throw INTERP_KERNEL::Exception(oss.str());
3523 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
3525 if(pflId<0 || pflId>=(int)_pfls.size())
3526 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3527 return _pfls[pflId];
3530 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
3532 std::vector< MCAuto<DataArrayInt> > newPfls;
3534 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3536 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
3537 newPfls.push_back(*it);
3542 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
3544 std::vector< MCAuto<MEDFileFieldLoc> > newLocs;
3546 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3548 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
3549 newLocs.push_back(*it);
3554 void MEDFileFieldGlobs::killStructureElementsInGlobs()
3556 std::vector< MCAuto<MEDFileFieldLoc> > newLocs;
3557 for(std::vector< MCAuto<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
3561 if(!(*it)->isOnStructureElement())
3562 newLocs.push_back(*it);
3567 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
3569 int sz=_pfls.size();
3570 std::vector<std::string> ret(sz);
3571 for(int i=0;i<sz;i++)
3572 ret[i]=_pfls[i]->getName();
3576 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
3578 int sz=_locs.size();
3579 std::vector<std::string> ret(sz);
3580 for(int i=0;i<sz;i++)
3581 ret[i]=_locs[i]->getName();
3585 bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
3587 std::vector<std::string> v=getPfls();
3588 std::string s(pflName);
3589 return std::find(v.begin(),v.end(),s)!=v.end();
3592 bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
3594 std::vector<std::string> v=getLocs();
3595 std::string s(locName);
3596 return std::find(v.begin(),v.end(),s)!=v.end();
3599 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
3601 std::map<int,std::vector<int> > m;
3603 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3605 const DataArrayInt *tmp=(*it);
3608 m[tmp->getHashCode()].push_back(i);
3611 std::vector< std::vector<int> > ret;
3612 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
3614 if((*it2).second.size()>1)
3616 std::vector<int> ret0;
3617 bool equalityOrNot=false;
3618 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
3620 std::vector<int>::const_iterator it4=it3; it4++;
3621 for(;it4!=(*it2).second.end();it4++)
3623 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
3626 ret0.push_back(*it3);
3627 ret0.push_back(*it4);
3633 ret.push_back(ret0);
3639 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
3641 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
3644 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
3646 std::string name(pfl->getName());
3648 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
3649 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3650 if(name==(*it)->getName())
3652 if(!pfl->isEqual(*(*it)))
3654 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
3655 throw INTERP_KERNEL::Exception(oss.str());
3659 _pfls.push_back(pfl);
3662 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)
3664 std::string name(locName);
3666 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
3667 MCAuto<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
3668 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3669 if((*it)->isName(locName))
3671 if(!(*it)->isEqual(*obj,1e-12))
3673 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
3674 throw INTERP_KERNEL::Exception(oss.str());
3677 _locs.push_back(obj);
3680 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
3682 std::vector<std::string> names=getPfls();
3683 return CreateNewNameNotIn("NewPfl_",names);
3686 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
3688 std::vector<std::string> names=getLocs();
3689 return CreateNewNameNotIn("NewLoc_",names);
3692 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
3694 for(std::size_t sz=0;sz<100000;sz++)
3696 std::ostringstream tryName;
3697 tryName << prefix << sz;
3698 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
3699 return tryName.str();
3701 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
3705 * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
3706 * \param [in] fname - the file name.
3708 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(med_idt fid):_globals(MEDFileFieldGlobs::New(fid))
3713 * Creates an empty MEDFileFieldGlobsReal.
3715 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
3719 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
3724 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildrenWithNull() const
3726 std::vector<const BigMemoryObject *> ret;
3727 ret.push_back((const MEDFileFieldGlobs *)_globals);
3732 * Returns a string describing profiles and Gauss points held in \a this.
3733 * \return std::string - the description string.
3735 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
3737 const MEDFileFieldGlobs *glob=_globals;
3738 std::ostringstream oss2; oss2 << glob;
3739 std::string stars(oss2.str().length(),'*');
3740 oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n";
3742 glob->simpleRepr(oss);
3744 oss << "NO GLOBAL INFORMATION !\n";
3747 void MEDFileFieldGlobsReal::resetContent()
3749 _globals=MEDFileFieldGlobs::New();
3752 void MEDFileFieldGlobsReal::killStructureElementsInGlobs()
3754 contentNotNull()->killStructureElementsInGlobs();
3757 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
3762 * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
3763 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3765 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3767 _globals=other._globals;
3771 * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3772 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3774 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3776 const MEDFileFieldGlobs *otherg(other._globals);
3779 _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3783 * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3784 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3786 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3788 const MEDFileFieldGlobs *otherg(other._globals);
3791 _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3794 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3796 _globals=other._globals;
3797 if((const MEDFileFieldGlobs *)_globals)
3798 _globals=other._globals->deepCopy();
3802 * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3803 * \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3804 * \param [in] eps - a precision used to compare Gauss points with same name held by
3805 * \a this and \a other MEDFileFieldGlobsReal.
3806 * \throw If \a this and \a other hold profiles with equal names but different ids.
3807 * \throw If \a this and \a other hold different Gauss points with equal names.
3809 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
3811 const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3812 if(thisGlobals==otherGlobals)
3816 _globals=other._globals;
3819 _globals->appendGlobs(*other._globals,eps);
3822 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
3824 checkGlobsPflsPartCoherency();
3825 checkGlobsLocsPartCoherency();
3828 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
3830 contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3833 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
3835 contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3838 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3840 contentNotNull()->loadProfileInFile(fid,id,pflName);
3843 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3845 contentNotNull()->loadProfileInFile(fid,id);
3848 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
3850 contentNotNull()->loadGlobals(fid,*this);
3853 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid, const MEDFileEntities *entities)
3855 contentNotNull()->loadAllGlobals(fid,entities);
3858 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3860 contentNotNull()->writeGlobals(fid,opt);
3864 * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3865 * or getPflsReallyUsedMulti().
3866 * \return std::vector<std::string> - a sequence of names of all profiles.
3868 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3870 return contentNotNull()->getPfls();
3874 * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3875 * or getLocsReallyUsedMulti().
3876 * \return std::vector<std::string> - a sequence of names of all localizations.
3878 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3880 return contentNotNull()->getLocs();
3884 * Checks if the profile with a given name exists.
3885 * \param [in] pflName - the profile name of interest.
3886 * \return bool - \c true if the profile named \a pflName exists.
3888 bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
3890 return contentNotNull()->existsPfl(pflName);
3894 * Checks if the localization with a given name exists.
3895 * \param [in] locName - the localization name of interest.
3896 * \return bool - \c true if the localization named \a locName exists.
3898 bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
3900 return contentNotNull()->existsLoc(locName);
3903 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
3905 return contentNotNull()->createNewNameOfPfl();
3908 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
3910 return contentNotNull()->createNewNameOfLoc();
3914 * Sets the name of a MED file.
3915 * \param [inout] fileName - the file name.
3917 void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
3919 contentNotNull()->setFileName(fileName);
3923 * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3924 * in the same order.
3925 * \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3926 * Each item of this sequence is a vector containing ids of equal profiles.
3928 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3930 return contentNotNull()->whichAreEqualProfiles();
3934 * Finds equal localizations.
3935 * \param [in] eps - a precision used to compare real values of the localizations.
3936 * \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3937 * Each item of this sequence is a vector containing ids of equal localizations.
3939 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3941 return contentNotNull()->whichAreEqualLocs(eps);
3945 * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3946 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3947 * this sequence is a pair whose
3948 * - the first item is a vector of profile names to replace by the second item,
3949 * - the second item is a profile name to replace every profile name of the first item.
3951 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3953 contentNotNull()->changePflsNamesInStruct(mapOfModif);
3957 * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3958 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3959 * this sequence is a pair whose
3960 * - the first item is a vector of localization names to replace by the second item,
3961 * - the second item is a localization name to replace every localization name of the first item.
3963 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3965 contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3969 * Replaces references to some profiles (a reference is a profile name) by references
3970 * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3971 * them-selves accordingly. <br>
3972 * This method is a generalization of changePflName().
3973 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3974 * this sequence is a pair whose
3975 * - the first item is a vector of profile names to replace by the second item,
3976 * - the second item is a profile name to replace every profile of the first item.
3977 * \sa changePflsRefsNamesGen()
3978 * \sa changePflName()
3980 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3982 changePflsRefsNamesGen(mapOfModif);
3983 changePflsNamesInStruct(mapOfModif);
3987 * Replaces references to some localizations (a reference is a localization name) by references
3988 * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3989 * them-selves accordingly. <br>
3990 * This method is a generalization of changeLocName().
3991 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3992 * this sequence is a pair whose
3993 * - the first item is a vector of localization names to replace by the second item,
3994 * - the second item is a localization name to replace every localization of the first item.
3995 * \sa changeLocsRefsNamesGen()
3996 * \sa changeLocName()
3998 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4000 changeLocsRefsNamesGen(mapOfModif);
4001 changeLocsNamesInStruct(mapOfModif);
4005 * Renames the profile having a given name and updates references to this profile.
4006 * \param [in] oldName - the name of the profile to rename.
4007 * \param [in] newName - a new name of the profile.
4008 * \sa changePflsNames().
4010 void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
4012 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
4013 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
4015 changePflsNames(mapOfModif);
4019 * Renames the localization having a given name and updates references to this localization.
4020 * \param [in] oldName - the name of the localization to rename.
4021 * \param [in] newName - a new name of the localization.
4022 * \sa changeLocsNames().
4024 void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
4026 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
4027 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
4029 changeLocsNames(mapOfModif);
4033 * Removes duplicated profiles. Returns a map used to update references to removed
4034 * profiles via changePflsRefsNamesGen().
4035 * Equal profiles are found using whichAreEqualProfiles().
4036 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
4037 * a sequence describing the performed replacements of profiles. Each element of
4038 * this sequence is a pair whose
4039 * - the first item is a vector of profile names replaced by the second item,
4040 * - the second item is a profile name replacing every profile of the first item.
4042 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
4044 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
4045 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
4047 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
4049 std::vector< std::string > tmp((*it).size());
4051 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
4052 tmp[j]=std::string(getProfileFromId(*it2)->getName());
4053 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
4055 std::vector<int> tmp2((*it).begin()+1,(*it).end());
4056 killProfileIds(tmp2);
4058 changePflsRefsNamesGen(ret);
4063 * Removes duplicated localizations. Returns a map used to update references to removed
4064 * localizations via changeLocsRefsNamesGen().
4065 * Equal localizations are found using whichAreEqualLocs().
4066 * \param [in] eps - a precision used to compare real values of the localizations.
4067 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
4068 * a sequence describing the performed replacements of localizations. Each element of
4069 * this sequence is a pair whose
4070 * - the first item is a vector of localization names replaced by the second item,
4071 * - the second item is a localization name replacing every localization of the first item.
4073 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
4075 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
4076 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
4078 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
4080 std::vector< std::string > tmp((*it).size());
4082 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
4083 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
4084 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
4086 std::vector<int> tmp2((*it).begin()+1,(*it).end());
4087 killLocalizationIds(tmp2);
4089 changeLocsRefsNamesGen(ret);
4094 * Returns number of Gauss points per cell in a given localization.
4095 * \param [in] locId - an id of the localization of interest.
4096 * \return int - the number of the Gauss points per cell.
4098 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
4100 return contentNotNull()->getNbOfGaussPtPerCell(locId);
4104 * Returns an id of a localization by its name.
4105 * \param [in] loc - the localization name of interest.
4106 * \return int - the id of the localization.
4107 * \throw If there is no a localization named \a loc.
4109 int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
4111 return contentNotNull()->getLocalizationId(loc);
4115 * Returns the name of the MED file.
4116 * \return const std::string& - the MED file name.
4118 std::string MEDFileFieldGlobsReal::getFileName() const
4120 return contentNotNull()->getFileName();
4124 * Returns a localization object by its name.
4125 * \param [in] locName - the name of the localization of interest.
4126 * \return const MEDFileFieldLoc& - the localization object having the name \a locName.
4127 * \throw If there is no a localization named \a locName.
4129 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
4131 return contentNotNull()->getLocalization(locName);
4135 * Returns a localization object by its id.
4136 * \param [in] locId - the id of the localization of interest.
4137 * \return const MEDFileFieldLoc& - the localization object having the id \a locId.
4138 * \throw If there is no a localization with id \a locId.
4140 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
4142 return contentNotNull()->getLocalizationFromId(locId);
4146 * Returns a profile array by its name.
4147 * \param [in] pflName - the name of the profile of interest.
4148 * \return const DataArrayInt * - the profile array having the name \a pflName.
4149 * \throw If there is no a profile named \a pflName.
4151 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
4153 return contentNotNull()->getProfile(pflName);
4157 * Returns a profile array by its id.
4158 * \param [in] pflId - the id of the profile of interest.
4159 * \return const DataArrayInt * - the profile array having the id \a pflId.
4160 * \throw If there is no a profile with id \a pflId.
4162 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
4164 return contentNotNull()->getProfileFromId(pflId);
4168 * Returns a localization object, apt for modification, by its id.
4169 * \param [in] locId - the id of the localization of interest.
4170 * \return MEDFileFieldLoc& - a non-const reference to the localization object
4171 * having the id \a locId.
4172 * \throw If there is no a localization with id \a locId.
4174 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
4176 return contentNotNull()->getLocalizationFromId(locId);
4180 * Returns a localization object, apt for modification, by its name.
4181 * \param [in] locName - the name of the localization of interest.
4182 * \return MEDFileFieldLoc& - a non-const reference to the localization object
4183 * having the name \a locName.
4184 * \throw If there is no a localization named \a locName.
4186 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
4188 return contentNotNull()->getLocalization(locName);
4192 * Returns a profile array, apt for modification, by its name.
4193 * \param [in] pflName - the name of the profile of interest.
4194 * \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
4195 * \throw If there is no a profile named \a pflName.
4197 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
4199 return contentNotNull()->getProfile(pflName);
4203 * Returns a profile array, apt for modification, by its id.
4204 * \param [in] pflId - the id of the profile of interest.
4205 * \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
4206 * \throw If there is no a profile with id \a pflId.
4208 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
4210 return contentNotNull()->getProfileFromId(pflId);
4214 * Removes profiles given by their ids. No data is updated to track this removal.
4215 * \param [in] pflIds - a sequence of ids of the profiles to remove.
4217 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
4219 contentNotNull()->killProfileIds(pflIds);
4223 * Removes localizations given by their ids. No data is updated to track this removal.
4224 * \param [in] locIds - a sequence of ids of the localizations to remove.
4226 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
4228 contentNotNull()->killLocalizationIds(locIds);
4232 * Stores a profile array.
4233 * \param [in] pfl - the profile array to store.
4234 * \throw If the name of \a pfl is empty.
4235 * \throw If a profile with the same name as that of \a pfl already exists but contains
4238 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
4240 contentNotNull()->appendProfile(pfl);
4244 * Adds a new localization of Gauss points.
4245 * \param [in] locName - the name of the new localization.
4246 * \param [in] geoType - a geometrical type of the reference cell.
4247 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
4248 * must be \c nbOfNodesPerCell * \c dimOfType.
4249 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
4250 * must be _wg_.size() * \c dimOfType.
4251 * \param [in] w - the weights of Gauss points.
4252 * \throw If \a locName is empty.
4253 * \throw If a localization with the name \a locName already exists but is
4254 * different form the new one.
4256 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)
4258 contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
4261 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
4263 MEDFileFieldGlobs *g(_globals);
4265 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
4269 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
4271 const MEDFileFieldGlobs *g(_globals);
4273 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
4277 //= MEDFileFieldNameScope
4279 MEDFileFieldNameScope::MEDFileFieldNameScope()
4283 MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName, const std::string& meshName):_name(fieldName),_mesh_name(meshName)
4288 * Returns the name of \a this field.
4289 * \return std::string - a string containing the field name.
4291 std::string MEDFileFieldNameScope::getName() const
4297 * Sets name of \a this field
4298 * \param [in] name - the new field name.
4300 void MEDFileFieldNameScope::setName(const std::string& fieldName)
4305 std::string MEDFileFieldNameScope::getDtUnit() const
4310 void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
4315 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
4318 _mesh_name=other._mesh_name;
4319 _dt_unit=other._dt_unit;
4323 * Returns the mesh name.
4324 * \return std::string - a string holding the mesh name.
4325 * \throw If \c _field_per_mesh.empty()
4327 std::string MEDFileFieldNameScope::getMeshName() const
4332 void MEDFileFieldNameScope::setMeshName(const std::string& meshName)
4334 _mesh_name=meshName;
4337 //= MEDFileAnyTypeField1TSWithoutSDA
4339 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
4341 _field_per_mesh.resize(other._field_per_mesh.size());
4343 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
4345 if((const MEDFileFieldPerMesh *)*it)
4346 _field_per_mesh[i]=(*it)->deepCopy(this);
4350 void MEDFileAnyTypeField1TSWithoutSDA::accept(MEDFileFieldVisitor& visitor) const
4352 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4353 if((*it).isNotNull())
4355 visitor.newMeshEntry(*it);
4356 (*it)->accept(visitor);
4357 visitor.endMeshEntry(*it);
4362 * Prints a string describing \a this field into a stream. This string is outputted
4363 * by \c print Python command.
4364 * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
4365 * \param [in,out] oss - the out stream.
4366 * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
4367 * info id printed, else, not.
4369 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
4371 std::string startOfLine(bkOffset,' ');
4372 oss << startOfLine << "Field ";
4374 oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
4375 oss << "on one time Step ";
4377 oss << "(" << f1tsId << ") ";
4378 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
4379 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
4380 const DataArray *arr=getUndergroundDataArray();
4383 const std::vector<std::string> &comps=arr->getInfoOnComponents();
4386 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
4387 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
4388 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
4390 if(arr->isAllocated())
4392 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
4395 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
4399 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
4401 oss << startOfLine << "----------------------" << std::endl;
4402 if(!_field_per_mesh.empty())
4405 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
4407 const MEDFileFieldPerMesh *cur=(*it2);
4409 cur->simpleRepr(bkOffset,oss,i);
4411 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
4416 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
4418 oss << startOfLine << "----------------------" << std::endl;
4421 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
4423 const DataArray *arr(getUndergroundDataArray());
4425 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
4426 int nbOfCompo=arr->getNumberOfComponents();
4427 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
4428 for(int i=0;i<nbOfCompo;i++)
4431 std::vector<int> v(1,i);
4432 MCAuto<DataArray> arr2=arr->keepSelectedComponents(v);
4433 ret[i]->setArray(arr2);
4438 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)
4442 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
4447 * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
4448 * empty. Returns -1 if this in on nodes.
4449 * \return int - the dimension of \a this.
4451 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
4454 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4455 (*it)->getDimension(ret);
4459 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
4462 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4464 MEDFileFieldPerMesh *cur(*it);
4466 ret=cur->changeMeshNames(modifTab) || ret;
4472 * Returns the number of iteration of the state of underlying mesh.
4473 * \return int - the iteration number.
4474 * \throw If \c _field_per_mesh.empty()
4476 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
4478 if(_field_per_mesh.empty())
4479 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
4480 return _field_per_mesh[0]->getMeshIteration();
4484 * Returns the order number of iteration of the state of underlying mesh.
4485 * \return int - the order number.
4486 * \throw If \c _field_per_mesh.empty()
4488 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
4490 if(_field_per_mesh.empty())
4491 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
4492 return _field_per_mesh[0]->getMeshOrder();
4496 * Checks if \a this field is tagged by a given iteration number and a given
4497 * iteration order number.
4498 * \param [in] iteration - the iteration number of interest.
4499 * \param [in] order - the iteration order number of interest.
4500 * \return bool - \c true if \a this->getIteration() == \a iteration &&
4501 * \a this->getOrder() == \a order.
4503 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
4505 return iteration==_iteration && order==_order;
4509 * Returns number of iteration and order number of iteration when
4510 * \a this field has been calculated.
4511 * \return std::pair<int,int> - a pair of the iteration number and the iteration
4514 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
4516 std::pair<int,int> p;
4522 * Returns number of iteration and order number of iteration when
4523 * \a this field has been calculated.
4524 * \param [in,out] p - a pair returning the iteration number and the iteration
4527 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
4534 * Returns all types of spatial discretization of \a this field.
4535 * \param [in,out] types - a sequence of types of \a this field.
4537 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
4539 std::set<TypeOfField> types2;
4540 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4542 (*it)->fillTypesOfFieldAvailable(types2);
4544 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
4545 std::copy(types2.begin(),types2.end(),bi);
4549 * Returns all types of spatial discretization of \a this field.
4550 * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
4553 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
4555 std::vector<TypeOfField> ret;
4556 fillTypesOfFieldAvailable(ret);
4560 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
4562 std::vector<std::string> ret;
4563 std::set<std::string> ret2;
4564 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4566 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
4567 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4568 if(ret2.find(*it2)==ret2.end())
4570 ret.push_back(*it2);
4577 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
4579 std::vector<std::string> ret;
4580 std::set<std::string> ret2;
4581 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4583 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
4584 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4585 if(ret2.find(*it2)==ret2.end())
4587 ret.push_back(*it2);
4594 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
4596 std::vector<std::string> ret;
4597 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4599 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
4600 ret.insert(ret.end(),tmp.begin(),tmp.end());
4605 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
4607 std::vector<std::string> ret;
4608 std::set<std::string> ret2;
4609 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4611 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
4612 ret.insert(ret.end(),tmp.begin(),tmp.end());
4617 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4619 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4620 (*it)->changePflsRefsNamesGen(mapOfModif);
4623 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4625 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4626 (*it)->changeLocsRefsNamesGen(mapOfModif);
4630 * Returns all attributes of parts of \a this field lying on a given mesh.
4631 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4632 * item of every of returned sequences refers to the _i_-th part of \a this field.
4633 * Thus all sequences returned by this method are of the same length equal to number
4634 * of different types of supporting entities.<br>
4635 * A field part can include sub-parts with several different spatial discretizations,
4636 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
4637 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4638 * of a nested sequence corresponds to a type of spatial discretization.<br>
4639 * This method allows for iteration over MEDFile DataStructure without any overhead.
4640 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4641 * for the case with only one underlying mesh. (Actually, the number of meshes is
4642 * not checked if \a mname == \c NULL).
4643 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4644 * a field part is returned.
4645 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4646 * This sequence is of the same length as \a types.
4647 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4648 * discretization. A profile name can be empty.
4649 * Length of this and of nested sequences is the same as that of \a typesF.
4650 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4651 * discretization. A localization name can be empty.
4652 * Length of this and of nested sequences is the same as that of \a typesF.
4653 * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
4654 * of ids of tuples within the data array, per each type of spatial
4655 * discretization within one mesh entity type.
4656 * Length of this and of nested sequences is the same as that of \a typesF.
4657 * \throw If no field is lying on \a mname.
4659 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
4661 if(_field_per_mesh.empty())
4662 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4663 return _field_per_mesh[0]->getFieldSplitedByType(types,typesF,pfls,locs);
4667 * Returns dimensions of mesh elements \a this field lies on. The returned value is a
4668 * maximal absolute dimension and values returned via the out parameter \a levs are
4669 * dimensions relative to the maximal absolute dimension. <br>
4670 * This method is designed for MEDFileField1TS instances that have a discretization
4671 * \ref MEDCoupling::ON_CELLS "ON_CELLS",
4672 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT",
4673 * \ref MEDCoupling::ON_GAUSS_NE "ON_GAUSS_NE".
4674 * Only these 3 discretizations will be taken into account here. If \a this is
4675 * \ref MEDCoupling::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
4676 * This method is useful to make the link between the dimension of the underlying mesh
4677 * and the levels of \a this, because it is possible that the highest dimension of \a this
4678 * field is not equal to the dimension of the underlying mesh.
4680 * Let's consider the following case:
4681 * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
4682 * TETRA4, HEXA8, TRI3 and SEG2.
4683 * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
4684 * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
4686 * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
4687 * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
4688 * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
4689 * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
4690 * parameter of getFieldAtLevel() is computed basing on the returned values as this:
4691 * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
4693 * to retrieve the highest level of
4694 * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br>
4695 * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
4696 * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
4697 * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
4698 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4699 * for the case with only one underlying mesh. (Actually, the number of meshes is
4700 * not checked if \a mname == \c NULL).
4701 * \param [in,out] levs - a sequence returning the dimensions relative to the maximal
4702 * absolute one. They are in decreasing order. This sequence is cleared before
4704 * \return int - the maximal absolute dimension of elements \a this fields lies on.
4705 * \throw If no field is lying on \a mname.
4707 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
4710 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4711 std::vector< std::vector<TypeOfField> > typesF;
4712 std::vector< std::vector<std::string> > pfls, locs;
4713 if(_field_per_mesh.empty())
4714 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels : This is empty !");
4715 _field_per_mesh[0]->getFieldSplitedByType(types,typesF,pfls,locs);
4717 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
4718 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
4719 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
4721 st.erase(INTERP_KERNEL::NORM_ERROR);
4723 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
4725 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
4726 ret1.insert((int)cm.getDimension());
4728 int ret=*std::max_element(ret1.begin(),ret1.end());
4729 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
4730 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
4734 void MEDFileAnyTypeField1TSWithoutSDA::convertMedBallIntoClassic()
4736 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it<_field_per_mesh.end();it++)
4737 if((*it).isNotNull())
4738 (*it)->convertMedBallIntoClassic();
4741 void MEDFileAnyTypeField1TSWithoutSDA::makeReduction(INTERP_KERNEL::NormalizedCellType ct, TypeOfField tof, const DataArrayInt *pfl)
4744 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : null pfl !");
4745 std::string name(pfl->getName());
4746 pfl->checkAllocated();
4747 if(pfl->getNumberOfComponents()!=1)
4748 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : non mono compo array !");
4750 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : empty pfl name !");
4751 if(_field_per_mesh.size()!=1)
4752 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : only single mesh supported !");
4753 MCAuto<MEDFileFieldPerMesh> fpm(_field_per_mesh[0]);
4755 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : only single not null mesh supported !");
4756 MEDFileFieldPerMeshPerTypePerDisc *disc(fpm->getLeafGivenTypeAndLocId(ct,0));
4757 if(disc->getType()!=tof)
4758 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : error !");
4759 int s(disc->getStart()),e(disc->getEnd()),nt(pfl->getNumberOfTuples());
4760 DataArray *arr(getUndergroundDataArray());
4761 int nt2(arr->getNumberOfTuples()),delta((e-s)-nt);
4763 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : internal error !");
4764 MCAuto<DataArray> arr0(arr->selectByTupleIdSafeSlice(0,s,1)),arr1(arr->selectByTupleIdSafeSlice(s,e,1)),arr2(arr->selectByTupleIdSafeSlice(e,nt2,1));
4765 MCAuto<DataArray> arr11(arr1->selectByTupleIdSafe(pfl->begin(),pfl->end()));
4766 MCAuto<DataArray> arrOut(arr->buildNewEmptyInstance());
4767 arrOut->alloc(nt2-delta,arr->getNumberOfComponents());
4768 arrOut->copyStringInfoFrom(*arr);
4769 arrOut->setContigPartOfSelectedValuesSlice(0,arr0,0,s,1);
4770 arrOut->setContigPartOfSelectedValuesSlice(s,arr11,0,nt,1);
4771 arrOut->setContigPartOfSelectedValuesSlice(e-delta,arr2,0,nt2-e,1);
4773 disc->setEnd(e-delta);
4774 disc->setProfile(name);
4778 * \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.
4779 * \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.
4780 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4781 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4783 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
4785 if(_field_per_mesh.empty())
4786 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId : This is empty !");
4787 return _field_per_mesh[0]->getLeafGivenTypeAndLocId(typ,locId);
4791 * \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.
4792 * \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.
4793 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4794 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4796 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
4798 if(_field_per_mesh.empty())
4799 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId : This is empty !");
4800 return _field_per_mesh[0]->getLeafGivenTypeAndLocId(typ,locId);
4804 * \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.
4806 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
4808 if(_field_per_mesh.empty())
4809 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4812 std::string mName2(mName);
4814 std::vector<std::string> msg;
4815 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4816 if(mName2==(*it)->getMeshName())
4819 msg.push_back((*it)->getMeshName());
4820 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4821 oss << "Possible meshes are : ";
4822 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4823 oss << "\"" << (*it2) << "\" ";
4824 throw INTERP_KERNEL::Exception(oss.str());
4827 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
4830 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4831 std::string tmp(mesh->getName());
4833 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4835 std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4837 for(;it!=_field_per_mesh.end();it++,i++)
4839 if((*it)->getMeshName()==tmp)
4842 int sz=_field_per_mesh.size();
4843 _field_per_mesh.resize(sz+1);
4844 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4848 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4849 MEDFileFieldGlobsReal& glob)
4852 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4854 MEDFileFieldPerMesh *fpm(*it);
4856 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4862 * This method splits \a this into several sub-parts so that each sub parts have exactly one spatial discretization. This method implements the minimal
4863 * splitting that leads to single spatial discretization of this.
4865 * \sa splitMultiDiscrPerGeoTypes
4867 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
4869 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4870 std::vector< std::vector<TypeOfField> > typesF;
4871 std::vector< std::vector<std::string> > pfls,locs;
4872 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4873 std::set<TypeOfField> allEnt;
4874 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4875 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4876 allEnt.insert(*it2);
4877 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4878 std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4879 for(std::size_t i=0;i<allEnt.size();i++,it3++)
4881 std::vector< std::pair<int,int> > its;
4882 ret[i]=shallowCpy();
4883 int newLgth(ret[i]->keepOnlySpatialDiscretization(*it3,its));
4884 ret[i]->updateData(newLgth,its);
4890 * This method performs a sub splitting as splitDiscretizations does but finer. This is the finest spliting level that can be done.
4891 * This method implements the minimal splitting so that each returned elements are mono Gauss discretization per geometric type.
4893 * \sa splitDiscretizations
4895 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes() const
4897 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4898 std::vector< std::vector<TypeOfField> > typesF;
4899 std::vector< std::vector<std::string> > pfls,locs;
4900 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4901 std::set<TypeOfField> allEnt;
4902 std::size_t nbOfMDPGT(0),ii(0);
4903 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++,ii++)
4905 nbOfMDPGT=std::max(nbOfMDPGT,locs[ii].size());
4906 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4907 allEnt.insert(*it2);
4909 if(allEnt.size()!=1)
4910 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : this field is expected to be defined only on one spatial discretization !");
4912 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
4915 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret0(1);
4916 ret0[0]=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(this); this->incrRef();
4919 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfMDPGT);
4920 for(std::size_t i=0;i<nbOfMDPGT;i++)
4922 std::vector< std::pair<int,int> > its;
4923 ret[i]=shallowCpy();
4924 int newLgth(ret[i]->keepOnlyGaussDiscretization(i,its));
4925 ret[i]->updateData(newLgth,its);
4930 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
4932 int globalCounter(0);
4933 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4934 (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4935 return globalCounter;
4938 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlyGaussDiscretization(std::size_t idOfDisc, std::vector< std::pair<int,int> >& its)
4940 int globalCounter(0);
4941 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4942 (*it)->keepOnlyGaussDiscretization(idOfDisc,globalCounter,its);
4943 return globalCounter;
4946 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
4948 if(_nb_of_tuples_to_be_allocated>=0)
4950 _nb_of_tuples_to_be_allocated=newLgth;
4951 const DataArray *oldArr(getUndergroundDataArray());
4954 MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4955 newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
4957 _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
4961 if(_nb_of_tuples_to_be_allocated==-1)
4963 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4965 const DataArray *oldArr(getUndergroundDataArray());
4966 if(!oldArr || !oldArr->isAllocated())
4967 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4968 MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4969 newArr->alloc(newLgth,getNumberOfComponents());
4971 newArr->copyStringInfoFrom(*oldArr);
4973 for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4975 if((*it).second<(*it).first)
4976 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4977 newArr->setContigPartOfSelectedValuesSlice(pos,oldArr,(*it).first,(*it).second,1);
4978 pos+=(*it).second-(*it).first;
4983 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4986 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
4988 if(_field_per_mesh.empty())
4989 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4990 if(_field_per_mesh.size()>1)
4991 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4992 _field_per_mesh[0]->copyOptionsFrom(opts);
4993 _field_per_mesh[0]->writeLL(fid,nasc);
4997 * 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.
4998 * If false is returned the memory allocation is not required.
5000 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
5002 if(_nb_of_tuples_to_be_allocated>=0)
5004 getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
5005 _nb_of_tuples_to_be_allocated=-2;
5008 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
5010 if(_nb_of_tuples_to_be_allocated==-1)
5011 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
5012 if(_nb_of_tuples_to_be_allocated<-3)
5013 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
5014 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
5017 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
5019 med_int numdt,numit;
5021 med_int meshnumdt,meshnumit;
5022 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt));
5026 INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
5027 MEDFILESAFECALLERRD0(MEDfield23ComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit)); // to check with Adrien for legacy MED files
5029 //MEDFILESAFECALLERRD0(MEDfieldComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt,&meshnumdt,&meshnumit));
5030 if(_iteration!=numdt || _order!=numit)
5031 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
5032 _field_per_mesh.resize(1);
5037 mm=ms->getMeshWithName(getMeshName());
5040 _field_per_mesh[0]=MEDFileFieldPerMesh::NewOnRead(fid,this,0,meshnumdt,meshnumit,nasc,mm,entities);
5041 _nb_of_tuples_to_be_allocated=0;
5042 _field_per_mesh[0]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
5045 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
5047 allocIfNecessaryTheArrayToReceiveDataFromFile();
5048 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5049 (*it)->loadBigArraysRecursively(fid,nasc);
5052 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
5054 if(allocIfNecessaryTheArrayToReceiveDataFromFile())
5055 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5056 (*it)->loadBigArraysRecursively(fid,nasc);
5059 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
5061 loadOnlyStructureOfDataRecursively(fid,nasc,ms,entities);
5062 loadBigArraysRecursively(fid,nasc);
5065 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
5067 DataArray *thisArr(getUndergroundDataArray());
5068 if(thisArr && thisArr->isAllocated())
5070 _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
5071 thisArr->desallocate();
5075 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
5077 return _mesh_name.capacity()+_dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MCAuto< MEDFileFieldPerMesh >);
5080 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
5082 std::vector<const BigMemoryObject *> ret;
5083 if(getUndergroundDataArray())
5084 ret.push_back(getUndergroundDataArray());
5085 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5086 ret.push_back((const MEDFileFieldPerMesh *)*it);
5091 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
5092 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
5093 * "Sort By Type"), if not, an exception is thrown.
5094 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
5095 * \param [in] arr - the array of values.
5096 * \param [in,out] glob - the global data where profiles and localization present in
5097 * \a field, if any, are added.
5098 * \throw If the name of \a field is empty.
5099 * \throw If the data array of \a field is not set.
5100 * \throw If \a this->_arr is already allocated but has different number of components
5102 * \throw If the underlying mesh of \a field has no name.
5103 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
5105 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
5107 const MEDCouplingMesh *mesh=field->getMesh();
5109 TypeOfField type=field->getTypeOfField();
5110 std::vector<DataArrayInt *> dummy;
5112 setMeshName(mesh->getName());
5113 int start=copyTinyInfoFrom(field,arr);
5114 int pos=addNewEntryIfNecessary(mesh);
5117 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
5118 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
5121 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
5125 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
5126 * of a given mesh are used as the support of the given field (a real support is not used).
5127 * Elements of the given mesh must be sorted suitable for writing to MED file.
5128 * Order of underlying mesh entities of the given field specified by \a profile parameter
5129 * is not prescribed; this method permutes field values to have them sorted by element
5130 * type as required for writing to MED file. A new profile is added only if no equal
5131 * profile is missing.
5132 * \param [in] field - the field to add to \a this. The field double values are ignored.
5133 * \param [in] arrOfVals - the values of the field \a field used.
5134 * \param [in] mesh - the supporting mesh of \a field.
5135 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
5136 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
5137 * \param [in,out] glob - the global data where profiles and localization present in
5138 * \a field, if any, are added.
5139 * \throw If either \a field or \a mesh or \a profile has an empty name.
5140 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
5141 * \throw If the data array of \a field is not set.
5142 * \throw If \a this->_arr is already allocated but has different number of components
5144 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
5145 * \sa setFieldNoProfileSBT()
5147 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
5150 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
5151 if(!arrOfVals || !arrOfVals->isAllocated())
5152 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
5153 TypeOfField type=field->getTypeOfField();
5154 std::vector<DataArrayInt *> idsInPflPerType;
5155 std::vector<DataArrayInt *> idsPerType;
5156 std::vector<int> code,code2;
5157 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
5160 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
5161 std::vector< MCAuto<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
5162 std::vector< MCAuto<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin());
5163 std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
5165 MCAuto<MEDCouplingFieldDouble> field2=field->clone(false);
5166 int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
5167 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
5169 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
5170 throw INTERP_KERNEL::Exception(oss.str());
5173 int start=copyTinyInfoFrom(field,arrOfVals);
5174 code2=m->getDistributionOfTypes();
5176 int pos=addNewEntryIfNecessary(m);
5177 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
5181 if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
5182 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
5183 std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
5184 std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
5185 int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
5186 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
5188 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
5189 throw INTERP_KERNEL::Exception(oss.str());
5191 int start=copyTinyInfoFrom(field,arrOfVals);
5192 int pos=addNewEntryIfNecessary(m);
5193 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
5198 * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
5200 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
5202 if(_nb_of_tuples_to_be_allocated>=0)
5203 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 !");
5204 DataArray *arr(getOrCreateAndGetArray());
5205 arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
5206 _nb_of_tuples_to_be_allocated=-3;
5210 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
5211 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
5212 * larger by the size of \a field. Returns an id of the first not filled
5213 * tuple of \a this->_arr.
5214 * \param [in] field - the field to copy the info on components and the name from.
5215 * \return int - the id of first not initialized tuple of \a this->_arr.
5216 * \throw If the name of \a field is empty.
5217 * \throw If the data array of \a field is not set.
5218 * \throw If \a this->_arr is already allocated but has different number of components
5221 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
5224 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
5225 std::string name(field->getName());
5226 setName(name.c_str());
5227 if(field->getMesh())
5228 setMeshName(field->getMesh()->getName());
5229 setDtUnit(field->getTimeUnit());
5231 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
5233 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
5234 if(!arr->isAllocated())
5235 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
5236 _dt=field->getTime(_iteration,_order);
5237 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
5238 if(!getOrCreateAndGetArray()->isAllocated())
5240 allocNotFromFile(arr->getNumberOfTuples());
5245 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
5246 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
5247 getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
5248 _nb_of_tuples_to_be_allocated=-3;
5249 return oldNbOfTuples;
5254 * Returns number of components in \a this field
5255 * \return int - the number of components.
5257 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
5259 return getOrCreateAndGetArray()->getNumberOfComponents();
5263 * Change info on components in \a this.
5264 * \throw If size of \a infos is not equal to the number of components already in \a this.
5266 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
5268 DataArray *arr=getOrCreateAndGetArray();
5269 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
5273 * Returns info on components of \a this field.
5274 * \return const std::vector<std::string>& - a sequence of strings each being an
5275 * information on _i_-th component.
5277 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
5279 const DataArray *arr=getOrCreateAndGetArray();
5280 return arr->getInfoOnComponents();
5284 * Returns a mutable info on components of \a this field.
5285 * \return std::vector<std::string>& - a sequence of strings each being an
5286 * information on _i_-th component.
5288 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
5290 DataArray *arr=getOrCreateAndGetArray();
5291 return arr->getInfoOnComponents();
5294 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const
5296 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5298 const MEDFileFieldPerMesh *fpm(*it);
5301 if(fpm->presenceOfMultiDiscPerGeoType())
5307 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfStructureElements() const
5309 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5310 if((*it).isNotNull())
5311 if((*it)->presenceOfStructureElements())
5316 bool MEDFileAnyTypeField1TSWithoutSDA::onlyStructureElements() const
5318 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5319 if((*it).isNotNull())
5320 if(!(*it)->onlyStructureElements())
5325 void MEDFileAnyTypeField1TSWithoutSDA::killStructureElements()
5327 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5328 if((*it).isNotNull())
5329 (*it)->killStructureElements();
5332 void MEDFileAnyTypeField1TSWithoutSDA::keepOnlyStructureElements()
5334 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5335 if((*it).isNotNull())
5336 (*it)->keepOnlyStructureElements();
5339 void MEDFileAnyTypeField1TSWithoutSDA::keepOnlyOnSE(const std::string& seName)
5341 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5342 if((*it).isNotNull())
5343 (*it)->keepOnlyOnSE(seName);
5346 void MEDFileAnyTypeField1TSWithoutSDA::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
5348 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5349 if((*it).isNotNull())
5350 (*it)->getMeshSENames(ps);
5353 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh(const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5355 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 !";
5356 if(_field_per_mesh.empty())
5357 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is empty ! Nothing to extract !");
5358 if(_field_per_mesh.size()>1)
5359 throw INTERP_KERNEL::Exception(MSG0);
5360 if(_field_per_mesh[0].isNull())
5361 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is inconsistent !");
5362 const MEDFileFieldPerMesh *pm(_field_per_mesh[0]);
5363 std::set<TypeOfField> types;
5364 pm->fillTypesOfFieldAvailable(types);
5366 throw INTERP_KERNEL::Exception(MSG0);
5367 TypeOfField type(*types.begin());
5368 int meshDimRelToMax(0);
5373 int myDim(std::numeric_limits<int>::max());
5374 bool isUnique(pm->isUniqueLevel(myDim));
5376 throw INTERP_KERNEL::Exception(MSG0);
5377 meshDimRelToMax=myDim-mesh->getMeshDimension();
5378 if(meshDimRelToMax>0)
5379 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the mesh attached to field is not compatible with the field !");
5381 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,0/*renumPol*/,glob,mesh,arrOut,nasc);
5385 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5386 * \param [in] type - a spatial discretization of the new field.
5387 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5388 * \param [in] mName - a name of the supporting mesh.
5389 * \param [in] renumPol - specifies how to permute values of the result field according to
5390 * the optional numbers of cells and nodes, if any. The valid values are
5391 * - 0 - do not permute.
5392 * - 1 - permute cells.
5393 * - 2 - permute nodes.
5394 * - 3 - permute cells and nodes.
5396 * \param [in] glob - the global data storing profiles and localization.
5397 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5398 * caller is to delete this field using decrRef() as it is no more needed.
5399 * \throw If the MED file is not readable.
5400 * \throw If there is no mesh named \a mName in the MED file.
5401 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5402 * \throw If no field of \a this is lying on the mesh \a mName.
5403 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5405 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5407 MCAuto<MEDFileMesh> mm;
5409 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
5411 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
5412 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
5416 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5417 * \param [in] type - a spatial discretization of the new field.
5418 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5419 * \param [in] renumPol - specifies how to permute values of the result field according to
5420 * the optional numbers of cells and nodes, if any. The valid values are
5421 * - 0 - do not permute.
5422 * - 1 - permute cells.
5423 * - 2 - permute nodes.
5424 * - 3 - permute cells and nodes.
5426 * \param [in] glob - the global data storing profiles and localization.
5427 * \param [in] mesh - the supporting mesh.
5428 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5429 * caller is to delete this field using decrRef() as it is no more needed.
5430 * \throw If the MED file is not readable.
5431 * \throw If no field of \a this is lying on \a mesh.
5432 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5433 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5435 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5437 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax,false));
5438 const DataArrayInt *d(mesh->getNumberFieldAtLevel(meshDimRelToMax)),*e(mesh->getNumberFieldAtLevel(1));
5439 if(meshDimRelToMax==1)
5440 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
5441 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
5445 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
5447 * \param [in] type - a spatial discretization of the new field.
5448 * \param [in] mName - a name of the supporting mesh.
5449 * \param [in] renumPol - specifies how to permute values of the result field according to
5450 * the optional numbers of cells and nodes, if any. The valid values are
5451 * - 0 - do not permute.
5452 * - 1 - permute cells.
5453 * - 2 - permute nodes.
5454 * - 3 - permute cells and nodes.
5456 * \param [in] glob - the global data storing profiles and localization.
5457 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5458 * caller is to delete this field using decrRef() as it is no more needed.
5459 * \throw If the MED file is not readable.
5460 * \throw If there is no mesh named \a mName in the MED file.
5461 * \throw If there are no mesh entities in the mesh.
5462 * \throw If no field values of the given \a type are available.
5464 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5466 MCAuto<MEDFileMesh> mm;
5468 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
5470 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
5471 int absDim=getDimension();
5472 int meshDimRelToMax=absDim-mm->getMeshDimension();
5473 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
5477 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5478 * \param [in] type - a spatial discretization of the new field.
5479 * \param [in] renumPol - specifies how to permute values of the result field according to
5480 * the optional numbers of cells and nodes, if any. The valid values are
5481 * - 0 - do not permute.
5482 * - 1 - permute cells.
5483 * - 2 - permute nodes.
5484 * - 3 - permute cells and nodes.
5486 * \param [in] glob - the global data storing profiles and localization.
5487 * \param [in] mesh - the supporting mesh.
5488 * \param [in] cellRenum - the cell numbers array used for permutation of the result
5489 * field according to \a renumPol.
5490 * \param [in] nodeRenum - the node numbers array used for permutation of the result
5491 * field according to \a renumPol.
5492 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5493 * caller is to delete this field using decrRef() as it is no more needed.
5494 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5495 * \throw If no field of \a this is lying on \a mesh.
5496 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5498 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
5500 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
5502 MCAuto<MEDCouplingFieldDouble> ret=_field_per_mesh[0]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
5507 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5514 throw INTERP_KERNEL::Exception(msg1);
5515 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5518 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
5520 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5521 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
5522 throw INTERP_KERNEL::Exception(oss.str());
5524 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
5525 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
5526 std::vector<DataArray *> arrOut2(1,arrOut);
5527 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
5528 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
5529 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
5536 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5538 throw INTERP_KERNEL::Exception(msg1);
5541 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
5543 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5544 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
5545 throw INTERP_KERNEL::Exception(oss.str());
5547 MCAuto<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
5548 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
5549 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
5550 ret->renumberNodes(nodeRenumSafe->getConstPointer());
5555 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
5560 * Returns values and a profile of the field of a given type lying on a given support.
5561 * \param [in] type - a spatial discretization of the field.
5562 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5563 * \param [in] mesh - the supporting mesh.
5564 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
5565 * field of interest lies on. If the field lies on all entities of the given
5566 * dimension, all ids in \a pfl are zero. The caller is to delete this array
5567 * using decrRef() as it is no more needed.
5568 * \param [in] glob - the global data storing profiles and localization.
5569 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
5570 * field. The caller is to delete this array using decrRef() as it is no more needed.
5571 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
5572 * \throw If no field of \a this is lying on \a mesh.
5573 * \throw If no field values of the given \a type are available.
5575 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
5577 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
5578 MCAuto<DataArray> ret=_field_per_mesh[0]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
5579 ret->setName(nasc.getName().c_str());
5583 //= MEDFileField1TSWithoutSDA
5586 * Throws if a given value is not a valid (non-extended) relative dimension.
5587 * \param [in] meshDimRelToMax - the relative dimension value.
5588 * \throw If \a meshDimRelToMax > 0.
5590 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
5592 if(meshDimRelToMax>0)
5593 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
5597 * Checks if elements of a given mesh are in the order suitable for writing
5598 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
5599 * vector describing types of elements and their number.
5600 * \param [in] mesh - the mesh to check.
5601 * \return std::vector<int> - a vector holding for each element type (1) item of
5602 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
5603 * These values are in full-interlace mode.
5604 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
5606 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
5609 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
5610 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
5611 int nbOfTypes=geoTypes.size();
5612 std::vector<int> code(3*nbOfTypes);
5613 MCAuto<DataArrayInt> arr1=DataArrayInt::New();
5614 arr1->alloc(nbOfTypes,1);
5615 int *arrPtr=arr1->getPointer();
5616 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
5617 for(int i=0;i<nbOfTypes;i++,it++)
5618 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
5619 MCAuto<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
5620 const int *arrPtr2=arr2->getConstPointer();
5622 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
5625 int nbCells=mesh->getNumberOfCellsWithType(*it);
5626 code[3*pos]=(int)(*it);
5627 code[3*pos+1]=nbCells;
5628 code[3*pos+2]=-1;//no profiles
5630 std::vector<const DataArrayInt *> idsPerType;//no profiles
5631 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
5635 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
5640 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5642 return new MEDFileField1TSWithoutSDA(fieldName,meshName,csit,iteration,order,infos);
5646 * Returns all attributes and values of parts of \a this field lying on a given mesh.
5647 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
5648 * item of every of returned sequences refers to the _i_-th part of \a this field.
5649 * Thus all sequences returned by this method are of the same length equal to number
5650 * of different types of supporting entities.<br>
5651 * A field part can include sub-parts with several different spatial discretizations,
5652 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
5653 * for example. Hence, some of the returned sequences contains nested sequences, and an item
5654 * of a nested sequence corresponds to a type of spatial discretization.<br>
5655 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
5656 * The overhead is due to selecting values into new instances of DataArrayDouble.
5657 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
5658 * for the case with only one underlying mesh. (Actually, the number of meshes is
5659 * not checked if \a mname == \c NULL).
5660 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
5661 * a field part is returned.
5662 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
5663 * A field part can include sub-parts with several different spatial discretizations,
5664 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and
5665 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT" for example.
5666 * This sequence is of the same length as \a types.
5667 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
5668 * discretization. A profile name can be empty.
5669 * Length of this and of nested sequences is the same as that of \a typesF.
5670 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
5671 * discretization. A localization name can be empty.
5672 * Length of this and of nested sequences is the same as that of \a typesF.
5673 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
5674 * per each type of spatial discretization within one mesh entity type.
5675 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
5676 * Length of this and of nested sequences is the same as that of \a typesF.
5677 * \throw If no field is lying on \a mname.
5679 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
5682 if(_field_per_mesh.empty())
5683 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
5684 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[0]->getFieldSplitedByType(types,typesF,pfls,locs);
5685 int nbOfRet=ret0.size();
5686 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
5687 for(int i=0;i<nbOfRet;i++)
5689 const std::vector< std::pair<int,int> >& p=ret0[i];
5690 int nbOfRet1=p.size();
5691 ret[i].resize(nbOfRet1);
5692 for(int j=0;j<nbOfRet1;j++)
5694 DataArrayDouble *tmp=_arr->selectByTupleIdSafeSlice(p[j].first,p[j].second,1);
5701 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
5706 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
5708 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
5709 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5710 ret->deepCpyLeavesFrom(*this);
5711 const DataArrayDouble *arr(_arr);
5714 MCAuto<DataArrayInt> arr2(arr->convertToIntArr());
5715 ret->setArray(arr2);
5721 * Returns a pointer to the underground DataArrayDouble instance and a
5722 * sequence describing parameters of a support of each part of \a this field. The
5723 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5724 * direct access to the field values. This method is intended for the field lying on one
5726 * \param [in,out] entries - the sequence describing parameters of a support of each
5727 * part of \a this field. Each item of this sequence consists of two parts. The
5728 * first part describes a type of mesh entity and an id of discretization of a
5729 * current field part. The second part describes a range of values [begin,end)
5730 * within the returned array relating to the current field part.
5731 * \return DataArrayDouble * - the pointer to the field values array.
5732 * \throw If the number of underlying meshes is not equal to 1.
5733 * \throw If no field values are available.
5734 * \sa getUndergroundDataArray()
5736 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5738 if(_field_per_mesh.size()!=1)
5739 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5740 if(_field_per_mesh[0]==0)
5741 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5742 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5743 return getUndergroundDataArrayTemplate();
5747 * Returns a pointer to the underground DataArrayDouble instance and a
5748 * sequence describing parameters of a support of each part of \a this field. The
5749 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5750 * direct access to the field values. This method is intended for the field lying on one
5752 * \param [in,out] entries - the sequence describing parameters of a support of each
5753 * part of \a this field. Each item of this sequence consists of two parts. The
5754 * first part describes a type of mesh entity and an id of discretization of a
5755 * current field part. The second part describes a range of values [begin,end)
5756 * within the returned array relating to the current field part.
5757 * \return DataArrayDouble * - the pointer to the field values array.
5758 * \throw If the number of underlying meshes is not equal to 1.
5759 * \throw If no field values are available.
5760 * \sa getUndergroundDataArray()
5762 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5764 return getUndergroundDataArrayDoubleExt(entries);
5767 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)
5769 DataArrayDouble *arr(getOrCreateAndGetArrayTemplate());
5770 arr->setInfoAndChangeNbOfCompo(infos);
5773 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<double>()
5777 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
5779 MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
5780 ret->deepCpyLeavesFrom(*this);
5784 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCopy() const
5786 MCAuto<MEDFileField1TSWithoutSDA> ret(shallowCpy());
5787 if(_arr.isNotNull())
5788 ret->_arr=_arr->deepCopy();
5792 //= MEDFileIntField1TSWithoutSDA
5794 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5796 return new MEDFileIntField1TSWithoutSDA(fieldName,meshName,csit,iteration,order,infos);
5799 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<int>()
5803 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order,
5804 const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<int>(fieldName,meshName,csit,iteration,order)
5806 DataArrayInt *arr(getOrCreateAndGetArrayTemplate());
5807 arr->setInfoAndChangeNbOfCompo(infos);
5810 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
5815 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const
5817 MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
5818 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5819 ret->deepCpyLeavesFrom(*this);
5820 const DataArrayInt *arr(_arr);
5823 MCAuto<DataArrayDouble> arr2(arr->convertToDblArr());
5824 ret->setArray(arr2);
5830 * Returns a pointer to the underground DataArrayInt instance and a
5831 * sequence describing parameters of a support of each part of \a this field. The
5832 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5833 * direct access to the field values. This method is intended for the field lying on one
5835 * \param [in,out] entries - the sequence describing parameters of a support of each
5836 * part of \a this field. Each item of this sequence consists of two parts. The
5837 * first part describes a type of mesh entity and an id of discretization of a
5838 * current field part. The second part describes a range of values [begin,end)
5839 * within the returned array relating to the current field part.
5840 * \return DataArrayInt * - the pointer to the field values array.
5841 * \throw If the number of underlying meshes is not equal to 1.
5842 * \throw If no field values are available.
5843 * \sa getUndergroundDataArray()
5845 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5847 return getUndergroundDataArrayIntExt(entries);
5851 * Returns a pointer to the underground DataArrayInt instance and a
5852 * sequence describing parameters of a support of each part of \a this field. The
5853 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5854 * direct access to the field values. This method is intended for the field lying on one
5856 * \param [in,out] entries - the sequence describing parameters of a support of each
5857 * part of \a this field. Each item of this sequence consists of two parts. The
5858 * first part describes a type of mesh entity and an id of discretization of a
5859 * current field part. The second part describes a range of values [begin,end)
5860 * within the returned array relating to the current field part.
5861 * \return DataArrayInt * - the pointer to the field values array.
5862 * \throw If the number of underlying meshes is not equal to 1.
5863 * \throw If no field values are available.
5864 * \sa getUndergroundDataArray()
5866 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5868 if(_field_per_mesh.size()!=1)
5869 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5870 if(_field_per_mesh[0]==0)
5871 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5872 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5873 return getUndergroundDataArrayTemplate();
5876 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5878 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5879 ret->deepCpyLeavesFrom(*this);
5883 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCopy() const
5885 MCAuto<MEDFileIntField1TSWithoutSDA> ret(shallowCpy());
5886 if(_arr.isNotNull())
5887 ret->_arr=_arr->deepCopy();
5891 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5895 //= MEDFileAnyTypeField1TS
5897 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
5899 med_field_type typcha;
5901 std::vector<std::string> infos;
5902 std::string dtunit,fieldName,meshName;
5903 LocateField2(fid,0,true,fieldName,typcha,infos,dtunit,meshName);
5904 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5909 ret=MEDFileField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5914 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5919 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] !";
5920 throw INTERP_KERNEL::Exception(oss.str());
5923 ret->setDtUnit(dtunit.c_str());
5924 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5926 med_int numdt,numit;
5928 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5929 ret->setTime(numdt,numit,dt);
5932 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
5934 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
5938 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
5939 try:MEDFileFieldGlobsReal(fid)
5941 _content=BuildContentFrom(fid,loadAll,ms,entities);
5944 catch(INTERP_KERNEL::Exception& e)
5949 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
5951 med_field_type typcha;
5952 std::vector<std::string> infos;
5953 std::string dtunit,meshName;
5955 int nbSteps=LocateField(fid,fieldName,iii,typcha,infos,dtunit,meshName);
5956 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5961 ret=MEDFileField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5966 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5971 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] !";
5972 throw INTERP_KERNEL::Exception(oss.str());
5975 ret->setMeshName(meshName);
5976 ret->setDtUnit(dtunit.c_str());
5977 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5981 std::ostringstream oss; oss << "MEDFileField1TS(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5982 throw INTERP_KERNEL::Exception(oss.str());
5985 med_int numdt,numit;
5987 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5988 ret->setTime(numdt,numit,dt);
5991 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
5993 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
5997 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
5998 try:MEDFileFieldGlobsReal(fid)
6000 _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
6003 catch(INTERP_KERNEL::Exception& e)
6008 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c)
6011 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
6012 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
6014 MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
6015 ret->_content=c; c->incrRef();
6018 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
6020 MCAuto<MEDFileIntField1TS> ret(MEDFileIntField1TS::New());
6021 ret->_content=c; c->incrRef();
6024 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
6027 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, med_idt fid)
6029 MEDFileAnyTypeField1TS *ret(BuildNewInstanceFromContent(c));
6030 ret->setFileName(FileNameFromFID(fid));
6034 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
6036 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6037 return New(fid,loadAll);
6040 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, bool loadAll)
6042 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,loadAll,0,0));
6043 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
6044 ret->loadGlobals(fid);
6048 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6050 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6051 return New(fid,fieldName,loadAll);
6054 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
6056 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
6057 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
6058 ret->loadGlobals(fid);
6062 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6064 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6065 return New(fid,fieldName,iteration,order,loadAll);
6068 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
6070 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0,0));
6071 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
6072 ret->loadGlobals(fid);
6076 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::NewAdv(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileEntities *entities)
6078 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6079 return NewAdv(fid,fieldName,iteration,order,loadAll,entities);
6082 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::NewAdv(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileEntities *entities)
6084 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0,entities));
6085 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
6086 ret->loadGlobals(fid);
6090 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
6092 med_field_type typcha;
6093 std::vector<std::string> infos;
6094 std::string dtunit,meshName;
6096 int nbOfStep2(LocateField(fid,fieldName,iii,typcha,infos,dtunit,meshName));
6097 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
6102 ret=MEDFileField1TSWithoutSDA::New(fieldName,meshName,-1,iteration,order,std::vector<std::string>());
6107 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,meshName,-1,iteration,order,std::vector<std::string>());
6112 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] !";
6113 throw INTERP_KERNEL::Exception(oss.str());
6116 ret->setDtUnit(dtunit.c_str());
6117 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
6120 std::vector< std::pair<int,int> > dtits(nbOfStep2);
6121 for(int i=0;i<nbOfStep2 && !found;i++)
6123 med_int numdt,numit;
6125 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt));
6126 if(numdt==iteration && numit==order)
6132 dtits[i]=std::pair<int,int>(numdt,numit);
6136 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available iterations are : ";
6137 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
6138 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
6139 throw INTERP_KERNEL::Exception(oss.str());
6142 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
6144 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
6148 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
6149 try:MEDFileFieldGlobsReal(fid)
6151 _content=BuildContentFrom(fid,fieldName,iteration,order,loadAll,ms,entities);
6154 catch(INTERP_KERNEL::Exception& e)
6160 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6161 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6163 * \warning this is a shallow copy constructor
6165 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
6167 if(!shallowCopyOfContent)
6169 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
6170 otherPtr->incrRef();
6171 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
6175 _content=other.shallowCpy();
6179 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)
6183 int nbFields=MEDnField(fid);
6184 if(fieldIdCFormat>=nbFields)
6186 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << FileNameFromFID(fid) << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
6187 throw INTERP_KERNEL::Exception(oss.str());
6190 int ncomp(MEDfieldnComponent(fid,fieldIdCFormat+1));
6191 INTERP_KERNEL::AutoPtr<char> comp(MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE));
6192 INTERP_KERNEL::AutoPtr<char> unit(MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE));
6193 INTERP_KERNEL::AutoPtr<char> dtunit(MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE));
6194 INTERP_KERNEL::AutoPtr<char> nomcha(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
6195 INTERP_KERNEL::AutoPtr<char> nomMaa(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
6198 MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep));
6199 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
6200 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
6201 meshName=MEDLoaderBase::buildStringFromFortran(nomMaa,MED_NAME_SIZE);
6202 infos.clear(); infos.resize(ncomp);
6203 for(int j=0;j<ncomp;j++)
6204 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
6209 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
6212 * \return in case of success the number of time steps available for the field with name \a fieldName.
6214 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)
6216 int nbFields=MEDnField(fid);
6218 std::vector<std::string> fns(nbFields);
6220 for(int i=0;i<nbFields && !found;i++)
6222 std::string tmp,tmp2;
6223 nbOfStep2=LocateField2(fid,i,false,tmp,typcha,infos,dtunitOut,tmp2);
6225 found=(tmp==fieldName);
6234 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available fields are : ";
6235 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
6236 oss << "\"" << *it << "\" ";
6237 throw INTERP_KERNEL::Exception(oss.str());
6243 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
6244 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
6245 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
6246 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
6247 * to keep a valid instance.
6248 * 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.
6249 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
6250 * 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.
6252 * \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.
6253 * \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.
6254 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
6255 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
6256 * \param [in] newLocName is the new localization name.
6257 * \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.
6258 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
6260 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
6262 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6263 std::string oldPflName=disc->getProfile();
6264 std::vector<std::string> vv=getPflsReallyUsedMulti();
6265 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
6266 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
6268 disc->setProfile(newPflName);
6269 DataArrayInt *pfl=getProfile(oldPflName.c_str());
6270 pfl->setName(newPflName);
6274 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
6275 throw INTERP_KERNEL::Exception(oss.str());
6280 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
6281 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
6282 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
6283 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
6284 * to keep a valid instance.
6285 * 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.
6286 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
6287 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
6288 * 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.
6290 * \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.
6291 * \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.
6292 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
6293 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
6294 * \param [in] newLocName is the new localization name.
6295 * \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.
6296 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
6298 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
6300 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6301 std::string oldLocName=disc->getLocalization();
6302 std::vector<std::string> vv=getLocsReallyUsedMulti();
6303 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
6304 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
6306 disc->setLocalization(newLocName);
6307 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
6308 loc.setName(newLocName);
6312 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
6313 throw INTERP_KERNEL::Exception(oss.str());
6317 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
6319 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
6321 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
6325 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
6327 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
6329 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
6334 * This method alloc the arrays and load potentially huge arrays contained in this field.
6335 * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
6336 * This method can be also called to refresh or reinit values from a file.
6338 * \throw If the fileName is not set or points to a non readable MED file.
6339 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
6341 void MEDFileAnyTypeField1TS::loadArrays()
6343 if(getFileName().empty())
6344 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
6345 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
6346 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
6350 * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
6351 * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
6352 * this method does not throw if \a this does not come from file read.
6354 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
6356 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
6358 if(!getFileName().empty())
6360 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
6361 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
6366 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
6367 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
6368 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
6370 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
6372 void MEDFileAnyTypeField1TS::unloadArrays()
6374 contentNotNullBase()->unloadArrays();
6378 * 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.
6379 * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
6380 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
6382 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
6384 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
6386 if(!getFileName().empty())
6387 contentNotNullBase()->unloadArrays();
6390 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
6392 int nbComp(getNumberOfComponents());
6393 INTERP_KERNEL::AutoPtr<char> comp(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
6394 INTERP_KERNEL::AutoPtr<char> unit(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
6395 for(int i=0;i<nbComp;i++)
6397 std::string info=getInfo()[i];
6399 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
6400 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
6401 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
6403 if(getName().empty())
6404 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
6405 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
6406 writeGlobals(fid,*this);
6407 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
6410 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
6412 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
6415 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
6417 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
6418 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
6423 * Returns a string describing \a this field. This string is outputted
6424 * by \c print Python command.
6426 std::string MEDFileAnyTypeField1TS::simpleRepr() const
6428 std::ostringstream oss;
6429 contentNotNullBase()->simpleRepr(0,oss,-1);
6430 simpleReprGlobs(oss);
6435 * This method returns all profiles whose name is non empty used.
6436 * \b WARNING If profile is used several times it will be reported \b only \b once.
6437 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
6439 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
6441 return contentNotNullBase()->getPflsReallyUsed2();
6445 * This method returns all localizations whose name is non empty used.
6446 * \b WARNING If localization is used several times it will be reported \b only \b once.
6448 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
6450 return contentNotNullBase()->getLocsReallyUsed2();
6454 * This method returns all profiles whose name is non empty used.
6455 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
6457 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
6459 return contentNotNullBase()->getPflsReallyUsedMulti2();
6463 * This method returns all localizations whose name is non empty used.
6464 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
6466 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
6468 return contentNotNullBase()->getLocsReallyUsedMulti2();
6471 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6473 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
6476 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6478 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
6481 int MEDFileAnyTypeField1TS::getDimension() const
6483 return contentNotNullBase()->getDimension();
6486 int MEDFileAnyTypeField1TS::getIteration() const
6488 return contentNotNullBase()->getIteration();
6491 int MEDFileAnyTypeField1TS::getOrder() const
6493 return contentNotNullBase()->getOrder();
6496 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
6498 return contentNotNullBase()->getTime(iteration,order);
6501 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
6503 contentNotNullBase()->setTime(iteration,order,val);
6506 std::string MEDFileAnyTypeField1TS::getName() const
6508 return contentNotNullBase()->getName();
6511 void MEDFileAnyTypeField1TS::setName(const std::string& name)
6513 contentNotNullBase()->setName(name);
6516 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
6518 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
6521 std::string MEDFileAnyTypeField1TS::getDtUnit() const
6523 return contentNotNullBase()->getDtUnit();
6526 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
6528 contentNotNullBase()->setDtUnit(dtUnit);
6531 std::string MEDFileAnyTypeField1TS::getMeshName() const
6533 return contentNotNullBase()->getMeshName();
6536 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
6538 contentNotNullBase()->setMeshName(newMeshName);
6541 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
6543 return contentNotNullBase()->changeMeshNames(modifTab);
6546 int MEDFileAnyTypeField1TS::getMeshIteration() const
6548 return contentNotNullBase()->getMeshIteration();
6551 int MEDFileAnyTypeField1TS::getMeshOrder() const
6553 return contentNotNullBase()->getMeshOrder();
6556 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
6558 return contentNotNullBase()->getNumberOfComponents();
6561 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
6563 return contentNotNullBase()->isDealingTS(iteration,order);
6566 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
6568 return contentNotNullBase()->getDtIt();
6571 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
6573 contentNotNullBase()->fillIteration(p);
6576 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
6578 contentNotNullBase()->fillTypesOfFieldAvailable(types);
6581 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
6583 contentNotNullBase()->setInfo(infos);
6586 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
6588 return contentNotNullBase()->getInfo();
6590 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
6592 return contentNotNullBase()->getInfo();
6595 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
6597 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
6600 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
6602 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6605 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
6607 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6610 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
6612 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
6615 void MEDFileAnyTypeField1TS::convertMedBallIntoClassic()
6617 return contentNotNullBase()->convertMedBallIntoClassic();
6620 void MEDFileAnyTypeField1TS::makeReduction(INTERP_KERNEL::NormalizedCellType ct, TypeOfField tof, const DataArrayInt *pfl)
6622 return contentNotNullBase()->makeReduction(ct,tof,pfl);
6625 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
6627 return contentNotNullBase()->getTypesOfFieldAvailable();
6630 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,
6631 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6633 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
6637 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
6638 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
6639 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
6641 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
6643 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6645 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
6646 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
6647 std::size_t sz(contentsSplit.size());
6648 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6649 for(std::size_t i=0;i<sz;i++)
6651 ret[i]=shallowCpy();
6652 ret[i]->_content=contentsSplit[i];
6658 * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
6659 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6661 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
6663 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6665 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
6666 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
6667 std::size_t sz(contentsSplit.size());
6668 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6669 for(std::size_t i=0;i<sz;i++)
6671 ret[i]=shallowCpy();
6672 ret[i]->_content=contentsSplit[i];
6678 * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this.
6679 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6681 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const
6683 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6685 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !");
6686 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
6687 std::size_t sz(contentsSplit.size());
6688 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6689 for(std::size_t i=0;i<sz;i++)
6691 ret[i]=shallowCpy();
6692 ret[i]->_content=contentsSplit[i];
6697 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCopy() const
6699 MCAuto<MEDFileAnyTypeField1TS> ret=shallowCpy();
6700 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
6701 ret->_content=_content->deepCopy();
6702 ret->deepCpyGlobs(*this);
6706 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
6708 return contentNotNullBase()->copyTinyInfoFrom(field,arr);
6714 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6715 * the first field that has been read from a specified MED file.
6716 * \param [in] fileName - the name of the MED file to read.
6717 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6718 * is to delete this field using decrRef() as it is no more needed.
6719 * \throw If reading the file fails.
6721 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll)
6723 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6724 return New(fid,loadAll);
6727 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, bool loadAll)
6729 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,loadAll,0));
6730 ret->contentNotNull();
6735 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6736 * a given field that has been read from a specified MED file.
6737 * \param [in] fileName - the name of the MED file to read.
6738 * \param [in] fieldName - the name of the field to read.
6739 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6740 * is to delete this field using decrRef() as it is no more needed.
6741 * \throw If reading the file fails.
6742 * \throw If there is no field named \a fieldName in the file.
6744 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6746 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6747 return New(fid,fieldName,loadAll);
6750 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
6752 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,fieldName,loadAll,0));
6753 ret->contentNotNull();
6758 * Returns a new instance of MEDFileField1TS holding data of a given time step of
6759 * a given field that has been read from a specified MED file.
6760 * \param [in] fileName - the name of the MED file to read.
6761 * \param [in] fieldName - the name of the field to read.
6762 * \param [in] iteration - the iteration number of a required time step.
6763 * \param [in] order - the iteration order number of required time step.
6764 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6765 * is to delete this field using decrRef() as it is no more needed.
6766 * \throw If reading the file fails.
6767 * \throw If there is no field named \a fieldName in the file.
6768 * \throw If the required time step is missing from the file.
6770 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6772 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6773 return New(fid,fieldName,iteration,order,loadAll);
6776 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
6778 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,fieldName,iteration,order,loadAll,0));
6779 ret->contentNotNull();
6784 * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6785 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6787 * Returns a new instance of MEDFileField1TS holding either a shallow copy
6788 * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
6789 * \warning this is a shallow copy constructor
6790 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
6791 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
6792 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6793 * is to delete this field using decrRef() as it is no more needed.
6795 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6797 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(other,shallowCopyOfContent));
6798 ret->contentNotNull();
6803 * Returns a new empty instance of MEDFileField1TS.
6804 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6805 * is to delete this field using decrRef() as it is no more needed.
6807 MEDFileField1TS *MEDFileField1TS::New()
6809 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS);
6810 ret->contentNotNull();
6815 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
6816 * following the given input policy.
6818 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6819 * By default (true) the globals are deeply copied.
6820 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
6822 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
6824 MCAuto<MEDFileIntField1TS> ret;
6825 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6828 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
6830 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
6831 MCAuto<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
6832 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc));
6835 ret=MEDFileIntField1TS::New();
6837 ret->deepCpyGlobs(*this);
6839 ret->shallowCpyGlobs(*this);
6843 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const
6845 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6847 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
6848 const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
6850 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is not null but it is not of type double ! Reason is maybe that the read field has not the type FLOAT64 !");
6854 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull()
6856 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6858 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
6859 MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
6861 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is not null but it is not of type double ! Reason is maybe that the read field has not the type FLOAT64 !");
6865 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
6868 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
6870 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
6871 DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6873 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6874 f->setArray(arrOutC);
6877 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MCAuto<DataArray>& arr)
6880 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
6881 DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6883 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6889 * Return an extraction of \a this using \a extractDef map to specify the extraction.
6890 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
6892 * \return A new object that the caller is responsible to deallocate.
6893 * \sa MEDFileUMesh::deduceNodeSubPartFromCellSubPart , MEDFileUMesh::extractPart
6895 MEDFileField1TS *MEDFileField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
6898 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : input mesh is NULL !");
6899 MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
6900 std::vector<TypeOfField> tof(getTypesOfFieldAvailable());
6901 for(std::vector<TypeOfField>::const_iterator it0=tof.begin();it0!=tof.end();it0++)
6903 if((*it0)!=ON_NODES)
6905 std::vector<int> levs;
6906 getNonEmptyLevels(mm->getName(),levs);
6907 for(std::vector<int>::const_iterator lev=levs.begin();lev!=levs.end();lev++)
6909 std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(*lev));
6910 if(it2!=extractDef.end())
6912 MCAuto<DataArrayInt> t((*it2).second);
6914 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6915 MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_CELLS,(*lev),mm));
6916 MCAuto<MEDCouplingFieldDouble> fOut(f->buildSubPart(t));
6917 ret->setFieldNoProfileSBT(fOut);
6923 std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(1));
6924 if(it2==extractDef.end())
6925 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a NODE field and no extract array available for NODE !");
6926 MCAuto<DataArrayInt> t((*it2).second);
6928 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6929 MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_NODES,0,mm));
6930 MCAuto<MEDCouplingFieldDouble> fOut(f->deepCopy());
6931 DataArrayDouble *arr(f->getArray());
6932 MCAuto<DataArrayDouble> newArr(arr->selectByTupleIdSafe(t->begin(),t->end()));
6933 fOut->setArray(newArr);
6934 ret->setFieldNoProfileSBT(fOut);
6940 MEDFileField1TS::MEDFileField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
6941 try:MEDFileAnyTypeField1TS(fid,loadAll,ms)
6944 catch(INTERP_KERNEL::Exception& e)
6947 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6948 try:MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms)
6951 catch(INTERP_KERNEL::Exception& e)
6954 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6955 try:MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms)
6958 catch(INTERP_KERNEL::Exception& e)
6962 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6963 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6965 * \warning this is a shallow copy constructor
6967 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6968 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6971 catch(INTERP_KERNEL::Exception& e)
6974 MEDFileField1TS::MEDFileField1TS()
6976 _content=new MEDFileField1TSWithoutSDA;
6980 * 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
6981 * method should be called (getFieldOnMeshAtLevel for example).
6982 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
6984 * \param [in] mesh - the mesh the field is lying on
6985 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6986 * caller is to delete this field using decrRef() as it is no more needed.
6988 MEDCouplingFieldDouble *MEDFileField1TS::field(const MEDFileMesh *mesh) const
6990 MCAuto<DataArray> arrOut;
6991 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
6992 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6997 * Returns a new MEDCouplingFieldDouble of a given type lying on
6998 * mesh entities of a given dimension of the first mesh in MED file. If \a this field
6999 * has not been constructed via file reading, an exception is thrown.
7000 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7001 * \param [in] type - a spatial discretization of interest.
7002 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7003 * \param [in] renumPol - specifies how to permute values of the result field according to
7004 * the optional numbers of cells and nodes, if any. The valid values are
7005 * - 0 - do not permute.
7006 * - 1 - permute cells.
7007 * - 2 - permute nodes.
7008 * - 3 - permute cells and nodes.
7010 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
7011 * caller is to delete this field using decrRef() as it is no more needed.
7012 * \throw If \a this field has not been constructed via file reading.
7013 * \throw If the MED file is not readable.
7014 * \throw If there is no mesh in the MED file.
7015 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7016 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7017 * \sa getFieldOnMeshAtLevel()
7019 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
7021 if(getFileName().empty())
7022 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7023 MCAuto<DataArray> arrOut;
7024 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
7025 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
7030 * Returns a new MEDCouplingFieldDouble of a given type lying on
7031 * the top level cells of the first mesh in MED file. If \a this field
7032 * has not been constructed via file reading, an exception is thrown.
7033 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7034 * \param [in] type - a spatial discretization of interest.
7035 * \param [in] renumPol - specifies how to permute values of the result field according to
7036 * the optional numbers of cells and nodes, if any. The valid values are
7037 * - 0 - do not permute.
7038 * - 1 - permute cells.
7039 * - 2 - permute nodes.
7040 * - 3 - permute cells and nodes.
7042 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
7043 * caller is to delete this field using decrRef() as it is no more needed.
7044 * \throw If \a this field has not been constructed via file reading.
7045 * \throw If the MED file is not readable.
7046 * \throw If there is no mesh in the MED file.
7047 * \throw If no field values of the given \a type.
7048 * \throw If no field values lying on the top level support.
7049 * \sa getFieldAtLevel()
7051 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
7053 if(getFileName().empty())
7054 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
7055 MCAuto<DataArray> arrOut;
7056 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
7057 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
7062 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
7063 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7064 * \param [in] type - a spatial discretization of the new field.
7065 * \param [in] mesh - the supporting mesh.
7066 * \param [in] renumPol - specifies how to permute values of the result field according to
7067 * the optional numbers of cells and nodes, if any. The valid values are
7068 * - 0 - do not permute.
7069 * - 1 - permute cells.
7070 * - 2 - permute nodes.
7071 * - 3 - permute cells and nodes.
7073 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
7074 * caller is to delete this field using decrRef() as it is no more needed.
7075 * \throw If no field of \a this is lying on \a mesh.
7076 * \throw If the mesh is empty.
7077 * \throw If no field values of the given \a type are available.
7078 * \sa getFieldAtLevel()
7079 * \sa getFieldOnMeshAtLevel()
7081 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
7083 MCAuto<DataArray> arrOut;
7084 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
7085 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
7090 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
7091 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7092 * \param [in] type - a spatial discretization of interest.
7093 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7094 * \param [in] mesh - the supporting mesh.
7095 * \param [in] renumPol - specifies how to permute values of the result field according to
7096 * the optional numbers of cells and nodes, if any. The valid values are
7097 * - 0 - do not permute.
7098 * - 1 - permute cells.
7099 * - 2 - permute nodes.
7100 * - 3 - permute cells and nodes.
7102 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
7103 * caller is to delete this field using decrRef() as it is no more needed.
7104 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7105 * \throw If no field of \a this is lying on \a mesh.
7106 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7107 * \sa getFieldAtLevel()
7108 * \sa getFieldOnMeshAtLevel()
7110 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
7112 MCAuto<DataArray> arrOut;
7113 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
7114 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
7119 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
7120 * This method is called "Old" because in MED3 norm a field has only one meshName
7121 * attached, so this method is for readers of MED2 files. If \a this field
7122 * has not been constructed via file reading, an exception is thrown.
7123 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7124 * \param [in] type - a spatial discretization of interest.
7125 * \param [in] mName - a name of the supporting mesh.
7126 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7127 * \param [in] renumPol - specifies how to permute values of the result field according to
7128 * the optional numbers of cells and nodes, if any. The valid values are
7129 * - 0 - do not permute.
7130 * - 1 - permute cells.
7131 * - 2 - permute nodes.
7132 * - 3 - permute cells and nodes.
7134 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
7135 * caller is to delete this field using decrRef() as it is no more needed.
7136 * \throw If the MED file is not readable.
7137 * \throw If there is no mesh named \a mName in the MED file.
7138 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7139 * \throw If \a this field has not been constructed via file reading.
7140 * \throw If no field of \a this is lying on the mesh named \a mName.
7141 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7142 * \sa getFieldAtLevel()
7144 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
7146 if(getFileName().empty())
7147 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7148 MCAuto<DataArray> arrOut;
7149 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull()));
7150 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
7155 * Returns values and a profile of the field of a given type lying on a given support.
7156 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7157 * \param [in] type - a spatial discretization of the field.
7158 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7159 * \param [in] mesh - the supporting mesh.
7160 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
7161 * field of interest lies on. If the field lies on all entities of the given
7162 * dimension, all ids in \a pfl are zero. The caller is to delete this array
7163 * using decrRef() as it is no more needed.
7164 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
7165 * field. The caller is to delete this array using decrRef() as it is no more needed.
7166 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7167 * \throw If no field of \a this is lying on \a mesh.
7168 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7170 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
7172 MCAuto<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
7173 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
7177 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
7178 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
7179 * "Sort By Type"), if not, an exception is thrown.
7180 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7181 * \param [in] field - the field to add to \a this.
7182 * \throw If the name of \a field is empty.
7183 * \throw If the data array of \a field is not set.
7184 * \throw If the data array is already allocated but has different number of components
7186 * \throw If the underlying mesh of \a field has no name.
7187 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
7189 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
7192 contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
7196 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
7197 * can be an aggregation of several MEDCouplingFieldDouble instances.
7198 * The mesh support of input parameter \a field is ignored here, it can be NULL.
7199 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
7202 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
7203 * A new profile is added only if no equal profile is missing.
7204 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7205 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
7206 * \param [in] mesh - the supporting mesh of \a field.
7207 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
7208 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
7209 * \throw If either \a field or \a mesh or \a profile has an empty name.
7210 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7211 * \throw If the data array of \a field is not set.
7212 * \throw If the data array of \a this is already allocated but has different number of
7213 * components than \a field.
7214 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
7215 * \sa setFieldNoProfileSBT()
7217 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
7220 contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
7223 MEDFileField1TS *MEDFileField1TS::shallowCpy() const
7225 return new MEDFileField1TS(*this);
7228 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const
7230 return contentNotNull()->getUndergroundDataArrayTemplate();
7233 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7235 return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
7238 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
7239 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
7241 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
7244 //= MEDFileIntField1TS
7246 MEDFileIntField1TS *MEDFileIntField1TS::New()
7248 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS);
7249 ret->contentNotNull();
7253 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll)
7255 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
7256 return MEDFileIntField1TS::New(fid,loadAll);
7259 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, bool loadAll)
7261 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,loadAll,0));
7262 ret->contentNotNull();
7266 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
7268 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
7269 return MEDFileIntField1TS::New(fid,fieldName,loadAll);
7272 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
7274 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,loadAll,0));
7275 ret->contentNotNull();
7279 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
7281 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
7282 return MEDFileIntField1TS::New(fid,fieldName,iteration,order,loadAll);
7285 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
7287 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,iteration,order,loadAll,0));
7288 ret->contentNotNull();
7292 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
7294 MCAuto<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
7295 ret->contentNotNull();
7299 MEDFileIntField1TS::MEDFileIntField1TS()
7301 _content=new MEDFileIntField1TSWithoutSDA;
7304 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
7305 try:MEDFileAnyTypeField1TS(fid,loadAll,ms)
7308 catch(INTERP_KERNEL::Exception& e)
7311 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
7312 try:MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms)
7315 catch(INTERP_KERNEL::Exception& e)
7318 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
7319 try:MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms)
7322 catch(INTERP_KERNEL::Exception& e)
7326 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
7327 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
7329 * \warning this is a shallow copy constructor
7331 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
7335 MEDFileIntField1TS *MEDFileIntField1TS::shallowCpy() const
7337 return new MEDFileIntField1TS(*this);
7341 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
7342 * following the given input policy.
7344 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
7345 * By default (true) the globals are deeply copied.
7346 * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
7348 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const
7350 MCAuto<MEDFileField1TS> ret;
7351 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
7354 const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
7356 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
7357 MCAuto<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
7358 ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc));
7361 ret=MEDFileField1TS::New();
7363 ret->deepCpyGlobs(*this);
7365 ret->shallowCpyGlobs(*this);
7370 * Adds a MEDCouplingFieldInt to \a this. The underlying mesh of the given field is
7371 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
7372 * "Sort By Type"), if not, an exception is thrown.
7373 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7374 * \param [in] field - the field to add to \a this.
7375 * \throw If the name of \a field is empty.
7376 * \throw If the data array of \a field is not set.
7377 * \throw If the data array is already allocated but has different number of components
7379 * \throw If the underlying mesh of \a field has no name.
7380 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
7382 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldInt *field)
7384 MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
7386 contentNotNull()->setFieldNoProfileSBT(field2,field->getArray(),*this,*contentNotNull());
7390 * Adds a MEDCouplingFieldInt to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
7391 * can be an aggregation of several MEDCouplingFieldDouble instances.
7392 * The mesh support of input parameter \a field is ignored here, it can be NULL.
7393 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
7396 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
7397 * A new profile is added only if no equal profile is missing.
7398 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7399 * \param [in] field - the field to add to \a this.
7400 * \param [in] mesh - the supporting mesh of \a field.
7401 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
7402 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
7403 * \throw If either \a field or \a mesh or \a profile has an empty name.
7404 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7405 * \throw If the data array of \a field is not set.
7406 * \throw If the data array of \a this is already allocated but has different number of
7407 * components than \a field.
7408 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
7409 * \sa setFieldNoProfileSBT()
7411 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
7413 MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
7415 contentNotNull()->setFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
7418 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const
7420 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7422 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
7423 const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
7425 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is not null but it is not of type int32 ! Reason is maybe that the read field has not the type INT32 !");
7429 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
7431 if(getFileName().empty())
7432 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7433 MCAuto<DataArray> arrOut;
7434 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
7435 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7439 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MCAuto<DataArray>& arr)
7442 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
7443 DataArrayInt *arrC(dynamic_cast<DataArrayInt *>((DataArray *)arr));
7445 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
7450 MCAuto<MEDCouplingFieldInt> MEDFileIntField1TS::SetDataArrayDoubleInIntField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
7453 double t0(f->getTime(t1,t2));
7454 MCAuto<DataArrayInt> arr2(DynamicCastSafe<DataArray,DataArrayInt>(arr));
7455 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
7456 MCAuto<MEDCouplingFieldInt> ret(MEDCouplingFieldInt::New(*ft));
7457 ret->setTime(t0,t1,t2); ret->setArray(arr2);
7461 MCAuto<MEDCouplingFieldDouble> MEDFileIntField1TS::ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f)
7464 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ConvertFieldIntToFieldDouble : null input field !");
7466 double t0(f->getTime(t1,t2));
7467 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
7468 MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(*ft));
7469 ret->setTime(t0,t1,t2);
7473 MEDFileIntField1TS *MEDFileIntField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
7475 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::extractPart : not implemented yet !");
7479 * 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
7480 * method should be called (getFieldOnMeshAtLevel for example).
7481 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
7483 * \param [in] mesh - the mesh the field is lying on
7484 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
7485 * caller is to delete this field using decrRef() as it is no more needed.
7487 MEDCouplingFieldInt *MEDFileIntField1TS::field(const MEDFileMesh *mesh) const
7489 MCAuto<DataArray> arrOut;
7490 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
7491 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7496 * Returns a new MEDCouplingFieldInt of a given type lying on
7497 * the top level cells of the first mesh in MED file. If \a this field
7498 * has not been constructed via file reading, an exception is thrown.
7499 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7500 * \param [in] type - a spatial discretization of interest.
7501 * \param [in] renumPol - specifies how to permute values of the result field according to
7502 * the optional numbers of cells and nodes, if any. The valid values are
7503 * - 0 - do not permute.
7504 * - 1 - permute cells.
7505 * - 2 - permute nodes.
7506 * - 3 - permute cells and nodes.
7508 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7509 * caller is to delete this field using decrRef() as it is no more needed.
7510 * \throw If \a this field has not been constructed via file reading.
7511 * \throw If the MED file is not readable.
7512 * \throw If there is no mesh in the MED file.
7513 * \throw If no field values of the given \a type.
7514 * \throw If no field values lying on the top level support.
7515 * \sa getFieldAtLevel()
7517 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
7519 if(getFileName().empty())
7520 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
7521 MCAuto<DataArray> arrOut;
7522 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
7523 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7528 * Returns a new MEDCouplingFieldInt of given type lying on a given mesh.
7529 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7530 * \param [in] type - a spatial discretization of the new field.
7531 * \param [in] mesh - the supporting mesh.
7532 * \param [in] renumPol - specifies how to permute values of the result field according to
7533 * the optional numbers of cells and nodes, if any. The valid values are
7534 * - 0 - do not permute.
7535 * - 1 - permute cells.
7536 * - 2 - permute nodes.
7537 * - 3 - permute cells and nodes.
7539 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7540 * caller is to delete this field using decrRef() as it is no more needed.
7541 * \throw If no field of \a this is lying on \a mesh.
7542 * \throw If the mesh is empty.
7543 * \throw If no field values of the given \a type are available.
7544 * \sa getFieldAtLevel()
7545 * \sa getFieldOnMeshAtLevel()
7547 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
7549 MCAuto<DataArray> arrOut;
7550 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
7551 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7556 * Returns a new MEDCouplingFieldInt of a given type lying on a given support.
7557 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7558 * \param [in] type - a spatial discretization of interest.
7559 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7560 * \param [in] mesh - the supporting mesh.
7561 * \param [in] renumPol - specifies how to permute values of the result field according to
7562 * the optional numbers of cells and nodes, if any. The valid values are
7563 * - 0 - do not permute.
7564 * - 1 - permute cells.
7565 * - 2 - permute nodes.
7566 * - 3 - permute cells and nodes.
7568 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7569 * caller is to delete this field using decrRef() as it is no more needed.
7570 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7571 * \throw If no field of \a this is lying on \a mesh.
7572 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7573 * \sa getFieldAtLevel()
7574 * \sa getFieldOnMeshAtLevel()
7576 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
7578 MCAuto<DataArray> arrOut;
7579 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
7580 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7585 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
7586 * This method is called "Old" because in MED3 norm a field has only one meshName
7587 * attached, so this method is for readers of MED2 files. If \a this field
7588 * has not been constructed via file reading, an exception is thrown.
7589 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7590 * \param [in] type - a spatial discretization of interest.
7591 * \param [in] mName - a name of the supporting mesh.
7592 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7593 * \param [in] renumPol - specifies how to permute values of the result field according to
7594 * the optional numbers of cells and nodes, if any. The valid values are
7595 * - 0 - do not permute.
7596 * - 1 - permute cells.
7597 * - 2 - permute nodes.
7598 * - 3 - permute cells and nodes.
7600 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7601 * caller is to delete this field using decrRef() as it is no more needed.
7602 * \throw If the MED file is not readable.
7603 * \throw If there is no mesh named \a mName in the MED file.
7604 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7605 * \throw If \a this field has not been constructed via file reading.
7606 * \throw If no field of \a this is lying on the mesh named \a mName.
7607 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7608 * \sa getFieldAtLevel()
7610 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
7612 if(getFileName().empty())
7613 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7614 MCAuto<DataArray> arrOut;
7615 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
7616 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7621 * Returns values and a profile of the field of a given type lying on a given support.
7622 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7623 * \param [in] type - a spatial discretization of the field.
7624 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7625 * \param [in] mesh - the supporting mesh.
7626 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
7627 * field of interest lies on. If the field lies on all entities of the given
7628 * dimension, all ids in \a pfl are zero. The caller is to delete this array
7629 * using decrRef() as it is no more needed.
7630 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
7631 * field. The caller is to delete this array using decrRef() as it is no more needed.
7632 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7633 * \throw If no field of \a this is lying on \a mesh.
7634 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7636 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
7638 MCAuto<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
7639 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
7642 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull()
7644 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7646 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
7647 MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
7649 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is not null but it is not of type int32 ! Reason is maybe that the read field has not the type INT32 !");
7653 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const
7655 return contentNotNull()->getUndergroundDataArrayTemplate();
7658 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
7660 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
7664 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName):MEDFileFieldNameScope(fieldName,meshName)
7669 * \param [in] fieldId field id in C mode
7671 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7673 med_field_type typcha;
7674 std::string dtunitOut,meshName;
7675 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fieldId,false,_name,typcha,_infos,dtunitOut,meshName));
7676 setMeshName(meshName);
7677 setDtUnit(dtunitOut.c_str());
7678 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities);
7681 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)
7682 try:MEDFileFieldNameScope(fieldName,meshName),_infos(infos)
7684 setDtUnit(dtunit.c_str());
7685 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities);
7687 catch(INTERP_KERNEL::Exception& e)
7692 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
7694 std::size_t ret(_mesh_name.capacity()+_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MCAuto<MEDFileField1TSWithoutSDA>));
7695 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7696 ret+=(*it).capacity();
7700 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
7702 std::vector<const BigMemoryObject *> ret;
7703 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7704 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
7709 * 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
7712 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
7714 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7715 ret->setInfo(_infos);
7716 int sz=(int)_time_steps.size();
7717 for(const int *id=startIds;id!=endIds;id++)
7719 if(*id>=0 && *id<sz)
7721 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
7722 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7726 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7728 ret->pushBackTimeStep(tse2);
7732 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
7733 oss << " ! Should be in [0," << sz << ") !";
7734 throw INTERP_KERNEL::Exception(oss.str());
7737 if(ret->getNumberOfTS()>0)
7738 ret->synchronizeNameScope();
7739 ret->copyNameScope(*this);
7744 * 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
7747 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
7749 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
7750 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7751 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7752 ret->setInfo(_infos);
7753 int sz=(int)_time_steps.size();
7755 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
7759 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
7760 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7764 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7766 ret->pushBackTimeStep(tse2);
7770 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
7771 oss << " ! Should be in [0," << sz << ") !";
7772 throw INTERP_KERNEL::Exception(oss.str());
7775 if(ret->getNumberOfTS()>0)
7776 ret->synchronizeNameScope();
7777 ret->copyNameScope(*this);
7781 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7784 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7785 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7787 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7790 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7791 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
7792 ids->pushBackSilent(id);
7794 return buildFromTimeStepIds(ids->begin(),ids->end());
7797 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7800 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7801 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7803 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7806 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7807 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
7808 ids->pushBackSilent(id);
7810 return buildFromTimeStepIds(ids->begin(),ids->end());
7813 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfStructureElements() const
7815 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7816 if((*it).isNotNull())
7817 if((*it)->presenceOfStructureElements())
7822 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::onlyStructureElements() const
7824 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7825 if((*it).isNotNull())
7826 if(!(*it)->onlyStructureElements())
7831 void MEDFileAnyTypeFieldMultiTSWithoutSDA::killStructureElements()
7833 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
7834 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7835 if((*it).isNotNull())
7837 if((*it)->presenceOfStructureElements())
7839 if(!(*it)->onlyStructureElements())
7841 (*it)->killStructureElements();
7853 void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyStructureElements()
7855 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
7856 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7857 if((*it).isNotNull())
7859 if((*it)->presenceOfStructureElements())
7861 if(!(*it)->onlyStructureElements())
7862 (*it)->keepOnlyStructureElements();
7869 void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyOnSE(const std::string& seName)
7871 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
7872 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7873 if((*it).isNotNull())
7874 (*it)->keepOnlyOnSE(seName);
7877 void MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
7879 std::vector< std::pair<std::string,std::string> > ps2;
7880 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7881 if((*it).isNotNull())
7883 (*it)->getMeshSENames(ps2);
7887 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames : this appears to not contain SE only !");
7888 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7889 if((*it).isNotNull())
7891 std::vector< std::pair<std::string,std::string> > ps3;
7892 (*it)->getMeshSENames(ps3);
7894 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames : For the moment only homogeneous SE def through time managed !");
7896 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=ps2.begin();it!=ps2.end();it++)
7898 std::vector< std::pair<std::string,std::string> >::iterator it2(std::find(ps.begin(),ps.end(),*it));
7904 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
7906 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7908 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7911 if(cur->presenceOfMultiDiscPerGeoType())
7917 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
7922 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
7927 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
7930 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7932 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
7933 if(pt->isDealingTS(iteration,order))
7936 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
7937 std::vector< std::pair<int,int> > vp=getIterations();
7938 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
7939 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
7940 throw INTERP_KERNEL::Exception(oss.str());
7943 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
7945 return *_time_steps[getTimeStepPos(iteration,order)];
7948 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
7950 return *_time_steps[getTimeStepPos(iteration,order)];
7953 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
7956 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
7958 if((*it).first==getMeshName())
7960 setMeshName((*it).second);
7964 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7966 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7968 ret=cur->changeMeshNames(modifTab) || ret;
7974 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
7976 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
7978 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
7982 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
7984 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7986 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
7989 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
7990 MEDFileFieldGlobsReal& glob)
7993 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7995 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
7997 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
8002 void MEDFileAnyTypeFieldMultiTSWithoutSDA::accept(MEDFileFieldVisitor& visitor) const
8004 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8005 if((*it).isNotNull())
8007 visitor.newTimeStepEntry(*it);
8008 (*it)->accept(visitor);
8009 visitor.endTimeStepEntry(*it);
8013 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8015 std::string startLine(bkOffset,' ');
8016 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
8018 oss << " (" << fmtsId << ")";
8019 oss << " has the following name: \"" << _name << "\"." << std::endl;
8020 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
8021 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
8023 oss << startLine << " - \"" << *it << "\"" << std::endl;
8026 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8028 std::string chapter(17,'0'+i);
8029 oss << startLine << chapter << std::endl;
8030 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
8032 cur->simpleRepr(bkOffset+2,oss,i);
8034 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
8035 oss << startLine << chapter << std::endl;
8039 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
8041 std::size_t sz=_time_steps.size();
8042 std::vector< std::pair<int,int> > ret(sz);
8044 for(std::size_t i=0;i<sz;i++)
8046 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
8049 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
8053 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
8054 throw INTERP_KERNEL::Exception(oss.str());
8060 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MCAuto<MEDFileAnyTypeField1TSWithoutSDA>& tse)
8062 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
8064 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
8065 checkCoherencyOfType(tse2);
8066 if(_time_steps.empty())
8068 setName(tse2->getName());
8069 setMeshName(tse2->getMeshName());
8070 setInfo(tse2->getInfo());
8072 checkThatComponentsMatch(tse2->getInfo());
8073 if(getDtUnit().empty() && !tse->getDtUnit().empty())
8074 setDtUnit(tse->getDtUnit());
8075 _time_steps.push_back(tse);
8078 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
8080 std::size_t nbOfCompo=_infos.size();
8081 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8083 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
8086 if((cur->getInfo()).size()!=nbOfCompo)
8088 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
8089 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
8090 throw INTERP_KERNEL::Exception(oss.str());
8092 cur->copyNameScope(*this);
8097 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8099 _time_steps.resize(nbPdt);
8100 for(int i=0;i<nbPdt;i++)
8102 std::vector< std::pair<int,int> > ts;
8103 med_int numdt=0,numo=0;
8105 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt));
8110 _time_steps[i]=MEDFileField1TSWithoutSDA::New(getName(),getMeshName(),i+1,numdt,numo,_infos);
8115 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(getName(),getMeshName(),i+1,numdt,numo,_infos);
8119 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
8122 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities);
8124 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entities);
8125 synchronizeNameScope();
8129 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
8131 if(_time_steps.empty())
8132 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
8133 checkThatNbOfCompoOfTSMatchThis();
8134 std::vector<std::string> infos(getInfo());
8135 int nbComp=infos.size();
8136 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
8137 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
8138 for(int i=0;i<nbComp;i++)
8140 std::string info=infos[i];
8142 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
8143 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
8144 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
8147 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
8148 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
8149 int nbOfTS=_time_steps.size();
8150 for(int i=0;i<nbOfTS;i++)
8151 _time_steps[i]->writeLL(fid,opts,*this);
8154 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
8156 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8158 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
8160 elt->loadBigArraysRecursively(fid,nasc);
8164 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
8166 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8168 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
8170 elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
8174 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
8176 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8178 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
8180 elt->unloadArrays();
8184 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
8186 return _time_steps.size();
8189 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
8191 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
8192 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8194 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
8196 newTS.push_back(*it);
8201 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
8203 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
8204 int maxId=(int)_time_steps.size();
8206 std::set<int> idsToDel;
8207 for(const int *id=startIds;id!=endIds;id++,ii++)
8209 if(*id>=0 && *id<maxId)
8211 idsToDel.insert(*id);
8215 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
8216 throw INTERP_KERNEL::Exception(oss.str());
8219 for(int iii=0;iii<maxId;iii++)
8220 if(idsToDel.find(iii)==idsToDel.end())
8221 newTS.push_back(_time_steps[iii]);
8225 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
8227 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
8228 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
8229 if(nbOfEntriesToKill==0)
8231 std::size_t sz=_time_steps.size();
8232 std::vector<bool> b(sz,true);
8234 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
8236 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
8237 for(std::size_t i=0;i<sz;i++)
8239 newTS.push_back(_time_steps[i]);
8243 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
8246 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
8247 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
8249 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
8253 tmp->getTime(it2,ord);
8254 if(it2==iteration && order==ord)
8257 oss << "(" << it2 << "," << ord << "), ";
8260 throw INTERP_KERNEL::Exception(oss.str());
8263 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
8266 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
8268 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
8270 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
8274 double ti=tmp->getTime(it2,ord);
8275 if(fabs(time-ti)<eps)
8281 throw INTERP_KERNEL::Exception(oss.str());
8284 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
8286 int lgth=_time_steps.size();
8287 std::vector< std::pair<int,int> > ret(lgth);
8288 for(int i=0;i<lgth;i++)
8289 _time_steps[i]->fillIteration(ret[i]);
8294 * 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'
8295 * This method returns two things.
8296 * - The absolute dimension of 'this' in first parameter.
8297 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
8298 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
8300 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
8301 * Only these 3 discretizations will be taken into account here.
8303 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
8304 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
8305 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
8307 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
8308 * 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'.
8310 * Let's consider the typical following case :
8311 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
8312 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
8313 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
8315 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
8317 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
8319 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
8320 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
8321 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
8322 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
8324 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8326 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
8329 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
8331 if(pos<0 || pos>=(int)_time_steps.size())
8333 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
8334 throw INTERP_KERNEL::Exception(oss.str());
8336 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
8339 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
8340 oss << "\nTry to use following method eraseEmptyTS !";
8341 throw INTERP_KERNEL::Exception(oss.str());
8346 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
8348 if(pos<0 || pos>=(int)_time_steps.size())
8350 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
8351 throw INTERP_KERNEL::Exception(oss.str());
8353 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
8356 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
8357 oss << "\nTry to use following method eraseEmptyTS !";
8358 throw INTERP_KERNEL::Exception(oss.str());
8363 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
8365 std::vector<std::string> ret;
8366 std::set<std::string> ret2;
8367 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8369 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
8370 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
8371 if(ret2.find(*it2)==ret2.end())
8373 ret.push_back(*it2);
8380 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
8382 std::vector<std::string> ret;
8383 std::set<std::string> ret2;
8384 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8386 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
8387 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
8388 if(ret2.find(*it2)==ret2.end())
8390 ret.push_back(*it2);
8397 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
8399 std::vector<std::string> ret;
8400 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8402 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
8403 ret.insert(ret.end(),tmp.begin(),tmp.end());
8408 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
8410 std::vector<std::string> ret;
8411 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8413 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
8414 ret.insert(ret.end(),tmp.begin(),tmp.end());
8419 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8421 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8422 (*it)->changePflsRefsNamesGen2(mapOfModif);
8425 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8427 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8428 (*it)->changeLocsRefsNamesGen2(mapOfModif);
8431 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
8433 int lgth=_time_steps.size();
8434 std::vector< std::vector<TypeOfField> > ret(lgth);
8435 for(int i=0;i<lgth;i++)
8436 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
8441 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
8443 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
8445 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
8448 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCopy() const
8450 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
8452 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8454 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
8455 ret->_time_steps[i]=(*it)->deepCopy();
8460 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
8462 std::size_t sz(_infos.size()),sz2(_time_steps.size());
8463 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
8464 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
8465 for(std::size_t i=0;i<sz;i++)
8467 ret[i]=shallowCpy();
8468 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
8470 for(std::size_t i=0;i<sz2;i++)
8472 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
8475 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
8476 throw INTERP_KERNEL::Exception(oss.str());
8480 for(std::size_t i=0;i<sz;i++)
8481 for(std::size_t j=0;j<sz2;j++)
8482 ret[i]->_time_steps[j]=ts[j][i];
8487 * This method splits into discretization each time steps in \a this.
8488 * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
8490 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
8492 std::size_t sz(_time_steps.size());
8493 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
8494 for(std::size_t i=0;i<sz;i++)
8496 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
8499 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
8500 throw INTERP_KERNEL::Exception(oss.str());
8502 items[i]=timeStep->splitDiscretizations();
8505 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
8506 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
8507 std::vector< TypeOfField > types;
8508 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
8509 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
8511 std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
8513 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
8514 std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
8515 if(it2==types.end())
8516 types.push_back(ts[0]);
8518 ret.resize(types.size()); ret2.resize(types.size());
8519 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
8520 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
8522 TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
8523 std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
8524 ret2[pos].push_back(*it1);
8526 for(std::size_t i=0;i<types.size();i++)
8528 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
8529 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
8530 elt->pushBackTimeStep(*it1);//also updates infos in elt
8532 elt->MEDFileFieldNameScope::operator=(*this);
8538 * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
8540 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
8542 std::size_t sz(_time_steps.size());
8543 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
8544 std::size_t szOut(std::numeric_limits<std::size_t>::max());
8545 for(std::size_t i=0;i<sz;i++)
8547 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
8550 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
8551 throw INTERP_KERNEL::Exception(oss.str());
8553 items[i]=timeStep->splitMultiDiscrPerGeoTypes();
8554 if(szOut==std::numeric_limits<std::size_t>::max())
8555 szOut=items[i].size();
8557 if(items[i].size()!=szOut)
8558 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
8560 if(szOut==std::numeric_limits<std::size_t>::max())
8561 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
8562 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
8563 for(std::size_t i=0;i<szOut;i++)
8565 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
8566 for(std::size_t j=0;j<sz;j++)
8567 elt->pushBackTimeStep(items[j][i]);
8569 elt->MEDFileFieldNameScope::operator=(*this);
8574 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
8576 setName(field->getName());
8577 if(field->getMesh())
8578 setMeshName(field->getMesh()->getName());
8580 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
8582 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
8583 _infos=arr->getInfoOnComponents();
8586 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
8588 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
8589 if(_name!=field->getName())
8591 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
8592 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
8593 throw INTERP_KERNEL::Exception(oss.str());
8596 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
8597 checkThatComponentsMatch(arr->getInfoOnComponents());
8600 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
8602 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
8603 if(getInfo().size()!=compos.size())
8605 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
8606 oss << " number of components of element to append (" << compos.size() << ") !";
8607 throw INTERP_KERNEL::Exception(oss.str());
8611 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
8612 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
8613 oss << " But compo in input fields are : ";
8614 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
8616 throw INTERP_KERNEL::Exception(oss.str());
8620 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
8622 std::size_t sz=_infos.size();
8624 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
8626 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
8628 if(elt->getInfo().size()!=sz)
8630 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
8631 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
8632 throw INTERP_KERNEL::Exception(oss.str());
8637 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
8640 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8641 if(!_time_steps.empty())
8642 checkCoherencyOfTinyInfo(field,arr);
8643 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8644 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8645 objC->setFieldNoProfileSBT(field,arr,glob,*this);
8646 copyTinyInfoFrom(field,arr);
8647 _time_steps.push_back(obj);
8650 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
8653 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8654 if(!_time_steps.empty())
8655 checkCoherencyOfTinyInfo(field,arr);
8656 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8657 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8658 objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
8659 copyTinyInfoFrom(field,arr);
8660 setMeshName(objC->getMeshName());
8661 _time_steps.push_back(obj);
8664 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ts)
8666 int sz=(int)_time_steps.size();
8669 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
8670 throw INTERP_KERNEL::Exception(oss.str());
8672 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
8675 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
8677 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
8678 throw INTERP_KERNEL::Exception(oss.str());
8684 //= MEDFileFieldMultiTSWithoutSDA
8686 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)
8688 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,meshName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8691 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
8695 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName,meshName)
8700 * \param [in] fieldId field id in C mode
8702 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8703 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8706 catch(INTERP_KERNEL::Exception& e)
8709 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)
8710 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,meshName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8713 catch(INTERP_KERNEL::Exception& e)
8716 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8718 return new MEDFileField1TSWithoutSDA;
8721 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8724 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8725 const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
8727 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8730 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const
8732 return MEDFileField1TSWithoutSDA::TYPE_STR;
8735 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const
8737 return new MEDFileFieldMultiTSWithoutSDA(*this);
8740 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const
8742 return new MEDFileFieldMultiTSWithoutSDA;
8746 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
8747 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
8749 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
8751 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
8752 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8754 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
8755 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
8758 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
8760 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
8761 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8763 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8765 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8768 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
8770 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
8771 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
8772 ret->setIteration(i,elt);
8778 //= MEDFileAnyTypeFieldMultiTS
8780 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
8784 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8785 try:MEDFileFieldGlobsReal(fid)
8787 _content=BuildContentFrom(fid,loadAll,ms);
8790 catch(INTERP_KERNEL::Exception& e)
8795 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8797 med_field_type typcha;
8798 std::vector<std::string> infos;
8800 std::string meshName;
8802 MEDFileAnyTypeField1TS::LocateField(fid,fieldName,i,typcha,infos,dtunit,meshName);
8803 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8808 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8813 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8818 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] !";
8819 throw INTERP_KERNEL::Exception(oss.str());
8822 ret->setMeshName(meshName);
8823 ret->setDtUnit(dtunit.c_str());
8827 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8829 med_field_type typcha;
8831 std::vector<std::string> infos;
8832 std::string dtunit,fieldName,meshName;
8833 MEDFileAnyTypeField1TS::LocateField2(fid,0,true,fieldName,typcha,infos,dtunit,meshName);
8834 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8839 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8844 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8849 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] !";
8850 throw INTERP_KERNEL::Exception(oss.str());
8853 ret->setMeshName(meshName);
8854 ret->setDtUnit(dtunit.c_str());
8858 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c)
8861 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
8862 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
8864 MCAuto<MEDFileFieldMultiTS> ret(MEDFileFieldMultiTS::New());
8865 ret->_content=c; c->incrRef();
8868 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
8870 MCAuto<MEDFileIntFieldMultiTS> ret(MEDFileIntFieldMultiTS::New());
8871 ret->_content=c; c->incrRef();
8874 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
8877 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, med_idt fid)
8879 MEDFileAnyTypeFieldMultiTS *ret(BuildNewInstanceFromContent(c));
8880 std::string fileName(FileNameFromFID(fid));
8881 ret->setFileName(fileName);
8885 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8886 try:MEDFileFieldGlobsReal(fid)
8888 _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
8891 catch(INTERP_KERNEL::Exception& e)
8896 //= MEDFileIntFieldMultiTSWithoutSDA
8898 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)
8900 return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,meshName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8903 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
8907 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName,meshName)
8911 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)
8912 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,meshName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8915 catch(INTERP_KERNEL::Exception& e)
8919 * \param [in] fieldId field id in C mode
8921 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8922 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8925 catch(INTERP_KERNEL::Exception& e)
8928 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8930 return new MEDFileIntField1TSWithoutSDA;
8933 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8936 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8937 const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
8939 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8942 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const
8944 return MEDFileIntField1TSWithoutSDA::TYPE_STR;
8947 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const
8949 return new MEDFileIntFieldMultiTSWithoutSDA(*this);
8952 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const
8954 return new MEDFileIntFieldMultiTSWithoutSDA;
8957 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const
8959 MCAuto<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
8960 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8962 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8964 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8967 const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
8969 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
8970 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
8971 ret->setIteration(i,elt);
8977 //= MEDFileAnyTypeFieldMultiTS
8980 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
8981 * that has been read from a specified MED file.
8982 * \param [in] fileName - the name of the MED file to read.
8983 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8984 * is to delete this field using decrRef() as it is no more needed.
8985 * \throw If reading the file fails.
8987 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
8989 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8990 return New(fid,loadAll);
8993 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, bool loadAll)
8995 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
8996 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8997 ret->loadGlobals(fid);
9002 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
9003 * that has been read from a specified MED file.
9004 * \param [in] fileName - the name of the MED file to read.
9005 * \param [in] fieldName - the name of the field to read.
9006 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
9007 * is to delete this field using decrRef() as it is no more needed.
9008 * \throw If reading the file fails.
9009 * \throw If there is no field named \a fieldName in the file.
9011 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9013 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9014 return New(fid,fieldName,loadAll);
9017 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
9019 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
9020 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
9021 ret->loadGlobals(fid);
9026 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9027 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9029 * \warning this is a shallow copy constructor
9031 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9033 if(!shallowCopyOfContent)
9035 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
9036 otherPtr->incrRef();
9037 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
9041 _content=other.shallowCpy();
9045 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
9047 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
9049 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
9053 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
9055 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
9057 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
9061 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
9063 return contentNotNullBase()->getPflsReallyUsed2();
9066 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
9068 return contentNotNullBase()->getLocsReallyUsed2();
9071 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
9073 return contentNotNullBase()->getPflsReallyUsedMulti2();
9076 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
9078 return contentNotNullBase()->getLocsReallyUsedMulti2();
9081 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
9083 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
9086 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
9088 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
9091 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
9093 return contentNotNullBase()->getNumberOfTS();
9096 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
9098 contentNotNullBase()->eraseEmptyTS();
9101 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
9103 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
9106 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
9108 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
9111 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
9113 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
9114 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
9119 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
9121 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
9122 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
9127 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
9129 return contentNotNullBase()->getIterations();
9132 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
9134 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
9135 pushBackTimeStep(*it);
9138 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
9141 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
9142 int nbOfTS(fmts->getNumberOfTS());
9143 for(int i=0;i<nbOfTS;i++)
9145 MCAuto<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
9146 pushBackTimeStep(elt);
9150 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
9153 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
9154 checkCoherencyOfType(f1ts);
9156 MCAuto<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
9157 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
9159 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
9160 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
9161 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
9162 _content->pushBackTimeStep(cSafe);
9163 appendGlobs(*f1ts,1e-12);
9166 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
9168 contentNotNullBase()->synchronizeNameScope();
9171 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
9173 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
9176 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
9178 return contentNotNullBase()->getPosGivenTime(time,eps);
9181 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
9183 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
9186 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
9188 return contentNotNullBase()->getTypesOfFieldAvailable();
9191 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
9193 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
9196 std::string MEDFileAnyTypeFieldMultiTS::getName() const
9198 return contentNotNullBase()->getName();
9201 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
9203 contentNotNullBase()->setName(name);
9206 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
9208 return contentNotNullBase()->getDtUnit();
9211 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
9213 contentNotNullBase()->setDtUnit(dtUnit);
9216 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
9218 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
9221 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
9223 return contentNotNullBase()->getTimeSteps(ret1);
9226 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
9228 return contentNotNullBase()->getMeshName();
9231 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
9233 contentNotNullBase()->setMeshName(newMeshName);
9236 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
9238 return contentNotNullBase()->changeMeshNames(modifTab);
9241 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
9243 return contentNotNullBase()->getInfo();
9246 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
9248 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
9251 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
9253 return contentNotNullBase()->setInfo(info);
9256 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
9258 const std::vector<std::string> ret=getInfo();
9259 return (int)ret.size();
9262 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
9264 writeGlobals(fid,*this);
9265 contentNotNullBase()->writeLL(fid,*this);
9269 * This method alloc the arrays and load potentially huge arrays contained in this field.
9270 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
9271 * This method can be also called to refresh or reinit values from a file.
9273 * \throw If the fileName is not set or points to a non readable MED file.
9275 void MEDFileAnyTypeFieldMultiTS::loadArrays()
9277 if(getFileName().empty())
9278 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
9279 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
9280 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
9284 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
9285 * But once data loaded once, this method does nothing.
9287 * \throw If the fileName is not set or points to a non readable MED file.
9288 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
9290 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
9292 if(!getFileName().empty())
9294 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
9295 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
9300 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
9301 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
9302 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
9304 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
9306 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
9308 contentNotNullBase()->unloadArrays();
9312 * 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.
9313 * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
9314 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
9316 * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
9318 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
9320 if(!getFileName().empty())
9321 contentNotNullBase()->unloadArrays();
9324 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
9326 std::ostringstream oss;
9327 contentNotNullBase()->simpleRepr(0,oss,-1);
9328 simpleReprGlobs(oss);
9332 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
9334 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
9337 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
9339 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
9340 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
9345 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
9346 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
9347 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
9349 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
9351 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9353 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
9354 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
9355 std::size_t sz(contentsSplit.size());
9356 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
9357 for(std::size_t i=0;i<sz;i++)
9359 ret[i]=shallowCpy();
9360 ret[i]->_content=contentsSplit[i];
9366 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
9367 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
9369 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
9371 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9373 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
9374 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
9375 std::size_t sz(contentsSplit.size());
9376 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
9377 for(std::size_t i=0;i<sz;i++)
9379 ret[i]=shallowCpy();
9380 ret[i]->_content=contentsSplit[i];
9386 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
9387 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
9389 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
9391 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9393 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
9394 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
9395 std::size_t sz(contentsSplit.size());
9396 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
9397 for(std::size_t i=0;i<sz;i++)
9399 ret[i]=shallowCpy();
9400 ret[i]->_content=contentsSplit[i];
9405 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCopy() const
9407 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
9408 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
9409 ret->_content=_content->deepCopy();
9410 ret->deepCpyGlobs(*this);
9414 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
9420 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
9421 * \param [in] iteration - the iteration number of a required time step.
9422 * \param [in] order - the iteration order number of required time step.
9423 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
9424 * delete this field using decrRef() as it is no more needed.
9425 * \throw If there is no required time step in \a this field.
9427 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
9429 int pos=getPosOfTimeStep(iteration,order);
9430 return getTimeStepAtPos(pos);
9434 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
9435 * \param [in] time - the time of the time step of interest.
9436 * \param [in] eps - a precision used to compare time values.
9437 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9438 * delete this field using decrRef() as it is no more needed.
9439 * \throw If there is no required time step in \a this field.
9441 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
9443 int pos=getPosGivenTime(time,eps);
9444 return getTimeStepAtPos(pos);
9448 * 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.
9449 * The float64 value of time attached to the pair of integers are not considered here.
9450 * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
9452 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
9453 * \throw If there is a null pointer in \a vectFMTS.
9455 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
9457 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
9458 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9459 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
9460 while(!lstFMTS.empty())
9462 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
9463 MEDFileAnyTypeFieldMultiTS *curIt(*it);
9465 throw INTERP_KERNEL::Exception(msg);
9466 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
9467 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
9468 elt.push_back(curIt); it=lstFMTS.erase(it);
9469 while(it!=lstFMTS.end())
9473 throw INTERP_KERNEL::Exception(msg);
9474 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
9476 { elt.push_back(curIt); it=lstFMTS.erase(it); }
9486 * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
9487 * All returned instances in a subvector can be safely loaded, rendered along time
9488 * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
9489 * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
9490 * 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).
9491 * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
9492 * 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.
9494 * \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().
9495 * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
9496 * \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.
9497 * \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.
9499 * \throw If an element in \a vectFMTS has not only one spatial discretization set.
9500 * \throw If an element in \a vectFMTS change of spatial discretization along time.
9501 * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
9502 * \thorw If some elements in \a vectFMTS do not have the same times steps.
9503 * \throw If mesh is null.
9504 * \throw If an element in \a vectFMTS is null.
9505 * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
9507 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& fsc)
9509 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
9511 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
9512 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9513 if(vectFMTS.empty())
9515 std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
9516 MEDFileAnyTypeFieldMultiTS *frstElt(*it);
9518 throw INTERP_KERNEL::Exception(msg);
9520 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
9521 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
9522 for(;it!=vectFMTS.end();it++,i++)
9525 throw INTERP_KERNEL::Exception(msg);
9526 TypeOfField tof0,tof1;
9527 if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
9530 vectFMTSNotNodes.push_back(*it);
9532 vectFMTSNodes.push_back(*it);
9535 vectFMTSNotNodes.push_back(*it);
9537 std::vector< MCAuto<MEDFileFastCellSupportComparator> > cmps;
9538 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
9540 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
9543 bool isFetched(false);
9544 for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
9547 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
9548 if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
9549 { ret[i].push_back(*it2); isFetched=true; }
9553 std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
9554 MCAuto<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
9555 ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
9563 * 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.
9564 * \param [out] cmps - same size than the returned vector.
9566 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& cmps)
9568 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9569 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
9570 while(!lstFMTS.empty())
9572 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
9573 MEDFileAnyTypeFieldMultiTS *ref(*it);
9574 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
9575 elt.push_back(ref); it=lstFMTS.erase(it);
9576 MCAuto<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
9577 MCAuto<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
9578 while(it!=lstFMTS.end())
9580 MEDFileAnyTypeFieldMultiTS *curIt(*it);
9581 if(cmp->isEqual(curIt))
9582 { elt.push_back(curIt); it=lstFMTS.erase(it); }
9586 ret.push_back(elt); cmps.push_back(cmp);
9592 * 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.
9593 * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
9595 * \throw If \a f0 or \a f1 has not only one spatial discretization set.
9596 * \throw If \a f0 or \a f1 change of spatial discretization along time.
9597 * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
9598 * \thorw If \a f0 and \a f1 do not have the same times steps.
9599 * \throw If mesh is null.
9600 * \throw If \a f0 or \a f1 is null.
9601 * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
9603 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
9606 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
9608 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
9609 if(f0->getMeshName()!=mesh->getName())
9611 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9612 throw INTERP_KERNEL::Exception(oss.str());
9614 if(f1->getMeshName()!=mesh->getName())
9616 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9617 throw INTERP_KERNEL::Exception(oss.str());
9619 int nts=f0->getNumberOfTS();
9620 if(nts!=f1->getNumberOfTS())
9621 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
9624 for(int i=0;i<nts;i++)
9626 MCAuto<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
9627 MCAuto<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
9628 std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
9629 if(tofs0.size()!=1 || tofs1.size()!=1)
9630 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
9633 if(tof0!=tofs0[0] || tof1!=tofs1[0])
9634 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
9637 { tof0=tofs0[0]; tof1=tofs1[0]; }
9638 if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
9640 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() << ") !";
9641 throw INTERP_KERNEL::Exception(oss.str());
9643 if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
9645 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() << ") !";
9646 throw INTERP_KERNEL::Exception(oss.str());
9648 if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
9650 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() << ") !";
9651 throw INTERP_KERNEL::Exception(oss.str());
9658 * Return an extraction of \a this using \a extractDef map to specify the extraction.
9659 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
9661 * \return A new object that the caller is responsible to deallocate.
9663 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
9666 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::extractPart : mesh is null !");
9667 MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(buildNewEmpty());
9668 int nbTS(getNumberOfTS());
9669 for(int i=0;i<nbTS;i++)
9671 MCAuto<MEDFileAnyTypeField1TS> f1ts(getTimeStepAtPos(i));
9672 MCAuto<MEDFileAnyTypeField1TS> f1tsOut(f1ts->extractPart(extractDef,mm));
9673 fmtsOut->pushBackTimeStep(f1tsOut);
9675 return fmtsOut.retn();
9679 MCAuto<MEDFileAnyTypeField1TS> AggregateHelperF1TS(const std::vector< typename MLFieldTraits<T>::F1TSType const *>& f1tss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9681 MCAuto< typename MLFieldTraits<T>::F1TSType > ret(MLFieldTraits<T>::F1TSType::New());
9683 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : empty vector !");
9684 std::size_t sz(f1tss.size()),i(0);
9685 std::vector< typename MLFieldTraits<T>::F1TSWSDAType const *> f1tsw(sz);
9686 for(typename std::vector< typename MLFieldTraits<T>::F1TSType const *>::const_iterator it=f1tss.begin();it!=f1tss.end();it++,i++)
9688 typename MLFieldTraits<T>::F1TSType const *elt(*it);
9690 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : presence of a null pointer !");
9691 f1tsw[i]=dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType const *>(elt->contentNotNullBase());
9693 typename MLFieldTraits<T>::F1TSWSDAType *retc(dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType *>(ret->contentNotNullBase()));
9695 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : internal error 1 !");
9696 retc->aggregate(f1tsw,dts);
9697 ret->setDtUnit(f1tss[0]->getDtUnit());
9698 return DynamicCast<typename MLFieldTraits<T>::F1TSType , MEDFileAnyTypeField1TS>(ret);
9702 MCAuto< MEDFileAnyTypeFieldMultiTS > AggregateHelperFMTS(const std::vector< typename MLFieldTraits<T>::FMTSType const *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9704 MCAuto< typename MLFieldTraits<T>::FMTSType > ret(MLFieldTraits<T>::FMTSType::New());
9706 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : empty vector !");
9707 std::size_t sz(fmtss.size());
9708 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9710 typename MLFieldTraits<T>::FMTSType const *elt(*it);
9712 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : presence of null pointer !");
9714 int nbTS(fmtss[0]->getNumberOfTS());
9715 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9716 if((*it)->getNumberOfTS()!=nbTS)
9717 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : all fields must have the same number of TS !");
9718 for(int iterTS=0;iterTS<nbTS;iterTS++)
9721 std::vector< typename MLFieldTraits<T>::F1TSType const *> f1tss(sz);
9722 std::vector< MCAuto<typename MLFieldTraits<T>::F1TSType> > f1tss2(sz);
9723 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++,i++)
9724 { f1tss2[i]=(*it)->getTimeStepAtPos(iterTS); f1tss[i]=f1tss2[i]; }
9725 MCAuto<MEDFileAnyTypeField1TS> f1ts(AggregateHelperF1TS<T>(f1tss,dts));
9726 ret->pushBackTimeStep(f1ts);
9727 ret->setDtUnit(f1ts->getDtUnit());
9729 return DynamicCast<typename MLFieldTraits<T>::FMTSType , MEDFileAnyTypeFieldMultiTS>(ret);
9733 * \a dts and \a ftmss are expected to have same size.
9735 MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileAnyTypeFieldMultiTS::Aggregate(const std::vector<const MEDFileAnyTypeFieldMultiTS *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9738 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : input vector is empty !");
9739 std::size_t sz(fmtss.size());
9740 std::vector<const MEDFileFieldMultiTS *> fmtss1;
9741 std::vector<const MEDFileIntFieldMultiTS *> fmtss2;
9742 for(std::vector<const MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9745 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : presence of null instance in input vector !");
9746 const MEDFileFieldMultiTS *elt1(dynamic_cast<const MEDFileFieldMultiTS *>(*it));
9749 fmtss1.push_back(elt1);
9752 const MEDFileIntFieldMultiTS *elt2(dynamic_cast<const MEDFileIntFieldMultiTS *>(*it));
9755 fmtss2.push_back(elt2);
9758 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not recognized type !");
9760 if(fmtss1.size()!=sz && fmtss2.size()!=sz)
9761 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : type of data is not homogeneous !");
9762 if(fmtss1.size()==sz)
9763 return AggregateHelperFMTS<double>(fmtss1,dts);
9764 if(fmtss2.size()!=sz)
9765 return AggregateHelperFMTS<int>(fmtss2,dts);
9766 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not implemented yet !");
9769 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
9771 return new MEDFileAnyTypeFieldMultiTSIterator(this);
9774 //= MEDFileFieldMultiTS
9777 * Returns a new empty instance of MEDFileFieldMultiTS.
9778 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9779 * is to delete this field using decrRef() as it is no more needed.
9781 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
9783 return new MEDFileFieldMultiTS;
9787 * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
9788 * that has been read from a specified MED file.
9789 * \param [in] fileName - the name of the MED file to read.
9790 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9791 * is to delete this field using decrRef() as it is no more needed.
9792 * \throw If reading the file fails.
9794 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll)
9796 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9797 return New(fid,loadAll);
9800 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, bool loadAll)
9802 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,loadAll,0));
9803 ret->contentNotNull();//to check that content type matches with \a this type.
9808 * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
9809 * that has been read from a specified MED file.
9810 * \param [in] fileName - the name of the MED file to read.
9811 * \param [in] fieldName - the name of the field to read.
9812 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9813 * is to delete this field using decrRef() as it is no more needed.
9814 * \throw If reading the file fails.
9815 * \throw If there is no field named \a fieldName in the file.
9817 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9819 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9820 return New(fid,fieldName,loadAll);
9823 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
9825 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0));
9826 ret->contentNotNull();//to check that content type matches with \a this type.
9831 * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9832 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9834 * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
9835 * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9836 * \warning this is a shallow copy constructor
9837 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
9838 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9839 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9840 * is to delete this field using decrRef() as it is no more needed.
9842 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9844 return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
9847 MEDFileFieldMultiTS *MEDFileFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9849 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9850 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
9851 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0,ent));
9852 ret->contentNotNull();//to check that content type matches with \a this type.
9856 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
9858 return new MEDFileFieldMultiTS(*this);
9861 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9864 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9865 const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
9867 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
9871 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
9872 * following the given input policy.
9874 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9875 * By default (true) the globals are deeply copied.
9876 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
9878 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
9880 MCAuto<MEDFileIntFieldMultiTS> ret;
9881 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9884 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
9886 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
9887 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
9888 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc));
9891 ret=MEDFileIntFieldMultiTS::New();
9893 ret->deepCpyGlobs(*this);
9895 ret->shallowCpyGlobs(*this);
9900 * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
9901 * \param [in] pos - a time step id.
9902 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9903 * delete this field using decrRef() as it is no more needed.
9904 * \throw If \a pos is not a valid time step id.
9906 MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const
9908 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9911 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9912 throw INTERP_KERNEL::Exception(oss.str());
9914 const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
9917 MCAuto<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
9918 ret->shallowCpyGlobs(*this);
9921 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
9922 throw INTERP_KERNEL::Exception(oss.str());
9926 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9927 * mesh entities of a given dimension of the first mesh in MED file.
9928 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9929 * \param [in] type - a spatial discretization of interest.
9930 * \param [in] iteration - the iteration number of a required time step.
9931 * \param [in] order - the iteration order number of required time step.
9932 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9933 * \param [in] renumPol - specifies how to permute values of the result field according to
9934 * the optional numbers of cells and nodes, if any. The valid values are
9935 * - 0 - do not permute.
9936 * - 1 - permute cells.
9937 * - 2 - permute nodes.
9938 * - 3 - permute cells and nodes.
9940 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9941 * caller is to delete this field using decrRef() as it is no more needed.
9942 * \throw If the MED file is not readable.
9943 * \throw If there is no mesh in the MED file.
9944 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9945 * \throw If no field values of the required parameters are available.
9947 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9949 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9950 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9952 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
9953 MCAuto<DataArray> arrOut;
9954 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9955 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9960 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9961 * the top level cells of the first mesh in MED file.
9962 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9963 * \param [in] type - a spatial discretization of interest.
9964 * \param [in] iteration - the iteration number of a required time step.
9965 * \param [in] order - the iteration order number of required time step.
9966 * \param [in] renumPol - specifies how to permute values of the result field according to
9967 * the optional numbers of cells and nodes, if any. The valid values are
9968 * - 0 - do not permute.
9969 * - 1 - permute cells.
9970 * - 2 - permute nodes.
9971 * - 3 - permute cells and nodes.
9973 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9974 * caller is to delete this field using decrRef() as it is no more needed.
9975 * \throw If the MED file is not readable.
9976 * \throw If there is no mesh in the MED file.
9977 * \throw If no field values of the required parameters are available.
9979 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9981 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9982 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9984 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
9985 MCAuto<DataArray> arrOut;
9986 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9987 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9992 * 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
9993 * method should be called (getFieldOnMeshAtLevel for example).
9994 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
9996 * \param [in] iteration - the iteration number of a required time step.
9997 * \param [in] order - the iteration order number of required time step.
9998 * \param [in] mesh - the mesh the field is lying on
9999 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
10000 * caller is to delete this field using decrRef() as it is no more needed.
10002 MEDCouplingFieldDouble *MEDFileFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
10004 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10005 MCAuto<DataArray> arrOut;
10006 MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
10007 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
10012 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
10014 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10015 * \param [in] type - a spatial discretization of interest.
10016 * \param [in] iteration - the iteration number of a required time step.
10017 * \param [in] order - the iteration order number of required time step.
10018 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10019 * \param [in] mesh - the supporting mesh.
10020 * \param [in] renumPol - specifies how to permute values of the result field according to
10021 * the optional numbers of cells and nodes, if any. The valid values are
10022 * - 0 - do not permute.
10023 * - 1 - permute cells.
10024 * - 2 - permute nodes.
10025 * - 3 - permute cells and nodes.
10027 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
10028 * caller is to delete this field using decrRef() as it is no more needed.
10029 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
10030 * \throw If no field of \a this is lying on \a mesh.
10031 * \throw If no field values of the required parameters are available.
10033 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
10035 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10036 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
10038 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
10039 MCAuto<DataArray> arrOut;
10040 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
10041 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
10046 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
10048 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10049 * \param [in] type - a spatial discretization of the new field.
10050 * \param [in] iteration - the iteration number of a required time step.
10051 * \param [in] order - the iteration order number of required time step.
10052 * \param [in] mesh - the supporting mesh.
10053 * \param [in] renumPol - specifies how to permute values of the result field according to
10054 * the optional numbers of cells and nodes, if any. The valid values are
10055 * - 0 - do not permute.
10056 * - 1 - permute cells.
10057 * - 2 - permute nodes.
10058 * - 3 - permute cells and nodes.
10060 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
10061 * caller is to delete this field using decrRef() as it is no more needed.
10062 * \throw If no field of \a this is lying on \a mesh.
10063 * \throw If no field values of the required parameters are available.
10065 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
10067 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
10068 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
10070 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
10071 MCAuto<DataArray> arrOut;
10072 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
10073 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
10078 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
10079 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
10080 * This method is useful for MED2 file format when field on different mesh was autorized.
10082 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
10084 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
10085 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
10087 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
10088 MCAuto<DataArray> arrOut;
10089 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
10090 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
10095 * Returns values and a profile of the field of a given type, of a given time step,
10096 * lying on a given support.
10097 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10098 * \param [in] type - a spatial discretization of the field.
10099 * \param [in] iteration - the iteration number of a required time step.
10100 * \param [in] order - the iteration order number of required time step.
10101 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10102 * \param [in] mesh - the supporting mesh.
10103 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
10104 * field of interest lies on. If the field lies on all entities of the given
10105 * dimension, all ids in \a pfl are zero. The caller is to delete this array
10106 * using decrRef() as it is no more needed.
10107 * \param [in] glob - the global data storing profiles and localization.
10108 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
10109 * field. The caller is to delete this array using decrRef() as it is no more needed.
10110 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10111 * \throw If no field of \a this is lying on \a mesh.
10112 * \throw If no field values of the required parameters are available.
10114 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
10116 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
10117 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
10119 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
10120 MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
10121 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
10124 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const
10126 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10128 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
10129 const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
10131 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 !");
10135 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull()
10137 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10139 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
10140 MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
10142 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 !");
10147 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
10148 * the given field is checked if its elements are sorted suitable for writing to MED file
10149 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
10150 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10151 * \param [in] field - the field to add to \a this.
10152 * \throw If the name of \a field is empty.
10153 * \throw If the data array of \a field is not set.
10154 * \throw If existing time steps have different name or number of components than \a field.
10155 * \throw If the underlying mesh of \a field has no name.
10156 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
10158 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
10160 const DataArrayDouble *arr=0;
10162 arr=field->getArray();
10163 contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
10167 * Adds a MEDCouplingFieldDouble to \a this as another time step.
10168 * The mesh support of input parameter \a field is ignored here, it can be NULL.
10169 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
10172 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
10173 * A new profile is added only if no equal profile is missing.
10174 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10175 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
10176 * \param [in] mesh - the supporting mesh of \a field.
10177 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
10178 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
10179 * \throw If either \a field or \a mesh or \a profile has an empty name.
10180 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10181 * \throw If the data array of \a field is not set.
10182 * \throw If the data array of \a this is already allocated but has different number of
10183 * components than \a field.
10184 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
10185 * \sa setFieldNoProfileSBT()
10187 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
10189 const DataArrayDouble *arr=0;
10191 arr=field->getArray();
10192 contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
10195 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
10197 _content=new MEDFileFieldMultiTSWithoutSDA;
10200 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
10201 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
10204 catch(INTERP_KERNEL::Exception& e)
10207 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10208 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
10211 catch(INTERP_KERNEL::Exception& e)
10214 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
10218 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
10220 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
10223 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
10225 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
10228 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
10230 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
10233 MEDFileFieldMultiTS *MEDFileFieldMultiTS::buildNewEmpty() const
10235 return MEDFileFieldMultiTS::New();
10238 //= MEDFileAnyTypeFieldMultiTSIterator
10240 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
10245 _nb_iter=fmts->getNumberOfTS();
10249 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
10253 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
10255 if(_iter_id<_nb_iter)
10257 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
10259 return fmts->getTimeStepAtPos(_iter_id++);
10267 //= MEDFileIntFieldMultiTS
10270 * Returns a new empty instance of MEDFileFieldMultiTS.
10271 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
10272 * is to delete this field using decrRef() as it is no more needed.
10274 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
10276 return new MEDFileIntFieldMultiTS;
10280 * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
10281 * that has been read from a specified MED file.
10282 * \param [in] fileName - the name of the MED file to read.
10283 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
10284 * is to delete this field using decrRef() as it is no more needed.
10285 * \throw If reading the file fails.
10287 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll)
10289 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10290 return New(fid,loadAll);
10293 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, bool loadAll)
10295 MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,loadAll,0));
10296 ret->contentNotNull();//to check that content type matches with \a this type.
10301 * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
10302 * that has been read from a specified MED file.
10303 * \param [in] fileName - the name of the MED file to read.
10304 * \param [in] fieldName - the name of the field to read.
10305 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
10306 * is to delete this field using decrRef() as it is no more needed.
10307 * \throw If reading the file fails.
10308 * \throw If there is no field named \a fieldName in the file.
10310 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
10312 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10313 return New(fid,fieldName,loadAll);
10316 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
10318 MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0));
10319 ret->contentNotNull();//to check that content type matches with \a this type.
10324 * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
10325 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
10327 * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
10328 * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
10329 * \warning this is a shallow copy constructor
10330 * \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
10331 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
10332 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
10333 * is to delete this field using decrRef() as it is no more needed.
10335 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
10337 return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
10340 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
10342 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10343 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
10344 MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0,ent));
10345 ret->contentNotNull();//to check that content type matches with \a this type.
10350 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
10351 * following the given input policy.
10353 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
10354 * By default (true) the globals are deeply copied.
10355 * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
10357 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const
10359 MCAuto<MEDFileFieldMultiTS> ret;
10360 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
10363 const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
10365 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
10366 MCAuto<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
10367 ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc));
10370 ret=MEDFileFieldMultiTS::New();
10372 ret->deepCpyGlobs(*this);
10374 ret->shallowCpyGlobs(*this);
10378 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const
10380 return new MEDFileIntFieldMultiTS(*this);
10383 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
10386 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
10387 const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
10389 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
10393 * 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
10394 * method should be called (getFieldOnMeshAtLevel for example).
10395 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
10397 * \param [in] iteration - the iteration number of a required time step.
10398 * \param [in] order - the iteration order number of required time step.
10399 * \param [in] mesh - the mesh the field is lying on
10400 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
10401 * caller is to delete this field using decrRef() as it is no more needed.
10403 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
10405 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10406 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10408 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::field : mismatch of type of field expecting INT32 !");
10409 MCAuto<DataArray> arrOut;
10410 MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
10411 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arrOut));
10412 return ret2.retn();
10416 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
10417 * mesh entities of a given dimension of the first mesh in MED file.
10418 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10419 * \param [in] type - a spatial discretization of interest.
10420 * \param [in] iteration - the iteration number of a required time step.
10421 * \param [in] order - the iteration order number of required time step.
10422 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10423 * \param [in] renumPol - specifies how to permute values of the result field according to
10424 * the optional numbers of cells and nodes, if any. The valid values are
10425 * - 0 - do not permute.
10426 * - 1 - permute cells.
10427 * - 2 - permute nodes.
10428 * - 3 - permute cells and nodes.
10430 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10431 * caller is to delete this field using decrRef() as it is no more needed.
10432 * \throw If the MED file is not readable.
10433 * \throw If there is no mesh in the MED file.
10434 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
10435 * \throw If no field values of the required parameters are available.
10437 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
10439 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10440 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10442 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
10443 MCAuto<DataArray> arr;
10444 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase()));
10445 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10446 return ret2.retn();
10450 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
10451 * the top level cells of the first mesh in MED file.
10452 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10453 * \param [in] type - a spatial discretization of interest.
10454 * \param [in] iteration - the iteration number of a required time step.
10455 * \param [in] order - the iteration order number of required time step.
10456 * \param [in] renumPol - specifies how to permute values of the result field according to
10457 * the optional numbers of cells and nodes, if any. The valid values are
10458 * - 0 - do not permute.
10459 * - 1 - permute cells.
10460 * - 2 - permute nodes.
10461 * - 3 - permute cells and nodes.
10463 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10464 * caller is to delete this field using decrRef() as it is no more needed.
10465 * \throw If the MED file is not readable.
10466 * \throw If there is no mesh in the MED file.
10467 * \throw If no field values of the required parameters are available.
10469 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
10471 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10472 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10474 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
10475 MCAuto<DataArray> arr;
10476 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase()));
10477 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10478 return ret2.retn();
10482 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
10484 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10485 * \param [in] type - a spatial discretization of interest.
10486 * \param [in] iteration - the iteration number of a required time step.
10487 * \param [in] order - the iteration order number of required time step.
10488 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10489 * \param [in] mesh - the supporting mesh.
10490 * \param [in] renumPol - specifies how to permute values of the result field according to
10491 * the optional numbers of cells and nodes, if any. The valid values are
10492 * - 0 - do not permute.
10493 * - 1 - permute cells.
10494 * - 2 - permute nodes.
10495 * - 3 - permute cells and nodes.
10497 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10498 * caller is to delete this field using decrRef() as it is no more needed.
10499 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
10500 * \throw If no field of \a this is lying on \a mesh.
10501 * \throw If no field values of the required parameters are available.
10503 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
10505 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10506 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10508 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10509 MCAuto<DataArray> arr;
10510 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase()));
10511 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10512 return ret2.retn();
10516 * Returns a new MEDCouplingFieldInt of given type, of a given time step, lying on a
10518 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10519 * \param [in] type - a spatial discretization of the new field.
10520 * \param [in] iteration - the iteration number of a required time step.
10521 * \param [in] order - the iteration order number of required time step.
10522 * \param [in] mesh - the supporting mesh.
10523 * \param [out] arrOut - the DataArrayInt containing values of field.
10524 * \param [in] renumPol - specifies how to permute values of the result field according to
10525 * the optional numbers of cells and nodes, if any. The valid values are
10526 * - 0 - do not permute.
10527 * - 1 - permute cells.
10528 * - 2 - permute nodes.
10529 * - 3 - permute cells and nodes.
10531 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10532 * caller is to delete this field using decrRef() as it is no more needed.
10533 * \throw If no field of \a this is lying on \a mesh.
10534 * \throw If no field values of the required parameters are available.
10536 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
10538 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10539 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10541 throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10542 MCAuto<DataArray> arr;
10543 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase()));
10544 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10545 return ret2.retn();
10549 * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
10550 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
10551 * This method is useful for MED2 file format when field on different mesh was autorized.
10553 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol) const
10555 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10556 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10558 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10559 MCAuto<DataArray> arr;
10560 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase()));
10561 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10562 return ret2.retn();
10566 * Returns values and a profile of the field of a given type, of a given time step,
10567 * lying on a given support.
10568 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10569 * \param [in] type - a spatial discretization of the field.
10570 * \param [in] iteration - the iteration number of a required time step.
10571 * \param [in] order - the iteration order number of required time step.
10572 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10573 * \param [in] mesh - the supporting mesh.
10574 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
10575 * field of interest lies on. If the field lies on all entities of the given
10576 * dimension, all ids in \a pfl are zero. The caller is to delete this array
10577 * using decrRef() as it is no more needed.
10578 * \param [in] glob - the global data storing profiles and localization.
10579 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
10580 * field. The caller is to delete this array using decrRef() as it is no more needed.
10581 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10582 * \throw If no field of \a this is lying on \a mesh.
10583 * \throw If no field values of the required parameters are available.
10585 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
10587 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
10588 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
10590 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
10591 MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
10592 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
10596 * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
10597 * \param [in] pos - a time step id.
10598 * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
10599 * delete this field using decrRef() as it is no more needed.
10600 * \throw If \a pos is not a valid time step id.
10602 MEDFileIntField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
10604 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
10607 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
10608 throw INTERP_KERNEL::Exception(oss.str());
10610 const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
10613 MCAuto<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
10614 ret->shallowCpyGlobs(*this);
10617 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
10618 throw INTERP_KERNEL::Exception(oss.str());
10622 * Adds a MEDCouplingFieldInt to \a this as another time step. The underlying mesh of
10623 * the given field is checked if its elements are sorted suitable for writing to MED file
10624 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
10625 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10626 * \param [in] field - the field to add to \a this.
10627 * \throw If the name of \a field is empty.
10628 * \throw If the data array of \a field is not set.
10629 * \throw If existing time steps have different name or number of components than \a field.
10630 * \throw If the underlying mesh of \a field has no name.
10631 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
10633 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldInt *field)
10635 MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
10636 contentNotNull()->appendFieldNoProfileSBT(field2,field->getArray(),*this);
10640 * Adds a MEDCouplingFieldDouble to \a this as another time step.
10641 * The mesh support of input parameter \a field is ignored here, it can be NULL.
10642 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
10645 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
10646 * A new profile is added only if no equal profile is missing.
10647 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10648 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
10649 * \param [in] arrOfVals - the values of the field \a field used.
10650 * \param [in] mesh - the supporting mesh of \a field.
10651 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
10652 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
10653 * \throw If either \a field or \a mesh or \a profile has an empty name.
10654 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10655 * \throw If the data array of \a field is not set.
10656 * \throw If the data array of \a this is already allocated but has different number of
10657 * components than \a field.
10658 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
10659 * \sa setFieldNoProfileSBT()
10661 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
10663 MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
10664 contentNotNull()->appendFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this);
10667 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const
10669 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10671 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
10672 const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10674 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 !");
10678 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull()
10680 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10682 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
10683 MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10685 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 !");
10689 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
10691 _content=new MEDFileIntFieldMultiTSWithoutSDA;
10694 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
10698 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
10699 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
10702 catch(INTERP_KERNEL::Exception& e)
10705 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10706 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
10709 catch(INTERP_KERNEL::Exception& e)
10712 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
10714 return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
10717 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::buildNewEmpty() const
10719 return MEDFileIntFieldMultiTS::New();
10724 MEDFileFields *MEDFileFields::New()
10726 return new MEDFileFields;
10729 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
10731 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10732 return New(fid,loadAll);
10735 MEDFileFields *MEDFileFields::NewAdv(const std::string& fileName, bool loadAll, const MEDFileEntities *entities)
10737 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10738 return NewAdv(fid,loadAll,entities);
10741 MEDFileFields *MEDFileFields::NewAdv(med_idt fid, bool loadAll, const MEDFileEntities *entities)
10743 return new MEDFileFields(fid,loadAll,0,entities);
10746 MEDFileFields *MEDFileFields::NewWithDynGT(const std::string& fileName, const MEDFileStructureElements *se, bool loadAll)
10748 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10749 return NewWithDynGT(fid,se,loadAll);
10752 MEDFileFields *MEDFileFields::NewWithDynGT(med_idt fid, const MEDFileStructureElements *se, bool loadAll)
10755 throw INTERP_KERNEL::Exception("MEDFileFields::NewWithDynGT : null struct element pointer !");
10756 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> entities(MEDFileEntities::BuildFrom(*se));
10757 return new MEDFileFields(fid,loadAll,0,entities);
10760 MEDFileFields *MEDFileFields::New(med_idt fid, bool loadAll)
10762 return new MEDFileFields(fid,loadAll,0,0);
10765 MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
10767 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10768 return new MEDFileFields(fid,loadAll,ms,0);
10771 MEDFileFields *MEDFileFields::LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
10773 MEDFileUtilities::CheckFileForRead(fileName);
10774 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
10775 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10776 return new MEDFileFields(fid,loadAll,0,ent);
10779 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
10781 std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
10782 ret+=_fields.capacity()*sizeof(MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
10786 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
10788 std::vector<const BigMemoryObject *> ret;
10789 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10790 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
10794 MEDFileFields *MEDFileFields::deepCopy() const
10796 MCAuto<MEDFileFields> ret(shallowCpy());
10798 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10800 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10801 ret->_fields[i]=(*it)->deepCopy();
10803 ret->deepCpyGlobs(*this);
10807 MEDFileFields *MEDFileFields::shallowCpy() const
10809 return new MEDFileFields(*this);
10813 * 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
10814 * 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.
10815 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
10817 * \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.
10818 * \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.
10820 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10822 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
10824 std::set< std::pair<int,int> > s;
10825 bool firstShot=true;
10826 areThereSomeForgottenTS=false;
10827 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10829 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10831 std::vector< std::pair<int,int> > v=(*it)->getIterations();
10832 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
10834 { s=s1; firstShot=false; }
10837 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
10839 areThereSomeForgottenTS=true;
10843 std::vector< std::pair<int,int> > ret;
10844 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
10848 int MEDFileFields::getNumberOfFields() const
10850 return _fields.size();
10853 std::vector<std::string> MEDFileFields::getFieldsNames() const
10855 std::vector<std::string> ret(_fields.size());
10857 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10859 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
10862 ret[i]=f->getName();
10866 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
10867 throw INTERP_KERNEL::Exception(oss.str());
10873 std::vector<std::string> MEDFileFields::getMeshesNames() const
10875 std::vector<std::string> ret;
10876 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10878 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10880 ret.push_back(cur->getMeshName());
10885 std::string MEDFileFields::simpleRepr() const
10887 std::ostringstream oss;
10888 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
10893 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
10895 int nbOfFields(getNumberOfFields());
10896 std::string startLine(bkOffset,' ');
10897 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
10899 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10901 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10904 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
10908 oss << startLine << " - not defined !" << std::endl;
10912 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10914 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10915 std::string chapter(17,'0'+i);
10916 oss << startLine << chapter << std::endl;
10919 cur->simpleRepr(bkOffset+2,oss,i);
10923 oss << startLine << " - not defined !" << std::endl;
10925 oss << startLine << chapter << std::endl;
10927 simpleReprGlobs(oss);
10930 MEDFileFields::MEDFileFields()
10934 MEDFileFields::MEDFileFields(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10935 try:MEDFileFieldGlobsReal(fid)
10937 int nbFields(MEDnField(fid));
10938 _fields.resize(nbFields);
10939 med_field_type typcha;
10940 for(int i=0;i<nbFields;i++)
10942 std::vector<std::string> infos;
10943 std::string fieldName,dtunit,meshName;
10944 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,i,false,fieldName,typcha,infos,dtunit,meshName));
10949 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName,meshName,typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10954 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName,meshName,typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10959 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] !";
10960 throw INTERP_KERNEL::Exception(oss.str());
10964 loadAllGlobals(fid,entities);
10966 catch(INTERP_KERNEL::Exception& e)
10971 void MEDFileFields::writeLL(med_idt fid) const
10974 writeGlobals(fid,*this);
10975 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10977 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
10980 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
10981 throw INTERP_KERNEL::Exception(oss.str());
10983 elt->writeLL(fid,*this);
10988 * This method alloc the arrays and load potentially huge arrays contained in this field.
10989 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
10990 * This method can be also called to refresh or reinit values from a file.
10992 * \throw If the fileName is not set or points to a non readable MED file.
10994 void MEDFileFields::loadArrays()
10996 if(getFileName().empty())
10997 throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
10998 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
10999 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11001 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
11003 elt->loadBigArraysRecursively(fid,*elt);
11008 * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
11009 * But once data loaded once, this method does nothing.
11011 * \throw If the fileName is not set or points to a non readable MED file.
11012 * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
11014 void MEDFileFields::loadArraysIfNecessary()
11016 if(!getFileName().empty())
11018 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
11019 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11021 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
11023 elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
11029 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
11030 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
11031 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
11033 * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
11035 void MEDFileFields::unloadArrays()
11037 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11039 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
11041 elt->unloadArrays();
11046 * 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.
11047 * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
11048 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
11050 * \sa MEDFileFields::loadArraysIfNecessary
11052 void MEDFileFields::unloadArraysWithoutDataLoss()
11054 if(!getFileName().empty())
11058 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
11060 std::vector<std::string> ret;
11061 std::set<std::string> ret2;
11062 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11064 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
11065 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
11066 if(ret2.find(*it2)==ret2.end())
11068 ret.push_back(*it2);
11075 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
11077 std::vector<std::string> ret;
11078 std::set<std::string> ret2;
11079 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11081 std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
11082 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
11083 if(ret2.find(*it2)==ret2.end())
11085 ret.push_back(*it2);
11092 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
11094 std::vector<std::string> ret;
11095 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11097 std::vector<std::string> tmp((*it)->getPflsReallyUsedMulti2());
11098 ret.insert(ret.end(),tmp.begin(),tmp.end());
11103 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
11105 std::vector<std::string> ret;
11106 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11108 std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
11109 ret.insert(ret.end(),tmp.begin(),tmp.end());
11114 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
11116 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
11117 (*it)->changePflsRefsNamesGen2(mapOfModif);
11120 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
11122 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
11123 (*it)->changeLocsRefsNamesGen2(mapOfModif);
11126 void MEDFileFields::resize(int newSize)
11128 _fields.resize(newSize);
11131 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
11133 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
11137 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
11140 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
11141 _fields.push_back(field->getContent());
11142 appendGlobs(*field,1e-12);
11145 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
11148 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
11149 if(i>=(int)_fields.size())
11150 _fields.resize(i+1);
11151 _fields[i]=field->getContent();
11152 appendGlobs(*field,1e-12);
11155 void MEDFileFields::destroyFieldAtPos(int i)
11157 destroyFieldsAtPos(&i,&i+1);
11160 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
11162 std::vector<bool> b(_fields.size(),true);
11163 for(const int *i=startIds;i!=endIds;i++)
11165 if(*i<0 || *i>=(int)_fields.size())
11167 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
11168 throw INTERP_KERNEL::Exception(oss.str());
11172 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
11174 for(std::size_t i=0;i<_fields.size();i++)
11176 fields[j++]=_fields[i];
11180 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
11182 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
11183 int nbOfEntriesToKill(DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg));
11184 std::vector<bool> b(_fields.size(),true);
11186 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
11188 if(k<0 || k>=(int)_fields.size())
11190 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
11191 throw INTERP_KERNEL::Exception(oss.str());
11195 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
11197 for(std::size_t i=0;i<_fields.size();i++)
11199 fields[j++]=_fields[i];
11203 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
11206 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11208 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
11210 ret=cur->changeMeshNames(modifTab) || ret;
11216 * \param [in] meshName the name of the mesh that will be renumbered.
11217 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
11218 * This code corresponds to the distribution of types in the corresponding mesh.
11219 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
11220 * \param [in] renumO2N the old to new renumber array.
11221 * \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
11222 * field in \a this.
11224 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
11227 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11229 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
11232 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
11239 * Return an extraction of \a this using \a extractDef map to specify the extraction.
11240 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
11242 * \return A new object that the caller is responsible to deallocate.
11244 MEDFileFields *MEDFileFields::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
11247 throw INTERP_KERNEL::Exception("MEDFileFields::extractPart : input mesh is NULL !");
11248 MCAuto<MEDFileFields> fsOut(MEDFileFields::New());
11249 int nbFields(getNumberOfFields());
11250 for(int i=0;i<nbFields;i++)
11252 MCAuto<MEDFileAnyTypeFieldMultiTS> fmts(getFieldAtPos(i));
11255 std::ostringstream oss; oss << "MEDFileFields::extractPart : at pos #" << i << " field is null !";
11256 throw INTERP_KERNEL::Exception(oss.str());
11258 MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(fmts->extractPart(extractDef,mm));
11259 fsOut->pushField(fmtsOut);
11261 return fsOut.retn();
11264 void MEDFileFields::accept(MEDFileFieldVisitor& visitor) const
11266 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11267 if((*it).isNotNull())
11269 visitor.newFieldEntry(*it);
11270 (*it)->accept(visitor);
11271 visitor.endFieldEntry(*it);
11275 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
11277 if(i<0 || i>=(int)_fields.size())
11279 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
11280 throw INTERP_KERNEL::Exception(oss.str());
11282 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
11285 MCAuto<MEDFileAnyTypeFieldMultiTS> ret;
11286 const MEDFileFieldMultiTSWithoutSDA *fmtsC(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts));
11287 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts));
11289 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
11291 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
11294 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
11295 throw INTERP_KERNEL::Exception(oss.str());
11297 ret->shallowCpyGlobs(*this);
11302 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
11303 * This method is accessible in python using __getitem__ with a list in input.
11304 * \return a new object that the caller should deal with.
11306 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
11308 MCAuto<MEDFileFields> ret=shallowCpy();
11309 std::size_t sz=std::distance(startIds,endIds);
11310 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
11312 for(const int *i=startIds;i!=endIds;i++,j++)
11314 if(*i<0 || *i>=(int)_fields.size())
11316 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
11317 throw INTERP_KERNEL::Exception(oss.str());
11319 fields[j]=_fields[*i];
11321 ret->_fields=fields;
11325 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
11327 return getFieldAtPos(getPosFromFieldName(fieldName));
11331 * This method removes, if any, fields in \a this having no time steps.
11332 * 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.
11334 * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
11336 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
11338 std::vector<MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
11339 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11341 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
11344 if(elt->getNumberOfTS()>0)
11345 newFields.push_back(*it);
11348 if(_fields.size()==newFields.size())
11355 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
11356 * This method can be seen as a filter applied on \a this, that returns an object containing
11357 * 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
11358 * shallow copied from \a this.
11360 * \param [in] meshName - the name of the mesh on w
11361 * \return a new object that the caller should deal with.
11363 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
11365 MCAuto<MEDFileFields> ret(MEDFileFields::New());
11366 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11368 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
11371 if(cur->getMeshName()==meshName)
11374 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
11375 ret->_fields.push_back(cur2);
11378 ret->shallowCpyOnlyUsedGlobs(*this);
11383 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
11384 * Input time steps are specified using a pair of integer (iteration, order).
11385 * 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,
11386 * but for each multitimestep only the time steps in \a timeSteps are kept.
11387 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
11389 * The returned object points to shallow copy of elements in \a this.
11391 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
11392 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
11393 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
11395 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
11397 MCAuto<MEDFileFields> ret(MEDFileFields::New());
11398 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11400 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
11403 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
11404 ret->_fields.push_back(elt);
11406 ret->shallowCpyOnlyUsedGlobs(*this);
11411 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
11413 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
11415 MCAuto<MEDFileFields> ret=MEDFileFields::New();
11416 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11418 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
11421 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
11422 if(elt->getNumberOfTS()!=0)
11423 ret->_fields.push_back(elt);
11425 ret->shallowCpyOnlyUsedGlobs(*this);
11429 bool MEDFileFields::presenceOfStructureElements() const
11431 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11432 if((*it).isNotNull())
11433 if((*it)->presenceOfStructureElements())
11438 void MEDFileFields::killStructureElements()
11440 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
11441 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11442 if((*it).isNotNull())
11444 if((*it)->presenceOfStructureElements())
11446 if(!(*it)->onlyStructureElements())
11448 (*it)->killStructureElements();
11449 ret.push_back(*it);
11454 ret.push_back(*it);
11460 void MEDFileFields::keepOnlyStructureElements()
11462 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
11463 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11464 if((*it).isNotNull())
11466 if((*it)->presenceOfStructureElements())
11468 if(!(*it)->onlyStructureElements())
11469 (*it)->keepOnlyStructureElements();
11470 ret.push_back(*it);
11476 void MEDFileFields::keepOnlyOnMeshSE(const std::string& meshName, const std::string& seName)
11478 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
11479 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11480 if((*it).isNotNull())
11482 if((*it)->getMeshName()!=meshName)
11484 std::vector< std::pair<std::string,std::string> > ps;
11485 (*it)->getMeshSENames(ps);
11486 std::pair<std::string,std::string> p(meshName,seName);
11487 if(std::find(ps.begin(),ps.end(),p)!=ps.end())
11488 (*it)->keepOnlyOnSE(seName);
11489 ret.push_back(*it);
11494 void MEDFileFields::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
11496 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11497 if((*it).isNotNull())
11498 (*it)->getMeshSENames(ps);
11501 void MEDFileFields::blowUpSE(MEDFileMeshes *ms, const MEDFileStructureElements *ses)
11503 MEDFileBlowStrEltUp::DealWithSE(this,ms,ses);
11506 MCAuto<MEDFileFields> MEDFileFields::partOfThisOnStructureElements() const
11508 MCAuto<MEDFileFields> ret(deepCopy());
11509 ret->keepOnlyStructureElements();
11513 MCAuto<MEDFileFields> MEDFileFields::partOfThisLyingOnSpecifiedMeshSEName(const std::string& meshName, const std::string& seName) const
11515 MCAuto<MEDFileFields> ret(deepCopy());
11516 ret->keepOnlyOnMeshSE(meshName,seName);
11520 void MEDFileFields::aggregate(const MEDFileFields& other)
11522 int nbFieldsToAdd(other.getNumberOfFields());
11523 std::vector<std::string> fsn(getFieldsNames());
11524 for(int i=0;i<nbFieldsToAdd;i++)
11526 MCAuto<MEDFileAnyTypeFieldMultiTS> elt(other.getFieldAtPos(i));
11527 std::string name(elt->getName());
11528 if(std::find(fsn.begin(),fsn.end(),name)!=fsn.end())
11530 std::ostringstream oss; oss << "MEDFileFields::aggregate : name \"" << name << "\" already appears !";
11531 throw INTERP_KERNEL::Exception(oss.str());
11537 MEDFileFieldsIterator *MEDFileFields::iterator()
11539 return new MEDFileFieldsIterator(this);
11542 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
11544 std::string tmp(fieldName);
11545 std::vector<std::string> poss;
11546 for(std::size_t i=0;i<_fields.size();i++)
11548 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f(_fields[i]);
11551 std::string fname(f->getName());
11555 poss.push_back(fname);
11558 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
11559 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
11561 throw INTERP_KERNEL::Exception(oss.str());
11564 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
11569 _nb_iter=fs->getNumberOfFields();
11573 MEDFileFieldsIterator::~MEDFileFieldsIterator()
11577 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
11579 if(_iter_id<_nb_iter)
11581 MEDFileFields *fs(_fs);
11583 return fs->getFieldAtPos(_iter_id++);