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"
28 #include "MEDCouplingFieldDouble.hxx"
29 #include "MEDCouplingFieldTemplate.hxx"
30 #include "MEDCouplingFieldDiscretization.hxx"
32 #include "InterpKernelAutoPtr.hxx"
33 #include "CellModel.hxx"
38 extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
39 extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
40 extern med_geometry_type typmainoeud[1];
41 extern med_geometry_type typmai3[34];
43 using namespace MEDCoupling;
45 template class MEDFileField1TSTemplateWithoutSDA<int>;
46 template class MEDFileField1TSTemplateWithoutSDA<double>;
48 const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64";
49 const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32";
51 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const std::string& locName)
53 return new MEDFileFieldLoc(fid,locName);
56 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, int id)
58 return new MEDFileFieldLoc(fid,id);
61 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)
63 return new MEDFileFieldLoc(locName,geoType,refCoo,gsCoo,w);
66 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, const std::string& locName):_name(locName)
68 med_geometry_type geotype;
69 med_geometry_type sectiongeotype;
71 INTERP_KERNEL::AutoPtr<char> geointerpname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
72 INTERP_KERNEL::AutoPtr<char> sectionmeshname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
73 MEDlocalizationInfoByName(fid,locName.c_str(),&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
74 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
75 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
76 _nb_node_per_cell=cm.getNumberOfNodes();
77 _ref_coo.resize(_dim*_nb_node_per_cell);
78 _gs_coo.resize(_dim*_nb_gauss_pt);
79 _w.resize(_nb_gauss_pt);
80 MEDlocalizationRd(fid,locName.c_str(),MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
83 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id)
85 med_geometry_type geotype;
86 med_geometry_type sectiongeotype;
88 INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
89 INTERP_KERNEL::AutoPtr<char> geointerpname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
90 INTERP_KERNEL::AutoPtr<char> sectionmeshname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
91 MEDlocalizationInfo(fid,id+1,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
93 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
94 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
95 _nb_node_per_cell=cm.getNumberOfNodes();
96 _ref_coo.resize(_dim*_nb_node_per_cell);
97 _gs_coo.resize(_dim*_nb_gauss_pt);
98 _w.resize(_nb_gauss_pt);
99 MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
102 MEDFileFieldLoc::MEDFileFieldLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType,
103 const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w):_name(locName),_geo_type(geoType),_ref_coo(refCoo),_gs_coo(gsCoo),
106 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
107 _dim=cm.getDimension();
108 _nb_node_per_cell=cm.getNumberOfNodes();
109 _nb_gauss_pt=_w.size();
112 MEDFileFieldLoc *MEDFileFieldLoc::deepCopy() const
114 return new MEDFileFieldLoc(*this);
117 std::size_t MEDFileFieldLoc::getHeapMemorySizeWithoutChildren() const
119 return (_ref_coo.capacity()+_gs_coo.capacity()+_w.capacity())*sizeof(double)+_name.capacity();
122 std::vector<const BigMemoryObject *> MEDFileFieldLoc::getDirectChildrenWithNull() const
124 return std::vector<const BigMemoryObject *>();
127 void MEDFileFieldLoc::simpleRepr(std::ostream& oss) const
129 static const char OFF7[]="\n ";
130 oss << "\"" << _name << "\"" << OFF7;
131 oss << "GeoType=" << INTERP_KERNEL::CellModel::GetCellModel(_geo_type).getRepr() << OFF7;
132 oss << "Dimension=" << _dim << OFF7;
133 oss << "Number of Gauss points=" << _nb_gauss_pt << OFF7;
134 oss << "Number of nodes per cell=" << _nb_node_per_cell << OFF7;
135 oss << "RefCoords="; std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
136 oss << "Weights="; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
137 oss << "GaussPtsCoords="; std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," ")); oss << std::endl;
140 void MEDFileFieldLoc::setName(const std::string& name)
145 bool MEDFileFieldLoc::isEqual(const MEDFileFieldLoc& other, double eps) const
147 if(_name!=other._name)
151 if(_nb_gauss_pt!=other._nb_gauss_pt)
153 if(_nb_node_per_cell!=other._nb_node_per_cell)
155 if(_geo_type!=other._geo_type)
157 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_ref_coo,other._ref_coo,eps))
159 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_gs_coo,other._gs_coo,eps))
161 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_w,other._w,eps))
167 void MEDFileFieldLoc::writeLL(med_idt fid) const
169 MEDlocalizationWr(fid,_name.c_str(),typmai3[(int)_geo_type],_dim,&_ref_coo[0],MED_FULL_INTERLACE,_nb_gauss_pt,&_gs_coo[0],&_w[0],MED_NO_INTERPOLATION,MED_NO_MESH_SUPPORT);
172 std::string MEDFileFieldLoc::repr() const
174 std::ostringstream oss; oss.precision(15);
175 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
176 oss << "Localization \"" << _name << "\" :\n" << " - Geometric Type : " << cm.getRepr();
177 oss << "\n - Dimension : " << _dim << "\n - Number of gauss points : ";
178 oss << _nb_gauss_pt << "\n - Number of nodes in cell : " << _nb_node_per_cell;
179 oss << "\n - Ref coords are : ";
180 int sz=_ref_coo.size();
183 int nbOfTuples=sz/_dim;
184 for(int i=0;i<nbOfTuples;i++)
187 for(int j=0;j<_dim;j++)
188 { oss << _ref_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
193 std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," "));
194 oss << "\n - Gauss coords in reference element : ";
198 int nbOfTuples=sz/_dim;
199 for(int i=0;i<nbOfTuples;i++)
202 for(int j=0;j<_dim;j++)
203 { oss << _gs_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
208 std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," "));
209 oss << "\n - Weights of Gauss coords are : "; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," "));
213 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
215 _type=field->getTypeOfField();
221 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,offset,offset+nbOfCells,1);
222 _end=_start+nbOfCells;
228 MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
229 const int *arrPtr=arr->getConstPointer();
230 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,arrPtr[offset],arrPtr[offset+nbOfCells],1);
231 _end=_start+(arrPtr[offset+nbOfCells]-arrPtr[offset]);
237 const MEDCouplingFieldDiscretization *disc(field->getDiscretization());
238 const MEDCouplingGaussLocalization& gsLoc(field->getGaussLocalization(_loc_id));
239 const MEDCouplingFieldDiscretizationGauss *disc2(dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc));
241 throw INTERP_KERNEL::Exception("assignFieldNoProfile : invalid call to this method ! Internal Error !");
242 const DataArrayInt *dai(disc2->getArrayOfDiscIds());
243 MCAuto<DataArrayInt> dai2(disc2->getOffsetArr(field->getMesh()));
244 const int *dai2Ptr(dai2->getConstPointer());
245 int nbi(gsLoc.getWeights().size());
246 MCAuto<DataArrayInt> da2(dai->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1));
247 MCAuto<DataArrayInt> da3(da2->findIdsEqual(_loc_id));
248 const int *da3Ptr(da3->getConstPointer());
249 if(da3->getNumberOfTuples()!=nbOfCells)
250 {//profile : for gauss even in NoProfile !!!
251 std::ostringstream oss; oss << "Pfl_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
253 da3->setName(_profile.c_str());
254 glob.appendProfile(da3);
256 MCAuto<DataArrayInt> da4(DataArrayInt::New());
257 _nval=da3->getNbOfElems();
258 da4->alloc(_nval*nbi,1);
259 int *da4Ptr(da4->getPointer());
260 for(int i=0;i<_nval;i++)
262 int ref=dai2Ptr[offset+da3Ptr[i]];
263 for(int j=0;j<nbi;j++)
266 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
267 _localization=oss2.str();
268 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,da4);
269 _end=_start+_nval*nbi;
270 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
274 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile : not implemented yet for such discretization type of field !");
280 * Leaf method of field with profile assignement. This method is the most general one. No optimization is done here.
281 * \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).
282 * \param [in] multiTypePfl is the end user profile specified in high level API
283 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
284 * \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.
285 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
286 * \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.
288 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)
291 _type=field->getTypeOfField();
292 std::string pflName(multiTypePfl->getName());
293 std::ostringstream oss; oss << pflName;
297 { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType()); oss << "_" << cm.getRepr(); }
304 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : existing profile with empty name !");
305 if(_type!=ON_GAUSS_PT)
307 locIds->setName(oss.str());
308 glob.appendProfile(locIds);
317 _nval=idsInPfl->getNumberOfTuples();
318 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,0,arrr->getNumberOfTuples(),1);
324 _nval=idsInPfl->getNumberOfTuples();
325 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,idsInPfl);
331 MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
332 MCAuto<DataArrayInt> arr2=arr->deltaShiftIndex();
333 MCAuto<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->begin(),multiTypePfl->end());
334 arr3->computeOffsetsFull();
335 MCAuto<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
336 int trueNval=tmp->getNumberOfTuples();
337 _nval=idsInPfl->getNumberOfTuples();
338 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
339 _end=_start+trueNval;
344 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(field->getDiscretization());
346 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
347 const DataArrayInt *da1=disc2->getArrayOfDiscIds();
348 const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
349 MCAuto<DataArrayInt> da2=da1->selectByTupleId(idsInPfl->begin(),idsInPfl->end());
350 MCAuto<DataArrayInt> da3=da2->findIdsEqual(_loc_id);
351 MCAuto<DataArrayInt> da4=idsInPfl->selectByTupleId(da3->begin(),da3->end());
353 MCAuto<MEDCouplingMesh> mesh2=mesh->buildPart(multiTypePfl->begin(),multiTypePfl->end());
354 MCAuto<DataArrayInt> arr=disc2->getOffsetArr(mesh2);
356 MCAuto<DataArrayInt> tmp=DataArrayInt::New();
358 for(const int *pt=da4->begin();pt!=da4->end();pt++)
359 trueNval+=arr->getIJ(*pt+1,0)-arr->getIJ(*pt,0);
360 tmp->alloc(trueNval,1);
361 int *tmpPtr=tmp->getPointer();
362 for(const int *pt=da4->begin();pt!=da4->end();pt++)
363 for(int j=arr->getIJ(*pt,0);j<arr->getIJ(*pt+1,0);j++)
366 _nval=da4->getNumberOfTuples();
367 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
368 _end=_start+trueNval;
369 oss << "_loc_" << _loc_id;
372 MCAuto<DataArrayInt> da5=locIds->selectByTupleId(da3->begin(),da3->end());
373 da5->setName(oss.str());
374 glob.appendProfile(da5);
379 if(!da3->isIota(nbOfEltsInWholeMesh))
381 da3->setName(oss.str());
382 glob.appendProfile(da3);
386 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
387 _localization=oss2.str();
388 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
392 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for such discretization type of field !");
397 void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob)
400 _nval=arrr->getNumberOfTuples();
401 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,0,_nval,1);
406 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int profileIt, const PartDefinition *pd)
408 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt,pd);
411 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int locId)
413 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string());
416 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(const MEDFileFieldPerMeshPerTypePerDisc& other)
418 return new MEDFileFieldPerMeshPerTypePerDisc(other);
421 std::size_t MEDFileFieldPerMeshPerTypePerDisc::getHeapMemorySizeWithoutChildren() const
423 return _profile.capacity()+_localization.capacity()+sizeof(MEDFileFieldPerMeshPerTypePerDisc);
426 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypePerDisc::getDirectChildrenWithNull() const
428 std::vector<const BigMemoryObject *> ret(1);
429 ret[0]=(const PartDefinition*)_pd;
433 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCopy(MEDFileFieldPerMeshPerTypeCommon *father) const
435 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret(new MEDFileFieldPerMeshPerTypePerDisc(*this));
440 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField atype, int profileIt, const PartDefinition *pd)
441 try:_type(atype),_father(fath),_profile_it(profileIt),_pd(const_cast<PartDefinition *>(pd))
446 catch(INTERP_KERNEL::Exception& e)
451 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
455 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)
459 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(0),_start(-std::numeric_limits<int>::max()),_end(-std::numeric_limits<int>::max()),
460 _nval(-std::numeric_limits<int>::max()),_loc_id(-std::numeric_limits<int>::max())
464 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)
466 const PartDefinition *pd(_pd);
469 INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
471 med_int nbValsInFile(MEDfieldnValueWithProfileByName(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile.c_str(),MED_COMPACT_PFLMODE,&tmp1,locname,&nbi));
472 if(_end-_start!=nbValsInFile*nbi)
474 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 !";
475 throw INTERP_KERNEL::Exception(oss.str());
477 MEDFILESAFECALLERRD0(MEDfieldValueWithProfileRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,_profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,startFeedingPtr));
481 if(!_profile.empty())
482 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : not implemented !");
483 INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)),locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
485 int overallNval(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
486 const SlicePartDefinition *spd(dynamic_cast<const SlicePartDefinition *>(pd));
490 spd->getSlice(start,stop,step);
491 int nbOfEltsToLoad(DataArray::GetNumberOfItemGivenBES(start,stop,step,"MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile"));
492 med_filter filter=MED_FILTER_INIT;
493 MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
494 MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
495 /*start*/start+1,/*stride*/step,/*count*/1,/*blocksize*/nbOfEltsToLoad,
496 /*lastblocksize=useless because count=1*/0,&filter);
497 MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,startFeedingPtr));
498 MEDfilterClose(&filter);
501 const DataArrayPartDefinition *dpd(dynamic_cast<const DataArrayPartDefinition *>(pd));
504 dpd->checkConsistencyLight();
505 MCAuto<DataArrayInt> myIds(dpd->toDAI());
506 int a(myIds->getMinValueInArray()),b(myIds->getMaxValueInArray());
507 myIds=myIds->deepCopy();// WARNING deep copy here because _pd is modified by applyLin !!!
508 myIds->applyLin(1,-a);
509 int nbOfEltsToLoad(b-a+1);
510 med_filter filter=MED_FILTER_INIT;
511 {//TODO : manage int32 !
512 MCAuto<DataArrayDouble> tmp(DataArrayDouble::New());
513 tmp->alloc(nbOfEltsToLoad,nbOfCompo);
514 MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
515 MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
516 /*start*/a+1,/*stride*/1,/*count*/1,/*blocksize*/nbOfEltsToLoad,
517 /*lastblocksize=useless because count=1*/0,&filter);
518 MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,reinterpret_cast<unsigned char *>(tmp->getPointer())));
519 MCAuto<DataArrayDouble> feeder(DataArrayDouble::New());
520 feeder->useExternalArrayWithRWAccess(reinterpret_cast<double *>(startFeedingPtr),_nval,nbOfCompo);
521 feeder->setContigPartOfSelectedValues(0,tmp,myIds);
523 MEDfilterClose(&filter);
526 throw INTERP_KERNEL::Exception("Not implemented yet for not slices!");
530 const MEDFileFieldPerMeshPerTypeCommon *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
535 void MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
537 INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
538 INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
539 std::string fieldName(nasc.getName()),meshName(getMeshName());
540 int iteration(getIteration()),order(getOrder()),profilesize,nbi;
541 TypeOfField type(getType());
542 med_geometry_type mgeoti;
543 med_entity_type menti;
544 _father->entriesForMEDfile(type,mgeoti,menti);
545 int zeNVal(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
546 _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
547 _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
548 const PartDefinition *pd(_pd);
555 if(!_profile.empty())
556 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively : profiles are not managed yet with part of def !");
557 _nval=pd->getNumberOfElems();
560 _end=start+_nval*nbi;
562 if(type==ON_CELLS && !_localization.empty())
564 if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
565 setType(ON_GAUSS_PT);
568 setType(ON_GAUSS_NE);
569 _localization.clear();
574 void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, const MEDFileFieldNameScope& nasc)
576 std::string fieldName(nasc.getName()),meshName(getMeshName());
577 int iteration(getIteration()),order(getOrder());
578 TypeOfField type(getType());
579 med_geometry_type mgeoti;
580 med_entity_type menti;
581 _father->entriesForMEDfile(type,mgeoti,menti);
583 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !");
586 DataArray *arr(getOrCreateAndGetArray());//arr is not null due to the spec of getOrCreateAndGetArray
587 if(_start<0 || _start>=arr->getNumberOfTuples())
589 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << ") !";
590 throw INTERP_KERNEL::Exception(oss.str());
592 if(_end<0 || _end>arr->getNumberOfTuples())
594 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !";
595 throw INTERP_KERNEL::Exception(oss.str());
597 int nbOfCompo(arr->getNumberOfComponents());
598 DataArrayDouble *arrD(dynamic_cast<DataArrayDouble *>(arr));
601 double *startFeeding(arrD->getPointer()+_start*nbOfCompo);
602 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
605 DataArrayInt *arrI(dynamic_cast<DataArrayInt *>(arr));
608 int *startFeeding(arrI->getPointer()+_start*nbOfCompo);
609 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
612 throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
616 * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
618 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart)
620 int delta=_end-_start;
621 _start=newValueOfStart;
625 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
627 return _father->getIteration();
630 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
632 return _father->getOrder();
635 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
637 return _father->getTime();
640 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
642 return _father->getMeshName();
645 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
647 const char startLine[]=" ## ";
648 std::string startLine2(bkOffset,' ');
649 startLine2+=startLine;
650 INTERP_KERNEL::AutoCppPtr<MEDCouplingFieldDiscretization> tmp(MEDCouplingFieldDiscretization::New(_type));
651 oss << startLine2 << "Localization #" << id << "." << std::endl;
652 oss << startLine2 << " Type=" << tmp->getRepr() << "." << std::endl;
653 oss << startLine2 << " This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
654 oss << startLine2 << " This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
655 oss << startLine2 << " This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
658 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
663 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
665 return _father->getGeoType();
668 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
673 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
678 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
680 return _father->getNumberOfComponents();
683 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
688 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray()
690 return _father->getOrCreateAndGetArray();
693 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const
695 const MEDFileFieldPerMeshPerTypeCommon *fath=_father;
696 return fath->getOrCreateAndGetArray();
699 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
701 return _father->getInfo();
704 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
709 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const std::string& newPflName)
714 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
716 return _localization;
719 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const std::string& newLocName)
721 _localization=newLocName;
724 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
726 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
728 if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
730 _profile=(*it2).second;
736 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
738 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
740 if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
742 _localization=(*it2).second;
748 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
752 dads.push_back(std::pair<int,int>(_start,_end));
753 geoTypes.push_back(getGeoType());
758 pfls.push_back(glob->getProfile(_profile.c_str()));
760 if(_localization.empty())
764 locs.push_back(glob->getLocalizationId(_localization.c_str()));
768 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
770 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));
774 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
776 TypeOfField type=getType();
777 INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
778 med_geometry_type mgeoti;
779 med_entity_type menti;
780 _father->entriesForMEDfile(getType(),mgeoti,menti);
781 const DataArray *arr(getOrCreateAndGetArray());
783 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
784 if(!arr->isAllocated())
785 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : the array to be written is not allocated !");
786 const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
787 const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
788 const unsigned char *locToWrite=0;
790 locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
792 locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
794 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
795 MEDFILESAFECALLERWR0(MEDfieldValueWithProfileWr,(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
796 MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
800 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const
805 dad.first=_start; dad.second=_end;
809 * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
810 * This code corresponds to the distribution of types in the corresponding mesh.
811 * \param [out] ptToFill memory zone where the output will be stored.
812 * \return the size of data pushed into output param \a ptToFill
814 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const
817 std::ostringstream oss;
818 std::size_t nbOfType=codeOfMesh.size()/3;
820 for(std::size_t i=0;i<nbOfType && found==-1;i++)
821 if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
825 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
826 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
827 throw INTERP_KERNEL::Exception(oss.str());
832 if(_nval!=codeOfMesh[3*found+1])
834 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
835 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
836 oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
837 throw INTERP_KERNEL::Exception(oss.str());
839 for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
844 const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
845 if(pfl->getNumberOfTuples()!=_nval)
847 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
848 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
850 oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
851 throw INTERP_KERNEL::Exception(oss.str());
853 int offset2=codeOfMesh[3*found+2];
854 for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
856 if(*pflId<codeOfMesh[3*found+1])
857 *work++=offset2+*pflId;
863 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const
865 for(int i=_start;i<_end;i++)
870 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId)
881 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
885 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
888 std::map<std::pair<std::string,TypeOfField>,int> m;
889 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
890 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
891 if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
892 m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
894 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
895 ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
900 * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
902 * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
903 * \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.
904 * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
905 * \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)
906 * \param [in,out] glob if necessary by the method, new profiles can be added to it
907 * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
908 * \param [out] result All new entries will be appended on it.
909 * \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 !)
911 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
912 const DataArrayInt *explicitIdsInMesh,
913 const std::vector<int>& newCode,
914 MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
915 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >& result)
917 if(entriesOnSameDisc.empty())
919 TypeOfField type=entriesOnSameDisc[0]->getType();
920 int szEntities=0,szTuples=0;
921 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
922 { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
923 int nbi=szTuples/szEntities;
924 if(szTuples%szEntities!=0)
925 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
926 MCAuto<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
927 MCAuto<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
928 std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
929 std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
930 std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
931 std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
932 MCAuto<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
934 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
936 int startOfEltIdOfChunk=(*it)->_start;
937 MCAuto<DataArrayInt> newEltIds=explicitIdsInMesh->subArray(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
938 MCAuto<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
939 MCAuto<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
941 MCAuto<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
942 newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
944 newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
945 newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
947 MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
948 MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
949 MCAuto<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
950 MCAuto<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
952 MCAuto<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
954 MCAuto<DataArrayDouble> arrPart=arr->subArray(offset,offset+szTuples);
955 arrPart->renumberInPlace(renumTupleIds->begin());
956 arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
958 const int *idIt=diffVals->begin();
959 std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
961 for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
963 MCAuto<DataArrayInt> ids=newGeoTypesEltIdsAllGather->findIdsEqual(*idIt);
964 MCAuto<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
965 int nbEntityElts=subIds->getNumberOfTuples();
967 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
968 NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIota(newCode[3*(*idIt)+1]),nbi,
972 result.push_back(eltToAdd);
973 offset2+=nbEntityElts*nbi;
975 ret=ret || li.empty();
980 * \param [in] typeF type of field of new chunk
981 * \param [in] geoType the geometric type of the chunk
982 * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
983 * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
984 * \param [in] nbi number of integration points
985 * \param [in] offset The offset in the **global array of data**.
986 * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
987 * to the new chunk to create.
988 * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
989 * \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
990 * and corresponding entry erased from \a entriesOnSameDisc.
991 * \return a newly allocated chunk
993 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
994 bool isPfl, int nbi, int offset,
995 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
996 MEDFileFieldGlobsReal& glob,
999 int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
1000 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
1001 for(;it!=entriesOnSameDisc.end();it++)
1003 if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
1007 if((*it)->_profile.empty())
1010 if(!(*it)->_profile.empty())
1012 const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
1013 if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
1019 if(it==entriesOnSameDisc.end())
1022 MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
1024 ret->_loc_id=(int)geoType;
1025 ret->_nval=nbMeshEntities;
1027 ret->_end=ret->_start+ret->_nval*nbi;
1030 idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
1031 glob.appendProfile(idsOfMeshElt);
1032 ret->_profile=idsOfMeshElt->getName();
1034 //tony treatment of localization
1039 notInExisting=false;
1040 MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1041 ret->_loc_id=(int)geoType;
1042 ret->setNewStart(offset);
1043 entriesOnSameDisc.erase(it);
1049 ////////////////////////////////////
1051 MEDFileFieldPerMeshPerTypeCommon::~MEDFileFieldPerMeshPerTypeCommon()
1055 void MEDFileFieldPerMeshPerTypeCommon::setFather(MEDFileFieldPerMesh *father)
1060 void MEDFileFieldPerMeshPerTypeCommon::deepCopyElements()
1063 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1065 if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
1066 _field_pm_pt_pd[i]=(*it)->deepCopy(this);
1070 std::size_t MEDFileFieldPerMeshPerTypeCommon::getHeapMemorySizeWithoutChildren() const
1072 return _field_pm_pt_pd.capacity()*sizeof(MCAuto<MEDFileFieldPerMeshPerTypePerDisc>);
1075 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypeCommon::getDirectChildrenWithNull() const
1077 std::vector<const BigMemoryObject *> ret;
1078 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1079 ret.push_back((const MEDFileFieldPerMeshPerTypePerDisc *)*it);
1083 void MEDFileFieldPerMeshPerTypeCommon::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1085 std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
1086 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1087 _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1091 * This method is the most general one. No optimization is done here.
1092 * \param [in] multiTypePfl is the end user profile specified in high level API
1093 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1094 * \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.
1095 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1096 * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1097 * \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.
1099 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)
1101 std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1102 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1103 _field_pm_pt_pd[*it]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1106 void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1108 _field_pm_pt_pd.resize(1);
1109 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1110 _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1113 void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1115 MCAuto<DataArrayInt> pfl2=pfl->deepCopy();
1116 if(!arr || !arr->isAllocated())
1117 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile : input array is null, or not allocated !");
1118 _field_pm_pt_pd.resize(1);
1119 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1120 _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.
1123 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1125 TypeOfField type=field->getTypeOfField();
1126 if(type!=ON_GAUSS_PT)
1128 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1129 int sz=_field_pm_pt_pd.size();
1131 for(int j=0;j<sz && !found;j++)
1133 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1135 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1141 _field_pm_pt_pd.resize(sz+1);
1142 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1144 std::vector<int> ret(1,(int)sz);
1149 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1150 int sz2=ret2.size();
1151 std::vector<int> ret3(sz2);
1153 for(int i=0;i<sz2;i++)
1155 int sz=_field_pm_pt_pd.size();
1156 int locIdToFind=ret2[i];
1158 for(int j=0;j<sz && !found;j++)
1160 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1162 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1169 _field_pm_pt_pd.resize(sz+1);
1170 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1178 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1180 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1181 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1183 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1184 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1186 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1187 MCAuto<DataArrayInt> da2=da->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1);
1188 MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1189 if(retTmp->presenceOfValue(-1))
1190 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1191 std::vector<int> ret(retTmp->begin(),retTmp->end());
1195 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1197 TypeOfField type=field->getTypeOfField();
1198 if(type!=ON_GAUSS_PT)
1200 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1201 int sz=_field_pm_pt_pd.size();
1203 for(int j=0;j<sz && !found;j++)
1205 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1207 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1213 _field_pm_pt_pd.resize(sz+1);
1214 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1216 std::vector<int> ret(1,0);
1221 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1222 int sz2=ret2.size();
1223 std::vector<int> ret3(sz2);
1225 for(int i=0;i<sz2;i++)
1227 int sz=_field_pm_pt_pd.size();
1228 int locIdToFind=ret2[i];
1230 for(int j=0;j<sz && !found;j++)
1232 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1234 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1241 _field_pm_pt_pd.resize(sz+1);
1242 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1250 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1252 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1253 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1255 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1256 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1258 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1259 MCAuto<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1260 MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1261 if(retTmp->presenceOfValue(-1))
1262 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1263 std::vector<int> ret(retTmp->begin(),retTmp->end());
1267 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerTypeCommon::getFather() const
1272 bool MEDFileFieldPerMeshPerTypeCommon::isUniqueLevel(int& dim) const
1274 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
1275 int curDim((int)cm.getDimension());
1276 if(dim!=std::numeric_limits<int>::max())
1286 void MEDFileFieldPerMeshPerTypeCommon::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1288 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1290 (*it)->fillTypesOfFieldAvailable(types);
1294 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
1296 int sz=_field_pm_pt_pd.size();
1297 dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1298 for(int i=0;i<sz;i++)
1300 _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1304 int MEDFileFieldPerMeshPerTypeCommon::getIteration() const
1306 return _father->getIteration();
1309 int MEDFileFieldPerMeshPerTypeCommon::getOrder() const
1311 return _father->getOrder();
1314 double MEDFileFieldPerMeshPerTypeCommon::getTime() const
1316 return _father->getTime();
1319 std::string MEDFileFieldPerMeshPerTypeCommon::getMeshName() const
1321 return _father->getMeshName();
1324 void MEDFileFieldPerMeshPerTypeCommon::getSizes(int& globalSz, int& nbOfEntries) const
1326 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1328 globalSz+=(*it)->getNumberOfTuples();
1330 nbOfEntries+=(int)_field_pm_pt_pd.size();
1333 int MEDFileFieldPerMeshPerTypeCommon::getNumberOfComponents() const
1335 return _father->getNumberOfComponents();
1338 bool MEDFileFieldPerMeshPerTypeCommon::presenceOfMultiDiscPerGeoType() const
1341 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1343 const MEDFileFieldPerMeshPerTypePerDisc *fmtd(*it);
1350 void MEDFileFieldPerMeshPerTypeCommon::pushDiscretization(MEDFileFieldPerMeshPerTypePerDisc *disc)
1352 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt;
1354 _field_pm_pt_pd.push_back(elt);
1357 DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray()
1359 return _father->getOrCreateAndGetArray();
1362 const DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray() const
1364 const MEDFileFieldPerMesh *fath=_father;
1365 return fath->getOrCreateAndGetArray();
1368 const std::vector<std::string>& MEDFileFieldPerMeshPerTypeCommon::getInfo() const
1370 return _father->getInfo();
1373 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsed() const
1375 std::vector<std::string> ret;
1376 std::set<std::string> ret2;
1377 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1379 std::string tmp=(*it1)->getProfile();
1381 if(ret2.find(tmp)==ret2.end())
1390 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsed() const
1392 std::vector<std::string> ret;
1393 std::set<std::string> ret2;
1394 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1396 std::string tmp=(*it1)->getLocalization();
1397 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1398 if(ret2.find(tmp)==ret2.end())
1407 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsedMulti() const
1409 std::vector<std::string> ret;
1410 std::set<std::string> ret2;
1411 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1413 std::string tmp=(*it1)->getProfile();
1420 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsedMulti() const
1422 std::vector<std::string> ret;
1423 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1425 std::string tmp=(*it1)->getLocalization();
1426 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1432 void MEDFileFieldPerMeshPerTypeCommon::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1434 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1435 (*it1)->changePflsRefsNamesGen(mapOfModif);
1438 void MEDFileFieldPerMeshPerTypeCommon::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1440 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1441 (*it1)->changeLocsRefsNamesGen(mapOfModif);
1444 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId)
1446 if(_field_pm_pt_pd.empty())
1448 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << getGeoTypeRepr() << "\" !";
1449 throw INTERP_KERNEL::Exception(oss.str());
1451 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1452 return _field_pm_pt_pd[locId];
1453 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
1454 oss2 << ") for geometric type \"" << getGeoTypeRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1455 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1456 return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1459 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId) const
1461 if(_field_pm_pt_pd.empty())
1463 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << getGeoTypeRepr() << "\" !";
1464 throw INTERP_KERNEL::Exception(oss.str());
1466 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1467 return _field_pm_pt_pd[locId];
1468 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
1469 oss2 << ") for geometric type \"" << getGeoTypeRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1470 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1471 return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1474 void MEDFileFieldPerMeshPerTypeCommon::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1477 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1479 (*it)->fillValues(i,startEntryId,entries);
1483 void MEDFileFieldPerMeshPerTypeCommon::setLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
1485 _field_pm_pt_pd=leaves;
1486 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1487 (*it)->setFather(this);
1491 * \param [in,out] globalNum a global numbering counter for the renumbering.
1492 * \param [out] its - list of pair (start,stop) kept
1493 * \return bool - false if the type of field \a tof is not contained in \a this.
1495 bool MEDFileFieldPerMeshPerTypeCommon::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
1498 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1499 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1500 if((*it)->getType()==tof)
1502 newPmPtPd.push_back(*it);
1503 std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1504 (*it)->setNewStart(globalNum);
1505 globalNum=(*it)->getEnd();
1506 its.push_back(bgEnd);
1510 _field_pm_pt_pd=newPmPtPd;
1515 * \param [in,out] globalNum a global numbering counter for the renumbering.
1516 * \param [out] its - list of pair (start,stop) kept
1517 * \return bool - false if the type of field \a tof is not contained in \a this.
1519 bool MEDFileFieldPerMeshPerTypeCommon::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
1521 if(_field_pm_pt_pd.size()<=idOfDisc)
1523 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt(_field_pm_pt_pd[idOfDisc]);
1524 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd(1,elt);
1525 std::pair<int,int> bgEnd; bgEnd.first=_field_pm_pt_pd[idOfDisc]->getStart(); bgEnd.second=_field_pm_pt_pd[idOfDisc]->getEnd();
1526 elt->setNewStart(globalNum);
1527 globalNum=elt->getEnd();
1528 its.push_back(bgEnd);
1529 _field_pm_pt_pd=newPmPtPd;
1533 void MEDFileFieldPerMeshPerTypeCommon::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
1535 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1536 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1539 void MEDFileFieldPerMeshPerTypeCommon::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1541 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1542 (*it)->loadBigArray(fid,nasc);
1545 void MEDFileFieldPerMeshPerTypeCommon::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1547 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1549 (*it)->copyOptionsFrom(*this);
1550 (*it)->writeLL(fid,nasc);
1554 med_entity_type MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1559 medfGeoType=typmai3[(int)ikGeoType];
1562 medfGeoType=MED_NONE;
1565 medfGeoType=typmai3[(int)ikGeoType];
1566 return MED_NODE_ELEMENT;
1568 medfGeoType=typmai3[(int)ikGeoType];
1571 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1573 return MED_UNDEF_ENTITY_TYPE;
1576 //////////////////////////////////////////////////
1578 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd)
1580 return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc,pd);
1583 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType)
1585 return new MEDFileFieldPerMeshPerType(fath,geoType);
1588 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCopy(MEDFileFieldPerMesh *father) const
1590 MCAuto<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
1591 ret->setFather(father);
1592 ret->deepCopyElements();
1596 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
1598 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1600 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1601 if(meshDim!=(int)cm.getDimension())
1604 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1605 (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1608 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1613 void MEDFileFieldPerMeshPerType::entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const
1615 ent=MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(mct,_geo_type,gt);
1618 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1620 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1621 int curDim((int)cm.getDimension());
1622 dim=std::max(dim,curDim);
1625 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1627 const char startLine[]=" ## ";
1628 std::string startLine2(bkOffset,' ');
1629 std::string startLine3(startLine2);
1630 startLine3+=startLine;
1631 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1633 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1634 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1637 oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1638 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1640 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1642 const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1644 cur->simpleRepr(bkOffset,oss,i);
1647 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1652 std::string MEDFileFieldPerMeshPerType::getGeoTypeRepr() const
1654 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1655 return std::string(cm.getRepr());
1658 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *father, INTERP_KERNEL::NormalizedCellType gt):MEDFileFieldPerMeshPerTypeCommon(father),_geo_type(gt)
1662 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):MEDFileFieldPerMeshPerTypeCommon(fath),_geo_type(geoType)
1664 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1665 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1666 med_geometry_type mgeoti;
1667 med_entity_type menti(ConvertIntoMEDFileType(type,geoType,mgeoti));
1668 int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName));
1669 _field_pm_pt_pd.resize(nbProfiles);
1670 for(int i=0;i<nbProfiles;i++)
1672 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i,pd);
1676 int nbProfiles2(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName));
1677 for(int i=0;i<nbProfiles2;i++)
1678 _field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i,pd));
1682 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)
1684 MCAuto<MEDFileFieldPerMeshPerType> ret(MEDFileFieldPerMeshPerType::New(father,gt));
1685 std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > > m;
1686 for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerType *> >::const_iterator it=pms.begin();it!=pms.end();it++)
1688 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it2=(*it).second->_field_pm_pt_pd.begin();it2!=(*it).second->_field_pm_pt_pd.end();it2++)
1689 m[(*it2)->getType()].push_back(std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * >((*it).first,*it2));
1691 for(std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > >::const_iterator it=m.begin();it!=m.end();it++)
1693 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> agg(MEDFileFieldPerMeshPerTypePerDisc::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
1694 ret->_field_pm_pt_pd.push_back(agg);
1699 //////////////////////////////////////////////////
1701 MEDFileFieldPerMeshPerTypeDyn *MEDFileFieldPerMeshPerTypeDyn::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileEntities *entities, int idGT, const MEDFileFieldNameScope& nasc)
1704 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeDyn::NewOnRead : null pointer !");
1705 const MEDFileAllStaticEntitiesPlusDyn *entities2(dynamic_cast<const MEDFileAllStaticEntitiesPlusDyn *>(entities));
1707 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeDyn::NewOnRead : invalid type of entities !");
1708 const MEDFileStructureElement *se(entities2->getWithGT(idGT));
1709 return new MEDFileFieldPerMeshPerTypeDyn(fid,fath,se,nasc);
1712 MEDFileFieldPerMeshPerTypeDyn::MEDFileFieldPerMeshPerTypeDyn(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileStructureElement *se, const MEDFileFieldNameScope& nasc):MEDFileFieldPerMeshPerTypeCommon(fath)
1715 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1716 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1717 int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,_se->getDynGT(),pflName,locName));
1718 _field_pm_pt_pd.resize(nbProfiles);
1719 for(int i=0;i<nbProfiles;i++)
1721 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,_se->getEntity(),i,NULL);
1725 int MEDFileFieldPerMeshPerTypeDyn::getDynGT() const
1727 return _se->getDynGT();
1730 std::string MEDFileFieldPerMeshPerTypeDyn::getModelName() const
1732 return _se->getName();
1735 void MEDFileFieldPerMeshPerTypeDyn::getDimension(int& dim) const
1737 throw INTERP_KERNEL::Exception("not implemented yet !");
1740 void MEDFileFieldPerMeshPerTypeDyn::entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const
1743 ent=MED_STRUCT_ELEMENT;
1746 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypeDyn::getGeoType() const
1748 throw INTERP_KERNEL::Exception("not implemented yet !");
1751 void MEDFileFieldPerMeshPerTypeDyn::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1753 const char startLine[]=" ## ";
1754 std::string startLine2(bkOffset,' ');
1755 std::string startLine3(startLine2);
1756 startLine3+=startLine;
1757 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry STRUCTURE_ELEMENT type " << getDynGT() << "." << std::endl;
1758 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1760 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1762 if((*it).isNotNull())
1763 (*it)->simpleRepr(bkOffset,oss,i);
1766 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1771 std::string MEDFileFieldPerMeshPerTypeDyn::getGeoTypeRepr() const
1773 throw INTERP_KERNEL::Exception("not implemented yet !");
1776 MEDFileFieldPerMeshPerTypeDyn *MEDFileFieldPerMeshPerTypeDyn::deepCopy(MEDFileFieldPerMesh *father) const
1778 MCAuto<MEDFileFieldPerMeshPerTypeDyn> ret(new MEDFileFieldPerMeshPerTypeDyn(*this));
1779 ret->setFather(father);
1780 ret->deepCopyElements();
1784 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
1786 throw INTERP_KERNEL::Exception("not implemented yet !");
1789 //////////////////////////////////////////////////
1791 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const MEDFileEntities *entities)
1793 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm,entities);
1796 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1798 return new MEDFileFieldPerMesh(fath,mesh);
1801 std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
1803 return _mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MCAuto< MEDFileFieldPerMeshPerType >);
1806 std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildrenWithNull() const
1808 std::vector<const BigMemoryObject *> ret;
1809 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1814 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCopy(MEDFileAnyTypeField1TSWithoutSDA *father) const
1816 MCAuto< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1817 ret->_father=father;
1819 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1821 if((*it).isNotNull())
1822 ret->_field_pm_pt[i]=(*it)->deepCopy((MEDFileFieldPerMesh *)(ret));
1827 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1829 std::string startLine(bkOffset,' ');
1830 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1831 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1833 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1835 if((*it).isNotNull())
1836 (*it)->simpleRepr(bkOffset,oss,i);
1839 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1844 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh)
1846 _mesh_name=mesh->getName();
1847 mesh->getTime(_mesh_iteration,_mesh_order);
1850 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1852 int nbOfTypes=code.size()/3;
1854 for(int i=0;i<nbOfTypes;i++)
1856 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1857 int nbOfCells=code[3*i+1];
1858 int pos=addNewEntryIfNecessary(type);
1859 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1865 * This method is the most general one. No optimization is done here.
1866 * \param [in] multiTypePfl is the end user profile specified in high level API
1867 * \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].
1868 * \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.
1869 * \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.
1870 * \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.
1871 * \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.
1873 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)
1875 int nbOfTypes(code.size()/3);
1876 for(int i=0;i<nbOfTypes;i++)
1878 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1879 int pos=addNewEntryIfNecessary(type);
1880 DataArrayInt *pfl=0;
1882 pfl=idsPerType[code[3*i+2]];
1883 int nbOfTupes2=code2.size()/3;
1885 for(;found<nbOfTupes2;found++)
1886 if(code[3*i]==code2[3*found])
1888 if(found==nbOfTupes2)
1889 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1890 _field_pm_pt[pos]->assignFieldProfile(nbOfTypes==1,start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1894 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1896 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1897 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1900 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1902 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1903 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1906 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
1908 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1909 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1912 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1914 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1915 (*it)->loadBigArraysRecursively(fid,nasc);
1918 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1920 int nbOfTypes=_field_pm_pt.size();
1921 for(int i=0;i<nbOfTypes;i++)
1923 _field_pm_pt[i]->copyOptionsFrom(*this);
1924 _field_pm_pt[i]->writeLL(fid,nasc);
1928 void MEDFileFieldPerMesh::getDimension(int& dim) const
1930 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1931 (*it)->getDimension(dim);
1934 bool MEDFileFieldPerMesh::isUniqueLevel(int& dim) const
1936 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1937 if(!(*it)->isUniqueLevel(dim))
1942 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1944 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1945 (*it)->fillTypesOfFieldAvailable(types);
1948 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
1950 int sz=_field_pm_pt.size();
1951 std::vector< std::vector<std::pair<int,int> > > ret(sz);
1952 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1953 for(int i=0;i<sz;i++)
1955 types[i]=_field_pm_pt[i]->getGeoType();
1956 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1961 double MEDFileFieldPerMesh::getTime() const
1964 return _father->getTime(tmp1,tmp2);
1967 int MEDFileFieldPerMesh::getIteration() const
1969 return _father->getIteration();
1972 int MEDFileFieldPerMesh::getOrder() const
1974 return _father->getOrder();
1977 int MEDFileFieldPerMesh::getNumberOfComponents() const
1979 return _father->getNumberOfComponents();
1982 bool MEDFileFieldPerMesh::presenceOfMultiDiscPerGeoType() const
1984 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1988 if((*it)->presenceOfMultiDiscPerGeoType())
1994 bool MEDFileFieldPerMesh::presenceOfStructureElements() const
1996 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1997 if((*it).isNotNull())
1999 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2006 bool MEDFileFieldPerMesh::onlyStructureElements() const
2008 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2009 if((*it).isNotNull())
2011 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2018 void MEDFileFieldPerMesh::killStructureElements()
2020 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
2021 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2023 if((*it).isNotNull())
2025 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2033 void MEDFileFieldPerMesh::keepOnlyStructureElements()
2035 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
2036 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2038 if((*it).isNotNull())
2040 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2048 void MEDFileFieldPerMesh::keepOnlyOnSE(const std::string& seName)
2050 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
2051 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2053 if((*it).isNotNull())
2055 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2057 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::keepOnlyOnSE : presence of non SE !");
2058 if(pt->getModelName()==seName)
2065 void MEDFileFieldPerMesh::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
2067 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2069 if((*it).isNotNull())
2071 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2074 ps.push_back(std::pair<std::string,std::string>(getMeshName(),pt->getModelName()));
2077 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getMeshSENames : presence of a non structure element part !");
2082 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
2085 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
2086 return _father->getOrCreateAndGetArray();
2089 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
2092 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
2093 return _father->getOrCreateAndGetArray();
2096 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
2098 return _father->getInfo();
2102 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
2103 * 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.
2104 * It returns 2 output vectors :
2105 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
2106 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
2107 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
2109 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)
2111 int notNullPflsSz=0;
2112 int nbOfArrs=geoTypes.size();
2113 for(int i=0;i<nbOfArrs;i++)
2116 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
2117 int nbOfDiffGeoTypes=geoTypes3.size();
2118 code.resize(3*nbOfDiffGeoTypes);
2119 notNullPfls.resize(notNullPflsSz);
2122 for(int i=0;i<nbOfDiffGeoTypes;i++)
2125 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
2126 std::vector<const DataArrayInt *> notNullTmp;
2128 notNullTmp.push_back(pfls[j]);
2130 for(;j<nbOfArrs;j++)
2131 if(geoTypes[j]==refType)
2134 notNullTmp.push_back(pfls[j]);
2138 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
2139 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
2140 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
2141 code[3*i]=(int)refType;
2142 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
2143 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
2144 if(notNullTmp.empty())
2148 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
2149 code[3*i+2]=notNullPflsSz++;
2155 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
2157 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)
2161 for(int i=0;i<sz;i++)
2165 if(type!=ON_GAUSS_NE)
2166 ret+=dads[i].second-dads[i].first;
2169 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
2170 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
2175 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
2176 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
2182 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
2184 std::vector<std::string> ret;
2185 std::set<std::string> ret2;
2186 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2188 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
2189 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
2190 if(ret2.find(*it2)==ret2.end())
2192 ret.push_back(*it2);
2199 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
2201 std::vector<std::string> ret;
2202 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2204 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
2205 ret.insert(ret.end(),tmp.begin(),tmp.end());
2210 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
2212 std::vector<std::string> ret;
2213 std::set<std::string> ret2;
2214 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2216 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
2217 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
2218 if(ret2.find(*it2)==ret2.end())
2220 ret.push_back(*it2);
2227 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
2229 std::vector<std::string> ret;
2230 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2232 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
2233 ret.insert(ret.end(),tmp.begin(),tmp.end());
2238 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
2240 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
2242 if((*it).first==_mesh_name)
2244 _mesh_name=(*it).second;
2251 void MEDFileFieldPerMesh::convertMedBallIntoClassic()
2253 if(_field_pm_pt.size()!=1)
2254 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : Only managed for single mesh !");
2255 if(_field_pm_pt[0].isNull())
2256 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : null pointer !");
2257 MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<MEDFileFieldPerMeshPerTypeDyn *>((MEDFileFieldPerMeshPerTypeCommon *)_field_pm_pt[0]));
2259 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : this is expected to be marked as structure element !");
2260 if(pt->getNumberOfLoc()!=1)
2261 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : only one loc managed !");
2262 const MEDFileFieldPerMeshPerTypePerDisc *disc(pt->getLeafGivenLocId(0));
2264 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : internal error !");
2265 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> disc2(MEDFileFieldPerMeshPerTypePerDisc::New(*disc));
2266 disc2->setType(ON_NODES);
2267 MCAuto<MEDFileFieldPerMeshPerType> pt2(MEDFileFieldPerMeshPerType::New(this,INTERP_KERNEL::NORM_ERROR));
2268 disc2->setFather(pt2);
2269 pt2->setFather(this);
2270 pt2->pushDiscretization(disc2);
2271 _field_pm_pt[0]=DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(pt2);
2274 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
2275 MEDFileFieldGlobsReal& glob)
2277 if(_mesh_name!=meshName)
2279 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
2280 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
2281 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
2282 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
2283 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
2284 getUndergroundDataArrayExt(entries);
2285 DataArray *arr0(getOrCreateAndGetArray());//tony
2287 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
2288 DataArrayDouble *arr(dynamic_cast<DataArrayDouble *>(arr0));//tony
2290 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
2293 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
2294 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
2296 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
2298 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2299 sz+=(*it).second.second-(*it).second.first;
2302 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2304 MCAuto<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
2305 ////////////////////
2306 MCAuto<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
2307 int *workI2=explicitIdsOldInMesh->getPointer();
2308 int sz1=0,sz2=0,sid=1;
2309 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
2310 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
2311 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
2313 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
2314 MCAuto<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
2315 int *workI=explicitIdsOldInArr->getPointer();
2316 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
2318 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
2319 (*itL2)->setLocId(sz2);
2320 (*itL2)->_tmp_work1=(*itL2)->getStart();
2321 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
2323 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
2325 explicitIdsOldInMesh->reAlloc(sz2);
2326 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
2327 ////////////////////
2328 MCAuto<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
2329 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
2330 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
2331 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
2333 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
2334 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
2335 otherEntriesNew.back()->setLocId((*it)->getGeoType());
2337 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
2338 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
2339 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
2341 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
2342 int newStart=elt->getLocId();
2343 elt->setLocId((*it)->getGeoType());
2344 elt->setNewStart(newStart);
2345 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
2346 entriesKeptNew.push_back(elt);
2347 entriesKeptNew2.push_back(elt);
2349 MCAuto<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
2350 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
2351 MCAuto<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
2352 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
2354 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
2357 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
2359 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
2360 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
2362 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
2363 glob,arr2,otherEntriesNew) || ret;
2367 // Assign new dispatching
2368 assignNewLeaves(otherEntriesNew);
2369 arr->deepCopyFrom(*arr2);
2374 * \param [in,out] globalNum a global numbering counter for the renumbering.
2375 * \param [out] its - list of pair (start,stop) kept
2377 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
2379 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > ret;
2380 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2382 std::vector< std::pair<int,int> > its2;
2383 if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
2386 its.insert(its.end(),its2.begin(),its2.end());
2393 * \param [in,out] globalNum a global numbering counter for the renumbering.
2394 * \param [out] its - list of pair (start,stop) kept
2396 void MEDFileFieldPerMesh::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
2398 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > ret;
2399 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2401 std::vector< std::pair<int,int> > its2;
2402 if((*it)->keepOnlyGaussDiscretization(idOfDisc,globalNum,its2))
2405 its.insert(its.end(),its2.begin(),its2.end());
2411 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
2413 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > > types;
2414 for( std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
2415 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
2417 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > fieldPmPt(types.size());
2418 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
2419 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it2=fieldPmPt.begin();
2420 for(;it1!=types.end();it1++,it2++)
2422 MCAuto<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
2423 elt->setLeaves((*it1).second);
2424 MCAuto<MEDFileFieldPerMeshPerTypeCommon> elt2(DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(elt));
2427 _field_pm_pt=fieldPmPt;
2430 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2432 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2433 (*it)->changePflsRefsNamesGen(mapOfModif);
2436 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2438 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2439 (*it)->changeLocsRefsNamesGen(mapOfModif);
2443 * \param [in] mesh is the whole mesh
2445 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2447 if(_field_pm_pt.empty())
2448 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2450 std::vector< std::pair<int,int> > dads;
2451 std::vector<const DataArrayInt *> pfls;
2452 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2453 std::vector<int> locs,code;
2454 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2455 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2456 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2458 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2461 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2462 throw INTERP_KERNEL::Exception(oss.str());
2465 std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2466 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2469 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2471 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2474 MCAuto<DataArrayInt> arr2(arr);
2475 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2481 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2485 if(nb!=mesh->getNumberOfNodes())
2487 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2488 oss << " nodes in mesh !";
2489 throw INTERP_KERNEL::Exception(oss.str());
2491 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2494 return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2498 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
2500 if(_field_pm_pt.empty())
2501 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2503 std::vector<std::pair<int,int> > dads;
2504 std::vector<const DataArrayInt *> pfls;
2505 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2506 std::vector<int> locs,code;
2507 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2508 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2509 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2511 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2514 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2515 throw INTERP_KERNEL::Exception(oss.str());
2517 std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2518 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2521 MCAuto<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2522 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2527 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2531 if(nb!=mesh->getNumberOfNodes())
2533 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2534 oss << " nodes in mesh !";
2535 throw INTERP_KERNEL::Exception(oss.str());
2538 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2544 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
2548 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2550 (*it)->getSizes(globalSz,nbOfEntries);
2552 entries.resize(nbOfEntries);
2554 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2556 (*it)->fillValues(nbOfEntries,entries);
2560 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
2562 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2564 if((*it)->getGeoType()==typ)
2565 return (*it)->getLeafGivenLocId(locId);
2567 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2568 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2569 oss << "Possiblities are : ";
2570 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2572 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2573 oss << "\"" << cm2.getRepr() << "\", ";
2575 throw INTERP_KERNEL::Exception(oss.str());
2578 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
2580 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2582 if((*it)->getGeoType()==typ)
2583 return (*it)->getLeafGivenLocId(locId);
2585 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2586 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2587 oss << "Possiblities are : ";
2588 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2590 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2591 oss << "\"" << cm2.getRepr() << "\", ";
2593 throw INTERP_KERNEL::Exception(oss.str());
2597 * \param [in,out] start - Integer that gives the current position in the final aggregated array
2598 * \param [in] pms - list of elements to aggregate. integer gives the mesh id
2599 * \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.
2600 * \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.
2602 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)
2604 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret(new MEDFileFieldPerMeshPerTypePerDisc(father,tof));
2606 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : empty input vector !");
2607 for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it=pms.begin();it!=pms.end();it++)
2610 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : presence of null pointer !");
2611 if(!(*it).second->getProfile().empty())
2612 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for profiles !");
2613 if(!(*it).second->getLocalization().empty())
2614 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for gauss pts !");
2616 INTERP_KERNEL::NormalizedCellType gt(pms[0].second->getGeoType());
2618 std::vector< std::pair<int,int> > filteredDTS;
2619 for(std::vector< std::vector< std::pair<int,int> > >::const_iterator it=dts.begin();it!=dts.end();it++,i++)
2620 for(std::vector< std::pair<int,int> >::const_iterator it2=(*it).begin();it2!=(*it).end();it2++)
2621 if((*it2).first==gt)
2622 filteredDTS.push_back(std::pair<int,int>(i,(*it2).second));
2623 if(pms.size()!=filteredDTS.size())
2624 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles !");
2625 std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it1(pms.begin());
2626 std::vector< std::pair<int,int> >::const_iterator it2(filteredDTS.begin());
2627 int zeStart(start),nval(0);
2628 for(;it1!=pms.end();it1++,it2++)
2630 if((*it1).first!=(*it2).first)
2631 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles 2 !");
2632 int s1((*it1).second->getStart()),e1((*it1).second->getEnd());
2633 extractInfo.push_back(std::pair<int, std::pair<int,int> >((*it1).first,std::pair<int,int>(s1,e1)));
2635 nval+=((*it1).second)->getNumberOfVals();
2637 ret->_start=zeStart; ret->_end=start; ret->_nval=nval;
2641 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)
2643 MCAuto<MEDFileFieldPerMesh> ret(new MEDFileFieldPerMesh(father,pms[0]->getMeshName(),pms[0]->getMeshIteration(),pms[0]->getMeshOrder()));
2644 std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > > m;
2646 for(std::vector<const MEDFileFieldPerMesh *>::const_iterator it=pms.begin();it!=pms.end();it++,i++)
2648 const std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >& v((*it)->_field_pm_pt);
2649 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it2=v.begin();it2!=v.end();it2++)
2651 INTERP_KERNEL::NormalizedCellType gt((*it2)->getGeoType());
2652 const MEDFileFieldPerMeshPerType *elt(dynamic_cast<const MEDFileFieldPerMeshPerType *>((const MEDFileFieldPerMeshPerTypeCommon *)(*it2)));
2654 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::Aggregate : not managed for structelement !");
2655 m[gt].push_back(std::pair<int,const MEDFileFieldPerMeshPerType *>(i,elt));
2658 for(std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > >::const_iterator it=m.begin();it!=m.end();it++)
2660 MCAuto<MEDFileFieldPerMeshPerType> agg(MEDFileFieldPerMeshPerType::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
2661 MCAuto<MEDFileFieldPerMeshPerTypeCommon> agg2(DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(agg));
2662 ret->_field_pm_pt.push_back(agg2);
2667 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2670 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2671 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it2=_field_pm_pt.begin();
2672 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2674 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2679 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2684 int ret=std::distance(_field_pm_pt.begin(),it2);
2685 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2690 * 'dads' and 'locs' input parameters have the same number of elements
2691 * \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
2693 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2694 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2695 const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2698 MCAuto<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2699 ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2700 MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2701 const std::vector<std::string>& infos=getInfo();
2702 da->setInfoOnComponents(infos);
2704 if(type==ON_GAUSS_PT)
2707 int nbOfArrs=dads.size();
2708 for(int i=0;i<nbOfArrs;i++)
2710 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2711 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2712 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2713 MCAuto<DataArrayInt> di=DataArrayInt::New();
2714 di->alloc(nbOfElems,1);
2716 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2717 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2726 * 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.
2727 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2728 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2729 * The order of cells in the returned field is those imposed by the profile.
2730 * \param [in] mesh is the global mesh.
2732 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2733 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2734 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2735 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2737 if(da->isIota(mesh->getNumberOfCells()))
2738 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2739 MCAuto<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2740 m2->setName(mesh->getName().c_str());
2741 MCAuto<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2747 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2749 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2750 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2751 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2753 if(da->isIota(mesh->getNumberOfNodes()))
2754 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2755 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2756 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2759 if(meshu->getNodalConnectivity()==0)
2761 MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2762 int nb=da->getNbOfElems();
2763 const int *ptr=da->getConstPointer();
2764 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2765 meshuc->allocateCells(nb);
2766 for(int i=0;i<nb;i++)
2767 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2768 meshuc->finishInsertingCells();
2769 ret->setMesh(meshuc);
2770 const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2771 if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2772 disc->checkCoherencyBetween(meshuc,arrOut);
2777 MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2779 DataArrayInt *arr2=0;
2780 MCAuto<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2781 MCAuto<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2782 MCAuto<DataArrayInt> arr3(arr2);
2783 int nnodes=mesh2->getNumberOfNodes();
2784 if(nnodes==(int)da->getNbOfElems())
2786 MCAuto<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2787 arrOut->renumberInPlace(da3->getConstPointer());
2788 mesh2->setName(mesh->getName().c_str());
2789 ret->setMesh(mesh2);
2794 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 !!!";
2795 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2796 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2797 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2798 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2799 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2800 throw INTERP_KERNEL::Exception(oss.str());
2806 * This method is the most light method of field retrieving.
2808 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
2812 pflOut=DataArrayInt::New();
2813 pflOut->alloc(nbOfElems,1);
2818 pflOut=const_cast<DataArrayInt*>(pflIn);
2821 MCAuto<DataArrayInt> safePfl(pflOut);
2822 MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2823 const std::vector<std::string>& infos=getInfo();
2824 int nbOfComp=infos.size();
2825 for(int i=0;i<nbOfComp;i++)
2826 da->setInfoOnComponent(i,infos[i].c_str());
2837 static MFFPMIter *NewCell(const MEDFileEntities *entities);
2838 static bool IsPresenceOfNode(const MEDFileEntities *entities);
2839 virtual ~MFFPMIter() { }
2840 virtual void begin() = 0;
2841 virtual bool finished() const = 0;
2842 virtual void next() = 0;
2843 virtual int current() const = 0;
2846 class MFFPMIterSimple : public MFFPMIter
2849 MFFPMIterSimple():_pos(0) { }
2850 void begin() { _pos=0; }
2851 bool finished() const { return _pos>=MED_N_CELL_FIXED_GEO; }
2852 void next() { _pos++; }
2853 int current() const { return _pos; }
2858 class MFFPMIter2 : public MFFPMIter
2861 MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts);
2862 void begin() { _it=_ids.begin(); }
2863 bool finished() const { return _it==_ids.end(); }
2864 void next() { _it++; }
2865 int current() const { return *_it; }
2867 std::vector<int> _ids;
2868 std::vector<int>::const_iterator _it;
2871 MFFPMIter *MFFPMIter::NewCell(const MEDFileEntities *entities)
2874 return new MFFPMIterSimple;
2877 const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
2880 std::vector<INTERP_KERNEL::NormalizedCellType> tmp;
2881 const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
2882 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
2884 if((*it).first==ON_CELLS || (*it).first==ON_GAUSS_NE || (*it).first==ON_GAUSS_PT)
2885 tmp.push_back((*it).second);
2887 return new MFFPMIter2(tmp);
2889 return new MFFPMIterSimple;// for MEDFileAllStaticEntites and MEDFileAllStaticEntitiesPlusDyn cells are in
2893 bool MFFPMIter::IsPresenceOfNode(const MEDFileEntities *entities)
2899 const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
2902 const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
2903 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
2904 if((*it).first==ON_NODES)
2908 return true;// for MEDFileAllStaticEntites and MEDFileAllStaticEntitiesPlusDyn nodes are in
2912 MFFPMIter2::MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts)
2914 std::size_t sz(cts.size());
2916 for(std::size_t i=0;i<sz;i++)
2918 INTERP_KERNEL::NormalizedCellType *loc(std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,cts[i]));
2919 if(loc!=typmai2+MED_N_CELL_FIXED_GEO)
2920 _ids[i]=(int)std::distance(typmai2,loc);
2922 throw INTERP_KERNEL::Exception("MFFPMIter2 : The specified geo type does not exists !");
2928 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),
2931 INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2932 INTERP_KERNEL::AutoPtr<char> pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2933 INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2934 const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
2935 INTERP_KERNEL::AutoCppPtr<MFFPMIter> iter0(MFFPMIter::NewCell(entities));
2936 for(iter0->begin();!iter0->finished();iter0->next())
2938 int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL ,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2939 std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2940 int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2941 std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2942 if(nbProfile>0 || nbProfile2>0)
2944 const PartDefinition *pd(0);
2946 pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[iter0->current()]),typmai2[iter0->current()]);
2947 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nasc,pd));
2954 if(MFFPMIter::IsPresenceOfNode(entities))
2956 int nbProfile(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName));
2959 const PartDefinition *pd(0);
2961 pd=mmu->getPartDefAtLevel(1,INTERP_KERNEL::NORM_ERROR);
2962 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd));
2963 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2968 std::vector<int> dynGT(entities->getDynGTAvail());
2969 for(std::vector<int>::const_iterator it=dynGT.begin();it!=dynGT.end();it++)
2971 int nbPfl(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,*it,pflName,locName));
2974 _field_pm_pt.push_back(MEDFileFieldPerMeshPerTypeDyn::NewOnRead(fid,this,entities,*it,nasc));
2975 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2980 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2982 copyTinyInfoFrom(mesh);
2985 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
2987 if(id>=(int)_pfls.size())
2989 _pfls[id]=DataArrayInt::New();
2990 int lgth(MEDprofileSizeByName(fid,pflName.c_str()));
2991 _pfls[id]->setName(pflName);
2992 _pfls[id]->alloc(lgth,1);
2993 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName.c_str(),_pfls[id]->getPointer()));
2994 _pfls[id]->applyLin(1,-1,0);//Converting into C format
2997 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2999 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
3001 MEDFILESAFECALLERRD0(MEDprofileInfo,(fid,i+1,pflName,&sz));
3002 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
3003 if(i>=(int)_pfls.size())
3005 _pfls[i]=DataArrayInt::New();
3006 _pfls[i]->alloc(sz,1);
3007 _pfls[i]->setName(pflCpp.c_str());
3008 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName,_pfls[i]->getPointer()));
3009 _pfls[i]->applyLin(1,-1,0);//Converting into C format
3012 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3014 int nbOfPfls=_pfls.size();
3015 for(int i=0;i<nbOfPfls;i++)
3017 MCAuto<DataArrayInt> cpy=_pfls[i]->deepCopy();
3018 cpy->applyLin(1,1,0);
3019 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
3020 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
3021 MEDFILESAFECALLERWR0(MEDprofileWr,(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer()));
3024 int nbOfLocs=_locs.size();
3025 for(int i=0;i<nbOfLocs;i++)
3026 _locs[i]->writeLL(fid);
3029 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
3031 std::vector<std::string> pfls=getPfls();
3032 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
3034 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
3037 _pfls.push_back(*it);
3041 int id=std::distance(pfls.begin(),it2);
3042 if(!(*it)->isEqual(*_pfls[id]))
3044 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
3045 throw INTERP_KERNEL::Exception(oss.str());
3049 std::vector<std::string> locs=getLocs();
3050 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
3052 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
3055 _locs.push_back(*it);
3059 int id=std::distance(locs.begin(),it2);
3060 if(!(*it)->isEqual(*_locs[id],eps))
3062 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
3063 throw INTERP_KERNEL::Exception(oss.str());
3069 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
3071 for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
3072 getProfile((*it).c_str());
3075 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
3077 for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
3078 getLocalization((*it).c_str());
3081 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
3083 std::vector<std::string> profiles=real.getPflsReallyUsed();
3084 int sz=profiles.size();
3086 for(int i=0;i<sz;i++)
3087 loadProfileInFile(fid,i,profiles[i].c_str());
3089 std::vector<std::string> locs=real.getLocsReallyUsed();
3092 for(int i=0;i<sz;i++)
3093 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
3096 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid)
3098 int nProfil=MEDnProfile(fid);
3099 for(int i=0;i<nProfil;i++)
3100 loadProfileInFile(fid,i);
3101 int sz=MEDnLocalization(fid);
3103 for(int i=0;i<sz;i++)
3105 _locs[i]=MEDFileFieldLoc::New(fid,i);
3109 MEDFileFieldGlobs *MEDFileFieldGlobs::New(med_idt fid)
3111 return new MEDFileFieldGlobs(fid);
3114 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
3116 return new MEDFileFieldGlobs;
3119 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
3121 return _file_name.capacity()+_pfls.capacity()*sizeof(MCAuto<DataArrayInt>)+_locs.capacity()*sizeof(MCAuto<MEDFileFieldLoc>);
3124 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildrenWithNull() const
3126 std::vector<const BigMemoryObject *> ret;
3127 for(std::vector< MCAuto< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3128 ret.push_back((const DataArrayInt *)*it);
3129 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3130 ret.push_back((const MEDFileFieldLoc *)*it);
3134 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCopy() const
3136 MCAuto<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
3138 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3140 if((const DataArrayInt *)*it)
3141 ret->_pfls[i]=(*it)->deepCopy();
3144 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3146 if((const MEDFileFieldLoc*)*it)
3147 ret->_locs[i]=(*it)->deepCopy();
3153 * \throw if a profile in \a pfls in not in \a this.
3154 * \throw if a localization in \a locs in not in \a this.
3155 * \sa MEDFileFieldGlobs::deepCpyPart
3157 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
3159 MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
3160 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
3162 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
3164 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
3166 MCAuto<DataArrayInt> pfl2(pfl);
3167 ret->_pfls.push_back(pfl2);
3169 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
3171 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
3173 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
3175 MCAuto<MEDFileFieldLoc> loc2(loc);
3176 ret->_locs.push_back(loc2);
3178 ret->setFileName(getFileName());
3183 * \throw if a profile in \a pfls in not in \a this.
3184 * \throw if a localization in \a locs in not in \a this.
3185 * \sa MEDFileFieldGlobs::shallowCpyPart
3187 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
3189 MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
3190 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
3192 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
3194 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
3195 ret->_pfls.push_back(pfl->deepCopy());
3197 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
3199 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
3201 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
3202 ret->_locs.push_back(loc->deepCopy());
3204 ret->setFileName(getFileName());
3208 MEDFileFieldGlobs::MEDFileFieldGlobs(med_idt fid):_file_name(MEDFileWritable::FileNameFromFID(fid))
3212 MEDFileFieldGlobs::MEDFileFieldGlobs()
3216 MEDFileFieldGlobs::~MEDFileFieldGlobs()
3220 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
3222 oss << "Profiles :\n";
3223 std::size_t n=_pfls.size();
3224 for(std::size_t i=0;i<n;i++)
3226 oss << " - #" << i << " ";
3227 const DataArrayInt *pfl=_pfls[i];
3229 oss << "\"" << pfl->getName() << "\"\n";
3234 oss << "Localizations :\n";
3235 for(std::size_t i=0;i<n;i++)
3237 oss << " - #" << i << " ";
3238 const MEDFileFieldLoc *loc=_locs[i];
3240 loc->simpleRepr(oss);
3246 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3248 for(std::vector< MCAuto<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
3250 DataArrayInt *elt(*it);
3253 std::string name(elt->getName());
3254 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3256 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3258 elt->setName((*it2).second.c_str());
3266 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3268 for(std::vector< MCAuto<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
3270 MEDFileFieldLoc *elt(*it);
3273 std::string name(elt->getName());
3274 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3276 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3278 elt->setName((*it2).second.c_str());
3286 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
3288 if(locId<0 || locId>=(int)_locs.size())
3289 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
3290 return _locs[locId]->getNbOfGaussPtPerCell();
3293 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
3295 return getLocalizationFromId(getLocalizationId(locName));
3298 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
3300 if(locId<0 || locId>=(int)_locs.size())
3301 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3302 return *_locs[locId];
3306 namespace MEDCouplingImpl
3311 LocFinder(const std::string& loc):_loc(loc) { }
3312 bool operator() (const MCAuto<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
3314 const std::string &_loc;
3320 PflFinder(const std::string& pfl):_pfl(pfl) { }
3321 bool operator() (const MCAuto<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
3323 const std::string& _pfl;
3328 int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
3330 std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),MEDCouplingImpl::LocFinder(loc));
3333 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
3334 for(it=_locs.begin();it!=_locs.end();it++)
3335 oss << "\"" << (*it)->getName() << "\", ";
3336 throw INTERP_KERNEL::Exception(oss.str());
3338 return std::distance(_locs.begin(),it);
3342 * The returned value is never null.
3344 const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
3346 std::string pflNameCpp(pflName);
3347 std::vector< MCAuto<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3350 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3351 for(it=_pfls.begin();it!=_pfls.end();it++)
3352 oss << "\"" << (*it)->getName() << "\", ";
3353 throw INTERP_KERNEL::Exception(oss.str());
3358 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
3360 if(pflId<0 || pflId>=(int)_pfls.size())
3361 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3362 return _pfls[pflId];
3365 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
3367 if(locId<0 || locId>=(int)_locs.size())
3368 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3369 return *_locs[locId];
3372 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
3374 return getLocalizationFromId(getLocalizationId(locName));
3378 * The returned value is never null.
3380 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
3382 std::string pflNameCpp(pflName);
3383 std::vector< MCAuto<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3386 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3387 for(it=_pfls.begin();it!=_pfls.end();it++)
3388 oss << "\"" << (*it)->getName() << "\", ";
3389 throw INTERP_KERNEL::Exception(oss.str());
3394 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
3396 if(pflId<0 || pflId>=(int)_pfls.size())
3397 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3398 return _pfls[pflId];
3401 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
3403 std::vector< MCAuto<DataArrayInt> > newPfls;
3405 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3407 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
3408 newPfls.push_back(*it);
3413 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
3415 std::vector< MCAuto<MEDFileFieldLoc> > newLocs;
3417 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3419 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
3420 newLocs.push_back(*it);
3425 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
3427 int sz=_pfls.size();
3428 std::vector<std::string> ret(sz);
3429 for(int i=0;i<sz;i++)
3430 ret[i]=_pfls[i]->getName();
3434 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
3436 int sz=_locs.size();
3437 std::vector<std::string> ret(sz);
3438 for(int i=0;i<sz;i++)
3439 ret[i]=_locs[i]->getName();
3443 bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
3445 std::vector<std::string> v=getPfls();
3446 std::string s(pflName);
3447 return std::find(v.begin(),v.end(),s)!=v.end();
3450 bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
3452 std::vector<std::string> v=getLocs();
3453 std::string s(locName);
3454 return std::find(v.begin(),v.end(),s)!=v.end();
3457 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
3459 std::map<int,std::vector<int> > m;
3461 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3463 const DataArrayInt *tmp=(*it);
3466 m[tmp->getHashCode()].push_back(i);
3469 std::vector< std::vector<int> > ret;
3470 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
3472 if((*it2).second.size()>1)
3474 std::vector<int> ret0;
3475 bool equalityOrNot=false;
3476 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
3478 std::vector<int>::const_iterator it4=it3; it4++;
3479 for(;it4!=(*it2).second.end();it4++)
3481 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
3484 ret0.push_back(*it3);
3485 ret0.push_back(*it4);
3491 ret.push_back(ret0);
3497 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
3499 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
3502 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
3504 std::string name(pfl->getName());
3506 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
3507 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3508 if(name==(*it)->getName())
3510 if(!pfl->isEqual(*(*it)))
3512 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
3513 throw INTERP_KERNEL::Exception(oss.str());
3517 _pfls.push_back(pfl);
3520 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)
3522 std::string name(locName);
3524 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
3525 MCAuto<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
3526 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3527 if((*it)->isName(locName))
3529 if(!(*it)->isEqual(*obj,1e-12))
3531 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
3532 throw INTERP_KERNEL::Exception(oss.str());
3535 _locs.push_back(obj);
3538 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
3540 std::vector<std::string> names=getPfls();
3541 return CreateNewNameNotIn("NewPfl_",names);
3544 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
3546 std::vector<std::string> names=getLocs();
3547 return CreateNewNameNotIn("NewLoc_",names);
3550 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
3552 for(std::size_t sz=0;sz<100000;sz++)
3554 std::ostringstream tryName;
3555 tryName << prefix << sz;
3556 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
3557 return tryName.str();
3559 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
3563 * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
3564 * \param [in] fname - the file name.
3566 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(med_idt fid):_globals(MEDFileFieldGlobs::New(fid))
3571 * Creates an empty MEDFileFieldGlobsReal.
3573 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
3577 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
3582 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildrenWithNull() const
3584 std::vector<const BigMemoryObject *> ret;
3585 ret.push_back((const MEDFileFieldGlobs *)_globals);
3590 * Returns a string describing profiles and Gauss points held in \a this.
3591 * \return std::string - the description string.
3593 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
3595 const MEDFileFieldGlobs *glob=_globals;
3596 std::ostringstream oss2; oss2 << glob;
3597 std::string stars(oss2.str().length(),'*');
3598 oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n";
3600 glob->simpleRepr(oss);
3602 oss << "NO GLOBAL INFORMATION !\n";
3605 void MEDFileFieldGlobsReal::resetContent()
3607 _globals=MEDFileFieldGlobs::New();
3610 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
3615 * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
3616 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3618 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3620 _globals=other._globals;
3624 * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3625 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3627 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3629 const MEDFileFieldGlobs *otherg(other._globals);
3632 _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3636 * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3637 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3639 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3641 const MEDFileFieldGlobs *otherg(other._globals);
3644 _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3647 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3649 _globals=other._globals;
3650 if((const MEDFileFieldGlobs *)_globals)
3651 _globals=other._globals->deepCopy();
3655 * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3656 * \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3657 * \param [in] eps - a precision used to compare Gauss points with same name held by
3658 * \a this and \a other MEDFileFieldGlobsReal.
3659 * \throw If \a this and \a other hold profiles with equal names but different ids.
3660 * \throw If \a this and \a other hold different Gauss points with equal names.
3662 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
3664 const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3665 if(thisGlobals==otherGlobals)
3669 _globals=other._globals;
3672 _globals->appendGlobs(*other._globals,eps);
3675 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
3677 checkGlobsPflsPartCoherency();
3678 checkGlobsLocsPartCoherency();
3681 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
3683 contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3686 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
3688 contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3691 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3693 contentNotNull()->loadProfileInFile(fid,id,pflName);
3696 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3698 contentNotNull()->loadProfileInFile(fid,id);
3701 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
3703 contentNotNull()->loadGlobals(fid,*this);
3706 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid)
3708 contentNotNull()->loadAllGlobals(fid);
3711 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3713 contentNotNull()->writeGlobals(fid,opt);
3717 * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3718 * or getPflsReallyUsedMulti().
3719 * \return std::vector<std::string> - a sequence of names of all profiles.
3721 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3723 return contentNotNull()->getPfls();
3727 * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3728 * or getLocsReallyUsedMulti().
3729 * \return std::vector<std::string> - a sequence of names of all localizations.
3731 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3733 return contentNotNull()->getLocs();
3737 * Checks if the profile with a given name exists.
3738 * \param [in] pflName - the profile name of interest.
3739 * \return bool - \c true if the profile named \a pflName exists.
3741 bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
3743 return contentNotNull()->existsPfl(pflName);
3747 * Checks if the localization with a given name exists.
3748 * \param [in] locName - the localization name of interest.
3749 * \return bool - \c true if the localization named \a locName exists.
3751 bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
3753 return contentNotNull()->existsLoc(locName);
3756 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
3758 return contentNotNull()->createNewNameOfPfl();
3761 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
3763 return contentNotNull()->createNewNameOfLoc();
3767 * Sets the name of a MED file.
3768 * \param [inout] fileName - the file name.
3770 void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
3772 contentNotNull()->setFileName(fileName);
3776 * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3777 * in the same order.
3778 * \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3779 * Each item of this sequence is a vector containing ids of equal profiles.
3781 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3783 return contentNotNull()->whichAreEqualProfiles();
3787 * Finds equal localizations.
3788 * \param [in] eps - a precision used to compare real values of the localizations.
3789 * \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3790 * Each item of this sequence is a vector containing ids of equal localizations.
3792 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3794 return contentNotNull()->whichAreEqualLocs(eps);
3798 * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3799 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3800 * this sequence is a pair whose
3801 * - the first item is a vector of profile names to replace by the second item,
3802 * - the second item is a profile name to replace every profile name of the first item.
3804 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3806 contentNotNull()->changePflsNamesInStruct(mapOfModif);
3810 * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3811 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3812 * this sequence is a pair whose
3813 * - the first item is a vector of localization names to replace by the second item,
3814 * - the second item is a localization name to replace every localization name of the first item.
3816 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3818 contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3822 * Replaces references to some profiles (a reference is a profile name) by references
3823 * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3824 * them-selves accordingly. <br>
3825 * This method is a generalization of changePflName().
3826 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3827 * this sequence is a pair whose
3828 * - the first item is a vector of profile names to replace by the second item,
3829 * - the second item is a profile name to replace every profile of the first item.
3830 * \sa changePflsRefsNamesGen()
3831 * \sa changePflName()
3833 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3835 changePflsRefsNamesGen(mapOfModif);
3836 changePflsNamesInStruct(mapOfModif);
3840 * Replaces references to some localizations (a reference is a localization name) by references
3841 * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3842 * them-selves accordingly. <br>
3843 * This method is a generalization of changeLocName().
3844 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3845 * this sequence is a pair whose
3846 * - the first item is a vector of localization names to replace by the second item,
3847 * - the second item is a localization name to replace every localization of the first item.
3848 * \sa changeLocsRefsNamesGen()
3849 * \sa changeLocName()
3851 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3853 changeLocsRefsNamesGen(mapOfModif);
3854 changeLocsNamesInStruct(mapOfModif);
3858 * Renames the profile having a given name and updates references to this profile.
3859 * \param [in] oldName - the name of the profile to rename.
3860 * \param [in] newName - a new name of the profile.
3861 * \sa changePflsNames().
3863 void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
3865 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3866 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3868 changePflsNames(mapOfModif);
3872 * Renames the localization having a given name and updates references to this localization.
3873 * \param [in] oldName - the name of the localization to rename.
3874 * \param [in] newName - a new name of the localization.
3875 * \sa changeLocsNames().
3877 void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
3879 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3880 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3882 changeLocsNames(mapOfModif);
3886 * Removes duplicated profiles. Returns a map used to update references to removed
3887 * profiles via changePflsRefsNamesGen().
3888 * Equal profiles are found using whichAreEqualProfiles().
3889 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3890 * a sequence describing the performed replacements of profiles. Each element of
3891 * this sequence is a pair whose
3892 * - the first item is a vector of profile names replaced by the second item,
3893 * - the second item is a profile name replacing every profile of the first item.
3895 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
3897 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3898 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3900 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3902 std::vector< std::string > tmp((*it).size());
3904 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3905 tmp[j]=std::string(getProfileFromId(*it2)->getName());
3906 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3908 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3909 killProfileIds(tmp2);
3911 changePflsRefsNamesGen(ret);
3916 * Removes duplicated localizations. Returns a map used to update references to removed
3917 * localizations via changeLocsRefsNamesGen().
3918 * Equal localizations are found using whichAreEqualLocs().
3919 * \param [in] eps - a precision used to compare real values of the localizations.
3920 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3921 * a sequence describing the performed replacements of localizations. Each element of
3922 * this sequence is a pair whose
3923 * - the first item is a vector of localization names replaced by the second item,
3924 * - the second item is a localization name replacing every localization of the first item.
3926 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
3928 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3929 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3931 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3933 std::vector< std::string > tmp((*it).size());
3935 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3936 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3937 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3939 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3940 killLocalizationIds(tmp2);
3942 changeLocsRefsNamesGen(ret);
3947 * Returns number of Gauss points per cell in a given localization.
3948 * \param [in] locId - an id of the localization of interest.
3949 * \return int - the number of the Gauss points per cell.
3951 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
3953 return contentNotNull()->getNbOfGaussPtPerCell(locId);
3957 * Returns an id of a localization by its name.
3958 * \param [in] loc - the localization name of interest.
3959 * \return int - the id of the localization.
3960 * \throw If there is no a localization named \a loc.
3962 int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
3964 return contentNotNull()->getLocalizationId(loc);
3968 * Returns the name of the MED file.
3969 * \return const std::string& - the MED file name.
3971 std::string MEDFileFieldGlobsReal::getFileName() const
3973 return contentNotNull()->getFileName();
3977 * Returns a localization object by its name.
3978 * \param [in] locName - the name of the localization of interest.
3979 * \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3980 * \throw If there is no a localization named \a locName.
3982 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
3984 return contentNotNull()->getLocalization(locName);
3988 * Returns a localization object by its id.
3989 * \param [in] locId - the id of the localization of interest.
3990 * \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3991 * \throw If there is no a localization with id \a locId.
3993 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
3995 return contentNotNull()->getLocalizationFromId(locId);
3999 * Returns a profile array by its name.
4000 * \param [in] pflName - the name of the profile of interest.
4001 * \return const DataArrayInt * - the profile array having the name \a pflName.
4002 * \throw If there is no a profile named \a pflName.
4004 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
4006 return contentNotNull()->getProfile(pflName);
4010 * Returns a profile array by its id.
4011 * \param [in] pflId - the id of the profile of interest.
4012 * \return const DataArrayInt * - the profile array having the id \a pflId.
4013 * \throw If there is no a profile with id \a pflId.
4015 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
4017 return contentNotNull()->getProfileFromId(pflId);
4021 * Returns a localization object, apt for modification, by its id.
4022 * \param [in] locId - the id of the localization of interest.
4023 * \return MEDFileFieldLoc& - a non-const reference to the localization object
4024 * having the id \a locId.
4025 * \throw If there is no a localization with id \a locId.
4027 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
4029 return contentNotNull()->getLocalizationFromId(locId);
4033 * Returns a localization object, apt for modification, by its name.
4034 * \param [in] locName - the name of the localization of interest.
4035 * \return MEDFileFieldLoc& - a non-const reference to the localization object
4036 * having the name \a locName.
4037 * \throw If there is no a localization named \a locName.
4039 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
4041 return contentNotNull()->getLocalization(locName);
4045 * Returns a profile array, apt for modification, by its name.
4046 * \param [in] pflName - the name of the profile of interest.
4047 * \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
4048 * \throw If there is no a profile named \a pflName.
4050 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
4052 return contentNotNull()->getProfile(pflName);
4056 * Returns a profile array, apt for modification, by its id.
4057 * \param [in] pflId - the id of the profile of interest.
4058 * \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
4059 * \throw If there is no a profile with id \a pflId.
4061 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
4063 return contentNotNull()->getProfileFromId(pflId);
4067 * Removes profiles given by their ids. No data is updated to track this removal.
4068 * \param [in] pflIds - a sequence of ids of the profiles to remove.
4070 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
4072 contentNotNull()->killProfileIds(pflIds);
4076 * Removes localizations given by their ids. No data is updated to track this removal.
4077 * \param [in] locIds - a sequence of ids of the localizations to remove.
4079 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
4081 contentNotNull()->killLocalizationIds(locIds);
4085 * Stores a profile array.
4086 * \param [in] pfl - the profile array to store.
4087 * \throw If the name of \a pfl is empty.
4088 * \throw If a profile with the same name as that of \a pfl already exists but contains
4091 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
4093 contentNotNull()->appendProfile(pfl);
4097 * Adds a new localization of Gauss points.
4098 * \param [in] locName - the name of the new localization.
4099 * \param [in] geoType - a geometrical type of the reference cell.
4100 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
4101 * must be \c nbOfNodesPerCell * \c dimOfType.
4102 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
4103 * must be _wg_.size() * \c dimOfType.
4104 * \param [in] w - the weights of Gauss points.
4105 * \throw If \a locName is empty.
4106 * \throw If a localization with the name \a locName already exists but is
4107 * different form the new one.
4109 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)
4111 contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
4114 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
4116 MEDFileFieldGlobs *g(_globals);
4118 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
4122 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
4124 const MEDFileFieldGlobs *g(_globals);
4126 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
4130 //= MEDFileFieldNameScope
4132 MEDFileFieldNameScope::MEDFileFieldNameScope()
4136 MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName):_name(fieldName)
4141 * Returns the name of \a this field.
4142 * \return std::string - a string containing the field name.
4144 std::string MEDFileFieldNameScope::getName() const
4150 * Sets name of \a this field
4151 * \param [in] name - the new field name.
4153 void MEDFileFieldNameScope::setName(const std::string& fieldName)
4158 std::string MEDFileFieldNameScope::getDtUnit() const
4163 void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
4168 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
4171 _dt_unit=other._dt_unit;
4174 //= MEDFileAnyTypeField1TSWithoutSDA
4176 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
4178 _field_per_mesh.resize(other._field_per_mesh.size());
4180 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
4182 if((const MEDFileFieldPerMesh *)*it)
4183 _field_per_mesh[i]=(*it)->deepCopy(this);
4188 * Prints a string describing \a this field into a stream. This string is outputted
4189 * by \c print Python command.
4190 * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
4191 * \param [in,out] oss - the out stream.
4192 * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
4193 * info id printed, else, not.
4195 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
4197 std::string startOfLine(bkOffset,' ');
4198 oss << startOfLine << "Field ";
4200 oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
4201 oss << "on one time Step ";
4203 oss << "(" << f1tsId << ") ";
4204 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
4205 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
4206 const DataArray *arr=getUndergroundDataArray();
4209 const std::vector<std::string> &comps=arr->getInfoOnComponents();
4212 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
4213 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
4214 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
4216 if(arr->isAllocated())
4218 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
4221 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
4225 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
4227 oss << startOfLine << "----------------------" << std::endl;
4228 if(!_field_per_mesh.empty())
4231 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
4233 const MEDFileFieldPerMesh *cur=(*it2);
4235 cur->simpleRepr(bkOffset,oss,i);
4237 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
4242 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
4244 oss << startOfLine << "----------------------" << std::endl;
4247 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
4249 const DataArray *arr(getUndergroundDataArray());
4251 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
4252 int nbOfCompo=arr->getNumberOfComponents();
4253 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
4254 for(int i=0;i<nbOfCompo;i++)
4257 std::vector<int> v(1,i);
4258 MCAuto<DataArray> arr2=arr->keepSelectedComponents(v);
4259 ret[i]->setArray(arr2);
4264 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order):MEDFileFieldNameScope(fieldName),_iteration(iteration),_order(order),_csit(csit),_nb_of_tuples_to_be_allocated(-2)
4268 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
4273 * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
4274 * empty. Returns -1 if this in on nodes.
4275 * \return int - the dimension of \a this.
4277 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
4280 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4281 (*it)->getDimension(ret);
4286 * Returns the mesh name.
4287 * \return std::string - a string holding the mesh name.
4288 * \throw If \c _field_per_mesh.empty()
4290 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const
4292 if(_field_per_mesh.empty())
4293 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
4294 return _field_per_mesh[0]->getMeshName();
4297 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const std::string& newMeshName)
4299 std::string oldName(getMeshName());
4300 std::vector< std::pair<std::string,std::string> > v(1);
4301 v[0].first=oldName; v[0].second=newMeshName;
4305 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
4308 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4310 MEDFileFieldPerMesh *cur(*it);
4312 ret=cur->changeMeshNames(modifTab) || ret;
4318 * Returns the number of iteration of the state of underlying mesh.
4319 * \return int - the iteration number.
4320 * \throw If \c _field_per_mesh.empty()
4322 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
4324 if(_field_per_mesh.empty())
4325 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
4326 return _field_per_mesh[0]->getMeshIteration();
4330 * Returns the order number of iteration of the state of underlying mesh.
4331 * \return int - the order number.
4332 * \throw If \c _field_per_mesh.empty()
4334 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
4336 if(_field_per_mesh.empty())
4337 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
4338 return _field_per_mesh[0]->getMeshOrder();
4342 * Checks if \a this field is tagged by a given iteration number and a given
4343 * iteration order number.
4344 * \param [in] iteration - the iteration number of interest.
4345 * \param [in] order - the iteration order number of interest.
4346 * \return bool - \c true if \a this->getIteration() == \a iteration &&
4347 * \a this->getOrder() == \a order.
4349 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
4351 return iteration==_iteration && order==_order;
4355 * Returns number of iteration and order number of iteration when
4356 * \a this field has been calculated.
4357 * \return std::pair<int,int> - a pair of the iteration number and the iteration
4360 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
4362 std::pair<int,int> p;
4368 * Returns number of iteration and order number of iteration when
4369 * \a this field has been calculated.
4370 * \param [in,out] p - a pair returning the iteration number and the iteration
4373 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
4380 * Returns all types of spatial discretization of \a this field.
4381 * \param [in,out] types - a sequence of types of \a this field.
4383 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
4385 std::set<TypeOfField> types2;
4386 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4388 (*it)->fillTypesOfFieldAvailable(types2);
4390 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
4391 std::copy(types2.begin(),types2.end(),bi);
4395 * Returns all types of spatial discretization of \a this field.
4396 * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
4399 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
4401 std::vector<TypeOfField> ret;
4402 fillTypesOfFieldAvailable(ret);
4406 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
4408 std::vector<std::string> ret;
4409 std::set<std::string> ret2;
4410 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4412 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
4413 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4414 if(ret2.find(*it2)==ret2.end())
4416 ret.push_back(*it2);
4423 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
4425 std::vector<std::string> ret;
4426 std::set<std::string> ret2;
4427 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4429 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
4430 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4431 if(ret2.find(*it2)==ret2.end())
4433 ret.push_back(*it2);
4440 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
4442 std::vector<std::string> ret;
4443 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4445 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
4446 ret.insert(ret.end(),tmp.begin(),tmp.end());
4451 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
4453 std::vector<std::string> ret;
4454 std::set<std::string> ret2;
4455 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4457 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
4458 ret.insert(ret.end(),tmp.begin(),tmp.end());
4463 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4465 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4466 (*it)->changePflsRefsNamesGen(mapOfModif);
4469 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4471 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4472 (*it)->changeLocsRefsNamesGen(mapOfModif);
4476 * Returns all attributes of parts of \a this field lying on a given mesh.
4477 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4478 * item of every of returned sequences refers to the _i_-th part of \a this field.
4479 * Thus all sequences returned by this method are of the same length equal to number
4480 * of different types of supporting entities.<br>
4481 * A field part can include sub-parts with several different spatial discretizations,
4482 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
4483 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4484 * of a nested sequence corresponds to a type of spatial discretization.<br>
4485 * This method allows for iteration over MEDFile DataStructure without any overhead.
4486 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4487 * for the case with only one underlying mesh. (Actually, the number of meshes is
4488 * not checked if \a mname == \c NULL).
4489 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4490 * a field part is returned.
4491 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4492 * This sequence is of the same length as \a types.
4493 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4494 * discretization. A profile name can be empty.
4495 * Length of this and of nested sequences is the same as that of \a typesF.
4496 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4497 * discretization. A localization name can be empty.
4498 * Length of this and of nested sequences is the same as that of \a typesF.
4499 * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
4500 * of ids of tuples within the data array, per each type of spatial
4501 * discretization within one mesh entity type.
4502 * Length of this and of nested sequences is the same as that of \a typesF.
4503 * \throw If no field is lying on \a mname.
4505 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
4509 meshId=getMeshIdFromMeshName(mname);
4511 if(_field_per_mesh.empty())
4512 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4513 return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4517 * Returns dimensions of mesh elements \a this field lies on. The returned value is a
4518 * maximal absolute dimension and values returned via the out parameter \a levs are
4519 * dimensions relative to the maximal absolute dimension. <br>
4520 * This method is designed for MEDFileField1TS instances that have a discretization
4521 * \ref MEDCoupling::ON_CELLS "ON_CELLS",
4522 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT",
4523 * \ref MEDCoupling::ON_GAUSS_NE "ON_GAUSS_NE".
4524 * Only these 3 discretizations will be taken into account here. If \a this is
4525 * \ref MEDCoupling::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
4526 * This method is useful to make the link between the dimension of the underlying mesh
4527 * and the levels of \a this, because it is possible that the highest dimension of \a this
4528 * field is not equal to the dimension of the underlying mesh.
4530 * Let's consider the following case:
4531 * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
4532 * TETRA4, HEXA8, TRI3 and SEG2.
4533 * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
4534 * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
4536 * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
4537 * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
4538 * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
4539 * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
4540 * parameter of getFieldAtLevel() is computed basing on the returned values as this:
4541 * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
4543 * to retrieve the highest level of
4544 * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br>
4545 * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
4546 * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
4547 * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
4548 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4549 * for the case with only one underlying mesh. (Actually, the number of meshes is
4550 * not checked if \a mname == \c NULL).
4551 * \param [in,out] levs - a sequence returning the dimensions relative to the maximal
4552 * absolute one. They are in decreasing order. This sequence is cleared before
4554 * \return int - the maximal absolute dimension of elements \a this fields lies on.
4555 * \throw If no field is lying on \a mname.
4557 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
4560 int meshId=getMeshIdFromMeshName(mname);
4561 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4562 std::vector< std::vector<TypeOfField> > typesF;
4563 std::vector< std::vector<std::string> > pfls, locs;
4564 _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4566 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
4567 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
4568 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
4570 st.erase(INTERP_KERNEL::NORM_ERROR);
4572 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
4574 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
4575 ret1.insert((int)cm.getDimension());
4577 int ret=*std::max_element(ret1.begin(),ret1.end());
4578 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
4579 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
4583 void MEDFileAnyTypeField1TSWithoutSDA::convertMedBallIntoClassic()
4585 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it<_field_per_mesh.end();it++)
4586 if((*it).isNotNull())
4587 (*it)->convertMedBallIntoClassic();
4590 void MEDFileAnyTypeField1TSWithoutSDA::makeReduction(INTERP_KERNEL::NormalizedCellType ct, TypeOfField tof, const DataArrayInt *pfl)
4593 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : null pfl !");
4594 std::string name(pfl->getName());
4595 pfl->checkAllocated();
4596 if(pfl->getNumberOfComponents()!=1)
4597 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : non mono compo array !");
4599 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : empty pfl name !");
4600 if(_field_per_mesh.size()!=1)
4601 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : only single mesh supported !");
4602 MCAuto<MEDFileFieldPerMesh> fpm(_field_per_mesh[0]);
4604 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : only single not null mesh supported !");
4605 MEDFileFieldPerMeshPerTypePerDisc *disc(fpm->getLeafGivenTypeAndLocId(ct,0));
4606 if(disc->getType()!=tof)
4607 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : error !");
4608 int s(disc->getStart()),e(disc->getEnd()),nt(pfl->getNumberOfTuples());
4609 DataArray *arr(getUndergroundDataArray());
4610 int nt2(arr->getNumberOfTuples()),delta((e-s)-nt);
4612 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : internal error !");
4613 MCAuto<DataArray> arr0(arr->selectByTupleIdSafeSlice(0,s,1)),arr1(arr->selectByTupleIdSafeSlice(s,e,1)),arr2(arr->selectByTupleIdSafeSlice(e,nt2,1));
4614 MCAuto<DataArray> arr11(arr1->selectByTupleIdSafe(pfl->begin(),pfl->end()));
4615 MCAuto<DataArray> arrOut(arr->buildNewEmptyInstance());
4616 arrOut->alloc(nt2-delta,arr->getNumberOfComponents());
4617 arrOut->copyStringInfoFrom(*arr);
4618 arrOut->setContigPartOfSelectedValuesSlice(0,arr0,0,s,1);
4619 arrOut->setContigPartOfSelectedValuesSlice(s,arr11,0,nt,1);
4620 arrOut->setContigPartOfSelectedValuesSlice(e-delta,arr2,0,nt2-e,1);
4622 disc->setEnd(e-delta);
4623 disc->setProfile(name);
4627 * \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.
4628 * \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.
4629 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4630 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4632 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
4634 int mid=getMeshIdFromMeshName(mName);
4635 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4639 * \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.
4640 * \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.
4641 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4642 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4644 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
4646 int mid=getMeshIdFromMeshName(mName);
4647 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4651 * \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.
4653 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
4655 if(_field_per_mesh.empty())
4656 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4659 std::string mName2(mName);
4661 std::vector<std::string> msg;
4662 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4663 if(mName2==(*it)->getMeshName())
4666 msg.push_back((*it)->getMeshName());
4667 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4668 oss << "Possible meshes are : ";
4669 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4670 oss << "\"" << (*it2) << "\" ";
4671 throw INTERP_KERNEL::Exception(oss.str());
4674 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
4677 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4678 std::string tmp(mesh->getName());
4680 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4681 std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4683 for(;it!=_field_per_mesh.end();it++,i++)
4685 if((*it)->getMeshName()==tmp)
4688 int sz=_field_per_mesh.size();
4689 _field_per_mesh.resize(sz+1);
4690 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4694 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4695 MEDFileFieldGlobsReal& glob)
4698 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4700 MEDFileFieldPerMesh *fpm(*it);
4702 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4708 * This method splits \a this into several sub-parts so that each sub parts have exactly one spatial discretization. This method implements the minimal
4709 * splitting that leads to single spatial discretization of this.
4711 * \sa splitMultiDiscrPerGeoTypes
4713 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
4715 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4716 std::vector< std::vector<TypeOfField> > typesF;
4717 std::vector< std::vector<std::string> > pfls,locs;
4718 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4719 std::set<TypeOfField> allEnt;
4720 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4721 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4722 allEnt.insert(*it2);
4723 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4724 std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4725 for(std::size_t i=0;i<allEnt.size();i++,it3++)
4727 std::vector< std::pair<int,int> > its;
4728 ret[i]=shallowCpy();
4729 int newLgth(ret[i]->keepOnlySpatialDiscretization(*it3,its));
4730 ret[i]->updateData(newLgth,its);
4736 * This method performs a sub splitting as splitDiscretizations does but finer. This is the finest spliting level that can be done.
4737 * This method implements the minimal splitting so that each returned elements are mono Gauss discretization per geometric type.
4739 * \sa splitDiscretizations
4741 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes() const
4743 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4744 std::vector< std::vector<TypeOfField> > typesF;
4745 std::vector< std::vector<std::string> > pfls,locs;
4746 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4747 std::set<TypeOfField> allEnt;
4748 std::size_t nbOfMDPGT(0),ii(0);
4749 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++,ii++)
4751 nbOfMDPGT=std::max(nbOfMDPGT,locs[ii].size());
4752 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4753 allEnt.insert(*it2);
4755 if(allEnt.size()!=1)
4756 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : this field is expected to be defined only on one spatial discretization !");
4758 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
4761 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret0(1);
4762 ret0[0]=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(this); this->incrRef();
4765 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfMDPGT);
4766 for(std::size_t i=0;i<nbOfMDPGT;i++)
4768 std::vector< std::pair<int,int> > its;
4769 ret[i]=shallowCpy();
4770 int newLgth(ret[i]->keepOnlyGaussDiscretization(i,its));
4771 ret[i]->updateData(newLgth,its);
4776 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
4778 int globalCounter(0);
4779 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4780 (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4781 return globalCounter;
4784 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlyGaussDiscretization(std::size_t idOfDisc, std::vector< std::pair<int,int> >& its)
4786 int globalCounter(0);
4787 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4788 (*it)->keepOnlyGaussDiscretization(idOfDisc,globalCounter,its);
4789 return globalCounter;
4792 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
4794 if(_nb_of_tuples_to_be_allocated>=0)
4796 _nb_of_tuples_to_be_allocated=newLgth;
4797 const DataArray *oldArr(getUndergroundDataArray());
4800 MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4801 newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
4803 _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
4807 if(_nb_of_tuples_to_be_allocated==-1)
4809 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4811 const DataArray *oldArr(getUndergroundDataArray());
4812 if(!oldArr || !oldArr->isAllocated())
4813 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4814 MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4815 newArr->alloc(newLgth,getNumberOfComponents());
4817 newArr->copyStringInfoFrom(*oldArr);
4819 for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4821 if((*it).second<(*it).first)
4822 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4823 newArr->setContigPartOfSelectedValuesSlice(pos,oldArr,(*it).first,(*it).second,1);
4824 pos+=(*it).second-(*it).first;
4829 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4832 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
4834 if(_field_per_mesh.empty())
4835 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4836 if(_field_per_mesh.size()>1)
4837 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4838 _field_per_mesh[0]->copyOptionsFrom(opts);
4839 _field_per_mesh[0]->writeLL(fid,nasc);
4843 * 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.
4844 * If false is returned the memory allocation is not required.
4846 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
4848 if(_nb_of_tuples_to_be_allocated>=0)
4850 getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4851 _nb_of_tuples_to_be_allocated=-2;
4854 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4856 if(_nb_of_tuples_to_be_allocated==-1)
4857 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4858 if(_nb_of_tuples_to_be_allocated<-3)
4859 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4860 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4863 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
4865 med_int numdt,numit;
4869 med_int meshnumdt,meshnumit;
4870 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4871 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt));
4872 MEDFILESAFECALLERRD0(MEDfield23ComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit));
4873 if(_iteration!=numdt || _order!=numit)
4874 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4875 _field_per_mesh.resize(nmesh);
4880 std::string meshNameCpp(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
4881 mm=ms->getMeshWithName(meshNameCpp);
4884 for(int i=0;i<nmesh;i++)
4885 _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i,meshnumdt,meshnumit,nasc,mm,entities);
4886 _nb_of_tuples_to_be_allocated=0;
4887 for(int i=0;i<nmesh;i++)
4888 _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4891 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
4893 allocIfNecessaryTheArrayToReceiveDataFromFile();
4894 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4895 (*it)->loadBigArraysRecursively(fid,nasc);
4898 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
4900 if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4901 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4902 (*it)->loadBigArraysRecursively(fid,nasc);
4905 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
4907 loadOnlyStructureOfDataRecursively(fid,nasc,ms,entities);
4908 loadBigArraysRecursively(fid,nasc);
4911 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
4913 DataArray *thisArr(getUndergroundDataArray());
4914 if(thisArr && thisArr->isAllocated())
4916 _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
4917 thisArr->desallocate();
4921 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
4923 return _dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MCAuto< MEDFileFieldPerMesh >);
4926 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
4928 std::vector<const BigMemoryObject *> ret;
4929 if(getUndergroundDataArray())
4930 ret.push_back(getUndergroundDataArray());
4931 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4932 ret.push_back((const MEDFileFieldPerMesh *)*it);
4937 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4938 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4939 * "Sort By Type"), if not, an exception is thrown.
4940 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
4941 * \param [in] arr - the array of values.
4942 * \param [in,out] glob - the global data where profiles and localization present in
4943 * \a field, if any, are added.
4944 * \throw If the name of \a field is empty.
4945 * \throw If the data array of \a field is not set.
4946 * \throw If \a this->_arr is already allocated but has different number of components
4948 * \throw If the underlying mesh of \a field has no name.
4949 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4951 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4953 const MEDCouplingMesh *mesh=field->getMesh();
4955 TypeOfField type=field->getTypeOfField();
4956 std::vector<DataArrayInt *> dummy;
4957 int start=copyTinyInfoFrom(field,arr);
4958 int pos=addNewEntryIfNecessary(mesh);
4961 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4962 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4965 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4969 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4970 * of a given mesh are used as the support of the given field (a real support is not used).
4971 * Elements of the given mesh must be sorted suitable for writing to MED file.
4972 * Order of underlying mesh entities of the given field specified by \a profile parameter
4973 * is not prescribed; this method permutes field values to have them sorted by element
4974 * type as required for writing to MED file. A new profile is added only if no equal
4975 * profile is missing.
4976 * \param [in] field - the field to add to \a this. The field double values are ignored.
4977 * \param [in] arrOfVals - the values of the field \a field used.
4978 * \param [in] mesh - the supporting mesh of \a field.
4979 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4980 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
4981 * \param [in,out] glob - the global data where profiles and localization present in
4982 * \a field, if any, are added.
4983 * \throw If either \a field or \a mesh or \a profile has an empty name.
4984 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4985 * \throw If the data array of \a field is not set.
4986 * \throw If \a this->_arr is already allocated but has different number of components
4988 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4989 * \sa setFieldNoProfileSBT()
4991 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4994 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
4995 if(!arrOfVals || !arrOfVals->isAllocated())
4996 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
4997 TypeOfField type=field->getTypeOfField();
4998 std::vector<DataArrayInt *> idsInPflPerType;
4999 std::vector<DataArrayInt *> idsPerType;
5000 std::vector<int> code,code2;
5001 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
5004 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
5005 std::vector< MCAuto<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
5006 std::vector< MCAuto<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin());
5007 std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
5009 MCAuto<MEDCouplingFieldDouble> field2=field->clone(false);
5010 int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
5011 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
5013 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
5014 throw INTERP_KERNEL::Exception(oss.str());
5017 int start=copyTinyInfoFrom(field,arrOfVals);
5018 code2=m->getDistributionOfTypes();
5020 int pos=addNewEntryIfNecessary(m);
5021 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
5025 if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
5026 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
5027 std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
5028 std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
5029 int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
5030 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
5032 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
5033 throw INTERP_KERNEL::Exception(oss.str());
5035 int start=copyTinyInfoFrom(field,arrOfVals);
5036 int pos=addNewEntryIfNecessary(m);
5037 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
5042 * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
5044 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
5046 if(_nb_of_tuples_to_be_allocated>=0)
5047 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 !");
5048 DataArray *arr(getOrCreateAndGetArray());
5049 arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
5050 _nb_of_tuples_to_be_allocated=-3;
5054 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
5055 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
5056 * larger by the size of \a field. Returns an id of the first not filled
5057 * tuple of \a this->_arr.
5058 * \param [in] field - the field to copy the info on components and the name from.
5059 * \return int - the id of first not initialized tuple of \a this->_arr.
5060 * \throw If the name of \a field is empty.
5061 * \throw If the data array of \a field is not set.
5062 * \throw If \a this->_arr is already allocated but has different number of components
5065 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
5068 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
5069 std::string name(field->getName());
5070 setName(name.c_str());
5071 setDtUnit(field->getTimeUnit());
5073 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
5075 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
5076 if(!arr->isAllocated())
5077 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
5078 _dt=field->getTime(_iteration,_order);
5079 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
5080 if(!getOrCreateAndGetArray()->isAllocated())
5082 allocNotFromFile(arr->getNumberOfTuples());
5087 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
5088 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
5089 getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
5090 _nb_of_tuples_to_be_allocated=-3;
5091 return oldNbOfTuples;
5096 * Returns number of components in \a this field
5097 * \return int - the number of components.
5099 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
5101 return getOrCreateAndGetArray()->getNumberOfComponents();
5105 * Change info on components in \a this.
5106 * \throw If size of \a infos is not equal to the number of components already in \a this.
5108 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
5110 DataArray *arr=getOrCreateAndGetArray();
5111 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
5115 * Returns info on components of \a this field.
5116 * \return const std::vector<std::string>& - a sequence of strings each being an
5117 * information on _i_-th component.
5119 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
5121 const DataArray *arr=getOrCreateAndGetArray();
5122 return arr->getInfoOnComponents();
5126 * Returns a mutable info on components of \a this field.
5127 * \return std::vector<std::string>& - a sequence of strings each being an
5128 * information on _i_-th component.
5130 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
5132 DataArray *arr=getOrCreateAndGetArray();
5133 return arr->getInfoOnComponents();
5136 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const
5138 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5140 const MEDFileFieldPerMesh *fpm(*it);
5143 if(fpm->presenceOfMultiDiscPerGeoType())
5149 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfStructureElements() const
5151 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5152 if((*it).isNotNull())
5153 if((*it)->presenceOfStructureElements())
5158 bool MEDFileAnyTypeField1TSWithoutSDA::onlyStructureElements() const
5160 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5161 if((*it).isNotNull())
5162 if(!(*it)->onlyStructureElements())
5167 void MEDFileAnyTypeField1TSWithoutSDA::killStructureElements()
5169 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5170 if((*it).isNotNull())
5171 (*it)->killStructureElements();
5174 void MEDFileAnyTypeField1TSWithoutSDA::keepOnlyStructureElements()
5176 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5177 if((*it).isNotNull())
5178 (*it)->keepOnlyStructureElements();
5181 void MEDFileAnyTypeField1TSWithoutSDA::keepOnlyOnSE(const std::string& seName)
5183 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5184 if((*it).isNotNull())
5185 (*it)->keepOnlyOnSE(seName);
5188 void MEDFileAnyTypeField1TSWithoutSDA::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
5190 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5191 if((*it).isNotNull())
5192 (*it)->getMeshSENames(ps);
5195 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh(const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5197 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 !";
5198 if(_field_per_mesh.empty())
5199 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is empty ! Nothing to extract !");
5200 if(_field_per_mesh.size()>1)
5201 throw INTERP_KERNEL::Exception(MSG0);
5202 if(_field_per_mesh[0].isNull())
5203 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is inconsistent !");
5204 const MEDFileFieldPerMesh *pm(_field_per_mesh[0]);
5205 std::set<TypeOfField> types;
5206 pm->fillTypesOfFieldAvailable(types);
5208 throw INTERP_KERNEL::Exception(MSG0);
5209 TypeOfField type(*types.begin());
5210 int meshDimRelToMax(0);
5215 int myDim(std::numeric_limits<int>::max());
5216 bool isUnique(pm->isUniqueLevel(myDim));
5218 throw INTERP_KERNEL::Exception(MSG0);
5219 meshDimRelToMax=myDim-mesh->getMeshDimension();
5220 if(meshDimRelToMax>0)
5221 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the mesh attached to field is not compatible with the field !");
5223 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,0/*renumPol*/,glob,mesh,arrOut,nasc);
5227 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5228 * \param [in] type - a spatial discretization of the new field.
5229 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5230 * \param [in] mName - a name of the supporting mesh.
5231 * \param [in] renumPol - specifies how to permute values of the result field according to
5232 * the optional numbers of cells and nodes, if any. The valid values are
5233 * - 0 - do not permute.
5234 * - 1 - permute cells.
5235 * - 2 - permute nodes.
5236 * - 3 - permute cells and nodes.
5238 * \param [in] glob - the global data storing profiles and localization.
5239 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5240 * caller is to delete this field using decrRef() as it is no more needed.
5241 * \throw If the MED file is not readable.
5242 * \throw If there is no mesh named \a mName in the MED file.
5243 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5244 * \throw If no field of \a this is lying on the mesh \a mName.
5245 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5247 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5249 MCAuto<MEDFileMesh> mm;
5251 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
5253 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
5254 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
5258 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5259 * \param [in] type - a spatial discretization of the new field.
5260 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5261 * \param [in] renumPol - specifies how to permute values of the result field according to
5262 * the optional numbers of cells and nodes, if any. The valid values are
5263 * - 0 - do not permute.
5264 * - 1 - permute cells.
5265 * - 2 - permute nodes.
5266 * - 3 - permute cells and nodes.
5268 * \param [in] glob - the global data storing profiles and localization.
5269 * \param [in] mesh - the supporting mesh.
5270 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5271 * caller is to delete this field using decrRef() as it is no more needed.
5272 * \throw If the MED file is not readable.
5273 * \throw If no field of \a this is lying on \a mesh.
5274 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5275 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5277 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5279 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax,false));
5280 const DataArrayInt *d(mesh->getNumberFieldAtLevel(meshDimRelToMax)),*e(mesh->getNumberFieldAtLevel(1));
5281 if(meshDimRelToMax==1)
5282 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
5283 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
5287 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
5289 * \param [in] type - a spatial discretization of the new field.
5290 * \param [in] mName - a name of the supporting mesh.
5291 * \param [in] renumPol - specifies how to permute values of the result field according to
5292 * the optional numbers of cells and nodes, if any. The valid values are
5293 * - 0 - do not permute.
5294 * - 1 - permute cells.
5295 * - 2 - permute nodes.
5296 * - 3 - permute cells and nodes.
5298 * \param [in] glob - the global data storing profiles and localization.
5299 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5300 * caller is to delete this field using decrRef() as it is no more needed.
5301 * \throw If the MED file is not readable.
5302 * \throw If there is no mesh named \a mName in the MED file.
5303 * \throw If there are no mesh entities in the mesh.
5304 * \throw If no field values of the given \a type are available.
5306 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5308 MCAuto<MEDFileMesh> mm;
5310 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
5312 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
5313 int absDim=getDimension();
5314 int meshDimRelToMax=absDim-mm->getMeshDimension();
5315 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
5319 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5320 * \param [in] type - a spatial discretization of the new field.
5321 * \param [in] renumPol - specifies how to permute values of the result field according to
5322 * the optional numbers of cells and nodes, if any. The valid values are
5323 * - 0 - do not permute.
5324 * - 1 - permute cells.
5325 * - 2 - permute nodes.
5326 * - 3 - permute cells and nodes.
5328 * \param [in] glob - the global data storing profiles and localization.
5329 * \param [in] mesh - the supporting mesh.
5330 * \param [in] cellRenum - the cell numbers array used for permutation of the result
5331 * field according to \a renumPol.
5332 * \param [in] nodeRenum - the node numbers array used for permutation of the result
5333 * field according to \a renumPol.
5334 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5335 * caller is to delete this field using decrRef() as it is no more needed.
5336 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5337 * \throw If no field of \a this is lying on \a mesh.
5338 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5340 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
5342 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
5343 int meshId=getMeshIdFromMeshName(mesh->getName());
5345 MCAuto<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
5350 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5357 throw INTERP_KERNEL::Exception(msg1);
5358 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5361 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
5363 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5364 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
5365 throw INTERP_KERNEL::Exception(oss.str());
5367 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
5368 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
5369 std::vector<DataArray *> arrOut2(1,arrOut);
5370 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
5371 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
5372 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
5379 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5381 throw INTERP_KERNEL::Exception(msg1);
5384 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
5386 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5387 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
5388 throw INTERP_KERNEL::Exception(oss.str());
5390 MCAuto<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
5391 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
5392 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
5393 ret->renumberNodes(nodeRenumSafe->getConstPointer());
5398 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
5403 * Returns values and a profile of the field of a given type lying on a given support.
5404 * \param [in] type - a spatial discretization of the field.
5405 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5406 * \param [in] mesh - the supporting mesh.
5407 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
5408 * field of interest lies on. If the field lies on all entities of the given
5409 * dimension, all ids in \a pfl are zero. The caller is to delete this array
5410 * using decrRef() as it is no more needed.
5411 * \param [in] glob - the global data storing profiles and localization.
5412 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
5413 * field. The caller is to delete this array using decrRef() as it is no more needed.
5414 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
5415 * \throw If no field of \a this is lying on \a mesh.
5416 * \throw If no field values of the given \a type are available.
5418 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
5420 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
5421 int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
5422 MCAuto<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
5423 ret->setName(nasc.getName().c_str());
5427 //= MEDFileField1TSWithoutSDA
5430 * Throws if a given value is not a valid (non-extended) relative dimension.
5431 * \param [in] meshDimRelToMax - the relative dimension value.
5432 * \throw If \a meshDimRelToMax > 0.
5434 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
5436 if(meshDimRelToMax>0)
5437 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
5441 * Checks if elements of a given mesh are in the order suitable for writing
5442 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
5443 * vector describing types of elements and their number.
5444 * \param [in] mesh - the mesh to check.
5445 * \return std::vector<int> - a vector holding for each element type (1) item of
5446 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
5447 * These values are in full-interlace mode.
5448 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
5450 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
5453 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
5454 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
5455 int nbOfTypes=geoTypes.size();
5456 std::vector<int> code(3*nbOfTypes);
5457 MCAuto<DataArrayInt> arr1=DataArrayInt::New();
5458 arr1->alloc(nbOfTypes,1);
5459 int *arrPtr=arr1->getPointer();
5460 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
5461 for(int i=0;i<nbOfTypes;i++,it++)
5462 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
5463 MCAuto<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
5464 const int *arrPtr2=arr2->getConstPointer();
5466 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
5469 int nbCells=mesh->getNumberOfCellsWithType(*it);
5470 code[3*pos]=(int)(*it);
5471 code[3*pos+1]=nbCells;
5472 code[3*pos+2]=-1;//no profiles
5474 std::vector<const DataArrayInt *> idsPerType;//no profiles
5475 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
5479 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
5484 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5486 return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5490 * Returns all attributes and values of parts of \a this field lying on a given mesh.
5491 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
5492 * item of every of returned sequences refers to the _i_-th part of \a this field.
5493 * Thus all sequences returned by this method are of the same length equal to number
5494 * of different types of supporting entities.<br>
5495 * A field part can include sub-parts with several different spatial discretizations,
5496 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
5497 * for example. Hence, some of the returned sequences contains nested sequences, and an item
5498 * of a nested sequence corresponds to a type of spatial discretization.<br>
5499 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
5500 * The overhead is due to selecting values into new instances of DataArrayDouble.
5501 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
5502 * for the case with only one underlying mesh. (Actually, the number of meshes is
5503 * not checked if \a mname == \c NULL).
5504 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
5505 * a field part is returned.
5506 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
5507 * A field part can include sub-parts with several different spatial discretizations,
5508 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and
5509 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT" for example.
5510 * This sequence is of the same length as \a types.
5511 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
5512 * discretization. A profile name can be empty.
5513 * Length of this and of nested sequences is the same as that of \a typesF.
5514 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
5515 * discretization. A localization name can be empty.
5516 * Length of this and of nested sequences is the same as that of \a typesF.
5517 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
5518 * per each type of spatial discretization within one mesh entity type.
5519 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
5520 * Length of this and of nested sequences is the same as that of \a typesF.
5521 * \throw If no field is lying on \a mname.
5523 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
5527 meshId=getMeshIdFromMeshName(mname);
5529 if(_field_per_mesh.empty())
5530 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
5531 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
5532 int nbOfRet=ret0.size();
5533 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
5534 for(int i=0;i<nbOfRet;i++)
5536 const std::vector< std::pair<int,int> >& p=ret0[i];
5537 int nbOfRet1=p.size();
5538 ret[i].resize(nbOfRet1);
5539 for(int j=0;j<nbOfRet1;j++)
5541 DataArrayDouble *tmp=_arr->selectByTupleIdSafeSlice(p[j].first,p[j].second,1);
5548 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
5553 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
5555 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
5556 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5557 ret->deepCpyLeavesFrom(*this);
5558 const DataArrayDouble *arr(_arr);
5561 MCAuto<DataArrayInt> arr2(arr->convertToIntArr());
5562 ret->setArray(arr2);
5568 * Returns a pointer to the underground DataArrayDouble instance and a
5569 * sequence describing parameters of a support of each part of \a this field. The
5570 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5571 * direct access to the field values. This method is intended for the field lying on one
5573 * \param [in,out] entries - the sequence describing parameters of a support of each
5574 * part of \a this field. Each item of this sequence consists of two parts. The
5575 * first part describes a type of mesh entity and an id of discretization of a
5576 * current field part. The second part describes a range of values [begin,end)
5577 * within the returned array relating to the current field part.
5578 * \return DataArrayDouble * - the pointer to the field values array.
5579 * \throw If the number of underlying meshes is not equal to 1.
5580 * \throw If no field values are available.
5581 * \sa getUndergroundDataArray()
5583 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5585 if(_field_per_mesh.size()!=1)
5586 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5587 if(_field_per_mesh[0]==0)
5588 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5589 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5590 return getUndergroundDataArrayTemplate();
5594 * Returns a pointer to the underground DataArrayDouble instance and a
5595 * sequence describing parameters of a support of each part of \a this field. The
5596 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5597 * direct access to the field values. This method is intended for the field lying on one
5599 * \param [in,out] entries - the sequence describing parameters of a support of each
5600 * part of \a this field. Each item of this sequence consists of two parts. The
5601 * first part describes a type of mesh entity and an id of discretization of a
5602 * current field part. The second part describes a range of values [begin,end)
5603 * within the returned array relating to the current field part.
5604 * \return DataArrayDouble * - the pointer to the field values array.
5605 * \throw If the number of underlying meshes is not equal to 1.
5606 * \throw If no field values are available.
5607 * \sa getUndergroundDataArray()
5609 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5611 return getUndergroundDataArrayDoubleExt(entries);
5614 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<double>(fieldName,csit,iteration,order)
5616 DataArrayDouble *arr(getOrCreateAndGetArrayTemplate());
5617 arr->setInfoAndChangeNbOfCompo(infos);
5620 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<double>()
5624 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
5626 MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
5627 ret->deepCpyLeavesFrom(*this);
5631 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCopy() const
5633 MCAuto<MEDFileField1TSWithoutSDA> ret(shallowCpy());
5634 if(_arr.isNotNull())
5635 ret->_arr=_arr->deepCopy();
5639 //= MEDFileIntField1TSWithoutSDA
5641 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5643 return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5646 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<int>()
5650 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order,
5651 const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<int>(fieldName,csit,iteration,order)
5653 DataArrayInt *arr(getOrCreateAndGetArrayTemplate());
5654 arr->setInfoAndChangeNbOfCompo(infos);
5657 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
5662 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const
5664 MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
5665 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5666 ret->deepCpyLeavesFrom(*this);
5667 const DataArrayInt *arr(_arr);
5670 MCAuto<DataArrayDouble> arr2(arr->convertToDblArr());
5671 ret->setArray(arr2);
5677 * Returns a pointer to the underground DataArrayInt instance and a
5678 * sequence describing parameters of a support of each part of \a this field. The
5679 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5680 * direct access to the field values. This method is intended for the field lying on one
5682 * \param [in,out] entries - the sequence describing parameters of a support of each
5683 * part of \a this field. Each item of this sequence consists of two parts. The
5684 * first part describes a type of mesh entity and an id of discretization of a
5685 * current field part. The second part describes a range of values [begin,end)
5686 * within the returned array relating to the current field part.
5687 * \return DataArrayInt * - the pointer to the field values array.
5688 * \throw If the number of underlying meshes is not equal to 1.
5689 * \throw If no field values are available.
5690 * \sa getUndergroundDataArray()
5692 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5694 return getUndergroundDataArrayIntExt(entries);
5698 * Returns a pointer to the underground DataArrayInt instance and a
5699 * sequence describing parameters of a support of each part of \a this field. The
5700 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5701 * direct access to the field values. This method is intended for the field lying on one
5703 * \param [in,out] entries - the sequence describing parameters of a support of each
5704 * part of \a this field. Each item of this sequence consists of two parts. The
5705 * first part describes a type of mesh entity and an id of discretization of a
5706 * current field part. The second part describes a range of values [begin,end)
5707 * within the returned array relating to the current field part.
5708 * \return DataArrayInt * - the pointer to the field values array.
5709 * \throw If the number of underlying meshes is not equal to 1.
5710 * \throw If no field values are available.
5711 * \sa getUndergroundDataArray()
5713 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5715 if(_field_per_mesh.size()!=1)
5716 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5717 if(_field_per_mesh[0]==0)
5718 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5719 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5720 return getUndergroundDataArrayTemplate();
5723 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5725 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5726 ret->deepCpyLeavesFrom(*this);
5730 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCopy() const
5732 MCAuto<MEDFileIntField1TSWithoutSDA> ret(shallowCpy());
5733 if(_arr.isNotNull())
5734 ret->_arr=_arr->deepCopy();
5738 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5742 //= MEDFileAnyTypeField1TS
5744 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
5746 med_field_type typcha;
5748 std::vector<std::string> infos;
5749 std::string dtunit,fieldName;
5750 LocateField2(fid,0,true,fieldName,typcha,infos,dtunit);
5751 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5756 ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5761 ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5766 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] !";
5767 throw INTERP_KERNEL::Exception(oss.str());
5770 ret->setDtUnit(dtunit.c_str());
5771 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5773 med_int numdt,numit;
5775 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5776 ret->setTime(numdt,numit,dt);
5779 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5781 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5785 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
5786 try:MEDFileFieldGlobsReal(fid)
5788 _content=BuildContentFrom(fid,loadAll,ms);
5791 catch(INTERP_KERNEL::Exception& e)
5796 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5798 med_field_type typcha;
5799 std::vector<std::string> infos;
5802 int nbSteps=LocateField(fid,fieldName,iii,typcha,infos,dtunit);
5803 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5808 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5813 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5818 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] !";
5819 throw INTERP_KERNEL::Exception(oss.str());
5822 ret->setDtUnit(dtunit.c_str());
5823 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5827 std::ostringstream oss; oss << "MEDFileField1TS(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5828 throw INTERP_KERNEL::Exception(oss.str());
5831 med_int numdt,numit;
5833 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5834 ret->setTime(numdt,numit,dt);
5837 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5839 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5843 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5844 try:MEDFileFieldGlobsReal(fid)
5846 _content=BuildContentFrom(fid,fieldName,loadAll,ms);
5849 catch(INTERP_KERNEL::Exception& e)
5854 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c)
5857 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5858 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5860 MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
5861 ret->_content=c; c->incrRef();
5864 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5866 MCAuto<MEDFileIntField1TS> ret(MEDFileIntField1TS::New());
5867 ret->_content=c; c->incrRef();
5870 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5873 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, med_idt fid)
5875 MEDFileAnyTypeField1TS *ret(BuildNewInstanceFromContent(c));
5876 ret->setFileName(FileNameFromFID(fid));
5880 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
5882 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5883 return New(fid,loadAll);
5886 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, bool loadAll)
5888 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
5889 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5890 ret->loadGlobals(fid);
5894 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
5896 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5897 return New(fid,fieldName,loadAll);
5900 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
5902 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0));
5903 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5904 ret->loadGlobals(fid);
5908 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
5910 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5911 return New(fid,fieldName,iteration,order,loadAll);
5914 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
5916 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0));
5917 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5918 ret->loadGlobals(fid);
5922 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5924 med_field_type typcha;
5925 std::vector<std::string> infos;
5928 int nbOfStep2(LocateField(fid,fieldName,iii,typcha,infos,dtunit));
5929 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5934 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5939 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5944 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] !";
5945 throw INTERP_KERNEL::Exception(oss.str());
5948 ret->setDtUnit(dtunit.c_str());
5949 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5952 std::vector< std::pair<int,int> > dtits(nbOfStep2);
5953 for(int i=0;i<nbOfStep2 && !found;i++)
5955 med_int numdt,numit;
5957 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt));
5958 if(numdt==iteration && numit==order)
5964 dtits[i]=std::pair<int,int>(numdt,numit);
5968 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available iterations are : ";
5969 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5970 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5971 throw INTERP_KERNEL::Exception(oss.str());
5974 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5976 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5980 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5981 try:MEDFileFieldGlobsReal(fid)
5983 _content=BuildContentFrom(fid,fieldName,iteration,order,loadAll,ms);
5986 catch(INTERP_KERNEL::Exception& e)
5992 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5993 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5995 * \warning this is a shallow copy constructor
5997 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5999 if(!shallowCopyOfContent)
6001 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
6002 otherPtr->incrRef();
6003 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
6007 _content=other.shallowCpy();
6011 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)
6015 int nbFields=MEDnField(fid);
6016 if(fieldIdCFormat>=nbFields)
6018 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << FileNameFromFID(fid) << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
6019 throw INTERP_KERNEL::Exception(oss.str());
6022 int ncomp(MEDfieldnComponent(fid,fieldIdCFormat+1));
6023 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
6024 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
6025 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
6026 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
6027 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
6030 MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep));
6031 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
6032 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
6033 infos.clear(); infos.resize(ncomp);
6034 for(int j=0;j<ncomp;j++)
6035 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
6040 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
6043 * \return in case of success the number of time steps available for the field with name \a fieldName.
6045 int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const std::string& fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
6047 int nbFields=MEDnField(fid);
6049 std::vector<std::string> fns(nbFields);
6051 for(int i=0;i<nbFields && !found;i++)
6054 nbOfStep2=LocateField2(fid,i,false,tmp,typcha,infos,dtunitOut);
6056 found=(tmp==fieldName);
6062 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available fields are : ";
6063 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
6064 oss << "\"" << *it << "\" ";
6065 throw INTERP_KERNEL::Exception(oss.str());
6071 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
6072 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
6073 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
6074 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
6075 * to keep a valid instance.
6076 * 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.
6077 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
6078 * 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.
6080 * \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.
6081 * \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.
6082 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
6083 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
6084 * \param [in] newLocName is the new localization name.
6085 * \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.
6086 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
6088 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
6090 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6091 std::string oldPflName=disc->getProfile();
6092 std::vector<std::string> vv=getPflsReallyUsedMulti();
6093 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
6094 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
6096 disc->setProfile(newPflName);
6097 DataArrayInt *pfl=getProfile(oldPflName.c_str());
6098 pfl->setName(newPflName);
6102 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
6103 throw INTERP_KERNEL::Exception(oss.str());
6108 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
6109 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
6110 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
6111 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
6112 * to keep a valid instance.
6113 * 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.
6114 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
6115 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
6116 * 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.
6118 * \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.
6119 * \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.
6120 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
6121 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
6122 * \param [in] newLocName is the new localization name.
6123 * \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.
6124 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
6126 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
6128 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6129 std::string oldLocName=disc->getLocalization();
6130 std::vector<std::string> vv=getLocsReallyUsedMulti();
6131 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
6132 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
6134 disc->setLocalization(newLocName);
6135 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
6136 loc.setName(newLocName);
6140 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
6141 throw INTERP_KERNEL::Exception(oss.str());
6145 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
6147 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
6149 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
6153 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
6155 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
6157 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
6162 * This method alloc the arrays and load potentially huge arrays contained in this field.
6163 * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
6164 * This method can be also called to refresh or reinit values from a file.
6166 * \throw If the fileName is not set or points to a non readable MED file.
6167 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
6169 void MEDFileAnyTypeField1TS::loadArrays()
6171 if(getFileName().empty())
6172 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
6173 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
6174 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
6178 * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
6179 * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
6180 * this method does not throw if \a this does not come from file read.
6182 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
6184 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
6186 if(!getFileName().empty())
6188 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
6189 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
6194 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
6195 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
6196 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
6198 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
6200 void MEDFileAnyTypeField1TS::unloadArrays()
6202 contentNotNullBase()->unloadArrays();
6206 * 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.
6207 * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
6208 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
6210 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
6212 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
6214 if(!getFileName().empty())
6215 contentNotNullBase()->unloadArrays();
6218 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
6220 int nbComp(getNumberOfComponents());
6221 INTERP_KERNEL::AutoPtr<char> comp(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
6222 INTERP_KERNEL::AutoPtr<char> unit(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
6223 for(int i=0;i<nbComp;i++)
6225 std::string info=getInfo()[i];
6227 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
6228 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
6229 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
6231 if(getName().empty())
6232 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
6233 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
6234 writeGlobals(fid,*this);
6235 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
6238 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
6240 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
6243 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
6245 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
6246 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
6251 * Returns a string describing \a this field. This string is outputted
6252 * by \c print Python command.
6254 std::string MEDFileAnyTypeField1TS::simpleRepr() const
6256 std::ostringstream oss;
6257 contentNotNullBase()->simpleRepr(0,oss,-1);
6258 simpleReprGlobs(oss);
6263 * This method returns all profiles whose name is non empty used.
6264 * \b WARNING If profile is used several times it will be reported \b only \b once.
6265 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
6267 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
6269 return contentNotNullBase()->getPflsReallyUsed2();
6273 * This method returns all localizations whose name is non empty used.
6274 * \b WARNING If localization is used several times it will be reported \b only \b once.
6276 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
6278 return contentNotNullBase()->getLocsReallyUsed2();
6282 * This method returns all profiles whose name is non empty used.
6283 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
6285 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
6287 return contentNotNullBase()->getPflsReallyUsedMulti2();
6291 * This method returns all localizations whose name is non empty used.
6292 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
6294 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
6296 return contentNotNullBase()->getLocsReallyUsedMulti2();
6299 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6301 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
6304 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6306 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
6309 int MEDFileAnyTypeField1TS::getDimension() const
6311 return contentNotNullBase()->getDimension();
6314 int MEDFileAnyTypeField1TS::getIteration() const
6316 return contentNotNullBase()->getIteration();
6319 int MEDFileAnyTypeField1TS::getOrder() const
6321 return contentNotNullBase()->getOrder();
6324 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
6326 return contentNotNullBase()->getTime(iteration,order);
6329 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
6331 contentNotNullBase()->setTime(iteration,order,val);
6334 std::string MEDFileAnyTypeField1TS::getName() const
6336 return contentNotNullBase()->getName();
6339 void MEDFileAnyTypeField1TS::setName(const std::string& name)
6341 contentNotNullBase()->setName(name);
6344 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
6346 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
6349 std::string MEDFileAnyTypeField1TS::getDtUnit() const
6351 return contentNotNullBase()->getDtUnit();
6354 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
6356 contentNotNullBase()->setDtUnit(dtUnit);
6359 std::string MEDFileAnyTypeField1TS::getMeshName() const
6361 return contentNotNullBase()->getMeshName();
6364 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
6366 contentNotNullBase()->setMeshName(newMeshName);
6369 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
6371 return contentNotNullBase()->changeMeshNames(modifTab);
6374 int MEDFileAnyTypeField1TS::getMeshIteration() const
6376 return contentNotNullBase()->getMeshIteration();
6379 int MEDFileAnyTypeField1TS::getMeshOrder() const
6381 return contentNotNullBase()->getMeshOrder();
6384 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
6386 return contentNotNullBase()->getNumberOfComponents();
6389 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
6391 return contentNotNullBase()->isDealingTS(iteration,order);
6394 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
6396 return contentNotNullBase()->getDtIt();
6399 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
6401 contentNotNullBase()->fillIteration(p);
6404 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
6406 contentNotNullBase()->fillTypesOfFieldAvailable(types);
6409 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
6411 contentNotNullBase()->setInfo(infos);
6414 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
6416 return contentNotNullBase()->getInfo();
6418 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
6420 return contentNotNullBase()->getInfo();
6423 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
6425 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
6428 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
6430 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6433 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
6435 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6438 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
6440 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
6443 void MEDFileAnyTypeField1TS::convertMedBallIntoClassic()
6445 return contentNotNullBase()->convertMedBallIntoClassic();
6448 void MEDFileAnyTypeField1TS::makeReduction(INTERP_KERNEL::NormalizedCellType ct, TypeOfField tof, const DataArrayInt *pfl)
6450 return contentNotNullBase()->makeReduction(ct,tof,pfl);
6453 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
6455 return contentNotNullBase()->getTypesOfFieldAvailable();
6458 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,
6459 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6461 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
6465 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
6466 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
6467 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
6469 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
6471 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6473 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
6474 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
6475 std::size_t sz(contentsSplit.size());
6476 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6477 for(std::size_t i=0;i<sz;i++)
6479 ret[i]=shallowCpy();
6480 ret[i]->_content=contentsSplit[i];
6486 * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
6487 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6489 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
6491 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6493 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
6494 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
6495 std::size_t sz(contentsSplit.size());
6496 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6497 for(std::size_t i=0;i<sz;i++)
6499 ret[i]=shallowCpy();
6500 ret[i]->_content=contentsSplit[i];
6506 * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this.
6507 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6509 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const
6511 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6513 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !");
6514 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
6515 std::size_t sz(contentsSplit.size());
6516 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6517 for(std::size_t i=0;i<sz;i++)
6519 ret[i]=shallowCpy();
6520 ret[i]->_content=contentsSplit[i];
6525 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCopy() const
6527 MCAuto<MEDFileAnyTypeField1TS> ret=shallowCpy();
6528 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
6529 ret->_content=_content->deepCopy();
6530 ret->deepCpyGlobs(*this);
6534 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
6536 return contentNotNullBase()->copyTinyInfoFrom(field,arr);
6542 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6543 * the first field that has been read from a specified MED file.
6544 * \param [in] fileName - the name of the MED file to read.
6545 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6546 * is to delete this field using decrRef() as it is no more needed.
6547 * \throw If reading the file fails.
6549 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll)
6551 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6552 return New(fid,loadAll);
6555 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, bool loadAll)
6557 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,loadAll,0));
6558 ret->contentNotNull();
6563 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6564 * a given field that has been read from a specified MED file.
6565 * \param [in] fileName - the name of the MED file to read.
6566 * \param [in] fieldName - the name of the field to read.
6567 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6568 * is to delete this field using decrRef() as it is no more needed.
6569 * \throw If reading the file fails.
6570 * \throw If there is no field named \a fieldName in the file.
6572 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6574 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6575 return New(fid,fieldName,loadAll);
6578 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
6580 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,fieldName,loadAll,0));
6581 ret->contentNotNull();
6586 * Returns a new instance of MEDFileField1TS holding data of a given time step of
6587 * a given field that has been read from a specified MED file.
6588 * \param [in] fileName - the name of the MED file to read.
6589 * \param [in] fieldName - the name of the field to read.
6590 * \param [in] iteration - the iteration number of a required time step.
6591 * \param [in] order - the iteration order number of required time step.
6592 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6593 * is to delete this field using decrRef() as it is no more needed.
6594 * \throw If reading the file fails.
6595 * \throw If there is no field named \a fieldName in the file.
6596 * \throw If the required time step is missing from the file.
6598 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6600 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6601 return New(fid,fieldName,iteration,order,loadAll);
6604 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
6606 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,fieldName,iteration,order,loadAll,0));
6607 ret->contentNotNull();
6612 * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6613 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6615 * Returns a new instance of MEDFileField1TS holding either a shallow copy
6616 * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
6617 * \warning this is a shallow copy constructor
6618 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
6619 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
6620 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6621 * is to delete this field using decrRef() as it is no more needed.
6623 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6625 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(other,shallowCopyOfContent));
6626 ret->contentNotNull();
6631 * Returns a new empty instance of MEDFileField1TS.
6632 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6633 * is to delete this field using decrRef() as it is no more needed.
6635 MEDFileField1TS *MEDFileField1TS::New()
6637 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS);
6638 ret->contentNotNull();
6643 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
6644 * following the given input policy.
6646 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6647 * By default (true) the globals are deeply copied.
6648 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
6650 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
6652 MCAuto<MEDFileIntField1TS> ret;
6653 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6656 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
6658 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
6659 MCAuto<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
6660 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc));
6663 ret=MEDFileIntField1TS::New();
6665 ret->deepCpyGlobs(*this);
6667 ret->shallowCpyGlobs(*this);
6671 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const
6673 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6675 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
6676 const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
6678 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 !");
6682 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull()
6684 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6686 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
6687 MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
6689 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 !");
6693 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
6696 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
6698 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
6699 DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6701 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6702 f->setArray(arrOutC);
6705 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MCAuto<DataArray>& arr)
6708 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
6709 DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6711 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6717 * Return an extraction of \a this using \a extractDef map to specify the extraction.
6718 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
6720 * \return A new object that the caller is responsible to deallocate.
6721 * \sa MEDFileUMesh::deduceNodeSubPartFromCellSubPart , MEDFileUMesh::extractPart
6723 MEDFileField1TS *MEDFileField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
6726 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : input mesh is NULL !");
6727 MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
6728 std::vector<TypeOfField> tof(getTypesOfFieldAvailable());
6729 for(std::vector<TypeOfField>::const_iterator it0=tof.begin();it0!=tof.end();it0++)
6731 if((*it0)!=ON_NODES)
6733 std::vector<int> levs;
6734 getNonEmptyLevels(mm->getName(),levs);
6735 for(std::vector<int>::const_iterator lev=levs.begin();lev!=levs.end();lev++)
6737 std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(*lev));
6738 if(it2!=extractDef.end())
6740 MCAuto<DataArrayInt> t((*it2).second);
6742 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6743 MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_CELLS,(*lev),mm));
6744 MCAuto<MEDCouplingFieldDouble> fOut(f->buildSubPart(t));
6745 ret->setFieldNoProfileSBT(fOut);
6751 std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(1));
6752 if(it2==extractDef.end())
6753 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a NODE field and no extract array available for NODE !");
6754 MCAuto<DataArrayInt> t((*it2).second);
6756 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6757 MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_NODES,0,mm));
6758 MCAuto<MEDCouplingFieldDouble> fOut(f->deepCopy());
6759 DataArrayDouble *arr(f->getArray());
6760 MCAuto<DataArrayDouble> newArr(arr->selectByTupleIdSafe(t->begin(),t->end()));
6761 fOut->setArray(newArr);
6762 ret->setFieldNoProfileSBT(fOut);
6768 MEDFileField1TS::MEDFileField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
6769 try:MEDFileAnyTypeField1TS(fid,loadAll,ms)
6772 catch(INTERP_KERNEL::Exception& e)
6775 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6776 try:MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms)
6779 catch(INTERP_KERNEL::Exception& e)
6782 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6783 try:MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms)
6786 catch(INTERP_KERNEL::Exception& e)
6790 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6791 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6793 * \warning this is a shallow copy constructor
6795 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6796 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6799 catch(INTERP_KERNEL::Exception& e)
6802 MEDFileField1TS::MEDFileField1TS()
6804 _content=new MEDFileField1TSWithoutSDA;
6808 * 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
6809 * method should be called (getFieldOnMeshAtLevel for example).
6810 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
6812 * \param [in] mesh - the mesh the field is lying on
6813 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6814 * caller is to delete this field using decrRef() as it is no more needed.
6816 MEDCouplingFieldDouble *MEDFileField1TS::field(const MEDFileMesh *mesh) const
6818 MCAuto<DataArray> arrOut;
6819 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
6820 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6825 * Returns a new MEDCouplingFieldDouble of a given type lying on
6826 * mesh entities of a given dimension of the first mesh in MED file. If \a this field
6827 * has not been constructed via file reading, an exception is thrown.
6828 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6829 * \param [in] type - a spatial discretization of interest.
6830 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6831 * \param [in] renumPol - specifies how to permute values of the result field according to
6832 * the optional numbers of cells and nodes, if any. The valid values are
6833 * - 0 - do not permute.
6834 * - 1 - permute cells.
6835 * - 2 - permute nodes.
6836 * - 3 - permute cells and nodes.
6838 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6839 * caller is to delete this field using decrRef() as it is no more needed.
6840 * \throw If \a this field has not been constructed via file reading.
6841 * \throw If the MED file is not readable.
6842 * \throw If there is no mesh in the MED file.
6843 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6844 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6845 * \sa getFieldOnMeshAtLevel()
6847 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6849 if(getFileName().empty())
6850 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6851 MCAuto<DataArray> arrOut;
6852 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
6853 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6858 * Returns a new MEDCouplingFieldDouble of a given type lying on
6859 * the top level cells of the first mesh in MED file. If \a this field
6860 * has not been constructed via file reading, an exception is thrown.
6861 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6862 * \param [in] type - a spatial discretization of interest.
6863 * \param [in] renumPol - specifies how to permute values of the result field according to
6864 * the optional numbers of cells and nodes, if any. The valid values are
6865 * - 0 - do not permute.
6866 * - 1 - permute cells.
6867 * - 2 - permute nodes.
6868 * - 3 - permute cells and nodes.
6870 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6871 * caller is to delete this field using decrRef() as it is no more needed.
6872 * \throw If \a this field has not been constructed via file reading.
6873 * \throw If the MED file is not readable.
6874 * \throw If there is no mesh in the MED file.
6875 * \throw If no field values of the given \a type.
6876 * \throw If no field values lying on the top level support.
6877 * \sa getFieldAtLevel()
6879 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
6881 if(getFileName().empty())
6882 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6883 MCAuto<DataArray> arrOut;
6884 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
6885 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6890 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6891 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6892 * \param [in] type - a spatial discretization of the new field.
6893 * \param [in] mesh - the supporting mesh.
6894 * \param [in] renumPol - specifies how to permute values of the result field according to
6895 * the optional numbers of cells and nodes, if any. The valid values are
6896 * - 0 - do not permute.
6897 * - 1 - permute cells.
6898 * - 2 - permute nodes.
6899 * - 3 - permute cells and nodes.
6901 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6902 * caller is to delete this field using decrRef() as it is no more needed.
6903 * \throw If no field of \a this is lying on \a mesh.
6904 * \throw If the mesh is empty.
6905 * \throw If no field values of the given \a type are available.
6906 * \sa getFieldAtLevel()
6907 * \sa getFieldOnMeshAtLevel()
6909 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
6911 MCAuto<DataArray> arrOut;
6912 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
6913 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6918 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6919 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6920 * \param [in] type - a spatial discretization of interest.
6921 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6922 * \param [in] mesh - the supporting mesh.
6923 * \param [in] renumPol - specifies how to permute values of the result field according to
6924 * the optional numbers of cells and nodes, if any. The valid values are
6925 * - 0 - do not permute.
6926 * - 1 - permute cells.
6927 * - 2 - permute nodes.
6928 * - 3 - permute cells and nodes.
6930 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6931 * caller is to delete this field using decrRef() as it is no more needed.
6932 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6933 * \throw If no field of \a this is lying on \a mesh.
6934 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6935 * \sa getFieldAtLevel()
6936 * \sa getFieldOnMeshAtLevel()
6938 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
6940 MCAuto<DataArray> arrOut;
6941 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
6942 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6947 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6948 * This method is called "Old" because in MED3 norm a field has only one meshName
6949 * attached, so this method is for readers of MED2 files. If \a this field
6950 * has not been constructed via file reading, an exception is thrown.
6951 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6952 * \param [in] type - a spatial discretization of interest.
6953 * \param [in] mName - a name of the supporting mesh.
6954 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6955 * \param [in] renumPol - specifies how to permute values of the result field according to
6956 * the optional numbers of cells and nodes, if any. The valid values are
6957 * - 0 - do not permute.
6958 * - 1 - permute cells.
6959 * - 2 - permute nodes.
6960 * - 3 - permute cells and nodes.
6962 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6963 * caller is to delete this field using decrRef() as it is no more needed.
6964 * \throw If the MED file is not readable.
6965 * \throw If there is no mesh named \a mName in the MED file.
6966 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6967 * \throw If \a this field has not been constructed via file reading.
6968 * \throw If no field of \a this is lying on the mesh named \a mName.
6969 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6970 * \sa getFieldAtLevel()
6972 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
6974 if(getFileName().empty())
6975 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6976 MCAuto<DataArray> arrOut;
6977 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull()));
6978 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6983 * Returns values and a profile of the field of a given type lying on a given support.
6984 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6985 * \param [in] type - a spatial discretization of the field.
6986 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6987 * \param [in] mesh - the supporting mesh.
6988 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6989 * field of interest lies on. If the field lies on all entities of the given
6990 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6991 * using decrRef() as it is no more needed.
6992 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6993 * field. The caller is to delete this array using decrRef() as it is no more needed.
6994 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6995 * \throw If no field of \a this is lying on \a mesh.
6996 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6998 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
7000 MCAuto<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
7001 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
7005 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
7006 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
7007 * "Sort By Type"), if not, an exception is thrown.
7008 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7009 * \param [in] field - the field to add to \a this.
7010 * \throw If the name of \a field is empty.
7011 * \throw If the data array of \a field is not set.
7012 * \throw If the data array is already allocated but has different number of components
7014 * \throw If the underlying mesh of \a field has no name.
7015 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
7017 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
7020 contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
7024 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
7025 * can be an aggregation of several MEDCouplingFieldDouble instances.
7026 * The mesh support of input parameter \a field is ignored here, it can be NULL.
7027 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
7030 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
7031 * A new profile is added only if no equal profile is missing.
7032 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7033 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
7034 * \param [in] mesh - the supporting mesh of \a field.
7035 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
7036 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
7037 * \throw If either \a field or \a mesh or \a profile has an empty name.
7038 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7039 * \throw If the data array of \a field is not set.
7040 * \throw If the data array of \a this is already allocated but has different number of
7041 * components than \a field.
7042 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
7043 * \sa setFieldNoProfileSBT()
7045 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
7048 contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
7051 MEDFileField1TS *MEDFileField1TS::shallowCpy() const
7053 return new MEDFileField1TS(*this);
7056 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const
7058 return contentNotNull()->getUndergroundDataArrayTemplate();
7061 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7063 return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
7066 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
7067 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
7069 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
7072 //= MEDFileIntField1TS
7074 MEDFileIntField1TS *MEDFileIntField1TS::New()
7076 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS);
7077 ret->contentNotNull();
7081 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll)
7083 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
7084 return MEDFileIntField1TS::New(fid,loadAll);
7087 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, bool loadAll)
7089 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,loadAll,0));
7090 ret->contentNotNull();
7094 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
7096 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
7097 return MEDFileIntField1TS::New(fid,fieldName,loadAll);
7100 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
7102 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,loadAll,0));
7103 ret->contentNotNull();
7107 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
7109 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
7110 return MEDFileIntField1TS::New(fid,fieldName,iteration,order,loadAll);
7113 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
7115 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,iteration,order,loadAll,0));
7116 ret->contentNotNull();
7120 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
7122 MCAuto<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
7123 ret->contentNotNull();
7127 MEDFileIntField1TS::MEDFileIntField1TS()
7129 _content=new MEDFileIntField1TSWithoutSDA;
7132 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
7133 try:MEDFileAnyTypeField1TS(fid,loadAll,ms)
7136 catch(INTERP_KERNEL::Exception& e)
7139 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
7140 try:MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms)
7143 catch(INTERP_KERNEL::Exception& e)
7146 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
7147 try:MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms)
7150 catch(INTERP_KERNEL::Exception& e)
7154 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
7155 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
7157 * \warning this is a shallow copy constructor
7159 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
7163 MEDFileIntField1TS *MEDFileIntField1TS::shallowCpy() const
7165 return new MEDFileIntField1TS(*this);
7169 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
7170 * following the given input policy.
7172 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
7173 * By default (true) the globals are deeply copied.
7174 * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
7176 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const
7178 MCAuto<MEDFileField1TS> ret;
7179 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
7182 const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
7184 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
7185 MCAuto<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
7186 ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc));
7189 ret=MEDFileField1TS::New();
7191 ret->deepCpyGlobs(*this);
7193 ret->shallowCpyGlobs(*this);
7198 * Adds a MEDCouplingFieldInt to \a this. The underlying mesh of the given field is
7199 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
7200 * "Sort By Type"), if not, an exception is thrown.
7201 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7202 * \param [in] field - the field to add to \a this.
7203 * \throw If the name of \a field is empty.
7204 * \throw If the data array of \a field is not set.
7205 * \throw If the data array is already allocated but has different number of components
7207 * \throw If the underlying mesh of \a field has no name.
7208 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
7210 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldInt *field)
7212 MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
7214 contentNotNull()->setFieldNoProfileSBT(field2,field->getArray(),*this,*contentNotNull());
7218 * Adds a MEDCouplingFieldInt to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
7219 * can be an aggregation of several MEDCouplingFieldDouble instances.
7220 * The mesh support of input parameter \a field is ignored here, it can be NULL.
7221 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
7224 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
7225 * A new profile is added only if no equal profile is missing.
7226 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7227 * \param [in] field - the field to add to \a this.
7228 * \param [in] mesh - the supporting mesh of \a field.
7229 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
7230 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
7231 * \throw If either \a field or \a mesh or \a profile has an empty name.
7232 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7233 * \throw If the data array of \a field is not set.
7234 * \throw If the data array of \a this is already allocated but has different number of
7235 * components than \a field.
7236 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
7237 * \sa setFieldNoProfileSBT()
7239 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
7241 MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
7243 contentNotNull()->setFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
7246 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const
7248 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7250 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
7251 const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
7253 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 !");
7257 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
7259 if(getFileName().empty())
7260 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7261 MCAuto<DataArray> arrOut;
7262 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
7263 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7267 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MCAuto<DataArray>& arr)
7270 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
7271 DataArrayInt *arrC(dynamic_cast<DataArrayInt *>((DataArray *)arr));
7273 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
7278 MCAuto<MEDCouplingFieldInt> MEDFileIntField1TS::SetDataArrayDoubleInIntField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
7281 double t0(f->getTime(t1,t2));
7282 MCAuto<DataArrayInt> arr2(DynamicCastSafe<DataArray,DataArrayInt>(arr));
7283 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
7284 MCAuto<MEDCouplingFieldInt> ret(MEDCouplingFieldInt::New(*ft));
7285 ret->setTime(t0,t1,t2); ret->setArray(arr2);
7289 MCAuto<MEDCouplingFieldDouble> MEDFileIntField1TS::ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f)
7292 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ConvertFieldIntToFieldDouble : null input field !");
7294 double t0(f->getTime(t1,t2));
7295 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
7296 MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(*ft));
7297 ret->setTime(t0,t1,t2);
7301 MEDFileIntField1TS *MEDFileIntField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
7303 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::extractPart : not implemented yet !");
7307 * 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
7308 * method should be called (getFieldOnMeshAtLevel for example).
7309 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
7311 * \param [in] mesh - the mesh the field is lying on
7312 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
7313 * caller is to delete this field using decrRef() as it is no more needed.
7315 MEDCouplingFieldInt *MEDFileIntField1TS::field(const MEDFileMesh *mesh) const
7317 MCAuto<DataArray> arrOut;
7318 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
7319 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7324 * Returns a new MEDCouplingFieldInt of a given type lying on
7325 * the top level cells of the first mesh in MED file. If \a this field
7326 * has not been constructed via file reading, an exception is thrown.
7327 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7328 * \param [in] type - a spatial discretization of interest.
7329 * \param [in] renumPol - specifies how to permute values of the result field according to
7330 * the optional numbers of cells and nodes, if any. The valid values are
7331 * - 0 - do not permute.
7332 * - 1 - permute cells.
7333 * - 2 - permute nodes.
7334 * - 3 - permute cells and nodes.
7336 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7337 * caller is to delete this field using decrRef() as it is no more needed.
7338 * \throw If \a this field has not been constructed via file reading.
7339 * \throw If the MED file is not readable.
7340 * \throw If there is no mesh in the MED file.
7341 * \throw If no field values of the given \a type.
7342 * \throw If no field values lying on the top level support.
7343 * \sa getFieldAtLevel()
7345 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
7347 if(getFileName().empty())
7348 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
7349 MCAuto<DataArray> arrOut;
7350 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
7351 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7356 * Returns a new MEDCouplingFieldInt of given type lying on a given mesh.
7357 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7358 * \param [in] type - a spatial discretization of the new field.
7359 * \param [in] mesh - the supporting mesh.
7360 * \param [in] renumPol - specifies how to permute values of the result field according to
7361 * the optional numbers of cells and nodes, if any. The valid values are
7362 * - 0 - do not permute.
7363 * - 1 - permute cells.
7364 * - 2 - permute nodes.
7365 * - 3 - permute cells and nodes.
7367 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7368 * caller is to delete this field using decrRef() as it is no more needed.
7369 * \throw If no field of \a this is lying on \a mesh.
7370 * \throw If the mesh is empty.
7371 * \throw If no field values of the given \a type are available.
7372 * \sa getFieldAtLevel()
7373 * \sa getFieldOnMeshAtLevel()
7375 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
7377 MCAuto<DataArray> arrOut;
7378 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
7379 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7384 * Returns a new MEDCouplingFieldInt of a given type lying on a given support.
7385 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7386 * \param [in] type - a spatial discretization of interest.
7387 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7388 * \param [in] mesh - the supporting mesh.
7389 * \param [in] renumPol - specifies how to permute values of the result field according to
7390 * the optional numbers of cells and nodes, if any. The valid values are
7391 * - 0 - do not permute.
7392 * - 1 - permute cells.
7393 * - 2 - permute nodes.
7394 * - 3 - permute cells and nodes.
7396 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7397 * caller is to delete this field using decrRef() as it is no more needed.
7398 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7399 * \throw If no field of \a this is lying on \a mesh.
7400 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7401 * \sa getFieldAtLevel()
7402 * \sa getFieldOnMeshAtLevel()
7404 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
7406 MCAuto<DataArray> arrOut;
7407 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
7408 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7413 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
7414 * This method is called "Old" because in MED3 norm a field has only one meshName
7415 * attached, so this method is for readers of MED2 files. If \a this field
7416 * has not been constructed via file reading, an exception is thrown.
7417 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7418 * \param [in] type - a spatial discretization of interest.
7419 * \param [in] mName - a name of the supporting mesh.
7420 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7421 * \param [in] renumPol - specifies how to permute values of the result field according to
7422 * the optional numbers of cells and nodes, if any. The valid values are
7423 * - 0 - do not permute.
7424 * - 1 - permute cells.
7425 * - 2 - permute nodes.
7426 * - 3 - permute cells and nodes.
7428 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7429 * caller is to delete this field using decrRef() as it is no more needed.
7430 * \throw If the MED file is not readable.
7431 * \throw If there is no mesh named \a mName in the MED file.
7432 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7433 * \throw If \a this field has not been constructed via file reading.
7434 * \throw If no field of \a this is lying on the mesh named \a mName.
7435 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7436 * \sa getFieldAtLevel()
7438 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
7440 if(getFileName().empty())
7441 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7442 MCAuto<DataArray> arrOut;
7443 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
7444 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7449 * Returns values and a profile of the field of a given type lying on a given support.
7450 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7451 * \param [in] type - a spatial discretization of the field.
7452 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7453 * \param [in] mesh - the supporting mesh.
7454 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
7455 * field of interest lies on. If the field lies on all entities of the given
7456 * dimension, all ids in \a pfl are zero. The caller is to delete this array
7457 * using decrRef() as it is no more needed.
7458 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
7459 * field. The caller is to delete this array using decrRef() as it is no more needed.
7460 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7461 * \throw If no field of \a this is lying on \a mesh.
7462 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7464 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
7466 MCAuto<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
7467 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
7470 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull()
7472 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7474 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
7475 MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
7477 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 !");
7481 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const
7483 return contentNotNull()->getUndergroundDataArrayTemplate();
7486 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
7488 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
7492 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileFieldNameScope(fieldName)
7497 * \param [in] fieldId field id in C mode
7499 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7501 med_field_type typcha;
7502 std::string dtunitOut;
7503 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fieldId,false,_name,typcha,_infos,dtunitOut));
7504 setDtUnit(dtunitOut.c_str());
7505 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities);
7508 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7509 try:MEDFileFieldNameScope(fieldName),_infos(infos)
7511 setDtUnit(dtunit.c_str());
7512 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities);
7514 catch(INTERP_KERNEL::Exception& e)
7519 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
7521 std::size_t ret(_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MCAuto<MEDFileField1TSWithoutSDA>));
7522 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7523 ret+=(*it).capacity();
7527 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
7529 std::vector<const BigMemoryObject *> ret;
7530 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7531 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
7536 * 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
7539 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
7541 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7542 ret->setInfo(_infos);
7543 int sz=(int)_time_steps.size();
7544 for(const int *id=startIds;id!=endIds;id++)
7546 if(*id>=0 && *id<sz)
7548 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
7549 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7553 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7555 ret->pushBackTimeStep(tse2);
7559 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
7560 oss << " ! Should be in [0," << sz << ") !";
7561 throw INTERP_KERNEL::Exception(oss.str());
7564 if(ret->getNumberOfTS()>0)
7565 ret->synchronizeNameScope();
7566 ret->copyNameScope(*this);
7571 * 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
7574 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
7576 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
7577 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7578 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7579 ret->setInfo(_infos);
7580 int sz=(int)_time_steps.size();
7582 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
7586 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
7587 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7591 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7593 ret->pushBackTimeStep(tse2);
7597 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
7598 oss << " ! Should be in [0," << sz << ") !";
7599 throw INTERP_KERNEL::Exception(oss.str());
7602 if(ret->getNumberOfTS()>0)
7603 ret->synchronizeNameScope();
7604 ret->copyNameScope(*this);
7608 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7611 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7612 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7614 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7617 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7618 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
7619 ids->pushBackSilent(id);
7621 return buildFromTimeStepIds(ids->begin(),ids->end());
7624 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7627 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7628 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7630 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7633 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7634 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
7635 ids->pushBackSilent(id);
7637 return buildFromTimeStepIds(ids->begin(),ids->end());
7640 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfStructureElements() const
7642 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7643 if((*it).isNotNull())
7644 if((*it)->presenceOfStructureElements())
7649 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::onlyStructureElements() const
7651 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7652 if((*it).isNotNull())
7653 if(!(*it)->onlyStructureElements())
7658 void MEDFileAnyTypeFieldMultiTSWithoutSDA::killStructureElements()
7660 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
7661 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7662 if((*it).isNotNull())
7664 if((*it)->presenceOfStructureElements())
7666 if(!(*it)->onlyStructureElements())
7668 (*it)->killStructureElements();
7680 void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyStructureElements()
7682 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
7683 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7684 if((*it).isNotNull())
7686 if((*it)->presenceOfStructureElements())
7688 if(!(*it)->onlyStructureElements())
7689 (*it)->keepOnlyStructureElements();
7696 void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyOnSE(const std::string& seName)
7698 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
7699 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7700 if((*it).isNotNull())
7701 (*it)->keepOnlyOnSE(seName);
7704 void MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
7706 std::vector< std::pair<std::string,std::string> > ps2;
7707 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7708 if((*it).isNotNull())
7710 (*it)->getMeshSENames(ps2);
7714 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames : this appears to not contain SE only !");
7715 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7716 if((*it).isNotNull())
7718 std::vector< std::pair<std::string,std::string> > ps3;
7719 (*it)->getMeshSENames(ps3);
7721 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames : For the moment only homogeneous SE def through time managed !");
7723 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=ps2.begin();it!=ps2.end();it++)
7725 std::vector< std::pair<std::string,std::string> >::iterator it2(std::find(ps.begin(),ps.end(),*it));
7731 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
7733 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7735 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7738 if(cur->presenceOfMultiDiscPerGeoType())
7744 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
7749 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
7754 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
7757 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7759 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
7760 if(pt->isDealingTS(iteration,order))
7763 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
7764 std::vector< std::pair<int,int> > vp=getIterations();
7765 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
7766 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
7767 throw INTERP_KERNEL::Exception(oss.str());
7770 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
7772 return *_time_steps[getTimeStepPos(iteration,order)];
7775 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
7777 return *_time_steps[getTimeStepPos(iteration,order)];
7780 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const
7782 if(_time_steps.empty())
7783 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
7784 return _time_steps[0]->getMeshName();
7787 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const std::string& newMeshName)
7789 std::string oldName(getMeshName());
7790 std::vector< std::pair<std::string,std::string> > v(1);
7791 v[0].first=oldName; v[0].second=newMeshName;
7795 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
7798 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7800 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7802 ret=cur->changeMeshNames(modifTab) || ret;
7808 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
7810 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
7812 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
7816 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
7818 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7820 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
7823 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
7824 MEDFileFieldGlobsReal& glob)
7827 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7829 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
7831 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
7836 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7838 std::string startLine(bkOffset,' ');
7839 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
7841 oss << " (" << fmtsId << ")";
7842 oss << " has the following name: \"" << _name << "\"." << std::endl;
7843 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
7844 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7846 oss << startLine << " - \"" << *it << "\"" << std::endl;
7849 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7851 std::string chapter(17,'0'+i);
7852 oss << startLine << chapter << std::endl;
7853 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7855 cur->simpleRepr(bkOffset+2,oss,i);
7857 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
7858 oss << startLine << chapter << std::endl;
7862 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
7864 std::size_t sz=_time_steps.size();
7865 std::vector< std::pair<int,int> > ret(sz);
7867 for(std::size_t i=0;i<sz;i++)
7869 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
7872 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
7876 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
7877 throw INTERP_KERNEL::Exception(oss.str());
7883 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MCAuto<MEDFileAnyTypeField1TSWithoutSDA>& tse)
7885 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
7887 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
7888 checkCoherencyOfType(tse2);
7889 if(_time_steps.empty())
7891 setName(tse2->getName().c_str());
7892 setInfo(tse2->getInfo());
7894 checkThatComponentsMatch(tse2->getInfo());
7895 if(getDtUnit().empty() && !tse->getDtUnit().empty())
7896 setDtUnit(tse->getDtUnit());
7897 _time_steps.push_back(tse);
7900 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
7902 std::size_t nbOfCompo=_infos.size();
7903 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7905 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7908 if((cur->getInfo()).size()!=nbOfCompo)
7910 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
7911 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
7912 throw INTERP_KERNEL::Exception(oss.str());
7914 cur->copyNameScope(*this);
7919 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7921 _time_steps.resize(nbPdt);
7922 for(int i=0;i<nbPdt;i++)
7924 std::vector< std::pair<int,int> > ts;
7925 med_int numdt=0,numo=0;
7927 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt));
7932 _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7937 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7941 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
7944 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities);
7946 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entities);
7947 synchronizeNameScope();
7951 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
7953 if(_time_steps.empty())
7954 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
7955 checkThatNbOfCompoOfTSMatchThis();
7956 std::vector<std::string> infos(getInfo());
7957 int nbComp=infos.size();
7958 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7959 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7960 for(int i=0;i<nbComp;i++)
7962 std::string info=infos[i];
7964 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7965 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7966 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7969 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7970 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
7971 int nbOfTS=_time_steps.size();
7972 for(int i=0;i<nbOfTS;i++)
7973 _time_steps[i]->writeLL(fid,opts,*this);
7976 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
7978 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7980 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7982 elt->loadBigArraysRecursively(fid,nasc);
7986 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
7988 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7990 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7992 elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7996 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
7998 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8000 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
8002 elt->unloadArrays();
8006 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
8008 return _time_steps.size();
8011 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
8013 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
8014 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8016 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
8018 newTS.push_back(*it);
8023 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
8025 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
8026 int maxId=(int)_time_steps.size();
8028 std::set<int> idsToDel;
8029 for(const int *id=startIds;id!=endIds;id++,ii++)
8031 if(*id>=0 && *id<maxId)
8033 idsToDel.insert(*id);
8037 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
8038 throw INTERP_KERNEL::Exception(oss.str());
8041 for(int iii=0;iii<maxId;iii++)
8042 if(idsToDel.find(iii)==idsToDel.end())
8043 newTS.push_back(_time_steps[iii]);
8047 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
8049 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
8050 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
8051 if(nbOfEntriesToKill==0)
8053 std::size_t sz=_time_steps.size();
8054 std::vector<bool> b(sz,true);
8056 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
8058 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
8059 for(std::size_t i=0;i<sz;i++)
8061 newTS.push_back(_time_steps[i]);
8065 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
8068 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
8069 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
8071 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
8075 tmp->getTime(it2,ord);
8076 if(it2==iteration && order==ord)
8079 oss << "(" << it2 << "," << ord << "), ";
8082 throw INTERP_KERNEL::Exception(oss.str());
8085 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
8088 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
8090 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
8092 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
8096 double ti=tmp->getTime(it2,ord);
8097 if(fabs(time-ti)<eps)
8103 throw INTERP_KERNEL::Exception(oss.str());
8106 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
8108 int lgth=_time_steps.size();
8109 std::vector< std::pair<int,int> > ret(lgth);
8110 for(int i=0;i<lgth;i++)
8111 _time_steps[i]->fillIteration(ret[i]);
8116 * 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'
8117 * This method returns two things.
8118 * - The absolute dimension of 'this' in first parameter.
8119 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
8120 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
8122 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
8123 * Only these 3 discretizations will be taken into account here.
8125 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
8126 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
8127 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
8129 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
8130 * 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'.
8132 * Let's consider the typical following case :
8133 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
8134 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
8135 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
8137 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
8139 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
8141 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
8142 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
8143 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
8144 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
8146 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8148 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
8151 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
8153 if(pos<0 || pos>=(int)_time_steps.size())
8155 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
8156 throw INTERP_KERNEL::Exception(oss.str());
8158 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
8161 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
8162 oss << "\nTry to use following method eraseEmptyTS !";
8163 throw INTERP_KERNEL::Exception(oss.str());
8168 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
8170 if(pos<0 || pos>=(int)_time_steps.size())
8172 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
8173 throw INTERP_KERNEL::Exception(oss.str());
8175 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
8178 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
8179 oss << "\nTry to use following method eraseEmptyTS !";
8180 throw INTERP_KERNEL::Exception(oss.str());
8185 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
8187 std::vector<std::string> ret;
8188 std::set<std::string> ret2;
8189 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8191 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
8192 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
8193 if(ret2.find(*it2)==ret2.end())
8195 ret.push_back(*it2);
8202 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
8204 std::vector<std::string> ret;
8205 std::set<std::string> ret2;
8206 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8208 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
8209 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
8210 if(ret2.find(*it2)==ret2.end())
8212 ret.push_back(*it2);
8219 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
8221 std::vector<std::string> ret;
8222 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8224 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
8225 ret.insert(ret.end(),tmp.begin(),tmp.end());
8230 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
8232 std::vector<std::string> ret;
8233 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8235 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
8236 ret.insert(ret.end(),tmp.begin(),tmp.end());
8241 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8243 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8244 (*it)->changePflsRefsNamesGen2(mapOfModif);
8247 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8249 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8250 (*it)->changeLocsRefsNamesGen2(mapOfModif);
8253 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
8255 int lgth=_time_steps.size();
8256 std::vector< std::vector<TypeOfField> > ret(lgth);
8257 for(int i=0;i<lgth;i++)
8258 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
8263 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
8265 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
8267 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
8270 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCopy() const
8272 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
8274 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8276 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
8277 ret->_time_steps[i]=(*it)->deepCopy();
8282 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
8284 std::size_t sz(_infos.size()),sz2(_time_steps.size());
8285 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
8286 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
8287 for(std::size_t i=0;i<sz;i++)
8289 ret[i]=shallowCpy();
8290 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
8292 for(std::size_t i=0;i<sz2;i++)
8294 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
8297 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
8298 throw INTERP_KERNEL::Exception(oss.str());
8302 for(std::size_t i=0;i<sz;i++)
8303 for(std::size_t j=0;j<sz2;j++)
8304 ret[i]->_time_steps[j]=ts[j][i];
8309 * This method splits into discretization each time steps in \a this.
8310 * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
8312 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
8314 std::size_t sz(_time_steps.size());
8315 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
8316 for(std::size_t i=0;i<sz;i++)
8318 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
8321 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
8322 throw INTERP_KERNEL::Exception(oss.str());
8324 items[i]=timeStep->splitDiscretizations();
8327 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
8328 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
8329 std::vector< TypeOfField > types;
8330 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
8331 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
8333 std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
8335 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
8336 std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
8337 if(it2==types.end())
8338 types.push_back(ts[0]);
8340 ret.resize(types.size()); ret2.resize(types.size());
8341 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
8342 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
8344 TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
8345 std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
8346 ret2[pos].push_back(*it1);
8348 for(std::size_t i=0;i<types.size();i++)
8350 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
8351 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
8352 elt->pushBackTimeStep(*it1);//also updates infos in elt
8354 elt->MEDFileFieldNameScope::operator=(*this);
8360 * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
8362 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
8364 std::size_t sz(_time_steps.size());
8365 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
8366 std::size_t szOut(std::numeric_limits<std::size_t>::max());
8367 for(std::size_t i=0;i<sz;i++)
8369 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
8372 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
8373 throw INTERP_KERNEL::Exception(oss.str());
8375 items[i]=timeStep->splitMultiDiscrPerGeoTypes();
8376 if(szOut==std::numeric_limits<std::size_t>::max())
8377 szOut=items[i].size();
8379 if(items[i].size()!=szOut)
8380 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
8382 if(szOut==std::numeric_limits<std::size_t>::max())
8383 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
8384 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
8385 for(std::size_t i=0;i<szOut;i++)
8387 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
8388 for(std::size_t j=0;j<sz;j++)
8389 elt->pushBackTimeStep(items[j][i]);
8391 elt->MEDFileFieldNameScope::operator=(*this);
8396 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
8398 _name=field->getName();
8400 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
8402 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
8403 _infos=arr->getInfoOnComponents();
8406 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
8408 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
8409 if(_name!=field->getName())
8411 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
8412 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
8413 throw INTERP_KERNEL::Exception(oss.str());
8416 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
8417 checkThatComponentsMatch(arr->getInfoOnComponents());
8420 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
8422 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
8423 if(getInfo().size()!=compos.size())
8425 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
8426 oss << " number of components of element to append (" << compos.size() << ") !";
8427 throw INTERP_KERNEL::Exception(oss.str());
8431 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
8432 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
8433 oss << " But compo in input fields are : ";
8434 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
8436 throw INTERP_KERNEL::Exception(oss.str());
8440 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
8442 std::size_t sz=_infos.size();
8444 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
8446 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
8448 if(elt->getInfo().size()!=sz)
8450 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
8451 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
8452 throw INTERP_KERNEL::Exception(oss.str());
8457 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
8460 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8461 if(!_time_steps.empty())
8462 checkCoherencyOfTinyInfo(field,arr);
8463 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8464 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8465 objC->setFieldNoProfileSBT(field,arr,glob,*this);
8466 copyTinyInfoFrom(field,arr);
8467 _time_steps.push_back(obj);
8470 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
8473 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8474 if(!_time_steps.empty())
8475 checkCoherencyOfTinyInfo(field,arr);
8476 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8477 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8478 objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
8479 copyTinyInfoFrom(field,arr);
8480 _time_steps.push_back(obj);
8483 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ts)
8485 int sz=(int)_time_steps.size();
8488 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
8489 throw INTERP_KERNEL::Exception(oss.str());
8491 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
8494 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
8496 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
8497 throw INTERP_KERNEL::Exception(oss.str());
8503 //= MEDFileFieldMultiTSWithoutSDA
8505 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8507 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8510 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
8514 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8519 * \param [in] fieldId field id in C mode
8521 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8522 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8525 catch(INTERP_KERNEL::Exception& e)
8528 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8529 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8532 catch(INTERP_KERNEL::Exception& e)
8535 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8537 return new MEDFileField1TSWithoutSDA;
8540 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8543 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8544 const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
8546 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8549 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const
8551 return MEDFileField1TSWithoutSDA::TYPE_STR;
8554 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const
8556 return new MEDFileFieldMultiTSWithoutSDA(*this);
8559 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const
8561 return new MEDFileFieldMultiTSWithoutSDA;
8565 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
8566 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
8568 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
8570 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
8571 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8573 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
8574 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
8577 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
8579 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
8580 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8582 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8584 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8587 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
8589 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
8590 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
8591 ret->setIteration(i,elt);
8597 //= MEDFileAnyTypeFieldMultiTS
8599 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
8603 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8604 try:MEDFileFieldGlobsReal(fid)
8606 _content=BuildContentFrom(fid,loadAll,ms);
8609 catch(INTERP_KERNEL::Exception& e)
8614 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8616 med_field_type typcha;
8617 std::vector<std::string> infos;
8620 MEDFileAnyTypeField1TS::LocateField(fid,fieldName,i,typcha,infos,dtunit);
8621 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8626 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8631 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8636 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] !";
8637 throw INTERP_KERNEL::Exception(oss.str());
8640 ret->setDtUnit(dtunit.c_str());
8644 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8646 med_field_type typcha;
8648 std::vector<std::string> infos;
8649 std::string dtunit,fieldName;
8650 MEDFileAnyTypeField1TS::LocateField2(fid,0,true,fieldName,typcha,infos,dtunit);
8651 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8656 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8661 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8666 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] !";
8667 throw INTERP_KERNEL::Exception(oss.str());
8670 ret->setDtUnit(dtunit.c_str());
8674 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c)
8677 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
8678 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
8680 MCAuto<MEDFileFieldMultiTS> ret(MEDFileFieldMultiTS::New());
8681 ret->_content=c; c->incrRef();
8684 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
8686 MCAuto<MEDFileIntFieldMultiTS> ret(MEDFileIntFieldMultiTS::New());
8687 ret->_content=c; c->incrRef();
8690 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
8693 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, med_idt fid)
8695 MEDFileAnyTypeFieldMultiTS *ret(BuildNewInstanceFromContent(c));
8696 std::string fileName(FileNameFromFID(fid));
8697 ret->setFileName(fileName);
8701 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8702 try:MEDFileFieldGlobsReal(fid)
8704 _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
8707 catch(INTERP_KERNEL::Exception& e)
8712 //= MEDFileIntFieldMultiTSWithoutSDA
8714 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8716 return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8719 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
8723 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8727 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8728 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8731 catch(INTERP_KERNEL::Exception& e)
8735 * \param [in] fieldId field id in C mode
8737 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8738 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8741 catch(INTERP_KERNEL::Exception& e)
8744 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8746 return new MEDFileIntField1TSWithoutSDA;
8749 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8752 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8753 const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
8755 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8758 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const
8760 return MEDFileIntField1TSWithoutSDA::TYPE_STR;
8763 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const
8765 return new MEDFileIntFieldMultiTSWithoutSDA(*this);
8768 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const
8770 return new MEDFileIntFieldMultiTSWithoutSDA;
8773 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const
8775 MCAuto<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
8776 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8778 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8780 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8783 const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
8785 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
8786 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
8787 ret->setIteration(i,elt);
8793 //= MEDFileAnyTypeFieldMultiTS
8796 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
8797 * that has been read from a specified MED file.
8798 * \param [in] fileName - the name of the MED file to read.
8799 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8800 * is to delete this field using decrRef() as it is no more needed.
8801 * \throw If reading the file fails.
8803 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
8805 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8806 return New(fid,loadAll);
8809 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, bool loadAll)
8811 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
8812 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8813 ret->loadGlobals(fid);
8818 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
8819 * that has been read from a specified MED file.
8820 * \param [in] fileName - the name of the MED file to read.
8821 * \param [in] fieldName - the name of the field to read.
8822 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8823 * is to delete this field using decrRef() as it is no more needed.
8824 * \throw If reading the file fails.
8825 * \throw If there is no field named \a fieldName in the file.
8827 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8829 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8830 return New(fid,fieldName,loadAll);
8833 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
8835 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
8836 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8837 ret->loadGlobals(fid);
8842 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8843 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8845 * \warning this is a shallow copy constructor
8847 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8849 if(!shallowCopyOfContent)
8851 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
8852 otherPtr->incrRef();
8853 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
8857 _content=other.shallowCpy();
8861 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
8863 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8865 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
8869 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
8871 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8873 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
8877 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
8879 return contentNotNullBase()->getPflsReallyUsed2();
8882 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
8884 return contentNotNullBase()->getLocsReallyUsed2();
8887 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
8889 return contentNotNullBase()->getPflsReallyUsedMulti2();
8892 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
8894 return contentNotNullBase()->getLocsReallyUsedMulti2();
8897 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8899 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
8902 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8904 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
8907 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
8909 return contentNotNullBase()->getNumberOfTS();
8912 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
8914 contentNotNullBase()->eraseEmptyTS();
8917 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
8919 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
8922 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
8924 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
8927 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
8929 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
8930 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8935 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
8937 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
8938 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8943 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
8945 return contentNotNullBase()->getIterations();
8948 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
8950 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
8951 pushBackTimeStep(*it);
8954 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
8957 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
8958 int nbOfTS(fmts->getNumberOfTS());
8959 for(int i=0;i<nbOfTS;i++)
8961 MCAuto<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
8962 pushBackTimeStep(elt);
8966 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
8969 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
8970 checkCoherencyOfType(f1ts);
8972 MCAuto<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
8973 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
8975 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
8976 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
8977 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
8978 _content->pushBackTimeStep(cSafe);
8979 appendGlobs(*f1ts,1e-12);
8982 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
8984 contentNotNullBase()->synchronizeNameScope();
8987 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
8989 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
8992 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
8994 return contentNotNullBase()->getPosGivenTime(time,eps);
8997 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8999 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
9002 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
9004 return contentNotNullBase()->getTypesOfFieldAvailable();
9007 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
9009 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
9012 std::string MEDFileAnyTypeFieldMultiTS::getName() const
9014 return contentNotNullBase()->getName();
9017 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
9019 contentNotNullBase()->setName(name);
9022 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
9024 return contentNotNullBase()->getDtUnit();
9027 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
9029 contentNotNullBase()->setDtUnit(dtUnit);
9032 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
9034 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
9037 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
9039 return contentNotNullBase()->getTimeSteps(ret1);
9042 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
9044 return contentNotNullBase()->getMeshName();
9047 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
9049 contentNotNullBase()->setMeshName(newMeshName);
9052 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
9054 return contentNotNullBase()->changeMeshNames(modifTab);
9057 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
9059 return contentNotNullBase()->getInfo();
9062 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
9064 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
9067 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
9069 return contentNotNullBase()->setInfo(info);
9072 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
9074 const std::vector<std::string> ret=getInfo();
9075 return (int)ret.size();
9078 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
9080 writeGlobals(fid,*this);
9081 contentNotNullBase()->writeLL(fid,*this);
9085 * This method alloc the arrays and load potentially huge arrays contained in this field.
9086 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
9087 * This method can be also called to refresh or reinit values from a file.
9089 * \throw If the fileName is not set or points to a non readable MED file.
9091 void MEDFileAnyTypeFieldMultiTS::loadArrays()
9093 if(getFileName().empty())
9094 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
9095 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
9096 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
9100 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
9101 * But once data loaded once, this method does nothing.
9103 * \throw If the fileName is not set or points to a non readable MED file.
9104 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
9106 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
9108 if(!getFileName().empty())
9110 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
9111 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
9116 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
9117 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
9118 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
9120 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
9122 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
9124 contentNotNullBase()->unloadArrays();
9128 * 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.
9129 * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
9130 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
9132 * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
9134 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
9136 if(!getFileName().empty())
9137 contentNotNullBase()->unloadArrays();
9140 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
9142 std::ostringstream oss;
9143 contentNotNullBase()->simpleRepr(0,oss,-1);
9144 simpleReprGlobs(oss);
9148 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
9150 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
9153 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
9155 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
9156 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
9161 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
9162 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
9163 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
9165 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
9167 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9169 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
9170 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
9171 std::size_t sz(contentsSplit.size());
9172 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
9173 for(std::size_t i=0;i<sz;i++)
9175 ret[i]=shallowCpy();
9176 ret[i]->_content=contentsSplit[i];
9182 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
9183 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
9185 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
9187 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9189 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
9190 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
9191 std::size_t sz(contentsSplit.size());
9192 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
9193 for(std::size_t i=0;i<sz;i++)
9195 ret[i]=shallowCpy();
9196 ret[i]->_content=contentsSplit[i];
9202 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
9203 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
9205 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
9207 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9209 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
9210 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
9211 std::size_t sz(contentsSplit.size());
9212 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
9213 for(std::size_t i=0;i<sz;i++)
9215 ret[i]=shallowCpy();
9216 ret[i]->_content=contentsSplit[i];
9221 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCopy() const
9223 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
9224 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
9225 ret->_content=_content->deepCopy();
9226 ret->deepCpyGlobs(*this);
9230 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
9236 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
9237 * \param [in] iteration - the iteration number of a required time step.
9238 * \param [in] order - the iteration order number of required time step.
9239 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
9240 * delete this field using decrRef() as it is no more needed.
9241 * \throw If there is no required time step in \a this field.
9243 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
9245 int pos=getPosOfTimeStep(iteration,order);
9246 return getTimeStepAtPos(pos);
9250 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
9251 * \param [in] time - the time of the time step of interest.
9252 * \param [in] eps - a precision used to compare time values.
9253 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9254 * delete this field using decrRef() as it is no more needed.
9255 * \throw If there is no required time step in \a this field.
9257 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
9259 int pos=getPosGivenTime(time,eps);
9260 return getTimeStepAtPos(pos);
9264 * 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.
9265 * The float64 value of time attached to the pair of integers are not considered here.
9266 * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
9268 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
9269 * \throw If there is a null pointer in \a vectFMTS.
9271 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
9273 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
9274 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9275 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
9276 while(!lstFMTS.empty())
9278 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
9279 MEDFileAnyTypeFieldMultiTS *curIt(*it);
9281 throw INTERP_KERNEL::Exception(msg);
9282 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
9283 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
9284 elt.push_back(curIt); it=lstFMTS.erase(it);
9285 while(it!=lstFMTS.end())
9289 throw INTERP_KERNEL::Exception(msg);
9290 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
9292 { elt.push_back(curIt); it=lstFMTS.erase(it); }
9302 * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
9303 * All returned instances in a subvector can be safely loaded, rendered along time
9304 * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
9305 * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
9306 * 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).
9307 * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
9308 * 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.
9310 * \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().
9311 * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
9312 * \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.
9313 * \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.
9315 * \throw If an element in \a vectFMTS has not only one spatial discretization set.
9316 * \throw If an element in \a vectFMTS change of spatial discretization along time.
9317 * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
9318 * \thorw If some elements in \a vectFMTS do not have the same times steps.
9319 * \throw If mesh is null.
9320 * \throw If an element in \a vectFMTS is null.
9321 * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
9323 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& fsc)
9325 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
9327 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
9328 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9329 if(vectFMTS.empty())
9331 std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
9332 MEDFileAnyTypeFieldMultiTS *frstElt(*it);
9334 throw INTERP_KERNEL::Exception(msg);
9336 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
9337 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
9338 for(;it!=vectFMTS.end();it++,i++)
9341 throw INTERP_KERNEL::Exception(msg);
9342 TypeOfField tof0,tof1;
9343 if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
9346 vectFMTSNotNodes.push_back(*it);
9348 vectFMTSNodes.push_back(*it);
9351 vectFMTSNotNodes.push_back(*it);
9353 std::vector< MCAuto<MEDFileFastCellSupportComparator> > cmps;
9354 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
9356 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
9359 bool isFetched(false);
9360 for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
9363 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
9364 if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
9365 { ret[i].push_back(*it2); isFetched=true; }
9369 std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
9370 MCAuto<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
9371 ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
9379 * 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.
9380 * \param [out] cmps - same size than the returned vector.
9382 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& cmps)
9384 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9385 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
9386 while(!lstFMTS.empty())
9388 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
9389 MEDFileAnyTypeFieldMultiTS *ref(*it);
9390 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
9391 elt.push_back(ref); it=lstFMTS.erase(it);
9392 MCAuto<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
9393 MCAuto<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
9394 while(it!=lstFMTS.end())
9396 MEDFileAnyTypeFieldMultiTS *curIt(*it);
9397 if(cmp->isEqual(curIt))
9398 { elt.push_back(curIt); it=lstFMTS.erase(it); }
9402 ret.push_back(elt); cmps.push_back(cmp);
9408 * 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.
9409 * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
9411 * \throw If \a f0 or \a f1 has not only one spatial discretization set.
9412 * \throw If \a f0 or \a f1 change of spatial discretization along time.
9413 * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
9414 * \thorw If \a f0 and \a f1 do not have the same times steps.
9415 * \throw If mesh is null.
9416 * \throw If \a f0 or \a f1 is null.
9417 * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
9419 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
9422 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
9424 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
9425 if(f0->getMeshName()!=mesh->getName())
9427 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9428 throw INTERP_KERNEL::Exception(oss.str());
9430 if(f1->getMeshName()!=mesh->getName())
9432 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9433 throw INTERP_KERNEL::Exception(oss.str());
9435 int nts=f0->getNumberOfTS();
9436 if(nts!=f1->getNumberOfTS())
9437 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
9440 for(int i=0;i<nts;i++)
9442 MCAuto<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
9443 MCAuto<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
9444 std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
9445 if(tofs0.size()!=1 || tofs1.size()!=1)
9446 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
9449 if(tof0!=tofs0[0] || tof1!=tofs1[0])
9450 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
9453 { tof0=tofs0[0]; tof1=tofs1[0]; }
9454 if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
9456 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() << ") !";
9457 throw INTERP_KERNEL::Exception(oss.str());
9459 if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
9461 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() << ") !";
9462 throw INTERP_KERNEL::Exception(oss.str());
9464 if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
9466 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() << ") !";
9467 throw INTERP_KERNEL::Exception(oss.str());
9474 * Return an extraction of \a this using \a extractDef map to specify the extraction.
9475 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
9477 * \return A new object that the caller is responsible to deallocate.
9479 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
9482 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::extractPart : mesh is null !");
9483 MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(buildNewEmpty());
9484 int nbTS(getNumberOfTS());
9485 for(int i=0;i<nbTS;i++)
9487 MCAuto<MEDFileAnyTypeField1TS> f1ts(getTimeStepAtPos(i));
9488 MCAuto<MEDFileAnyTypeField1TS> f1tsOut(f1ts->extractPart(extractDef,mm));
9489 fmtsOut->pushBackTimeStep(f1tsOut);
9491 return fmtsOut.retn();
9495 MCAuto<MEDFileAnyTypeField1TS> AggregateHelperF1TS(const std::vector< typename MLFieldTraits<T>::F1TSType const *>& f1tss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9497 MCAuto< typename MLFieldTraits<T>::F1TSType > ret(MLFieldTraits<T>::F1TSType::New());
9499 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : empty vector !");
9500 std::size_t sz(f1tss.size()),i(0);
9501 std::vector< typename MLFieldTraits<T>::F1TSWSDAType const *> f1tsw(sz);
9502 for(typename std::vector< typename MLFieldTraits<T>::F1TSType const *>::const_iterator it=f1tss.begin();it!=f1tss.end();it++,i++)
9504 typename MLFieldTraits<T>::F1TSType const *elt(*it);
9506 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : presence of a null pointer !");
9507 f1tsw[i]=dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType const *>(elt->contentNotNullBase());
9509 typename MLFieldTraits<T>::F1TSWSDAType *retc(dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType *>(ret->contentNotNullBase()));
9511 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : internal error 1 !");
9512 retc->aggregate(f1tsw,dts);
9513 ret->setDtUnit(f1tss[0]->getDtUnit());
9514 return DynamicCast<typename MLFieldTraits<T>::F1TSType , MEDFileAnyTypeField1TS>(ret);
9518 MCAuto< MEDFileAnyTypeFieldMultiTS > AggregateHelperFMTS(const std::vector< typename MLFieldTraits<T>::FMTSType const *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9520 MCAuto< typename MLFieldTraits<T>::FMTSType > ret(MLFieldTraits<T>::FMTSType::New());
9522 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : empty vector !");
9523 std::size_t sz(fmtss.size());
9524 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9526 typename MLFieldTraits<T>::FMTSType const *elt(*it);
9528 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : presence of null pointer !");
9530 int nbTS(fmtss[0]->getNumberOfTS());
9531 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9532 if((*it)->getNumberOfTS()!=nbTS)
9533 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : all fields must have the same number of TS !");
9534 for(int iterTS=0;iterTS<nbTS;iterTS++)
9537 std::vector< typename MLFieldTraits<T>::F1TSType const *> f1tss(sz);
9538 std::vector< MCAuto<typename MLFieldTraits<T>::F1TSType> > f1tss2(sz);
9539 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++,i++)
9540 { f1tss2[i]=(*it)->getTimeStepAtPos(iterTS); f1tss[i]=f1tss2[i]; }
9541 MCAuto<MEDFileAnyTypeField1TS> f1ts(AggregateHelperF1TS<T>(f1tss,dts));
9542 ret->pushBackTimeStep(f1ts);
9543 ret->setDtUnit(f1ts->getDtUnit());
9545 return DynamicCast<typename MLFieldTraits<T>::FMTSType , MEDFileAnyTypeFieldMultiTS>(ret);
9549 * \a dts and \a ftmss are expected to have same size.
9551 MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileAnyTypeFieldMultiTS::Aggregate(const std::vector<const MEDFileAnyTypeFieldMultiTS *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9554 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : input vector is empty !");
9555 std::size_t sz(fmtss.size());
9556 std::vector<const MEDFileFieldMultiTS *> fmtss1;
9557 std::vector<const MEDFileIntFieldMultiTS *> fmtss2;
9558 for(std::vector<const MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9561 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : presence of null instance in input vector !");
9562 const MEDFileFieldMultiTS *elt1(dynamic_cast<const MEDFileFieldMultiTS *>(*it));
9565 fmtss1.push_back(elt1);
9568 const MEDFileIntFieldMultiTS *elt2(dynamic_cast<const MEDFileIntFieldMultiTS *>(*it));
9571 fmtss2.push_back(elt2);
9574 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not recognized type !");
9576 if(fmtss1.size()!=sz && fmtss2.size()!=sz)
9577 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : type of data is not homogeneous !");
9578 if(fmtss1.size()==sz)
9579 return AggregateHelperFMTS<double>(fmtss1,dts);
9580 if(fmtss2.size()!=sz)
9581 return AggregateHelperFMTS<int>(fmtss2,dts);
9582 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not implemented yet !");
9585 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
9587 return new MEDFileAnyTypeFieldMultiTSIterator(this);
9590 //= MEDFileFieldMultiTS
9593 * Returns a new empty instance of MEDFileFieldMultiTS.
9594 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9595 * is to delete this field using decrRef() as it is no more needed.
9597 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
9599 return new MEDFileFieldMultiTS;
9603 * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
9604 * that has been read from a specified MED file.
9605 * \param [in] fileName - the name of the MED file to read.
9606 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9607 * is to delete this field using decrRef() as it is no more needed.
9608 * \throw If reading the file fails.
9610 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll)
9612 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9613 return New(fid,loadAll);
9616 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, bool loadAll)
9618 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,loadAll,0));
9619 ret->contentNotNull();//to check that content type matches with \a this type.
9624 * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
9625 * that has been read from a specified MED file.
9626 * \param [in] fileName - the name of the MED file to read.
9627 * \param [in] fieldName - the name of the field to read.
9628 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9629 * is to delete this field using decrRef() as it is no more needed.
9630 * \throw If reading the file fails.
9631 * \throw If there is no field named \a fieldName in the file.
9633 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9635 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9636 return New(fid,fieldName,loadAll);
9639 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
9641 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0));
9642 ret->contentNotNull();//to check that content type matches with \a this type.
9647 * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9648 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9650 * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
9651 * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9652 * \warning this is a shallow copy constructor
9653 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
9654 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9655 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9656 * is to delete this field using decrRef() as it is no more needed.
9658 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9660 return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
9663 MEDFileFieldMultiTS *MEDFileFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9665 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9666 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
9667 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0,ent));
9668 ret->contentNotNull();//to check that content type matches with \a this type.
9672 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
9674 return new MEDFileFieldMultiTS(*this);
9677 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9680 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9681 const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
9683 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
9687 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
9688 * following the given input policy.
9690 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9691 * By default (true) the globals are deeply copied.
9692 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
9694 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
9696 MCAuto<MEDFileIntFieldMultiTS> ret;
9697 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9700 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
9702 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
9703 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
9704 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc));
9707 ret=MEDFileIntFieldMultiTS::New();
9709 ret->deepCpyGlobs(*this);
9711 ret->shallowCpyGlobs(*this);
9716 * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
9717 * \param [in] pos - a time step id.
9718 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9719 * delete this field using decrRef() as it is no more needed.
9720 * \throw If \a pos is not a valid time step id.
9722 MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const
9724 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9727 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9728 throw INTERP_KERNEL::Exception(oss.str());
9730 const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
9733 MCAuto<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
9734 ret->shallowCpyGlobs(*this);
9737 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
9738 throw INTERP_KERNEL::Exception(oss.str());
9742 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9743 * mesh entities of a given dimension of the first mesh in MED file.
9744 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9745 * \param [in] type - a spatial discretization of interest.
9746 * \param [in] iteration - the iteration number of a required time step.
9747 * \param [in] order - the iteration order number of required time step.
9748 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9749 * \param [in] renumPol - specifies how to permute values of the result field according to
9750 * the optional numbers of cells and nodes, if any. The valid values are
9751 * - 0 - do not permute.
9752 * - 1 - permute cells.
9753 * - 2 - permute nodes.
9754 * - 3 - permute cells and nodes.
9756 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9757 * caller is to delete this field using decrRef() as it is no more needed.
9758 * \throw If the MED file is not readable.
9759 * \throw If there is no mesh in the MED file.
9760 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9761 * \throw If no field values of the required parameters are available.
9763 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9765 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9766 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9768 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
9769 MCAuto<DataArray> arrOut;
9770 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9771 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9776 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9777 * the top level cells of the first mesh in MED file.
9778 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9779 * \param [in] type - a spatial discretization of interest.
9780 * \param [in] iteration - the iteration number of a required time step.
9781 * \param [in] order - the iteration order number of required time step.
9782 * \param [in] renumPol - specifies how to permute values of the result field according to
9783 * the optional numbers of cells and nodes, if any. The valid values are
9784 * - 0 - do not permute.
9785 * - 1 - permute cells.
9786 * - 2 - permute nodes.
9787 * - 3 - permute cells and nodes.
9789 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9790 * caller is to delete this field using decrRef() as it is no more needed.
9791 * \throw If the MED file is not readable.
9792 * \throw If there is no mesh in the MED file.
9793 * \throw If no field values of the required parameters are available.
9795 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9797 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9798 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9800 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
9801 MCAuto<DataArray> arrOut;
9802 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9803 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9808 * 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
9809 * method should be called (getFieldOnMeshAtLevel for example).
9810 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
9812 * \param [in] iteration - the iteration number of a required time step.
9813 * \param [in] order - the iteration order number of required time step.
9814 * \param [in] mesh - the mesh the field is lying on
9815 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9816 * caller is to delete this field using decrRef() as it is no more needed.
9818 MEDCouplingFieldDouble *MEDFileFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
9820 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9821 MCAuto<DataArray> arrOut;
9822 MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
9823 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9828 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9830 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9831 * \param [in] type - a spatial discretization of interest.
9832 * \param [in] iteration - the iteration number of a required time step.
9833 * \param [in] order - the iteration order number of required time step.
9834 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9835 * \param [in] mesh - the supporting mesh.
9836 * \param [in] renumPol - specifies how to permute values of the result field according to
9837 * the optional numbers of cells and nodes, if any. The valid values are
9838 * - 0 - do not permute.
9839 * - 1 - permute cells.
9840 * - 2 - permute nodes.
9841 * - 3 - permute cells and nodes.
9843 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9844 * caller is to delete this field using decrRef() as it is no more needed.
9845 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9846 * \throw If no field of \a this is lying on \a mesh.
9847 * \throw If no field values of the required parameters are available.
9849 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9851 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9852 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9854 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9855 MCAuto<DataArray> arrOut;
9856 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
9857 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9862 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9864 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9865 * \param [in] type - a spatial discretization of the new field.
9866 * \param [in] iteration - the iteration number of a required time step.
9867 * \param [in] order - the iteration order number of required time step.
9868 * \param [in] mesh - the supporting mesh.
9869 * \param [in] renumPol - specifies how to permute values of the result field according to
9870 * the optional numbers of cells and nodes, if any. The valid values are
9871 * - 0 - do not permute.
9872 * - 1 - permute cells.
9873 * - 2 - permute nodes.
9874 * - 3 - permute cells and nodes.
9876 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9877 * caller is to delete this field using decrRef() as it is no more needed.
9878 * \throw If no field of \a this is lying on \a mesh.
9879 * \throw If no field values of the required parameters are available.
9881 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
9883 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9884 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9886 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9887 MCAuto<DataArray> arrOut;
9888 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
9889 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9894 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
9895 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9896 * This method is useful for MED2 file format when field on different mesh was autorized.
9898 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
9900 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9901 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9903 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
9904 MCAuto<DataArray> arrOut;
9905 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
9906 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9911 * Returns values and a profile of the field of a given type, of a given time step,
9912 * lying on a given support.
9913 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9914 * \param [in] type - a spatial discretization of the field.
9915 * \param [in] iteration - the iteration number of a required time step.
9916 * \param [in] order - the iteration order number of required time step.
9917 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9918 * \param [in] mesh - the supporting mesh.
9919 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9920 * field of interest lies on. If the field lies on all entities of the given
9921 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9922 * using decrRef() as it is no more needed.
9923 * \param [in] glob - the global data storing profiles and localization.
9924 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
9925 * field. The caller is to delete this array using decrRef() as it is no more needed.
9926 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9927 * \throw If no field of \a this is lying on \a mesh.
9928 * \throw If no field values of the required parameters are available.
9930 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9932 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9933 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9935 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
9936 MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9937 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
9940 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const
9942 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9944 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
9945 const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
9947 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 !");
9951 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull()
9953 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9955 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
9956 MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
9958 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 !");
9963 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9964 * the given field is checked if its elements are sorted suitable for writing to MED file
9965 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9966 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9967 * \param [in] field - the field to add to \a this.
9968 * \throw If the name of \a field is empty.
9969 * \throw If the data array of \a field is not set.
9970 * \throw If existing time steps have different name or number of components than \a field.
9971 * \throw If the underlying mesh of \a field has no name.
9972 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9974 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
9976 const DataArrayDouble *arr=0;
9978 arr=field->getArray();
9979 contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
9983 * Adds a MEDCouplingFieldDouble to \a this as another time step.
9984 * The mesh support of input parameter \a field is ignored here, it can be NULL.
9985 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9988 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9989 * A new profile is added only if no equal profile is missing.
9990 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9991 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
9992 * \param [in] mesh - the supporting mesh of \a field.
9993 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9994 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
9995 * \throw If either \a field or \a mesh or \a profile has an empty name.
9996 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9997 * \throw If the data array of \a field is not set.
9998 * \throw If the data array of \a this is already allocated but has different number of
9999 * components than \a field.
10000 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
10001 * \sa setFieldNoProfileSBT()
10003 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
10005 const DataArrayDouble *arr=0;
10007 arr=field->getArray();
10008 contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
10011 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
10013 _content=new MEDFileFieldMultiTSWithoutSDA;
10016 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
10017 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
10020 catch(INTERP_KERNEL::Exception& e)
10023 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10024 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
10027 catch(INTERP_KERNEL::Exception& e)
10030 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
10034 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
10036 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
10039 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
10041 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
10044 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
10046 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
10049 MEDFileFieldMultiTS *MEDFileFieldMultiTS::buildNewEmpty() const
10051 return MEDFileFieldMultiTS::New();
10054 //= MEDFileAnyTypeFieldMultiTSIterator
10056 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
10061 _nb_iter=fmts->getNumberOfTS();
10065 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
10069 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
10071 if(_iter_id<_nb_iter)
10073 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
10075 return fmts->getTimeStepAtPos(_iter_id++);
10083 //= MEDFileIntFieldMultiTS
10086 * Returns a new empty instance of MEDFileFieldMultiTS.
10087 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
10088 * is to delete this field using decrRef() as it is no more needed.
10090 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
10092 return new MEDFileIntFieldMultiTS;
10096 * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
10097 * that has been read from a specified MED file.
10098 * \param [in] fileName - the name of the MED file to read.
10099 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
10100 * is to delete this field using decrRef() as it is no more needed.
10101 * \throw If reading the file fails.
10103 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll)
10105 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10106 return New(fid,loadAll);
10109 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, bool loadAll)
10111 MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,loadAll,0));
10112 ret->contentNotNull();//to check that content type matches with \a this type.
10117 * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
10118 * that has been read from a specified MED file.
10119 * \param [in] fileName - the name of the MED file to read.
10120 * \param [in] fieldName - the name of the field to read.
10121 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
10122 * is to delete this field using decrRef() as it is no more needed.
10123 * \throw If reading the file fails.
10124 * \throw If there is no field named \a fieldName in the file.
10126 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
10128 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10129 return New(fid,fieldName,loadAll);
10132 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
10134 MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0));
10135 ret->contentNotNull();//to check that content type matches with \a this type.
10140 * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
10141 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
10143 * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
10144 * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
10145 * \warning this is a shallow copy constructor
10146 * \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
10147 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
10148 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
10149 * is to delete this field using decrRef() as it is no more needed.
10151 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
10153 return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
10156 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
10158 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10159 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
10160 MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0,ent));
10161 ret->contentNotNull();//to check that content type matches with \a this type.
10166 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
10167 * following the given input policy.
10169 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
10170 * By default (true) the globals are deeply copied.
10171 * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
10173 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const
10175 MCAuto<MEDFileFieldMultiTS> ret;
10176 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
10179 const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
10181 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
10182 MCAuto<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
10183 ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc));
10186 ret=MEDFileFieldMultiTS::New();
10188 ret->deepCpyGlobs(*this);
10190 ret->shallowCpyGlobs(*this);
10194 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const
10196 return new MEDFileIntFieldMultiTS(*this);
10199 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
10202 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
10203 const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
10205 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
10209 * 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
10210 * method should be called (getFieldOnMeshAtLevel for example).
10211 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
10213 * \param [in] iteration - the iteration number of a required time step.
10214 * \param [in] order - the iteration order number of required time step.
10215 * \param [in] mesh - the mesh the field is lying on
10216 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
10217 * caller is to delete this field using decrRef() as it is no more needed.
10219 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
10221 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10222 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10224 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::field : mismatch of type of field expecting INT32 !");
10225 MCAuto<DataArray> arrOut;
10226 MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
10227 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arrOut));
10228 return ret2.retn();
10232 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
10233 * mesh entities of a given dimension of the first mesh in MED file.
10234 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10235 * \param [in] type - a spatial discretization of interest.
10236 * \param [in] iteration - the iteration number of a required time step.
10237 * \param [in] order - the iteration order number of required time step.
10238 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10239 * \param [in] renumPol - specifies how to permute values of the result field according to
10240 * the optional numbers of cells and nodes, if any. The valid values are
10241 * - 0 - do not permute.
10242 * - 1 - permute cells.
10243 * - 2 - permute nodes.
10244 * - 3 - permute cells and nodes.
10246 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10247 * caller is to delete this field using decrRef() as it is no more needed.
10248 * \throw If the MED file is not readable.
10249 * \throw If there is no mesh in the MED file.
10250 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
10251 * \throw If no field values of the required parameters are available.
10253 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
10255 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10256 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10258 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
10259 MCAuto<DataArray> arr;
10260 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase()));
10261 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10262 return ret2.retn();
10266 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
10267 * the top level cells of the first mesh in MED file.
10268 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10269 * \param [in] type - a spatial discretization of interest.
10270 * \param [in] iteration - the iteration number of a required time step.
10271 * \param [in] order - the iteration order number of required time step.
10272 * \param [in] renumPol - specifies how to permute values of the result field according to
10273 * the optional numbers of cells and nodes, if any. The valid values are
10274 * - 0 - do not permute.
10275 * - 1 - permute cells.
10276 * - 2 - permute nodes.
10277 * - 3 - permute cells and nodes.
10279 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10280 * caller is to delete this field using decrRef() as it is no more needed.
10281 * \throw If the MED file is not readable.
10282 * \throw If there is no mesh in the MED file.
10283 * \throw If no field values of the required parameters are available.
10285 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
10287 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10288 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10290 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
10291 MCAuto<DataArray> arr;
10292 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase()));
10293 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10294 return ret2.retn();
10298 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
10300 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10301 * \param [in] type - a spatial discretization of interest.
10302 * \param [in] iteration - the iteration number of a required time step.
10303 * \param [in] order - the iteration order number of required time step.
10304 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10305 * \param [in] mesh - the supporting mesh.
10306 * \param [in] renumPol - specifies how to permute values of the result field according to
10307 * the optional numbers of cells and nodes, if any. The valid values are
10308 * - 0 - do not permute.
10309 * - 1 - permute cells.
10310 * - 2 - permute nodes.
10311 * - 3 - permute cells and nodes.
10313 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10314 * caller is to delete this field using decrRef() as it is no more needed.
10315 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
10316 * \throw If no field of \a this is lying on \a mesh.
10317 * \throw If no field values of the required parameters are available.
10319 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
10321 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10322 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10324 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10325 MCAuto<DataArray> arr;
10326 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase()));
10327 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10328 return ret2.retn();
10332 * Returns a new MEDCouplingFieldInt of given type, of a given time step, lying on a
10334 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10335 * \param [in] type - a spatial discretization of the new field.
10336 * \param [in] iteration - the iteration number of a required time step.
10337 * \param [in] order - the iteration order number of required time step.
10338 * \param [in] mesh - the supporting mesh.
10339 * \param [out] arrOut - the DataArrayInt containing values of field.
10340 * \param [in] renumPol - specifies how to permute values of the result field according to
10341 * the optional numbers of cells and nodes, if any. The valid values are
10342 * - 0 - do not permute.
10343 * - 1 - permute cells.
10344 * - 2 - permute nodes.
10345 * - 3 - permute cells and nodes.
10347 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10348 * caller is to delete this field using decrRef() as it is no more needed.
10349 * \throw If no field of \a this is lying on \a mesh.
10350 * \throw If no field values of the required parameters are available.
10352 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
10354 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10355 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10357 throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10358 MCAuto<DataArray> arr;
10359 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase()));
10360 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10361 return ret2.retn();
10365 * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
10366 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
10367 * This method is useful for MED2 file format when field on different mesh was autorized.
10369 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol) const
10371 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10372 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10374 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10375 MCAuto<DataArray> arr;
10376 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase()));
10377 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10378 return ret2.retn();
10382 * Returns values and a profile of the field of a given type, of a given time step,
10383 * lying on a given support.
10384 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10385 * \param [in] type - a spatial discretization of the field.
10386 * \param [in] iteration - the iteration number of a required time step.
10387 * \param [in] order - the iteration order number of required time step.
10388 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10389 * \param [in] mesh - the supporting mesh.
10390 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
10391 * field of interest lies on. If the field lies on all entities of the given
10392 * dimension, all ids in \a pfl are zero. The caller is to delete this array
10393 * using decrRef() as it is no more needed.
10394 * \param [in] glob - the global data storing profiles and localization.
10395 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
10396 * field. The caller is to delete this array using decrRef() as it is no more needed.
10397 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10398 * \throw If no field of \a this is lying on \a mesh.
10399 * \throw If no field values of the required parameters are available.
10401 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
10403 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
10404 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
10406 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
10407 MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
10408 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
10412 * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
10413 * \param [in] pos - a time step id.
10414 * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
10415 * delete this field using decrRef() as it is no more needed.
10416 * \throw If \a pos is not a valid time step id.
10418 MEDFileIntField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
10420 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
10423 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
10424 throw INTERP_KERNEL::Exception(oss.str());
10426 const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
10429 MCAuto<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
10430 ret->shallowCpyGlobs(*this);
10433 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
10434 throw INTERP_KERNEL::Exception(oss.str());
10438 * Adds a MEDCouplingFieldInt to \a this as another time step. The underlying mesh of
10439 * the given field is checked if its elements are sorted suitable for writing to MED file
10440 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
10441 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10442 * \param [in] field - the field to add to \a this.
10443 * \throw If the name of \a field is empty.
10444 * \throw If the data array of \a field is not set.
10445 * \throw If existing time steps have different name or number of components than \a field.
10446 * \throw If the underlying mesh of \a field has no name.
10447 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
10449 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldInt *field)
10451 MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
10452 contentNotNull()->appendFieldNoProfileSBT(field2,field->getArray(),*this);
10456 * Adds a MEDCouplingFieldDouble to \a this as another time step.
10457 * The mesh support of input parameter \a field is ignored here, it can be NULL.
10458 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
10461 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
10462 * A new profile is added only if no equal profile is missing.
10463 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10464 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
10465 * \param [in] arrOfVals - the values of the field \a field used.
10466 * \param [in] mesh - the supporting mesh of \a field.
10467 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
10468 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
10469 * \throw If either \a field or \a mesh or \a profile has an empty name.
10470 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10471 * \throw If the data array of \a field is not set.
10472 * \throw If the data array of \a this is already allocated but has different number of
10473 * components than \a field.
10474 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
10475 * \sa setFieldNoProfileSBT()
10477 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
10479 MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
10480 contentNotNull()->appendFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this);
10483 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const
10485 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10487 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
10488 const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10490 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 !");
10494 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull()
10496 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10498 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
10499 MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10501 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 !");
10505 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
10507 _content=new MEDFileIntFieldMultiTSWithoutSDA;
10510 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
10514 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
10515 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
10518 catch(INTERP_KERNEL::Exception& e)
10521 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10522 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
10525 catch(INTERP_KERNEL::Exception& e)
10528 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
10530 return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
10533 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::buildNewEmpty() const
10535 return MEDFileIntFieldMultiTS::New();
10540 MEDFileFields *MEDFileFields::New()
10542 return new MEDFileFields;
10545 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
10547 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10548 return New(fid,loadAll);
10551 MEDFileFields *MEDFileFields::NewWithDynGT(const std::string& fileName, const MEDFileStructureElements *se, bool loadAll)
10553 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10554 return NewWithDynGT(fid,se,loadAll);
10557 MEDFileFields *MEDFileFields::NewWithDynGT(med_idt fid, const MEDFileStructureElements *se, bool loadAll)
10560 throw INTERP_KERNEL::Exception("MEDFileFields::NewWithDynGT : null struct element pointer !");
10561 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> entities(MEDFileEntities::BuildFrom(*se));
10562 return new MEDFileFields(fid,loadAll,0,entities);
10565 MEDFileFields *MEDFileFields::New(med_idt fid, bool loadAll)
10567 return new MEDFileFields(fid,loadAll,0,0);
10570 MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
10572 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10573 return new MEDFileFields(fid,loadAll,ms,0);
10576 MEDFileFields *MEDFileFields::LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
10578 MEDFileUtilities::CheckFileForRead(fileName);
10579 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
10580 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10581 return new MEDFileFields(fid,loadAll,0,ent);
10584 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
10586 std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
10587 ret+=_fields.capacity()*sizeof(MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
10591 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
10593 std::vector<const BigMemoryObject *> ret;
10594 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10595 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
10599 MEDFileFields *MEDFileFields::deepCopy() const
10601 MCAuto<MEDFileFields> ret(shallowCpy());
10603 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10605 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10606 ret->_fields[i]=(*it)->deepCopy();
10608 ret->deepCpyGlobs(*this);
10612 MEDFileFields *MEDFileFields::shallowCpy() const
10614 return new MEDFileFields(*this);
10618 * 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
10619 * 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.
10620 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
10622 * \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.
10623 * \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.
10625 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10627 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
10629 std::set< std::pair<int,int> > s;
10630 bool firstShot=true;
10631 areThereSomeForgottenTS=false;
10632 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10634 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10636 std::vector< std::pair<int,int> > v=(*it)->getIterations();
10637 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
10639 { s=s1; firstShot=false; }
10642 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
10644 areThereSomeForgottenTS=true;
10648 std::vector< std::pair<int,int> > ret;
10649 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
10653 int MEDFileFields::getNumberOfFields() const
10655 return _fields.size();
10658 std::vector<std::string> MEDFileFields::getFieldsNames() const
10660 std::vector<std::string> ret(_fields.size());
10662 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10664 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
10667 ret[i]=f->getName();
10671 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
10672 throw INTERP_KERNEL::Exception(oss.str());
10678 std::vector<std::string> MEDFileFields::getMeshesNames() const
10680 std::vector<std::string> ret;
10681 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10683 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10685 ret.push_back(cur->getMeshName());
10690 std::string MEDFileFields::simpleRepr() const
10692 std::ostringstream oss;
10693 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
10698 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
10700 int nbOfFields(getNumberOfFields());
10701 std::string startLine(bkOffset,' ');
10702 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
10704 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10706 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10709 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
10713 oss << startLine << " - not defined !" << std::endl;
10717 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10719 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10720 std::string chapter(17,'0'+i);
10721 oss << startLine << chapter << std::endl;
10724 cur->simpleRepr(bkOffset+2,oss,i);
10728 oss << startLine << " - not defined !" << std::endl;
10730 oss << startLine << chapter << std::endl;
10732 simpleReprGlobs(oss);
10735 MEDFileFields::MEDFileFields()
10739 MEDFileFields::MEDFileFields(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10740 try:MEDFileFieldGlobsReal(fid)
10742 int nbFields(MEDnField(fid));
10743 _fields.resize(nbFields);
10744 med_field_type typcha;
10745 for(int i=0;i<nbFields;i++)
10747 std::vector<std::string> infos;
10748 std::string fieldName,dtunit;
10749 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,i,false,fieldName,typcha,infos,dtunit));
10754 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10759 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10764 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] !";
10765 throw INTERP_KERNEL::Exception(oss.str());
10769 loadAllGlobals(fid);
10771 catch(INTERP_KERNEL::Exception& e)
10776 void MEDFileFields::writeLL(med_idt fid) const
10779 writeGlobals(fid,*this);
10780 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10782 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
10785 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
10786 throw INTERP_KERNEL::Exception(oss.str());
10788 elt->writeLL(fid,*this);
10793 * This method alloc the arrays and load potentially huge arrays contained in this field.
10794 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
10795 * This method can be also called to refresh or reinit values from a file.
10797 * \throw If the fileName is not set or points to a non readable MED file.
10799 void MEDFileFields::loadArrays()
10801 if(getFileName().empty())
10802 throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
10803 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
10804 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10806 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10808 elt->loadBigArraysRecursively(fid,*elt);
10813 * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
10814 * But once data loaded once, this method does nothing.
10816 * \throw If the fileName is not set or points to a non readable MED file.
10817 * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
10819 void MEDFileFields::loadArraysIfNecessary()
10821 if(!getFileName().empty())
10823 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
10824 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10826 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10828 elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
10834 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
10835 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
10836 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
10838 * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
10840 void MEDFileFields::unloadArrays()
10842 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10844 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10846 elt->unloadArrays();
10851 * 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.
10852 * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
10853 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
10855 * \sa MEDFileFields::loadArraysIfNecessary
10857 void MEDFileFields::unloadArraysWithoutDataLoss()
10859 if(!getFileName().empty())
10863 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
10865 std::vector<std::string> ret;
10866 std::set<std::string> ret2;
10867 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10869 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
10870 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10871 if(ret2.find(*it2)==ret2.end())
10873 ret.push_back(*it2);
10880 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
10882 std::vector<std::string> ret;
10883 std::set<std::string> ret2;
10884 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10886 std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
10887 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10888 if(ret2.find(*it2)==ret2.end())
10890 ret.push_back(*it2);
10897 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
10899 std::vector<std::string> ret;
10900 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10902 std::vector<std::string> tmp((*it)->getPflsReallyUsedMulti2());
10903 ret.insert(ret.end(),tmp.begin(),tmp.end());
10908 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
10910 std::vector<std::string> ret;
10911 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10913 std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
10914 ret.insert(ret.end(),tmp.begin(),tmp.end());
10919 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10921 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10922 (*it)->changePflsRefsNamesGen2(mapOfModif);
10925 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10927 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10928 (*it)->changeLocsRefsNamesGen2(mapOfModif);
10931 void MEDFileFields::resize(int newSize)
10933 _fields.resize(newSize);
10936 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
10938 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
10942 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
10945 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
10946 _fields.push_back(field->getContent());
10947 appendGlobs(*field,1e-12);
10950 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
10953 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
10954 if(i>=(int)_fields.size())
10955 _fields.resize(i+1);
10956 _fields[i]=field->getContent();
10957 appendGlobs(*field,1e-12);
10960 void MEDFileFields::destroyFieldAtPos(int i)
10962 destroyFieldsAtPos(&i,&i+1);
10965 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
10967 std::vector<bool> b(_fields.size(),true);
10968 for(const int *i=startIds;i!=endIds;i++)
10970 if(*i<0 || *i>=(int)_fields.size())
10972 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10973 throw INTERP_KERNEL::Exception(oss.str());
10977 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10979 for(std::size_t i=0;i<_fields.size();i++)
10981 fields[j++]=_fields[i];
10985 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
10987 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
10988 int nbOfEntriesToKill(DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg));
10989 std::vector<bool> b(_fields.size(),true);
10991 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
10993 if(k<0 || k>=(int)_fields.size())
10995 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
10996 throw INTERP_KERNEL::Exception(oss.str());
11000 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
11002 for(std::size_t i=0;i<_fields.size();i++)
11004 fields[j++]=_fields[i];
11008 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
11011 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11013 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
11015 ret=cur->changeMeshNames(modifTab) || ret;
11021 * \param [in] meshName the name of the mesh that will be renumbered.
11022 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
11023 * This code corresponds to the distribution of types in the corresponding mesh.
11024 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
11025 * \param [in] renumO2N the old to new renumber array.
11026 * \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
11027 * field in \a this.
11029 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
11032 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11034 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
11037 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
11044 * Return an extraction of \a this using \a extractDef map to specify the extraction.
11045 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
11047 * \return A new object that the caller is responsible to deallocate.
11049 MEDFileFields *MEDFileFields::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
11052 throw INTERP_KERNEL::Exception("MEDFileFields::extractPart : input mesh is NULL !");
11053 MCAuto<MEDFileFields> fsOut(MEDFileFields::New());
11054 int nbFields(getNumberOfFields());
11055 for(int i=0;i<nbFields;i++)
11057 MCAuto<MEDFileAnyTypeFieldMultiTS> fmts(getFieldAtPos(i));
11060 std::ostringstream oss; oss << "MEDFileFields::extractPart : at pos #" << i << " field is null !";
11061 throw INTERP_KERNEL::Exception(oss.str());
11063 MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(fmts->extractPart(extractDef,mm));
11064 fsOut->pushField(fmtsOut);
11066 return fsOut.retn();
11069 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
11071 if(i<0 || i>=(int)_fields.size())
11073 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
11074 throw INTERP_KERNEL::Exception(oss.str());
11076 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
11079 MCAuto<MEDFileAnyTypeFieldMultiTS> ret;
11080 const MEDFileFieldMultiTSWithoutSDA *fmtsC(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts));
11081 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts));
11083 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
11085 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
11088 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
11089 throw INTERP_KERNEL::Exception(oss.str());
11091 ret->shallowCpyGlobs(*this);
11096 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
11097 * This method is accessible in python using __getitem__ with a list in input.
11098 * \return a new object that the caller should deal with.
11100 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
11102 MCAuto<MEDFileFields> ret=shallowCpy();
11103 std::size_t sz=std::distance(startIds,endIds);
11104 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
11106 for(const int *i=startIds;i!=endIds;i++,j++)
11108 if(*i<0 || *i>=(int)_fields.size())
11110 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
11111 throw INTERP_KERNEL::Exception(oss.str());
11113 fields[j]=_fields[*i];
11115 ret->_fields=fields;
11119 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
11121 return getFieldAtPos(getPosFromFieldName(fieldName));
11125 * This method removes, if any, fields in \a this having no time steps.
11126 * 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.
11128 * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
11130 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
11132 std::vector<MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
11133 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11135 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
11138 if(elt->getNumberOfTS()>0)
11139 newFields.push_back(*it);
11142 if(_fields.size()==newFields.size())
11149 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
11150 * This method can be seen as a filter applied on \a this, that returns an object containing
11151 * 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
11152 * shallow copied from \a this.
11154 * \param [in] meshName - the name of the mesh on w
11155 * \return a new object that the caller should deal with.
11157 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
11159 MCAuto<MEDFileFields> ret(MEDFileFields::New());
11160 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11162 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
11165 if(cur->getMeshName()==meshName)
11168 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
11169 ret->_fields.push_back(cur2);
11172 ret->shallowCpyOnlyUsedGlobs(*this);
11177 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
11178 * Input time steps are specified using a pair of integer (iteration, order).
11179 * 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,
11180 * but for each multitimestep only the time steps in \a timeSteps are kept.
11181 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
11183 * The returned object points to shallow copy of elements in \a this.
11185 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
11186 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
11187 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
11189 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
11191 MCAuto<MEDFileFields> ret(MEDFileFields::New());
11192 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11194 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
11197 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
11198 ret->_fields.push_back(elt);
11200 ret->shallowCpyOnlyUsedGlobs(*this);
11205 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
11207 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
11209 MCAuto<MEDFileFields> ret=MEDFileFields::New();
11210 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11212 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
11215 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
11216 if(elt->getNumberOfTS()!=0)
11217 ret->_fields.push_back(elt);
11219 ret->shallowCpyOnlyUsedGlobs(*this);
11223 bool MEDFileFields::presenceOfStructureElements() const
11225 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11226 if((*it).isNotNull())
11227 if((*it)->presenceOfStructureElements())
11232 void MEDFileFields::killStructureElements()
11234 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
11235 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11236 if((*it).isNotNull())
11238 if((*it)->presenceOfStructureElements())
11240 if(!(*it)->onlyStructureElements())
11242 (*it)->killStructureElements();
11243 ret.push_back(*it);
11248 ret.push_back(*it);
11254 void MEDFileFields::keepOnlyStructureElements()
11256 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
11257 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11258 if((*it).isNotNull())
11260 if((*it)->presenceOfStructureElements())
11262 if(!(*it)->onlyStructureElements())
11263 (*it)->keepOnlyStructureElements();
11264 ret.push_back(*it);
11270 void MEDFileFields::keepOnlyOnMeshSE(const std::string& meshName, const std::string& seName)
11272 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
11273 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11274 if((*it).isNotNull())
11276 if((*it)->getMeshName()!=meshName)
11278 std::vector< std::pair<std::string,std::string> > ps;
11279 (*it)->getMeshSENames(ps);
11280 std::pair<std::string,std::string> p(meshName,seName);
11281 if(std::find(ps.begin(),ps.end(),p)!=ps.end())
11282 (*it)->keepOnlyOnSE(seName);
11283 ret.push_back(*it);
11288 void MEDFileFields::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
11290 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11291 if((*it).isNotNull())
11292 (*it)->getMeshSENames(ps);
11295 MCAuto<MEDFileFields> MEDFileFields::partOfThisOnStructureElements() const
11297 MCAuto<MEDFileFields> ret(deepCopy());
11298 ret->keepOnlyStructureElements();
11302 MCAuto<MEDFileFields> MEDFileFields::partOfThisLyingOnSpecifiedMeshSEName(const std::string& meshName, const std::string& seName) const
11304 MCAuto<MEDFileFields> ret(deepCopy());
11305 ret->keepOnlyOnMeshSE(meshName,seName);
11309 void MEDFileFields::aggregate(const MEDFileFields& other)
11311 int nbFieldsToAdd(other.getNumberOfFields());
11312 std::vector<std::string> fsn(getFieldsNames());
11313 for(int i=0;i<nbFieldsToAdd;i++)
11315 MCAuto<MEDFileAnyTypeFieldMultiTS> elt(other.getFieldAtPos(i));
11316 std::string name(elt->getName());
11317 if(std::find(fsn.begin(),fsn.end(),name)!=fsn.end())
11319 std::ostringstream oss; oss << "MEDFileFields::aggregate : name \"" << name << "\" already appears !";
11320 throw INTERP_KERNEL::Exception(oss.str());
11326 MEDFileFieldsIterator *MEDFileFields::iterator()
11328 return new MEDFileFieldsIterator(this);
11331 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
11333 std::string tmp(fieldName);
11334 std::vector<std::string> poss;
11335 for(std::size_t i=0;i<_fields.size();i++)
11337 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f(_fields[i]);
11340 std::string fname(f->getName());
11344 poss.push_back(fname);
11347 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
11348 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
11350 throw INTERP_KERNEL::Exception(oss.str());
11353 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
11358 _nb_iter=fs->getNumberOfFields();
11362 MEDFileFieldsIterator::~MEDFileFieldsIterator()
11366 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
11368 if(_iter_id<_nb_iter)
11370 MEDFileFields *fs(_fs);
11372 return fs->getFieldAtPos(_iter_id++);