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());
541 TypeOfField type(getType());
542 INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
544 med_geometry_type mgeoti;
545 med_entity_type menti(MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(type,geoType,mgeoti));
546 int zeNVal(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
547 _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
548 _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
549 const PartDefinition *pd(_pd);
556 if(!_profile.empty())
557 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively : profiles are not managed yet with part of def !");
558 _nval=pd->getNumberOfElems();
561 _end=start+_nval*nbi;
563 if(type==ON_CELLS && !_localization.empty())
565 if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
566 setType(ON_GAUSS_PT);
569 setType(ON_GAUSS_NE);
570 _localization.clear();
575 void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, const MEDFileFieldNameScope& nasc)
577 std::string fieldName(nasc.getName()),meshName(getMeshName());
578 int iteration(getIteration()),order(getOrder());
579 TypeOfField type(getType());
580 INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
581 med_geometry_type mgeoti;
582 med_entity_type menti(MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(type,geoType,mgeoti));
584 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !");
587 DataArray *arr(getOrCreateAndGetArray());//arr is not null due to the spec of getOrCreateAndGetArray
588 if(_start<0 || _start>=arr->getNumberOfTuples())
590 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << ") !";
591 throw INTERP_KERNEL::Exception(oss.str());
593 if(_end<0 || _end>arr->getNumberOfTuples())
595 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !";
596 throw INTERP_KERNEL::Exception(oss.str());
598 int nbOfCompo(arr->getNumberOfComponents());
599 DataArrayDouble *arrD(dynamic_cast<DataArrayDouble *>(arr));
602 double *startFeeding(arrD->getPointer()+_start*nbOfCompo);
603 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
606 DataArrayInt *arrI(dynamic_cast<DataArrayInt *>(arr));
609 int *startFeeding(arrI->getPointer()+_start*nbOfCompo);
610 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
613 throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
617 * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
619 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart)
621 int delta=_end-_start;
622 _start=newValueOfStart;
626 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
628 return _father->getIteration();
631 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
633 return _father->getOrder();
636 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
638 return _father->getTime();
641 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
643 return _father->getMeshName();
646 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
648 const char startLine[]=" ## ";
649 std::string startLine2(bkOffset,' ');
650 startLine2+=startLine;
651 MEDCouplingFieldDiscretization *tmp=MEDCouplingFieldDiscretization::New(_type);
652 oss << startLine2 << "Localization #" << id << "." << std::endl;
653 oss << startLine2 << " Type=" << tmp->getRepr() << "." << std::endl;
655 oss << startLine2 << " This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
656 oss << startLine2 << " This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
657 oss << startLine2 << " This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
660 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
665 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
667 return _father->getGeoType();
670 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
675 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
680 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
682 return _father->getNumberOfComponents();
685 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
690 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray()
692 return _father->getOrCreateAndGetArray();
695 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const
697 const MEDFileFieldPerMeshPerTypeCommon *fath=_father;
698 return fath->getOrCreateAndGetArray();
701 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
703 return _father->getInfo();
706 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
711 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const std::string& newPflName)
716 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
718 return _localization;
721 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const std::string& newLocName)
723 _localization=newLocName;
726 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
728 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
730 if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
732 _profile=(*it2).second;
738 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
740 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
742 if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
744 _localization=(*it2).second;
750 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
754 dads.push_back(std::pair<int,int>(_start,_end));
755 geoTypes.push_back(getGeoType());
760 pfls.push_back(glob->getProfile(_profile.c_str()));
762 if(_localization.empty())
766 locs.push_back(glob->getLocalizationId(_localization.c_str()));
770 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
772 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));
776 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
778 TypeOfField type=getType();
779 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
780 med_geometry_type mgeoti;
781 med_entity_type menti=MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(type,geoType,mgeoti);
782 const DataArray *arr=getOrCreateAndGetArray();
784 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
785 if(!arr->isAllocated())
786 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : the array to be written is not allocated !");
787 const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
788 const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
789 const unsigned char *locToWrite=0;
791 locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
793 locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
795 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
796 MEDFILESAFECALLERWR0(MEDfieldValueWithProfileWr,(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
797 MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
801 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const
806 dad.first=_start; dad.second=_end;
810 * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
811 * This code corresponds to the distribution of types in the corresponding mesh.
812 * \param [out] ptToFill memory zone where the output will be stored.
813 * \return the size of data pushed into output param \a ptToFill
815 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const
818 std::ostringstream oss;
819 std::size_t nbOfType=codeOfMesh.size()/3;
821 for(std::size_t i=0;i<nbOfType && found==-1;i++)
822 if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
826 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
827 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
828 throw INTERP_KERNEL::Exception(oss.str());
833 if(_nval!=codeOfMesh[3*found+1])
835 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
836 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
837 oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
838 throw INTERP_KERNEL::Exception(oss.str());
840 for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
845 const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
846 if(pfl->getNumberOfTuples()!=_nval)
848 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
849 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
851 oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
852 throw INTERP_KERNEL::Exception(oss.str());
854 int offset2=codeOfMesh[3*found+2];
855 for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
857 if(*pflId<codeOfMesh[3*found+1])
858 *work++=offset2+*pflId;
864 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const
866 for(int i=_start;i<_end;i++)
871 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId)
882 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
886 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
889 std::map<std::pair<std::string,TypeOfField>,int> m;
890 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
891 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
892 if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
893 m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
895 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
896 ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
901 * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
903 * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
904 * \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.
905 * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
906 * \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)
907 * \param [in,out] glob if necessary by the method, new profiles can be added to it
908 * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
909 * \param [out] result All new entries will be appended on it.
910 * \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 !)
912 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
913 const DataArrayInt *explicitIdsInMesh,
914 const std::vector<int>& newCode,
915 MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
916 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >& result)
918 if(entriesOnSameDisc.empty())
920 TypeOfField type=entriesOnSameDisc[0]->getType();
921 int szEntities=0,szTuples=0;
922 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
923 { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
924 int nbi=szTuples/szEntities;
925 if(szTuples%szEntities!=0)
926 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
927 MCAuto<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
928 MCAuto<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
929 std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
930 std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
931 std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
932 std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
933 MCAuto<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
935 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
937 int startOfEltIdOfChunk=(*it)->_start;
938 MCAuto<DataArrayInt> newEltIds=explicitIdsInMesh->subArray(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
939 MCAuto<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
940 MCAuto<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
942 MCAuto<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
943 newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
945 newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
946 newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
948 MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
949 MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
950 MCAuto<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
951 MCAuto<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
953 MCAuto<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
955 MCAuto<DataArrayDouble> arrPart=arr->subArray(offset,offset+szTuples);
956 arrPart->renumberInPlace(renumTupleIds->begin());
957 arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
959 const int *idIt=diffVals->begin();
960 std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
962 for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
964 MCAuto<DataArrayInt> ids=newGeoTypesEltIdsAllGather->findIdsEqual(*idIt);
965 MCAuto<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
966 int nbEntityElts=subIds->getNumberOfTuples();
968 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
969 NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIota(newCode[3*(*idIt)+1]),nbi,
973 result.push_back(eltToAdd);
974 offset2+=nbEntityElts*nbi;
976 ret=ret || li.empty();
981 * \param [in] typeF type of field of new chunk
982 * \param [in] geoType the geometric type of the chunk
983 * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
984 * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
985 * \param [in] nbi number of integration points
986 * \param [in] offset The offset in the **global array of data**.
987 * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
988 * to the new chunk to create.
989 * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
990 * \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
991 * and corresponding entry erased from \a entriesOnSameDisc.
992 * \return a newly allocated chunk
994 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
995 bool isPfl, int nbi, int offset,
996 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
997 MEDFileFieldGlobsReal& glob,
1000 int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
1001 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
1002 for(;it!=entriesOnSameDisc.end();it++)
1004 if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
1008 if((*it)->_profile.empty())
1011 if(!(*it)->_profile.empty())
1013 const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
1014 if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
1020 if(it==entriesOnSameDisc.end())
1023 MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
1025 ret->_loc_id=(int)geoType;
1026 ret->_nval=nbMeshEntities;
1028 ret->_end=ret->_start+ret->_nval*nbi;
1031 idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
1032 glob.appendProfile(idsOfMeshElt);
1033 ret->_profile=idsOfMeshElt->getName();
1035 //tony treatment of localization
1040 notInExisting=false;
1041 MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1042 ret->_loc_id=(int)geoType;
1043 ret->setNewStart(offset);
1044 entriesOnSameDisc.erase(it);
1050 ////////////////////////////////////
1052 MEDFileFieldPerMeshPerTypeCommon::~MEDFileFieldPerMeshPerTypeCommon()
1056 void MEDFileFieldPerMeshPerTypeCommon::setFather(MEDFileFieldPerMesh *father)
1061 void MEDFileFieldPerMeshPerTypeCommon::deepCopyElements()
1064 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1066 if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
1067 _field_pm_pt_pd[i]=(*it)->deepCopy(this);
1071 std::size_t MEDFileFieldPerMeshPerTypeCommon::getHeapMemorySizeWithoutChildren() const
1073 return _field_pm_pt_pd.capacity()*sizeof(MCAuto<MEDFileFieldPerMeshPerTypePerDisc>);
1076 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypeCommon::getDirectChildrenWithNull() const
1078 std::vector<const BigMemoryObject *> ret;
1079 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1080 ret.push_back((const MEDFileFieldPerMeshPerTypePerDisc *)*it);
1084 void MEDFileFieldPerMeshPerTypeCommon::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1086 std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
1087 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1088 _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1092 * This method is the most general one. No optimization is done here.
1093 * \param [in] multiTypePfl is the end user profile specified in high level API
1094 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1095 * \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.
1096 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1097 * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1098 * \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.
1100 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)
1102 std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1103 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1104 _field_pm_pt_pd[*it]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1107 void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1109 _field_pm_pt_pd.resize(1);
1110 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1111 _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1114 void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1116 MCAuto<DataArrayInt> pfl2=pfl->deepCopy();
1117 if(!arr || !arr->isAllocated())
1118 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile : input array is null, or not allocated !");
1119 _field_pm_pt_pd.resize(1);
1120 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1121 _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.
1124 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1126 TypeOfField type=field->getTypeOfField();
1127 if(type!=ON_GAUSS_PT)
1129 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1130 int sz=_field_pm_pt_pd.size();
1132 for(int j=0;j<sz && !found;j++)
1134 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1136 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1142 _field_pm_pt_pd.resize(sz+1);
1143 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1145 std::vector<int> ret(1,(int)sz);
1150 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1151 int sz2=ret2.size();
1152 std::vector<int> ret3(sz2);
1154 for(int i=0;i<sz2;i++)
1156 int sz=_field_pm_pt_pd.size();
1157 int locIdToFind=ret2[i];
1159 for(int j=0;j<sz && !found;j++)
1161 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1163 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1170 _field_pm_pt_pd.resize(sz+1);
1171 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1179 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1181 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1182 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1184 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1185 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1187 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1188 MCAuto<DataArrayInt> da2=da->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1);
1189 MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1190 if(retTmp->presenceOfValue(-1))
1191 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1192 std::vector<int> ret(retTmp->begin(),retTmp->end());
1196 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1198 TypeOfField type=field->getTypeOfField();
1199 if(type!=ON_GAUSS_PT)
1201 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1202 int sz=_field_pm_pt_pd.size();
1204 for(int j=0;j<sz && !found;j++)
1206 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1208 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1214 _field_pm_pt_pd.resize(sz+1);
1215 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1217 std::vector<int> ret(1,0);
1222 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1223 int sz2=ret2.size();
1224 std::vector<int> ret3(sz2);
1226 for(int i=0;i<sz2;i++)
1228 int sz=_field_pm_pt_pd.size();
1229 int locIdToFind=ret2[i];
1231 for(int j=0;j<sz && !found;j++)
1233 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1235 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1242 _field_pm_pt_pd.resize(sz+1);
1243 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1251 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1253 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1254 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1256 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1257 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1259 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1260 MCAuto<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1261 MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1262 if(retTmp->presenceOfValue(-1))
1263 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1264 std::vector<int> ret(retTmp->begin(),retTmp->end());
1268 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerTypeCommon::getFather() const
1273 bool MEDFileFieldPerMeshPerTypeCommon::isUniqueLevel(int& dim) const
1275 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
1276 int curDim((int)cm.getDimension());
1277 if(dim!=std::numeric_limits<int>::max())
1287 void MEDFileFieldPerMeshPerTypeCommon::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1289 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1291 (*it)->fillTypesOfFieldAvailable(types);
1295 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
1297 int sz=_field_pm_pt_pd.size();
1298 dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1299 for(int i=0;i<sz;i++)
1301 _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1305 int MEDFileFieldPerMeshPerTypeCommon::getIteration() const
1307 return _father->getIteration();
1310 int MEDFileFieldPerMeshPerTypeCommon::getOrder() const
1312 return _father->getOrder();
1315 double MEDFileFieldPerMeshPerTypeCommon::getTime() const
1317 return _father->getTime();
1320 std::string MEDFileFieldPerMeshPerTypeCommon::getMeshName() const
1322 return _father->getMeshName();
1325 void MEDFileFieldPerMeshPerTypeCommon::getSizes(int& globalSz, int& nbOfEntries) const
1327 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1329 globalSz+=(*it)->getNumberOfTuples();
1331 nbOfEntries+=(int)_field_pm_pt_pd.size();
1334 int MEDFileFieldPerMeshPerTypeCommon::getNumberOfComponents() const
1336 return _father->getNumberOfComponents();
1339 bool MEDFileFieldPerMeshPerTypeCommon::presenceOfMultiDiscPerGeoType() const
1342 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1344 const MEDFileFieldPerMeshPerTypePerDisc *fmtd(*it);
1351 DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray()
1353 return _father->getOrCreateAndGetArray();
1356 const DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray() const
1358 const MEDFileFieldPerMesh *fath=_father;
1359 return fath->getOrCreateAndGetArray();
1362 const std::vector<std::string>& MEDFileFieldPerMeshPerTypeCommon::getInfo() const
1364 return _father->getInfo();
1367 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsed() const
1369 std::vector<std::string> ret;
1370 std::set<std::string> ret2;
1371 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1373 std::string tmp=(*it1)->getProfile();
1375 if(ret2.find(tmp)==ret2.end())
1384 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsed() const
1386 std::vector<std::string> ret;
1387 std::set<std::string> ret2;
1388 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1390 std::string tmp=(*it1)->getLocalization();
1391 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1392 if(ret2.find(tmp)==ret2.end())
1401 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsedMulti() const
1403 std::vector<std::string> ret;
1404 std::set<std::string> ret2;
1405 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1407 std::string tmp=(*it1)->getProfile();
1414 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsedMulti() const
1416 std::vector<std::string> ret;
1417 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1419 std::string tmp=(*it1)->getLocalization();
1420 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1426 void MEDFileFieldPerMeshPerTypeCommon::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1428 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1429 (*it1)->changePflsRefsNamesGen(mapOfModif);
1432 void MEDFileFieldPerMeshPerTypeCommon::changeLocsRefsNamesGen(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)->changeLocsRefsNamesGen(mapOfModif);
1438 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId)
1440 if(_field_pm_pt_pd.empty())
1442 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << getGeoTypeRepr() << "\" !";
1443 throw INTERP_KERNEL::Exception(oss.str());
1445 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1446 return _field_pm_pt_pd[locId];
1447 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
1448 oss2 << ") for geometric type \"" << getGeoTypeRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1449 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1450 return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1453 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId) const
1455 if(_field_pm_pt_pd.empty())
1457 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << getGeoTypeRepr() << "\" !";
1458 throw INTERP_KERNEL::Exception(oss.str());
1460 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1461 return _field_pm_pt_pd[locId];
1462 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
1463 oss2 << ") for geometric type \"" << getGeoTypeRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1464 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1465 return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1468 void MEDFileFieldPerMeshPerTypeCommon::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1471 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1473 (*it)->fillValues(i,startEntryId,entries);
1477 void MEDFileFieldPerMeshPerTypeCommon::setLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
1479 _field_pm_pt_pd=leaves;
1480 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1481 (*it)->setFather(this);
1485 * \param [in,out] globalNum a global numbering counter for the renumbering.
1486 * \param [out] its - list of pair (start,stop) kept
1487 * \return bool - false if the type of field \a tof is not contained in \a this.
1489 bool MEDFileFieldPerMeshPerTypeCommon::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
1492 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1493 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1494 if((*it)->getType()==tof)
1496 newPmPtPd.push_back(*it);
1497 std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1498 (*it)->setNewStart(globalNum);
1499 globalNum=(*it)->getEnd();
1500 its.push_back(bgEnd);
1504 _field_pm_pt_pd=newPmPtPd;
1509 * \param [in,out] globalNum a global numbering counter for the renumbering.
1510 * \param [out] its - list of pair (start,stop) kept
1511 * \return bool - false if the type of field \a tof is not contained in \a this.
1513 bool MEDFileFieldPerMeshPerTypeCommon::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
1515 if(_field_pm_pt_pd.size()<=idOfDisc)
1517 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt(_field_pm_pt_pd[idOfDisc]);
1518 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd(1,elt);
1519 std::pair<int,int> bgEnd; bgEnd.first=_field_pm_pt_pd[idOfDisc]->getStart(); bgEnd.second=_field_pm_pt_pd[idOfDisc]->getEnd();
1520 elt->setNewStart(globalNum);
1521 globalNum=elt->getEnd();
1522 its.push_back(bgEnd);
1523 _field_pm_pt_pd=newPmPtPd;
1527 void MEDFileFieldPerMeshPerTypeCommon::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
1529 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1530 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1533 void MEDFileFieldPerMeshPerTypeCommon::loadBigArraysRecursively(med_idt fid, 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)->loadBigArray(fid,nasc);
1539 void MEDFileFieldPerMeshPerTypeCommon::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1541 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1543 (*it)->copyOptionsFrom(*this);
1544 (*it)->writeLL(fid,nasc);
1548 med_entity_type MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1553 medfGeoType=typmai3[(int)ikGeoType];
1556 medfGeoType=MED_NONE;
1559 medfGeoType=typmai3[(int)ikGeoType];
1560 return MED_NODE_ELEMENT;
1562 medfGeoType=typmai3[(int)ikGeoType];
1565 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1567 return MED_UNDEF_ENTITY_TYPE;
1570 //////////////////////////////////////////////////
1572 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd)
1574 return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc,pd);
1577 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType)
1579 return new MEDFileFieldPerMeshPerType(fath,geoType);
1582 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCopy(MEDFileFieldPerMesh *father) const
1584 MCAuto<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
1585 ret->setFather(father);
1586 ret->deepCopyElements();
1590 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
1592 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1594 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1595 if(meshDim!=(int)cm.getDimension())
1598 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1599 (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1602 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1607 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1609 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1610 int curDim((int)cm.getDimension());
1611 dim=std::max(dim,curDim);
1614 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1616 const char startLine[]=" ## ";
1617 std::string startLine2(bkOffset,' ');
1618 std::string startLine3(startLine2);
1619 startLine3+=startLine;
1620 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1622 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1623 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1626 oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1627 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1629 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1631 const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1633 cur->simpleRepr(bkOffset,oss,i);
1636 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1641 std::string MEDFileFieldPerMeshPerType::getGeoTypeRepr() const
1643 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1644 return std::string(cm.getRepr());
1647 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *father, INTERP_KERNEL::NormalizedCellType gt):MEDFileFieldPerMeshPerTypeCommon(father),_geo_type(gt)
1651 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):MEDFileFieldPerMeshPerTypeCommon(fath),_geo_type(geoType)
1653 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1654 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1655 med_geometry_type mgeoti;
1656 med_entity_type menti(ConvertIntoMEDFileType(type,geoType,mgeoti));
1657 int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName));
1658 _field_pm_pt_pd.resize(nbProfiles);
1659 for(int i=0;i<nbProfiles;i++)
1661 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i,pd);
1665 int nbProfiles2(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName));
1666 for(int i=0;i<nbProfiles2;i++)
1667 _field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i,pd));
1671 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)
1673 MCAuto<MEDFileFieldPerMeshPerType> ret(MEDFileFieldPerMeshPerType::New(father,gt));
1674 std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > > m;
1675 for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerType *> >::const_iterator it=pms.begin();it!=pms.end();it++)
1677 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it2=(*it).second->_field_pm_pt_pd.begin();it2!=(*it).second->_field_pm_pt_pd.end();it2++)
1678 m[(*it2)->getType()].push_back(std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * >((*it).first,*it2));
1680 for(std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > >::const_iterator it=m.begin();it!=m.end();it++)
1682 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> agg(MEDFileFieldPerMeshPerTypePerDisc::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
1683 ret->_field_pm_pt_pd.push_back(agg);
1688 //////////////////////////////////////////////////
1690 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const MEDFileEntities *entities)
1692 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm,entities);
1695 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1697 return new MEDFileFieldPerMesh(fath,mesh);
1700 std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
1702 return _mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MCAuto< MEDFileFieldPerMeshPerType >);
1705 std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildrenWithNull() const
1707 std::vector<const BigMemoryObject *> ret;
1708 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1713 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCopy(MEDFileAnyTypeField1TSWithoutSDA *father) const
1715 MCAuto< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1716 ret->_father=father;
1718 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1720 if((*it).isNotNull())
1721 ret->_field_pm_pt[i]=(*it)->deepCopy((MEDFileFieldPerMesh *)(ret));
1726 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1728 std::string startLine(bkOffset,' ');
1729 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1730 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1732 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1734 if((*it).isNotNull())
1735 (*it)->simpleRepr(bkOffset,oss,i);
1738 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1743 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh)
1745 _mesh_name=mesh->getName();
1746 mesh->getTime(_mesh_iteration,_mesh_order);
1749 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1751 int nbOfTypes=code.size()/3;
1753 for(int i=0;i<nbOfTypes;i++)
1755 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1756 int nbOfCells=code[3*i+1];
1757 int pos=addNewEntryIfNecessary(type);
1758 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1764 * This method is the most general one. No optimization is done here.
1765 * \param [in] multiTypePfl is the end user profile specified in high level API
1766 * \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].
1767 * \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.
1768 * \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.
1769 * \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.
1770 * \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.
1772 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)
1774 int nbOfTypes(code.size()/3);
1775 for(int i=0;i<nbOfTypes;i++)
1777 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1778 int pos=addNewEntryIfNecessary(type);
1779 DataArrayInt *pfl=0;
1781 pfl=idsPerType[code[3*i+2]];
1782 int nbOfTupes2=code2.size()/3;
1784 for(;found<nbOfTupes2;found++)
1785 if(code[3*i]==code2[3*found])
1787 if(found==nbOfTupes2)
1788 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1789 _field_pm_pt[pos]->assignFieldProfile(nbOfTypes==1,start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1793 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1795 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1796 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1799 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1801 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1802 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1805 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
1807 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1808 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1811 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1813 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1814 (*it)->loadBigArraysRecursively(fid,nasc);
1817 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1819 int nbOfTypes=_field_pm_pt.size();
1820 for(int i=0;i<nbOfTypes;i++)
1822 _field_pm_pt[i]->copyOptionsFrom(*this);
1823 _field_pm_pt[i]->writeLL(fid,nasc);
1827 void MEDFileFieldPerMesh::getDimension(int& dim) const
1829 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1830 (*it)->getDimension(dim);
1833 bool MEDFileFieldPerMesh::isUniqueLevel(int& dim) const
1835 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1836 if(!(*it)->isUniqueLevel(dim))
1841 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1843 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1844 (*it)->fillTypesOfFieldAvailable(types);
1847 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
1849 int sz=_field_pm_pt.size();
1850 std::vector< std::vector<std::pair<int,int> > > ret(sz);
1851 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1852 for(int i=0;i<sz;i++)
1854 types[i]=_field_pm_pt[i]->getGeoType();
1855 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1860 double MEDFileFieldPerMesh::getTime() const
1863 return _father->getTime(tmp1,tmp2);
1866 int MEDFileFieldPerMesh::getIteration() const
1868 return _father->getIteration();
1871 int MEDFileFieldPerMesh::getOrder() const
1873 return _father->getOrder();
1876 int MEDFileFieldPerMesh::getNumberOfComponents() const
1878 return _father->getNumberOfComponents();
1881 bool MEDFileFieldPerMesh::presenceOfMultiDiscPerGeoType() const
1883 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1887 if((*it)->presenceOfMultiDiscPerGeoType())
1893 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
1896 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1897 return _father->getOrCreateAndGetArray();
1900 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
1903 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1904 return _father->getOrCreateAndGetArray();
1907 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1909 return _father->getInfo();
1913 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
1914 * 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.
1915 * It returns 2 output vectors :
1916 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
1917 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
1918 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
1920 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)
1922 int notNullPflsSz=0;
1923 int nbOfArrs=geoTypes.size();
1924 for(int i=0;i<nbOfArrs;i++)
1927 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
1928 int nbOfDiffGeoTypes=geoTypes3.size();
1929 code.resize(3*nbOfDiffGeoTypes);
1930 notNullPfls.resize(notNullPflsSz);
1933 for(int i=0;i<nbOfDiffGeoTypes;i++)
1936 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
1937 std::vector<const DataArrayInt *> notNullTmp;
1939 notNullTmp.push_back(pfls[j]);
1941 for(;j<nbOfArrs;j++)
1942 if(geoTypes[j]==refType)
1945 notNullTmp.push_back(pfls[j]);
1949 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
1950 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
1951 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
1952 code[3*i]=(int)refType;
1953 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
1954 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
1955 if(notNullTmp.empty())
1959 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
1960 code[3*i+2]=notNullPflsSz++;
1966 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
1968 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)
1972 for(int i=0;i<sz;i++)
1976 if(type!=ON_GAUSS_NE)
1977 ret+=dads[i].second-dads[i].first;
1980 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
1981 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
1986 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
1987 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
1993 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
1995 std::vector<std::string> ret;
1996 std::set<std::string> ret2;
1997 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1999 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
2000 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
2001 if(ret2.find(*it2)==ret2.end())
2003 ret.push_back(*it2);
2010 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
2012 std::vector<std::string> ret;
2013 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2015 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
2016 ret.insert(ret.end(),tmp.begin(),tmp.end());
2021 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
2023 std::vector<std::string> ret;
2024 std::set<std::string> ret2;
2025 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2027 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
2028 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
2029 if(ret2.find(*it2)==ret2.end())
2031 ret.push_back(*it2);
2038 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
2040 std::vector<std::string> ret;
2041 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2043 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
2044 ret.insert(ret.end(),tmp.begin(),tmp.end());
2049 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
2051 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
2053 if((*it).first==_mesh_name)
2055 _mesh_name=(*it).second;
2062 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
2063 MEDFileFieldGlobsReal& glob)
2065 if(_mesh_name!=meshName)
2067 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
2068 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
2069 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
2070 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
2071 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
2072 getUndergroundDataArrayExt(entries);
2073 DataArray *arr0(getOrCreateAndGetArray());//tony
2075 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
2076 DataArrayDouble *arr(dynamic_cast<DataArrayDouble *>(arr0));//tony
2078 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
2081 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
2082 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
2084 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
2086 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2087 sz+=(*it).second.second-(*it).second.first;
2090 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2092 MCAuto<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
2093 ////////////////////
2094 MCAuto<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
2095 int *workI2=explicitIdsOldInMesh->getPointer();
2096 int sz1=0,sz2=0,sid=1;
2097 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
2098 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
2099 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
2101 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
2102 MCAuto<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
2103 int *workI=explicitIdsOldInArr->getPointer();
2104 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
2106 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
2107 (*itL2)->setLocId(sz2);
2108 (*itL2)->_tmp_work1=(*itL2)->getStart();
2109 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
2111 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
2113 explicitIdsOldInMesh->reAlloc(sz2);
2114 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
2115 ////////////////////
2116 MCAuto<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
2117 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
2118 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
2119 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
2121 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
2122 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
2123 otherEntriesNew.back()->setLocId((*it)->getGeoType());
2125 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
2126 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
2127 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
2129 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
2130 int newStart=elt->getLocId();
2131 elt->setLocId((*it)->getGeoType());
2132 elt->setNewStart(newStart);
2133 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
2134 entriesKeptNew.push_back(elt);
2135 entriesKeptNew2.push_back(elt);
2137 MCAuto<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
2138 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
2139 MCAuto<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
2140 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
2142 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
2145 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
2147 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
2148 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
2150 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
2151 glob,arr2,otherEntriesNew) || ret;
2155 // Assign new dispatching
2156 assignNewLeaves(otherEntriesNew);
2157 arr->deepCopyFrom(*arr2);
2162 * \param [in,out] globalNum a global numbering counter for the renumbering.
2163 * \param [out] its - list of pair (start,stop) kept
2165 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
2167 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > ret;
2168 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2170 std::vector< std::pair<int,int> > its2;
2171 if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
2174 its.insert(its.end(),its2.begin(),its2.end());
2181 * \param [in,out] globalNum a global numbering counter for the renumbering.
2182 * \param [out] its - list of pair (start,stop) kept
2184 void MEDFileFieldPerMesh::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
2186 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > ret;
2187 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2189 std::vector< std::pair<int,int> > its2;
2190 if((*it)->keepOnlyGaussDiscretization(idOfDisc,globalNum,its2))
2193 its.insert(its.end(),its2.begin(),its2.end());
2199 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
2201 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > > types;
2202 for( std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
2203 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
2205 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > fieldPmPt(types.size());
2206 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
2207 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it2=fieldPmPt.begin();
2208 for(;it1!=types.end();it1++,it2++)
2210 MCAuto<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
2211 elt->setLeaves((*it1).second);
2214 _field_pm_pt=fieldPmPt;
2217 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2219 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2220 (*it)->changePflsRefsNamesGen(mapOfModif);
2223 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2225 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2226 (*it)->changeLocsRefsNamesGen(mapOfModif);
2230 * \param [in] mesh is the whole mesh
2232 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2234 if(_field_pm_pt.empty())
2235 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2237 std::vector< std::pair<int,int> > dads;
2238 std::vector<const DataArrayInt *> pfls;
2239 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2240 std::vector<int> locs,code;
2241 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2242 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2243 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2245 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2248 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2249 throw INTERP_KERNEL::Exception(oss.str());
2252 std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2253 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2256 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2258 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2261 MCAuto<DataArrayInt> arr2(arr);
2262 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2268 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2272 if(nb!=mesh->getNumberOfNodes())
2274 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2275 oss << " nodes in mesh !";
2276 throw INTERP_KERNEL::Exception(oss.str());
2278 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2281 return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2285 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
2287 if(_field_pm_pt.empty())
2288 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2290 std::vector<std::pair<int,int> > dads;
2291 std::vector<const DataArrayInt *> pfls;
2292 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2293 std::vector<int> locs,code;
2294 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2295 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2296 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2298 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2301 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2302 throw INTERP_KERNEL::Exception(oss.str());
2304 std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2305 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2308 MCAuto<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2309 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2314 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2318 if(nb!=mesh->getNumberOfNodes())
2320 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2321 oss << " nodes in mesh !";
2322 throw INTERP_KERNEL::Exception(oss.str());
2325 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2331 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
2335 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2337 (*it)->getSizes(globalSz,nbOfEntries);
2339 entries.resize(nbOfEntries);
2341 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2343 (*it)->fillValues(nbOfEntries,entries);
2347 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
2349 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2351 if((*it)->getGeoType()==typ)
2352 return (*it)->getLeafGivenLocId(locId);
2354 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2355 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2356 oss << "Possiblities are : ";
2357 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2359 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2360 oss << "\"" << cm2.getRepr() << "\", ";
2362 throw INTERP_KERNEL::Exception(oss.str());
2365 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
2367 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2369 if((*it)->getGeoType()==typ)
2370 return (*it)->getLeafGivenLocId(locId);
2372 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2373 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2374 oss << "Possiblities are : ";
2375 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2377 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2378 oss << "\"" << cm2.getRepr() << "\", ";
2380 throw INTERP_KERNEL::Exception(oss.str());
2384 * \param [in,out] start - Integer that gives the current position in the final aggregated array
2385 * \param [in] pms - list of elements to aggregate. integer gives the mesh id
2386 * \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.
2387 * \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.
2389 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)
2391 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret(new MEDFileFieldPerMeshPerTypePerDisc(father,tof));
2393 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : empty input vector !");
2394 for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it=pms.begin();it!=pms.end();it++)
2397 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : presence of null pointer !");
2398 if(!(*it).second->getProfile().empty())
2399 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for profiles !");
2400 if(!(*it).second->getLocalization().empty())
2401 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for gauss pts !");
2403 INTERP_KERNEL::NormalizedCellType gt(pms[0].second->getGeoType());
2405 std::vector< std::pair<int,int> > filteredDTS;
2406 for(std::vector< std::vector< std::pair<int,int> > >::const_iterator it=dts.begin();it!=dts.end();it++,i++)
2407 for(std::vector< std::pair<int,int> >::const_iterator it2=(*it).begin();it2!=(*it).end();it2++)
2408 if((*it2).first==gt)
2409 filteredDTS.push_back(std::pair<int,int>(i,(*it2).second));
2410 if(pms.size()!=filteredDTS.size())
2411 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles !");
2412 std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it1(pms.begin());
2413 std::vector< std::pair<int,int> >::const_iterator it2(filteredDTS.begin());
2414 int zeStart(start),nval(0);
2415 for(;it1!=pms.end();it1++,it2++)
2417 if((*it1).first!=(*it2).first)
2418 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles 2 !");
2419 int s1((*it1).second->getStart()),e1((*it1).second->getEnd());
2420 extractInfo.push_back(std::pair<int, std::pair<int,int> >((*it1).first,std::pair<int,int>(s1,e1)));
2422 nval+=((*it1).second)->getNumberOfVals();
2424 ret->_start=zeStart; ret->_end=start; ret->_nval=nval;
2428 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)
2430 MCAuto<MEDFileFieldPerMesh> ret(new MEDFileFieldPerMesh(father,pms[0]->getMeshName(),pms[0]->getMeshIteration(),pms[0]->getMeshOrder()));
2431 std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > > m;
2433 for(std::vector<const MEDFileFieldPerMesh *>::const_iterator it=pms.begin();it!=pms.end();it++,i++)
2435 const std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >& v((*it)->_field_pm_pt);
2436 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it2=v.begin();it2!=v.end();it2++)
2438 INTERP_KERNEL::NormalizedCellType gt((*it2)->getGeoType());
2439 const MEDFileFieldPerMeshPerType *elt(dynamic_cast<const MEDFileFieldPerMeshPerType *>((const MEDFileFieldPerMeshPerTypeCommon *)(*it2)));
2441 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::Aggregate : not managed for structelement !");
2442 m[gt].push_back(std::pair<int,const MEDFileFieldPerMeshPerType *>(i,elt));
2445 for(std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > >::const_iterator it=m.begin();it!=m.end();it++)
2447 MCAuto<MEDFileFieldPerMeshPerTypeCommon> agg(MEDFileFieldPerMeshPerType::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
2448 ret->_field_pm_pt.push_back(agg);
2453 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2456 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2457 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it2=_field_pm_pt.begin();
2458 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2460 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2465 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2470 int ret=std::distance(_field_pm_pt.begin(),it2);
2471 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2476 * 'dads' and 'locs' input parameters have the same number of elements
2477 * \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
2479 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2480 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2481 const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2484 MCAuto<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2485 ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2486 MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2487 const std::vector<std::string>& infos=getInfo();
2488 da->setInfoOnComponents(infos);
2490 if(type==ON_GAUSS_PT)
2493 int nbOfArrs=dads.size();
2494 for(int i=0;i<nbOfArrs;i++)
2496 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2497 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2498 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2499 MCAuto<DataArrayInt> di=DataArrayInt::New();
2500 di->alloc(nbOfElems,1);
2502 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2503 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2512 * 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.
2513 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2514 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2515 * The order of cells in the returned field is those imposed by the profile.
2516 * \param [in] mesh is the global mesh.
2518 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2519 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2520 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2521 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2523 if(da->isIota(mesh->getNumberOfCells()))
2524 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2525 MCAuto<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2526 m2->setName(mesh->getName().c_str());
2527 MCAuto<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2533 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2535 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2536 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2537 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2539 if(da->isIota(mesh->getNumberOfNodes()))
2540 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2541 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2542 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2545 if(meshu->getNodalConnectivity()==0)
2547 MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2548 int nb=da->getNbOfElems();
2549 const int *ptr=da->getConstPointer();
2550 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2551 meshuc->allocateCells(nb);
2552 for(int i=0;i<nb;i++)
2553 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2554 meshuc->finishInsertingCells();
2555 ret->setMesh(meshuc);
2556 const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2557 if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2558 disc->checkCoherencyBetween(meshuc,arrOut);
2563 MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2565 DataArrayInt *arr2=0;
2566 MCAuto<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2567 MCAuto<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2568 MCAuto<DataArrayInt> arr3(arr2);
2569 int nnodes=mesh2->getNumberOfNodes();
2570 if(nnodes==(int)da->getNbOfElems())
2572 MCAuto<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2573 arrOut->renumberInPlace(da3->getConstPointer());
2574 mesh2->setName(mesh->getName().c_str());
2575 ret->setMesh(mesh2);
2580 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 !!!";
2581 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2582 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2583 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2584 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2585 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2586 throw INTERP_KERNEL::Exception(oss.str());
2592 * This method is the most light method of field retrieving.
2594 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
2598 pflOut=DataArrayInt::New();
2599 pflOut->alloc(nbOfElems,1);
2604 pflOut=const_cast<DataArrayInt*>(pflIn);
2607 MCAuto<DataArrayInt> safePfl(pflOut);
2608 MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2609 const std::vector<std::string>& infos=getInfo();
2610 int nbOfComp=infos.size();
2611 for(int i=0;i<nbOfComp;i++)
2612 da->setInfoOnComponent(i,infos[i].c_str());
2623 static MFFPMIter *NewCell(const MEDFileEntities *entities);
2624 static bool IsPresenceOfNode(const MEDFileEntities *entities);
2625 virtual ~MFFPMIter() { }
2626 virtual void begin() = 0;
2627 virtual bool finished() const = 0;
2628 virtual void next() = 0;
2629 virtual int current() const = 0;
2632 class MFFPMIterSimple : public MFFPMIter
2635 MFFPMIterSimple():_pos(0) { }
2636 void begin() { _pos=0; }
2637 bool finished() const { return _pos>=MED_N_CELL_FIXED_GEO; }
2638 void next() { _pos++; }
2639 int current() const { return _pos; }
2644 class MFFPMIter2 : public MFFPMIter
2647 MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts);
2648 void begin() { _it=_ids.begin(); }
2649 bool finished() const { return _it==_ids.end(); }
2650 void next() { _it++; }
2651 int current() const { return *_it; }
2653 std::vector<int> _ids;
2654 std::vector<int>::const_iterator _it;
2657 MFFPMIter *MFFPMIter::NewCell(const MEDFileEntities *entities)
2660 return new MFFPMIterSimple;
2663 const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
2666 std::vector<INTERP_KERNEL::NormalizedCellType> tmp;
2667 const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
2668 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
2670 if((*it).first==ON_CELLS || (*it).first==ON_GAUSS_NE || (*it).first==ON_GAUSS_PT)
2671 tmp.push_back((*it).second);
2673 return new MFFPMIter2(tmp);
2676 throw INTERP_KERNEL::Exception("MFFPMIter::NewCell : not recognized type !");
2680 bool MFFPMIter::IsPresenceOfNode(const MEDFileEntities *entities)
2686 const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
2689 const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
2690 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
2691 if((*it).first==ON_NODES)
2696 throw INTERP_KERNEL::Exception("MFFPMIter::IsPresenceOfNode : not recognized type !");
2700 MFFPMIter2::MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts)
2702 std::size_t sz(cts.size());
2704 for(std::size_t i=0;i<sz;i++)
2706 INTERP_KERNEL::NormalizedCellType *loc(std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,cts[i]));
2707 if(loc!=typmai2+MED_N_CELL_FIXED_GEO)
2708 _ids[i]=(int)std::distance(typmai2,loc);
2710 throw INTERP_KERNEL::Exception("MFFPMIter2 : The specified geo type does not exists !");
2716 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),
2719 INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2720 INTERP_KERNEL::AutoPtr<char> pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2721 INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2722 const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
2723 INTERP_KERNEL::AutoCppPtr<MFFPMIter> iter0(MFFPMIter::NewCell(entities));
2724 for(iter0->begin();!iter0->finished();iter0->next())
2726 int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL ,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2727 std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2728 int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2729 std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2730 if(nbProfile>0 || nbProfile2>0)
2732 const PartDefinition *pd(0);
2734 pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[iter0->current()]),typmai2[iter0->current()]);
2735 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nasc,pd));
2742 if(MFFPMIter::IsPresenceOfNode(entities))
2744 int nbProfile(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName));
2747 const PartDefinition *pd(0);
2749 pd=mmu->getPartDefAtLevel(1,INTERP_KERNEL::NORM_ERROR);
2750 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd));
2751 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2756 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2758 copyTinyInfoFrom(mesh);
2761 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
2763 if(id>=(int)_pfls.size())
2765 _pfls[id]=DataArrayInt::New();
2766 int lgth(MEDprofileSizeByName(fid,pflName.c_str()));
2767 _pfls[id]->setName(pflName);
2768 _pfls[id]->alloc(lgth,1);
2769 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName.c_str(),_pfls[id]->getPointer()));
2770 _pfls[id]->applyLin(1,-1,0);//Converting into C format
2773 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2775 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2777 MEDFILESAFECALLERRD0(MEDprofileInfo,(fid,i+1,pflName,&sz));
2778 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2779 if(i>=(int)_pfls.size())
2781 _pfls[i]=DataArrayInt::New();
2782 _pfls[i]->alloc(sz,1);
2783 _pfls[i]->setName(pflCpp.c_str());
2784 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName,_pfls[i]->getPointer()));
2785 _pfls[i]->applyLin(1,-1,0);//Converting into C format
2788 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
2790 int nbOfPfls=_pfls.size();
2791 for(int i=0;i<nbOfPfls;i++)
2793 MCAuto<DataArrayInt> cpy=_pfls[i]->deepCopy();
2794 cpy->applyLin(1,1,0);
2795 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2796 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2797 MEDFILESAFECALLERWR0(MEDprofileWr,(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer()));
2800 int nbOfLocs=_locs.size();
2801 for(int i=0;i<nbOfLocs;i++)
2802 _locs[i]->writeLL(fid);
2805 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
2807 std::vector<std::string> pfls=getPfls();
2808 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2810 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2813 _pfls.push_back(*it);
2817 int id=std::distance(pfls.begin(),it2);
2818 if(!(*it)->isEqual(*_pfls[id]))
2820 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2821 throw INTERP_KERNEL::Exception(oss.str());
2825 std::vector<std::string> locs=getLocs();
2826 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
2828 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2831 _locs.push_back(*it);
2835 int id=std::distance(locs.begin(),it2);
2836 if(!(*it)->isEqual(*_locs[id],eps))
2838 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2839 throw INTERP_KERNEL::Exception(oss.str());
2845 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
2847 for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
2848 getProfile((*it).c_str());
2851 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
2853 for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
2854 getLocalization((*it).c_str());
2857 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
2859 std::vector<std::string> profiles=real.getPflsReallyUsed();
2860 int sz=profiles.size();
2862 for(int i=0;i<sz;i++)
2863 loadProfileInFile(fid,i,profiles[i].c_str());
2865 std::vector<std::string> locs=real.getLocsReallyUsed();
2868 for(int i=0;i<sz;i++)
2869 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2872 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid)
2874 int nProfil=MEDnProfile(fid);
2875 for(int i=0;i<nProfil;i++)
2876 loadProfileInFile(fid,i);
2877 int sz=MEDnLocalization(fid);
2879 for(int i=0;i<sz;i++)
2881 _locs[i]=MEDFileFieldLoc::New(fid,i);
2885 MEDFileFieldGlobs *MEDFileFieldGlobs::New(med_idt fid)
2887 return new MEDFileFieldGlobs(fid);
2890 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2892 return new MEDFileFieldGlobs;
2895 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
2897 return _file_name.capacity()+_pfls.capacity()*sizeof(MCAuto<DataArrayInt>)+_locs.capacity()*sizeof(MCAuto<MEDFileFieldLoc>);
2900 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildrenWithNull() const
2902 std::vector<const BigMemoryObject *> ret;
2903 for(std::vector< MCAuto< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2904 ret.push_back((const DataArrayInt *)*it);
2905 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2906 ret.push_back((const MEDFileFieldLoc *)*it);
2910 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCopy() const
2912 MCAuto<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
2914 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2916 if((const DataArrayInt *)*it)
2917 ret->_pfls[i]=(*it)->deepCopy();
2920 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2922 if((const MEDFileFieldLoc*)*it)
2923 ret->_locs[i]=(*it)->deepCopy();
2929 * \throw if a profile in \a pfls in not in \a this.
2930 * \throw if a localization in \a locs in not in \a this.
2931 * \sa MEDFileFieldGlobs::deepCpyPart
2933 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2935 MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2936 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2938 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2940 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
2942 MCAuto<DataArrayInt> pfl2(pfl);
2943 ret->_pfls.push_back(pfl2);
2945 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2947 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2949 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
2951 MCAuto<MEDFileFieldLoc> loc2(loc);
2952 ret->_locs.push_back(loc2);
2954 ret->setFileName(getFileName());
2959 * \throw if a profile in \a pfls in not in \a this.
2960 * \throw if a localization in \a locs in not in \a this.
2961 * \sa MEDFileFieldGlobs::shallowCpyPart
2963 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2965 MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2966 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2968 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2970 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
2971 ret->_pfls.push_back(pfl->deepCopy());
2973 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2975 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2977 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
2978 ret->_locs.push_back(loc->deepCopy());
2980 ret->setFileName(getFileName());
2984 MEDFileFieldGlobs::MEDFileFieldGlobs(med_idt fid):_file_name(MEDFileWritable::FileNameFromFID(fid))
2988 MEDFileFieldGlobs::MEDFileFieldGlobs()
2992 MEDFileFieldGlobs::~MEDFileFieldGlobs()
2996 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
2998 oss << "Profiles :\n";
2999 std::size_t n=_pfls.size();
3000 for(std::size_t i=0;i<n;i++)
3002 oss << " - #" << i << " ";
3003 const DataArrayInt *pfl=_pfls[i];
3005 oss << "\"" << pfl->getName() << "\"\n";
3010 oss << "Localizations :\n";
3011 for(std::size_t i=0;i<n;i++)
3013 oss << " - #" << i << " ";
3014 const MEDFileFieldLoc *loc=_locs[i];
3016 loc->simpleRepr(oss);
3022 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3024 for(std::vector< MCAuto<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
3026 DataArrayInt *elt(*it);
3029 std::string name(elt->getName());
3030 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3032 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3034 elt->setName((*it2).second.c_str());
3042 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3044 for(std::vector< MCAuto<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
3046 MEDFileFieldLoc *elt(*it);
3049 std::string name(elt->getName());
3050 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3052 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3054 elt->setName((*it2).second.c_str());
3062 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
3064 if(locId<0 || locId>=(int)_locs.size())
3065 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
3066 return _locs[locId]->getNbOfGaussPtPerCell();
3069 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
3071 return getLocalizationFromId(getLocalizationId(locName));
3074 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
3076 if(locId<0 || locId>=(int)_locs.size())
3077 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3078 return *_locs[locId];
3082 namespace MEDCouplingImpl
3087 LocFinder(const std::string& loc):_loc(loc) { }
3088 bool operator() (const MCAuto<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
3090 const std::string &_loc;
3096 PflFinder(const std::string& pfl):_pfl(pfl) { }
3097 bool operator() (const MCAuto<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
3099 const std::string& _pfl;
3104 int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
3106 std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),MEDCouplingImpl::LocFinder(loc));
3109 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
3110 for(it=_locs.begin();it!=_locs.end();it++)
3111 oss << "\"" << (*it)->getName() << "\", ";
3112 throw INTERP_KERNEL::Exception(oss.str());
3114 return std::distance(_locs.begin(),it);
3118 * The returned value is never null.
3120 const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
3122 std::string pflNameCpp(pflName);
3123 std::vector< MCAuto<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3126 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3127 for(it=_pfls.begin();it!=_pfls.end();it++)
3128 oss << "\"" << (*it)->getName() << "\", ";
3129 throw INTERP_KERNEL::Exception(oss.str());
3134 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
3136 if(pflId<0 || pflId>=(int)_pfls.size())
3137 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3138 return _pfls[pflId];
3141 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
3143 if(locId<0 || locId>=(int)_locs.size())
3144 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3145 return *_locs[locId];
3148 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
3150 return getLocalizationFromId(getLocalizationId(locName));
3154 * The returned value is never null.
3156 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
3158 std::string pflNameCpp(pflName);
3159 std::vector< MCAuto<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3162 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3163 for(it=_pfls.begin();it!=_pfls.end();it++)
3164 oss << "\"" << (*it)->getName() << "\", ";
3165 throw INTERP_KERNEL::Exception(oss.str());
3170 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
3172 if(pflId<0 || pflId>=(int)_pfls.size())
3173 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3174 return _pfls[pflId];
3177 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
3179 std::vector< MCAuto<DataArrayInt> > newPfls;
3181 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3183 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
3184 newPfls.push_back(*it);
3189 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
3191 std::vector< MCAuto<MEDFileFieldLoc> > newLocs;
3193 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3195 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
3196 newLocs.push_back(*it);
3201 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
3203 int sz=_pfls.size();
3204 std::vector<std::string> ret(sz);
3205 for(int i=0;i<sz;i++)
3206 ret[i]=_pfls[i]->getName();
3210 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
3212 int sz=_locs.size();
3213 std::vector<std::string> ret(sz);
3214 for(int i=0;i<sz;i++)
3215 ret[i]=_locs[i]->getName();
3219 bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
3221 std::vector<std::string> v=getPfls();
3222 std::string s(pflName);
3223 return std::find(v.begin(),v.end(),s)!=v.end();
3226 bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
3228 std::vector<std::string> v=getLocs();
3229 std::string s(locName);
3230 return std::find(v.begin(),v.end(),s)!=v.end();
3233 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
3235 std::map<int,std::vector<int> > m;
3237 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3239 const DataArrayInt *tmp=(*it);
3242 m[tmp->getHashCode()].push_back(i);
3245 std::vector< std::vector<int> > ret;
3246 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
3248 if((*it2).second.size()>1)
3250 std::vector<int> ret0;
3251 bool equalityOrNot=false;
3252 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
3254 std::vector<int>::const_iterator it4=it3; it4++;
3255 for(;it4!=(*it2).second.end();it4++)
3257 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
3260 ret0.push_back(*it3);
3261 ret0.push_back(*it4);
3267 ret.push_back(ret0);
3273 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
3275 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
3278 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
3280 std::string name(pfl->getName());
3282 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
3283 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3284 if(name==(*it)->getName())
3286 if(!pfl->isEqual(*(*it)))
3288 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
3289 throw INTERP_KERNEL::Exception(oss.str());
3293 _pfls.push_back(pfl);
3296 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)
3298 std::string name(locName);
3300 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
3301 MCAuto<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
3302 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3303 if((*it)->isName(locName))
3305 if(!(*it)->isEqual(*obj,1e-12))
3307 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
3308 throw INTERP_KERNEL::Exception(oss.str());
3311 _locs.push_back(obj);
3314 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
3316 std::vector<std::string> names=getPfls();
3317 return CreateNewNameNotIn("NewPfl_",names);
3320 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
3322 std::vector<std::string> names=getLocs();
3323 return CreateNewNameNotIn("NewLoc_",names);
3326 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
3328 for(std::size_t sz=0;sz<100000;sz++)
3330 std::ostringstream tryName;
3331 tryName << prefix << sz;
3332 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
3333 return tryName.str();
3335 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
3339 * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
3340 * \param [in] fname - the file name.
3342 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(med_idt fid):_globals(MEDFileFieldGlobs::New(fid))
3347 * Creates an empty MEDFileFieldGlobsReal.
3349 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
3353 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
3358 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildrenWithNull() const
3360 std::vector<const BigMemoryObject *> ret;
3361 ret.push_back((const MEDFileFieldGlobs *)_globals);
3366 * Returns a string describing profiles and Gauss points held in \a this.
3367 * \return std::string - the description string.
3369 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
3371 const MEDFileFieldGlobs *glob=_globals;
3372 std::ostringstream oss2; oss2 << glob;
3373 std::string stars(oss2.str().length(),'*');
3374 oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n";
3376 glob->simpleRepr(oss);
3378 oss << "NO GLOBAL INFORMATION !\n";
3381 void MEDFileFieldGlobsReal::resetContent()
3383 _globals=MEDFileFieldGlobs::New();
3386 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
3391 * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
3392 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3394 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3396 _globals=other._globals;
3400 * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3401 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3403 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3405 const MEDFileFieldGlobs *otherg(other._globals);
3408 _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3412 * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3413 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3415 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3417 const MEDFileFieldGlobs *otherg(other._globals);
3420 _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3423 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3425 _globals=other._globals;
3426 if((const MEDFileFieldGlobs *)_globals)
3427 _globals=other._globals->deepCopy();
3431 * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3432 * \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3433 * \param [in] eps - a precision used to compare Gauss points with same name held by
3434 * \a this and \a other MEDFileFieldGlobsReal.
3435 * \throw If \a this and \a other hold profiles with equal names but different ids.
3436 * \throw If \a this and \a other hold different Gauss points with equal names.
3438 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
3440 const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3441 if(thisGlobals==otherGlobals)
3445 _globals=other._globals;
3448 _globals->appendGlobs(*other._globals,eps);
3451 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
3453 checkGlobsPflsPartCoherency();
3454 checkGlobsLocsPartCoherency();
3457 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
3459 contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3462 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
3464 contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3467 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3469 contentNotNull()->loadProfileInFile(fid,id,pflName);
3472 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3474 contentNotNull()->loadProfileInFile(fid,id);
3477 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
3479 contentNotNull()->loadGlobals(fid,*this);
3482 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid)
3484 contentNotNull()->loadAllGlobals(fid);
3487 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3489 contentNotNull()->writeGlobals(fid,opt);
3493 * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3494 * or getPflsReallyUsedMulti().
3495 * \return std::vector<std::string> - a sequence of names of all profiles.
3497 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3499 return contentNotNull()->getPfls();
3503 * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3504 * or getLocsReallyUsedMulti().
3505 * \return std::vector<std::string> - a sequence of names of all localizations.
3507 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3509 return contentNotNull()->getLocs();
3513 * Checks if the profile with a given name exists.
3514 * \param [in] pflName - the profile name of interest.
3515 * \return bool - \c true if the profile named \a pflName exists.
3517 bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
3519 return contentNotNull()->existsPfl(pflName);
3523 * Checks if the localization with a given name exists.
3524 * \param [in] locName - the localization name of interest.
3525 * \return bool - \c true if the localization named \a locName exists.
3527 bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
3529 return contentNotNull()->existsLoc(locName);
3532 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
3534 return contentNotNull()->createNewNameOfPfl();
3537 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
3539 return contentNotNull()->createNewNameOfLoc();
3543 * Sets the name of a MED file.
3544 * \param [inout] fileName - the file name.
3546 void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
3548 contentNotNull()->setFileName(fileName);
3552 * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3553 * in the same order.
3554 * \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3555 * Each item of this sequence is a vector containing ids of equal profiles.
3557 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3559 return contentNotNull()->whichAreEqualProfiles();
3563 * Finds equal localizations.
3564 * \param [in] eps - a precision used to compare real values of the localizations.
3565 * \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3566 * Each item of this sequence is a vector containing ids of equal localizations.
3568 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3570 return contentNotNull()->whichAreEqualLocs(eps);
3574 * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3575 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3576 * this sequence is a pair whose
3577 * - the first item is a vector of profile names to replace by the second item,
3578 * - the second item is a profile name to replace every profile name of the first item.
3580 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3582 contentNotNull()->changePflsNamesInStruct(mapOfModif);
3586 * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3587 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3588 * this sequence is a pair whose
3589 * - the first item is a vector of localization names to replace by the second item,
3590 * - the second item is a localization name to replace every localization name of the first item.
3592 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3594 contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3598 * Replaces references to some profiles (a reference is a profile name) by references
3599 * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3600 * them-selves accordingly. <br>
3601 * This method is a generalization of changePflName().
3602 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3603 * this sequence is a pair whose
3604 * - the first item is a vector of profile names to replace by the second item,
3605 * - the second item is a profile name to replace every profile of the first item.
3606 * \sa changePflsRefsNamesGen()
3607 * \sa changePflName()
3609 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3611 changePflsRefsNamesGen(mapOfModif);
3612 changePflsNamesInStruct(mapOfModif);
3616 * Replaces references to some localizations (a reference is a localization name) by references
3617 * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3618 * them-selves accordingly. <br>
3619 * This method is a generalization of changeLocName().
3620 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3621 * this sequence is a pair whose
3622 * - the first item is a vector of localization names to replace by the second item,
3623 * - the second item is a localization name to replace every localization of the first item.
3624 * \sa changeLocsRefsNamesGen()
3625 * \sa changeLocName()
3627 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3629 changeLocsRefsNamesGen(mapOfModif);
3630 changeLocsNamesInStruct(mapOfModif);
3634 * Renames the profile having a given name and updates references to this profile.
3635 * \param [in] oldName - the name of the profile to rename.
3636 * \param [in] newName - a new name of the profile.
3637 * \sa changePflsNames().
3639 void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
3641 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3642 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3644 changePflsNames(mapOfModif);
3648 * Renames the localization having a given name and updates references to this localization.
3649 * \param [in] oldName - the name of the localization to rename.
3650 * \param [in] newName - a new name of the localization.
3651 * \sa changeLocsNames().
3653 void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
3655 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3656 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3658 changeLocsNames(mapOfModif);
3662 * Removes duplicated profiles. Returns a map used to update references to removed
3663 * profiles via changePflsRefsNamesGen().
3664 * Equal profiles are found using whichAreEqualProfiles().
3665 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3666 * a sequence describing the performed replacements of profiles. Each element of
3667 * this sequence is a pair whose
3668 * - the first item is a vector of profile names replaced by the second item,
3669 * - the second item is a profile name replacing every profile of the first item.
3671 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
3673 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3674 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3676 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3678 std::vector< std::string > tmp((*it).size());
3680 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3681 tmp[j]=std::string(getProfileFromId(*it2)->getName());
3682 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3684 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3685 killProfileIds(tmp2);
3687 changePflsRefsNamesGen(ret);
3692 * Removes duplicated localizations. Returns a map used to update references to removed
3693 * localizations via changeLocsRefsNamesGen().
3694 * Equal localizations are found using whichAreEqualLocs().
3695 * \param [in] eps - a precision used to compare real values of the localizations.
3696 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3697 * a sequence describing the performed replacements of localizations. Each element of
3698 * this sequence is a pair whose
3699 * - the first item is a vector of localization names replaced by the second item,
3700 * - the second item is a localization name replacing every localization of the first item.
3702 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
3704 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3705 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3707 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3709 std::vector< std::string > tmp((*it).size());
3711 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3712 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3713 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3715 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3716 killLocalizationIds(tmp2);
3718 changeLocsRefsNamesGen(ret);
3723 * Returns number of Gauss points per cell in a given localization.
3724 * \param [in] locId - an id of the localization of interest.
3725 * \return int - the number of the Gauss points per cell.
3727 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
3729 return contentNotNull()->getNbOfGaussPtPerCell(locId);
3733 * Returns an id of a localization by its name.
3734 * \param [in] loc - the localization name of interest.
3735 * \return int - the id of the localization.
3736 * \throw If there is no a localization named \a loc.
3738 int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
3740 return contentNotNull()->getLocalizationId(loc);
3744 * Returns the name of the MED file.
3745 * \return const std::string& - the MED file name.
3747 std::string MEDFileFieldGlobsReal::getFileName() const
3749 return contentNotNull()->getFileName();
3753 * Returns a localization object by its name.
3754 * \param [in] locName - the name of the localization of interest.
3755 * \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3756 * \throw If there is no a localization named \a locName.
3758 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
3760 return contentNotNull()->getLocalization(locName);
3764 * Returns a localization object by its id.
3765 * \param [in] locId - the id of the localization of interest.
3766 * \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3767 * \throw If there is no a localization with id \a locId.
3769 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
3771 return contentNotNull()->getLocalizationFromId(locId);
3775 * Returns a profile array by its name.
3776 * \param [in] pflName - the name of the profile of interest.
3777 * \return const DataArrayInt * - the profile array having the name \a pflName.
3778 * \throw If there is no a profile named \a pflName.
3780 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
3782 return contentNotNull()->getProfile(pflName);
3786 * Returns a profile array by its id.
3787 * \param [in] pflId - the id of the profile of interest.
3788 * \return const DataArrayInt * - the profile array having the id \a pflId.
3789 * \throw If there is no a profile with id \a pflId.
3791 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
3793 return contentNotNull()->getProfileFromId(pflId);
3797 * Returns a localization object, apt for modification, by its id.
3798 * \param [in] locId - the id of the localization of interest.
3799 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3800 * having the id \a locId.
3801 * \throw If there is no a localization with id \a locId.
3803 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
3805 return contentNotNull()->getLocalizationFromId(locId);
3809 * Returns a localization object, apt for modification, by its name.
3810 * \param [in] locName - the name of the localization of interest.
3811 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3812 * having the name \a locName.
3813 * \throw If there is no a localization named \a locName.
3815 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
3817 return contentNotNull()->getLocalization(locName);
3821 * Returns a profile array, apt for modification, by its name.
3822 * \param [in] pflName - the name of the profile of interest.
3823 * \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3824 * \throw If there is no a profile named \a pflName.
3826 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
3828 return contentNotNull()->getProfile(pflName);
3832 * Returns a profile array, apt for modification, by its id.
3833 * \param [in] pflId - the id of the profile of interest.
3834 * \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3835 * \throw If there is no a profile with id \a pflId.
3837 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
3839 return contentNotNull()->getProfileFromId(pflId);
3843 * Removes profiles given by their ids. No data is updated to track this removal.
3844 * \param [in] pflIds - a sequence of ids of the profiles to remove.
3846 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
3848 contentNotNull()->killProfileIds(pflIds);
3852 * Removes localizations given by their ids. No data is updated to track this removal.
3853 * \param [in] locIds - a sequence of ids of the localizations to remove.
3855 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
3857 contentNotNull()->killLocalizationIds(locIds);
3861 * Stores a profile array.
3862 * \param [in] pfl - the profile array to store.
3863 * \throw If the name of \a pfl is empty.
3864 * \throw If a profile with the same name as that of \a pfl already exists but contains
3867 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
3869 contentNotNull()->appendProfile(pfl);
3873 * Adds a new localization of Gauss points.
3874 * \param [in] locName - the name of the new localization.
3875 * \param [in] geoType - a geometrical type of the reference cell.
3876 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
3877 * must be \c nbOfNodesPerCell * \c dimOfType.
3878 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
3879 * must be _wg_.size() * \c dimOfType.
3880 * \param [in] w - the weights of Gauss points.
3881 * \throw If \a locName is empty.
3882 * \throw If a localization with the name \a locName already exists but is
3883 * different form the new one.
3885 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)
3887 contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
3890 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
3892 MEDFileFieldGlobs *g(_globals);
3894 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
3898 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
3900 const MEDFileFieldGlobs *g(_globals);
3902 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
3906 //= MEDFileFieldNameScope
3908 MEDFileFieldNameScope::MEDFileFieldNameScope()
3912 MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName):_name(fieldName)
3917 * Returns the name of \a this field.
3918 * \return std::string - a string containing the field name.
3920 std::string MEDFileFieldNameScope::getName() const
3926 * Sets name of \a this field
3927 * \param [in] name - the new field name.
3929 void MEDFileFieldNameScope::setName(const std::string& fieldName)
3934 std::string MEDFileFieldNameScope::getDtUnit() const
3939 void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
3944 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
3947 _dt_unit=other._dt_unit;
3950 //= MEDFileAnyTypeField1TSWithoutSDA
3952 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
3954 _field_per_mesh.resize(other._field_per_mesh.size());
3956 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
3958 if((const MEDFileFieldPerMesh *)*it)
3959 _field_per_mesh[i]=(*it)->deepCopy(this);
3964 * Prints a string describing \a this field into a stream. This string is outputted
3965 * by \c print Python command.
3966 * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
3967 * \param [in,out] oss - the out stream.
3968 * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
3969 * info id printed, else, not.
3971 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
3973 std::string startOfLine(bkOffset,' ');
3974 oss << startOfLine << "Field ";
3976 oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
3977 oss << "on one time Step ";
3979 oss << "(" << f1tsId << ") ";
3980 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
3981 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
3982 const DataArray *arr=getUndergroundDataArray();
3985 const std::vector<std::string> &comps=arr->getInfoOnComponents();
3988 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
3989 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
3990 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
3992 if(arr->isAllocated())
3994 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
3997 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
4001 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
4003 oss << startOfLine << "----------------------" << std::endl;
4004 if(!_field_per_mesh.empty())
4007 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
4009 const MEDFileFieldPerMesh *cur=(*it2);
4011 cur->simpleRepr(bkOffset,oss,i);
4013 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
4018 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
4020 oss << startOfLine << "----------------------" << std::endl;
4023 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
4025 const DataArray *arr(getUndergroundDataArray());
4027 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
4028 int nbOfCompo=arr->getNumberOfComponents();
4029 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
4030 for(int i=0;i<nbOfCompo;i++)
4033 std::vector<int> v(1,i);
4034 MCAuto<DataArray> arr2=arr->keepSelectedComponents(v);
4035 ret[i]->setArray(arr2);
4040 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)
4044 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
4049 * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
4050 * empty. Returns -1 if this in on nodes.
4051 * \return int - the dimension of \a this.
4053 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
4056 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4057 (*it)->getDimension(ret);
4062 * Returns the mesh name.
4063 * \return std::string - a string holding the mesh name.
4064 * \throw If \c _field_per_mesh.empty()
4066 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const
4068 if(_field_per_mesh.empty())
4069 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
4070 return _field_per_mesh[0]->getMeshName();
4073 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const std::string& newMeshName)
4075 std::string oldName(getMeshName());
4076 std::vector< std::pair<std::string,std::string> > v(1);
4077 v[0].first=oldName; v[0].second=newMeshName;
4081 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
4084 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4086 MEDFileFieldPerMesh *cur(*it);
4088 ret=cur->changeMeshNames(modifTab) || ret;
4094 * Returns the number of iteration of the state of underlying mesh.
4095 * \return int - the iteration number.
4096 * \throw If \c _field_per_mesh.empty()
4098 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
4100 if(_field_per_mesh.empty())
4101 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
4102 return _field_per_mesh[0]->getMeshIteration();
4106 * Returns the order number of iteration of the state of underlying mesh.
4107 * \return int - the order number.
4108 * \throw If \c _field_per_mesh.empty()
4110 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
4112 if(_field_per_mesh.empty())
4113 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
4114 return _field_per_mesh[0]->getMeshOrder();
4118 * Checks if \a this field is tagged by a given iteration number and a given
4119 * iteration order number.
4120 * \param [in] iteration - the iteration number of interest.
4121 * \param [in] order - the iteration order number of interest.
4122 * \return bool - \c true if \a this->getIteration() == \a iteration &&
4123 * \a this->getOrder() == \a order.
4125 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
4127 return iteration==_iteration && order==_order;
4131 * Returns number of iteration and order number of iteration when
4132 * \a this field has been calculated.
4133 * \return std::pair<int,int> - a pair of the iteration number and the iteration
4136 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
4138 std::pair<int,int> p;
4144 * Returns number of iteration and order number of iteration when
4145 * \a this field has been calculated.
4146 * \param [in,out] p - a pair returning the iteration number and the iteration
4149 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
4156 * Returns all types of spatial discretization of \a this field.
4157 * \param [in,out] types - a sequence of types of \a this field.
4159 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
4161 std::set<TypeOfField> types2;
4162 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4164 (*it)->fillTypesOfFieldAvailable(types2);
4166 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
4167 std::copy(types2.begin(),types2.end(),bi);
4171 * Returns all types of spatial discretization of \a this field.
4172 * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
4175 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
4177 std::vector<TypeOfField> ret;
4178 fillTypesOfFieldAvailable(ret);
4182 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
4184 std::vector<std::string> ret;
4185 std::set<std::string> ret2;
4186 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4188 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
4189 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4190 if(ret2.find(*it2)==ret2.end())
4192 ret.push_back(*it2);
4199 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
4201 std::vector<std::string> ret;
4202 std::set<std::string> ret2;
4203 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4205 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
4206 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4207 if(ret2.find(*it2)==ret2.end())
4209 ret.push_back(*it2);
4216 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
4218 std::vector<std::string> ret;
4219 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4221 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
4222 ret.insert(ret.end(),tmp.begin(),tmp.end());
4227 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
4229 std::vector<std::string> ret;
4230 std::set<std::string> ret2;
4231 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4233 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
4234 ret.insert(ret.end(),tmp.begin(),tmp.end());
4239 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4241 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4242 (*it)->changePflsRefsNamesGen(mapOfModif);
4245 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4247 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4248 (*it)->changeLocsRefsNamesGen(mapOfModif);
4252 * Returns all attributes of parts of \a this field lying on a given mesh.
4253 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4254 * item of every of returned sequences refers to the _i_-th part of \a this field.
4255 * Thus all sequences returned by this method are of the same length equal to number
4256 * of different types of supporting entities.<br>
4257 * A field part can include sub-parts with several different spatial discretizations,
4258 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
4259 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4260 * of a nested sequence corresponds to a type of spatial discretization.<br>
4261 * This method allows for iteration over MEDFile DataStructure without any overhead.
4262 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4263 * for the case with only one underlying mesh. (Actually, the number of meshes is
4264 * not checked if \a mname == \c NULL).
4265 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4266 * a field part is returned.
4267 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4268 * This sequence is of the same length as \a types.
4269 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4270 * discretization. A profile name can be empty.
4271 * Length of this and of nested sequences is the same as that of \a typesF.
4272 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4273 * discretization. A localization name can be empty.
4274 * Length of this and of nested sequences is the same as that of \a typesF.
4275 * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
4276 * of ids of tuples within the data array, per each type of spatial
4277 * discretization within one mesh entity type.
4278 * Length of this and of nested sequences is the same as that of \a typesF.
4279 * \throw If no field is lying on \a mname.
4281 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
4285 meshId=getMeshIdFromMeshName(mname);
4287 if(_field_per_mesh.empty())
4288 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4289 return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4293 * Returns dimensions of mesh elements \a this field lies on. The returned value is a
4294 * maximal absolute dimension and values returned via the out parameter \a levs are
4295 * dimensions relative to the maximal absolute dimension. <br>
4296 * This method is designed for MEDFileField1TS instances that have a discretization
4297 * \ref MEDCoupling::ON_CELLS "ON_CELLS",
4298 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT",
4299 * \ref MEDCoupling::ON_GAUSS_NE "ON_GAUSS_NE".
4300 * Only these 3 discretizations will be taken into account here. If \a this is
4301 * \ref MEDCoupling::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
4302 * This method is useful to make the link between the dimension of the underlying mesh
4303 * and the levels of \a this, because it is possible that the highest dimension of \a this
4304 * field is not equal to the dimension of the underlying mesh.
4306 * Let's consider the following case:
4307 * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
4308 * TETRA4, HEXA8, TRI3 and SEG2.
4309 * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
4310 * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
4312 * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
4313 * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
4314 * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
4315 * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
4316 * parameter of getFieldAtLevel() is computed basing on the returned values as this:
4317 * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
4319 * to retrieve the highest level of
4320 * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br>
4321 * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
4322 * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
4323 * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
4324 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4325 * for the case with only one underlying mesh. (Actually, the number of meshes is
4326 * not checked if \a mname == \c NULL).
4327 * \param [in,out] levs - a sequence returning the dimensions relative to the maximal
4328 * absolute one. They are in decreasing order. This sequence is cleared before
4330 * \return int - the maximal absolute dimension of elements \a this fields lies on.
4331 * \throw If no field is lying on \a mname.
4333 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
4336 int meshId=getMeshIdFromMeshName(mname);
4337 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4338 std::vector< std::vector<TypeOfField> > typesF;
4339 std::vector< std::vector<std::string> > pfls, locs;
4340 _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4342 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
4343 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
4344 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
4346 st.erase(INTERP_KERNEL::NORM_ERROR);
4348 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
4350 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
4351 ret1.insert((int)cm.getDimension());
4353 int ret=*std::max_element(ret1.begin(),ret1.end());
4354 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
4355 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
4360 * \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.
4361 * \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.
4362 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4363 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4365 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
4367 int mid=getMeshIdFromMeshName(mName);
4368 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4372 * \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.
4373 * \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.
4374 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4375 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4377 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
4379 int mid=getMeshIdFromMeshName(mName);
4380 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4384 * \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.
4386 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
4388 if(_field_per_mesh.empty())
4389 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4392 std::string mName2(mName);
4394 std::vector<std::string> msg;
4395 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4396 if(mName2==(*it)->getMeshName())
4399 msg.push_back((*it)->getMeshName());
4400 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4401 oss << "Possible meshes are : ";
4402 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4403 oss << "\"" << (*it2) << "\" ";
4404 throw INTERP_KERNEL::Exception(oss.str());
4407 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
4410 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4411 std::string tmp(mesh->getName());
4413 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4414 std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4416 for(;it!=_field_per_mesh.end();it++,i++)
4418 if((*it)->getMeshName()==tmp)
4421 int sz=_field_per_mesh.size();
4422 _field_per_mesh.resize(sz+1);
4423 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4427 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4428 MEDFileFieldGlobsReal& glob)
4431 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4433 MEDFileFieldPerMesh *fpm(*it);
4435 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4441 * This method splits \a this into several sub-parts so that each sub parts have exactly one spatial discretization. This method implements the minimal
4442 * splitting that leads to single spatial discretization of this.
4444 * \sa splitMultiDiscrPerGeoTypes
4446 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
4448 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4449 std::vector< std::vector<TypeOfField> > typesF;
4450 std::vector< std::vector<std::string> > pfls,locs;
4451 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4452 std::set<TypeOfField> allEnt;
4453 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4454 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4455 allEnt.insert(*it2);
4456 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4457 std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4458 for(std::size_t i=0;i<allEnt.size();i++,it3++)
4460 std::vector< std::pair<int,int> > its;
4461 ret[i]=shallowCpy();
4462 int newLgth(ret[i]->keepOnlySpatialDiscretization(*it3,its));
4463 ret[i]->updateData(newLgth,its);
4469 * This method performs a sub splitting as splitDiscretizations does but finer. This is the finest spliting level that can be done.
4470 * This method implements the minimal splitting so that each returned elements are mono Gauss discretization per geometric type.
4472 * \sa splitDiscretizations
4474 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes() const
4476 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4477 std::vector< std::vector<TypeOfField> > typesF;
4478 std::vector< std::vector<std::string> > pfls,locs;
4479 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4480 std::set<TypeOfField> allEnt;
4481 std::size_t nbOfMDPGT(0),ii(0);
4482 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++,ii++)
4484 nbOfMDPGT=std::max(nbOfMDPGT,locs[ii].size());
4485 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4486 allEnt.insert(*it2);
4488 if(allEnt.size()!=1)
4489 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : this field is expected to be defined only on one spatial discretization !");
4491 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
4494 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret0(1);
4495 ret0[0]=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(this); this->incrRef();
4498 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfMDPGT);
4499 for(std::size_t i=0;i<nbOfMDPGT;i++)
4501 std::vector< std::pair<int,int> > its;
4502 ret[i]=shallowCpy();
4503 int newLgth(ret[i]->keepOnlyGaussDiscretization(i,its));
4504 ret[i]->updateData(newLgth,its);
4509 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
4511 int globalCounter(0);
4512 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4513 (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4514 return globalCounter;
4517 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlyGaussDiscretization(std::size_t idOfDisc, std::vector< std::pair<int,int> >& its)
4519 int globalCounter(0);
4520 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4521 (*it)->keepOnlyGaussDiscretization(idOfDisc,globalCounter,its);
4522 return globalCounter;
4525 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
4527 if(_nb_of_tuples_to_be_allocated>=0)
4529 _nb_of_tuples_to_be_allocated=newLgth;
4530 const DataArray *oldArr(getUndergroundDataArray());
4533 MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4534 newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
4536 _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
4540 if(_nb_of_tuples_to_be_allocated==-1)
4542 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4544 const DataArray *oldArr(getUndergroundDataArray());
4545 if(!oldArr || !oldArr->isAllocated())
4546 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4547 MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4548 newArr->alloc(newLgth,getNumberOfComponents());
4550 newArr->copyStringInfoFrom(*oldArr);
4552 for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4554 if((*it).second<(*it).first)
4555 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4556 newArr->setContigPartOfSelectedValuesSlice(pos,oldArr,(*it).first,(*it).second,1);
4557 pos+=(*it).second-(*it).first;
4562 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4565 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
4567 if(_field_per_mesh.empty())
4568 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4569 if(_field_per_mesh.size()>1)
4570 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4571 _field_per_mesh[0]->copyOptionsFrom(opts);
4572 _field_per_mesh[0]->writeLL(fid,nasc);
4576 * 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.
4577 * If false is returned the memory allocation is not required.
4579 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
4581 if(_nb_of_tuples_to_be_allocated>=0)
4583 getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4584 _nb_of_tuples_to_be_allocated=-2;
4587 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4589 if(_nb_of_tuples_to_be_allocated==-1)
4590 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4591 if(_nb_of_tuples_to_be_allocated<-3)
4592 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4593 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4596 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
4598 med_int numdt,numit;
4602 med_int meshnumdt,meshnumit;
4603 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4604 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt));
4605 MEDFILESAFECALLERRD0(MEDfield23ComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit));
4606 if(_iteration!=numdt || _order!=numit)
4607 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4608 _field_per_mesh.resize(nmesh);
4613 std::string meshNameCpp(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
4614 mm=ms->getMeshWithName(meshNameCpp);
4617 for(int i=0;i<nmesh;i++)
4618 _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i,meshnumdt,meshnumit,nasc,mm,entities);
4619 _nb_of_tuples_to_be_allocated=0;
4620 for(int i=0;i<nmesh;i++)
4621 _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4624 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
4626 allocIfNecessaryTheArrayToReceiveDataFromFile();
4627 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4628 (*it)->loadBigArraysRecursively(fid,nasc);
4631 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
4633 if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4634 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4635 (*it)->loadBigArraysRecursively(fid,nasc);
4638 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
4640 loadOnlyStructureOfDataRecursively(fid,nasc,ms,entities);
4641 loadBigArraysRecursively(fid,nasc);
4644 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
4646 DataArray *thisArr(getUndergroundDataArray());
4647 if(thisArr && thisArr->isAllocated())
4649 _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
4650 thisArr->desallocate();
4654 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
4656 return _dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MCAuto< MEDFileFieldPerMesh >);
4659 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
4661 std::vector<const BigMemoryObject *> ret;
4662 if(getUndergroundDataArray())
4663 ret.push_back(getUndergroundDataArray());
4664 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4665 ret.push_back((const MEDFileFieldPerMesh *)*it);
4670 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4671 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4672 * "Sort By Type"), if not, an exception is thrown.
4673 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
4674 * \param [in] arr - the array of values.
4675 * \param [in,out] glob - the global data where profiles and localization present in
4676 * \a field, if any, are added.
4677 * \throw If the name of \a field is empty.
4678 * \throw If the data array of \a field is not set.
4679 * \throw If \a this->_arr is already allocated but has different number of components
4681 * \throw If the underlying mesh of \a field has no name.
4682 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4684 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4686 const MEDCouplingMesh *mesh=field->getMesh();
4688 TypeOfField type=field->getTypeOfField();
4689 std::vector<DataArrayInt *> dummy;
4690 int start=copyTinyInfoFrom(field,arr);
4691 int pos=addNewEntryIfNecessary(mesh);
4694 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4695 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4698 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4702 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4703 * of a given mesh are used as the support of the given field (a real support is not used).
4704 * Elements of the given mesh must be sorted suitable for writing to MED file.
4705 * Order of underlying mesh entities of the given field specified by \a profile parameter
4706 * is not prescribed; this method permutes field values to have them sorted by element
4707 * type as required for writing to MED file. A new profile is added only if no equal
4708 * profile is missing.
4709 * \param [in] field - the field to add to \a this. The field double values are ignored.
4710 * \param [in] arrOfVals - the values of the field \a field used.
4711 * \param [in] mesh - the supporting mesh of \a field.
4712 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4713 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
4714 * \param [in,out] glob - the global data where profiles and localization present in
4715 * \a field, if any, are added.
4716 * \throw If either \a field or \a mesh or \a profile has an empty name.
4717 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4718 * \throw If the data array of \a field is not set.
4719 * \throw If \a this->_arr is already allocated but has different number of components
4721 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4722 * \sa setFieldNoProfileSBT()
4724 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4727 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
4728 if(!arrOfVals || !arrOfVals->isAllocated())
4729 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
4730 TypeOfField type=field->getTypeOfField();
4731 std::vector<DataArrayInt *> idsInPflPerType;
4732 std::vector<DataArrayInt *> idsPerType;
4733 std::vector<int> code,code2;
4734 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
4737 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4738 std::vector< MCAuto<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
4739 std::vector< MCAuto<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin());
4740 std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
4742 MCAuto<MEDCouplingFieldDouble> field2=field->clone(false);
4743 int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
4744 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4746 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4747 throw INTERP_KERNEL::Exception(oss.str());
4750 int start=copyTinyInfoFrom(field,arrOfVals);
4751 code2=m->getDistributionOfTypes();
4753 int pos=addNewEntryIfNecessary(m);
4754 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4758 if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
4759 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
4760 std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
4761 std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
4762 int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
4763 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4765 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4766 throw INTERP_KERNEL::Exception(oss.str());
4768 int start=copyTinyInfoFrom(field,arrOfVals);
4769 int pos=addNewEntryIfNecessary(m);
4770 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4775 * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
4777 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
4779 if(_nb_of_tuples_to_be_allocated>=0)
4780 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 !");
4781 DataArray *arr(getOrCreateAndGetArray());
4782 arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
4783 _nb_of_tuples_to_be_allocated=-3;
4787 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4788 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4789 * larger by the size of \a field. Returns an id of the first not filled
4790 * tuple of \a this->_arr.
4791 * \param [in] field - the field to copy the info on components and the name from.
4792 * \return int - the id of first not initialized tuple of \a this->_arr.
4793 * \throw If the name of \a field is empty.
4794 * \throw If the data array of \a field is not set.
4795 * \throw If \a this->_arr is already allocated but has different number of components
4798 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
4801 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4802 std::string name(field->getName());
4803 setName(name.c_str());
4804 setDtUnit(field->getTimeUnit());
4806 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4808 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4809 if(!arr->isAllocated())
4810 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
4811 _dt=field->getTime(_iteration,_order);
4812 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4813 if(!getOrCreateAndGetArray()->isAllocated())
4815 allocNotFromFile(arr->getNumberOfTuples());
4820 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4821 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4822 getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
4823 _nb_of_tuples_to_be_allocated=-3;
4824 return oldNbOfTuples;
4829 * Returns number of components in \a this field
4830 * \return int - the number of components.
4832 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4834 return getOrCreateAndGetArray()->getNumberOfComponents();
4838 * Change info on components in \a this.
4839 * \throw If size of \a infos is not equal to the number of components already in \a this.
4841 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
4843 DataArray *arr=getOrCreateAndGetArray();
4844 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
4848 * Returns info on components of \a this field.
4849 * \return const std::vector<std::string>& - a sequence of strings each being an
4850 * information on _i_-th component.
4852 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
4854 const DataArray *arr=getOrCreateAndGetArray();
4855 return arr->getInfoOnComponents();
4859 * Returns a mutable info on components of \a this field.
4860 * \return std::vector<std::string>& - a sequence of strings each being an
4861 * information on _i_-th component.
4863 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
4865 DataArray *arr=getOrCreateAndGetArray();
4866 return arr->getInfoOnComponents();
4869 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const
4871 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4873 const MEDFileFieldPerMesh *fpm(*it);
4876 if(fpm->presenceOfMultiDiscPerGeoType())
4882 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh(const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4884 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 !";
4885 if(_field_per_mesh.empty())
4886 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is empty ! Nothing to extract !");
4887 if(_field_per_mesh.size()>1)
4888 throw INTERP_KERNEL::Exception(MSG0);
4889 if(_field_per_mesh[0].isNull())
4890 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is inconsistent !");
4891 const MEDFileFieldPerMesh *pm(_field_per_mesh[0]);
4892 std::set<TypeOfField> types;
4893 pm->fillTypesOfFieldAvailable(types);
4895 throw INTERP_KERNEL::Exception(MSG0);
4896 TypeOfField type(*types.begin());
4897 int meshDimRelToMax(0);
4902 int myDim(std::numeric_limits<int>::max());
4903 bool isUnique(pm->isUniqueLevel(myDim));
4905 throw INTERP_KERNEL::Exception(MSG0);
4906 meshDimRelToMax=myDim-mesh->getMeshDimension();
4907 if(meshDimRelToMax>0)
4908 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the mesh attached to field is not compatible with the field !");
4910 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,0/*renumPol*/,glob,mesh,arrOut,nasc);
4914 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4915 * \param [in] type - a spatial discretization of the new field.
4916 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4917 * \param [in] mName - a name of the supporting mesh.
4918 * \param [in] renumPol - specifies how to permute values of the result field according to
4919 * the optional numbers of cells and nodes, if any. The valid values are
4920 * - 0 - do not permute.
4921 * - 1 - permute cells.
4922 * - 2 - permute nodes.
4923 * - 3 - permute cells and nodes.
4925 * \param [in] glob - the global data storing profiles and localization.
4926 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4927 * caller is to delete this field using decrRef() as it is no more needed.
4928 * \throw If the MED file is not readable.
4929 * \throw If there is no mesh named \a mName in the MED file.
4930 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4931 * \throw If no field of \a this is lying on the mesh \a mName.
4932 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4934 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4936 MCAuto<MEDFileMesh> mm;
4938 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4940 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4941 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4945 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4946 * \param [in] type - a spatial discretization of the new field.
4947 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4948 * \param [in] renumPol - specifies how to permute values of the result field according to
4949 * the optional numbers of cells and nodes, if any. The valid values are
4950 * - 0 - do not permute.
4951 * - 1 - permute cells.
4952 * - 2 - permute nodes.
4953 * - 3 - permute cells and nodes.
4955 * \param [in] glob - the global data storing profiles and localization.
4956 * \param [in] mesh - the supporting mesh.
4957 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4958 * caller is to delete this field using decrRef() as it is no more needed.
4959 * \throw If the MED file is not readable.
4960 * \throw If no field of \a this is lying on \a mesh.
4961 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4962 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4964 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4966 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax,false));
4967 const DataArrayInt *d(mesh->getNumberFieldAtLevel(meshDimRelToMax)),*e(mesh->getNumberFieldAtLevel(1));
4968 if(meshDimRelToMax==1)
4969 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
4970 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
4974 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
4976 * \param [in] type - a spatial discretization of the new field.
4977 * \param [in] mName - a name of the supporting mesh.
4978 * \param [in] renumPol - specifies how to permute values of the result field according to
4979 * the optional numbers of cells and nodes, if any. The valid values are
4980 * - 0 - do not permute.
4981 * - 1 - permute cells.
4982 * - 2 - permute nodes.
4983 * - 3 - permute cells and nodes.
4985 * \param [in] glob - the global data storing profiles and localization.
4986 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4987 * caller is to delete this field using decrRef() as it is no more needed.
4988 * \throw If the MED file is not readable.
4989 * \throw If there is no mesh named \a mName in the MED file.
4990 * \throw If there are no mesh entities in the mesh.
4991 * \throw If no field values of the given \a type are available.
4993 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4995 MCAuto<MEDFileMesh> mm;
4997 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4999 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
5000 int absDim=getDimension();
5001 int meshDimRelToMax=absDim-mm->getMeshDimension();
5002 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
5006 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5007 * \param [in] type - a spatial discretization of the new field.
5008 * \param [in] renumPol - specifies how to permute values of the result field according to
5009 * the optional numbers of cells and nodes, if any. The valid values are
5010 * - 0 - do not permute.
5011 * - 1 - permute cells.
5012 * - 2 - permute nodes.
5013 * - 3 - permute cells and nodes.
5015 * \param [in] glob - the global data storing profiles and localization.
5016 * \param [in] mesh - the supporting mesh.
5017 * \param [in] cellRenum - the cell numbers array used for permutation of the result
5018 * field according to \a renumPol.
5019 * \param [in] nodeRenum - the node numbers array used for permutation of the result
5020 * field according to \a renumPol.
5021 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5022 * caller is to delete this field using decrRef() as it is no more needed.
5023 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5024 * \throw If no field of \a this is lying on \a mesh.
5025 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5027 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
5029 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
5030 int meshId=getMeshIdFromMeshName(mesh->getName());
5032 MCAuto<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
5037 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5044 throw INTERP_KERNEL::Exception(msg1);
5045 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5048 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
5050 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5051 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
5052 throw INTERP_KERNEL::Exception(oss.str());
5054 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
5055 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
5056 std::vector<DataArray *> arrOut2(1,arrOut);
5057 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
5058 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
5059 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
5066 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5068 throw INTERP_KERNEL::Exception(msg1);
5071 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
5073 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5074 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
5075 throw INTERP_KERNEL::Exception(oss.str());
5077 MCAuto<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
5078 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
5079 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
5080 ret->renumberNodes(nodeRenumSafe->getConstPointer());
5085 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
5090 * Returns values and a profile of the field of a given type lying on a given support.
5091 * \param [in] type - a spatial discretization of the field.
5092 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5093 * \param [in] mesh - the supporting mesh.
5094 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
5095 * field of interest lies on. If the field lies on all entities of the given
5096 * dimension, all ids in \a pfl are zero. The caller is to delete this array
5097 * using decrRef() as it is no more needed.
5098 * \param [in] glob - the global data storing profiles and localization.
5099 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
5100 * field. The caller is to delete this array using decrRef() as it is no more needed.
5101 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
5102 * \throw If no field of \a this is lying on \a mesh.
5103 * \throw If no field values of the given \a type are available.
5105 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
5107 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
5108 int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
5109 MCAuto<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
5110 ret->setName(nasc.getName().c_str());
5114 //= MEDFileField1TSWithoutSDA
5117 * Throws if a given value is not a valid (non-extended) relative dimension.
5118 * \param [in] meshDimRelToMax - the relative dimension value.
5119 * \throw If \a meshDimRelToMax > 0.
5121 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
5123 if(meshDimRelToMax>0)
5124 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
5128 * Checks if elements of a given mesh are in the order suitable for writing
5129 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
5130 * vector describing types of elements and their number.
5131 * \param [in] mesh - the mesh to check.
5132 * \return std::vector<int> - a vector holding for each element type (1) item of
5133 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
5134 * These values are in full-interlace mode.
5135 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
5137 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
5140 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
5141 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
5142 int nbOfTypes=geoTypes.size();
5143 std::vector<int> code(3*nbOfTypes);
5144 MCAuto<DataArrayInt> arr1=DataArrayInt::New();
5145 arr1->alloc(nbOfTypes,1);
5146 int *arrPtr=arr1->getPointer();
5147 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
5148 for(int i=0;i<nbOfTypes;i++,it++)
5149 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
5150 MCAuto<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
5151 const int *arrPtr2=arr2->getConstPointer();
5153 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
5156 int nbCells=mesh->getNumberOfCellsWithType(*it);
5157 code[3*pos]=(int)(*it);
5158 code[3*pos+1]=nbCells;
5159 code[3*pos+2]=-1;//no profiles
5161 std::vector<const DataArrayInt *> idsPerType;//no profiles
5162 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
5166 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
5171 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5173 return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5177 * Returns all attributes and values of parts of \a this field lying on a given mesh.
5178 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
5179 * item of every of returned sequences refers to the _i_-th part of \a this field.
5180 * Thus all sequences returned by this method are of the same length equal to number
5181 * of different types of supporting entities.<br>
5182 * A field part can include sub-parts with several different spatial discretizations,
5183 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
5184 * for example. Hence, some of the returned sequences contains nested sequences, and an item
5185 * of a nested sequence corresponds to a type of spatial discretization.<br>
5186 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
5187 * The overhead is due to selecting values into new instances of DataArrayDouble.
5188 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
5189 * for the case with only one underlying mesh. (Actually, the number of meshes is
5190 * not checked if \a mname == \c NULL).
5191 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
5192 * a field part is returned.
5193 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
5194 * A field part can include sub-parts with several different spatial discretizations,
5195 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and
5196 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT" for example.
5197 * This sequence is of the same length as \a types.
5198 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
5199 * discretization. A profile name can be empty.
5200 * Length of this and of nested sequences is the same as that of \a typesF.
5201 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
5202 * discretization. A localization name can be empty.
5203 * Length of this and of nested sequences is the same as that of \a typesF.
5204 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
5205 * per each type of spatial discretization within one mesh entity type.
5206 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
5207 * Length of this and of nested sequences is the same as that of \a typesF.
5208 * \throw If no field is lying on \a mname.
5210 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
5214 meshId=getMeshIdFromMeshName(mname);
5216 if(_field_per_mesh.empty())
5217 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
5218 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
5219 int nbOfRet=ret0.size();
5220 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
5221 for(int i=0;i<nbOfRet;i++)
5223 const std::vector< std::pair<int,int> >& p=ret0[i];
5224 int nbOfRet1=p.size();
5225 ret[i].resize(nbOfRet1);
5226 for(int j=0;j<nbOfRet1;j++)
5228 DataArrayDouble *tmp=_arr->selectByTupleIdSafeSlice(p[j].first,p[j].second,1);
5235 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
5240 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
5242 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
5243 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5244 ret->deepCpyLeavesFrom(*this);
5245 const DataArrayDouble *arr(_arr);
5248 MCAuto<DataArrayInt> arr2(arr->convertToIntArr());
5249 ret->setArray(arr2);
5255 * Returns a pointer to the underground DataArrayDouble instance and a
5256 * sequence describing parameters of a support of each part of \a this field. The
5257 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5258 * direct access to the field values. This method is intended for the field lying on one
5260 * \param [in,out] entries - the sequence describing parameters of a support of each
5261 * part of \a this field. Each item of this sequence consists of two parts. The
5262 * first part describes a type of mesh entity and an id of discretization of a
5263 * current field part. The second part describes a range of values [begin,end)
5264 * within the returned array relating to the current field part.
5265 * \return DataArrayDouble * - the pointer to the field values array.
5266 * \throw If the number of underlying meshes is not equal to 1.
5267 * \throw If no field values are available.
5268 * \sa getUndergroundDataArray()
5270 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5272 if(_field_per_mesh.size()!=1)
5273 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5274 if(_field_per_mesh[0]==0)
5275 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5276 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5277 return getUndergroundDataArrayTemplate();
5281 * Returns a pointer to the underground DataArrayDouble instance and a
5282 * sequence describing parameters of a support of each part of \a this field. The
5283 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5284 * direct access to the field values. This method is intended for the field lying on one
5286 * \param [in,out] entries - the sequence describing parameters of a support of each
5287 * part of \a this field. Each item of this sequence consists of two parts. The
5288 * first part describes a type of mesh entity and an id of discretization of a
5289 * current field part. The second part describes a range of values [begin,end)
5290 * within the returned array relating to the current field part.
5291 * \return DataArrayDouble * - the pointer to the field values array.
5292 * \throw If the number of underlying meshes is not equal to 1.
5293 * \throw If no field values are available.
5294 * \sa getUndergroundDataArray()
5296 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5298 return getUndergroundDataArrayDoubleExt(entries);
5301 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<double>(fieldName,csit,iteration,order)
5303 DataArrayDouble *arr(getOrCreateAndGetArrayTemplate());
5304 arr->setInfoAndChangeNbOfCompo(infos);
5307 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<double>()
5311 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
5313 MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
5314 ret->deepCpyLeavesFrom(*this);
5318 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCopy() const
5320 MCAuto<MEDFileField1TSWithoutSDA> ret=static_cast<MEDFileField1TSWithoutSDA *>(shallowCpy());
5321 if((const DataArrayDouble *)_arr)
5322 ret->_arr=_arr->deepCopy();
5326 //= MEDFileIntField1TSWithoutSDA
5328 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5330 return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5333 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<int>()
5337 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order,
5338 const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<int>(fieldName,csit,iteration,order)
5340 DataArrayInt *arr(getOrCreateAndGetArrayTemplate());
5341 arr->setInfoAndChangeNbOfCompo(infos);
5344 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
5349 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const
5351 MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
5352 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5353 ret->deepCpyLeavesFrom(*this);
5354 const DataArrayInt *arr(_arr);
5357 MCAuto<DataArrayDouble> arr2(arr->convertToDblArr());
5358 ret->setArray(arr2);
5364 * Returns a pointer to the underground DataArrayInt instance and a
5365 * sequence describing parameters of a support of each part of \a this field. The
5366 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5367 * direct access to the field values. This method is intended for the field lying on one
5369 * \param [in,out] entries - the sequence describing parameters of a support of each
5370 * part of \a this field. Each item of this sequence consists of two parts. The
5371 * first part describes a type of mesh entity and an id of discretization of a
5372 * current field part. The second part describes a range of values [begin,end)
5373 * within the returned array relating to the current field part.
5374 * \return DataArrayInt * - the pointer to the field values array.
5375 * \throw If the number of underlying meshes is not equal to 1.
5376 * \throw If no field values are available.
5377 * \sa getUndergroundDataArray()
5379 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5381 return getUndergroundDataArrayIntExt(entries);
5385 * Returns a pointer to the underground DataArrayInt instance and a
5386 * sequence describing parameters of a support of each part of \a this field. The
5387 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5388 * direct access to the field values. This method is intended for the field lying on one
5390 * \param [in,out] entries - the sequence describing parameters of a support of each
5391 * part of \a this field. Each item of this sequence consists of two parts. The
5392 * first part describes a type of mesh entity and an id of discretization of a
5393 * current field part. The second part describes a range of values [begin,end)
5394 * within the returned array relating to the current field part.
5395 * \return DataArrayInt * - the pointer to the field values array.
5396 * \throw If the number of underlying meshes is not equal to 1.
5397 * \throw If no field values are available.
5398 * \sa getUndergroundDataArray()
5400 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5402 if(_field_per_mesh.size()!=1)
5403 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5404 if(_field_per_mesh[0]==0)
5405 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5406 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5407 return getUndergroundDataArrayTemplate();
5410 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5412 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5413 ret->deepCpyLeavesFrom(*this);
5417 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCopy() const
5419 MCAuto<MEDFileIntField1TSWithoutSDA> ret=static_cast<MEDFileIntField1TSWithoutSDA *>(shallowCpy());
5420 if((const DataArrayInt *)_arr)
5421 ret->_arr=_arr->deepCopy();
5425 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5429 //= MEDFileAnyTypeField1TS
5431 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
5433 med_field_type typcha;
5435 std::vector<std::string> infos;
5436 std::string dtunit,fieldName;
5437 LocateField2(fid,0,true,fieldName,typcha,infos,dtunit);
5438 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5443 ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5448 ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5453 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] !";
5454 throw INTERP_KERNEL::Exception(oss.str());
5457 ret->setDtUnit(dtunit.c_str());
5458 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5460 med_int numdt,numit;
5462 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5463 ret->setTime(numdt,numit,dt);
5466 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5468 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5472 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
5473 try:MEDFileFieldGlobsReal(fid)
5475 _content=BuildContentFrom(fid,loadAll,ms);
5478 catch(INTERP_KERNEL::Exception& e)
5483 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5485 med_field_type typcha;
5486 std::vector<std::string> infos;
5489 int nbSteps=LocateField(fid,fieldName,iii,typcha,infos,dtunit);
5490 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5495 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5500 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5505 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] !";
5506 throw INTERP_KERNEL::Exception(oss.str());
5509 ret->setDtUnit(dtunit.c_str());
5510 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5514 std::ostringstream oss; oss << "MEDFileField1TS(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5515 throw INTERP_KERNEL::Exception(oss.str());
5518 med_int numdt,numit;
5520 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5521 ret->setTime(numdt,numit,dt);
5524 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5526 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5530 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5531 try:MEDFileFieldGlobsReal(fid)
5533 _content=BuildContentFrom(fid,fieldName,loadAll,ms);
5536 catch(INTERP_KERNEL::Exception& e)
5541 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c)
5544 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5545 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5547 MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
5548 ret->_content=c; c->incrRef();
5551 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5553 MCAuto<MEDFileIntField1TS> ret(MEDFileIntField1TS::New());
5554 ret->_content=c; c->incrRef();
5557 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5560 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, med_idt fid)
5562 MEDFileAnyTypeField1TS *ret(BuildNewInstanceFromContent(c));
5563 ret->setFileName(FileNameFromFID(fid));
5567 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
5569 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5570 return New(fid,loadAll);
5573 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, bool loadAll)
5575 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
5576 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5577 ret->loadGlobals(fid);
5581 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
5583 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5584 return New(fid,fieldName,loadAll);
5587 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
5589 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0));
5590 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5591 ret->loadGlobals(fid);
5595 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
5597 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5598 return New(fid,fieldName,iteration,order,loadAll);
5601 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
5603 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0));
5604 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5605 ret->loadGlobals(fid);
5609 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5611 med_field_type typcha;
5612 std::vector<std::string> infos;
5615 int nbOfStep2(LocateField(fid,fieldName,iii,typcha,infos,dtunit));
5616 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5621 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5626 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5631 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] !";
5632 throw INTERP_KERNEL::Exception(oss.str());
5635 ret->setDtUnit(dtunit.c_str());
5636 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5639 std::vector< std::pair<int,int> > dtits(nbOfStep2);
5640 for(int i=0;i<nbOfStep2 && !found;i++)
5642 med_int numdt,numit;
5644 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt));
5645 if(numdt==iteration && numit==order)
5651 dtits[i]=std::pair<int,int>(numdt,numit);
5655 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available iterations are : ";
5656 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5657 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5658 throw INTERP_KERNEL::Exception(oss.str());
5661 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5663 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5667 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5668 try:MEDFileFieldGlobsReal(fid)
5670 _content=BuildContentFrom(fid,fieldName,iteration,order,loadAll,ms);
5673 catch(INTERP_KERNEL::Exception& e)
5679 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5680 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5682 * \warning this is a shallow copy constructor
5684 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5686 if(!shallowCopyOfContent)
5688 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5689 otherPtr->incrRef();
5690 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5694 _content=other.shallowCpy();
5698 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)
5702 int nbFields=MEDnField(fid);
5703 if(fieldIdCFormat>=nbFields)
5705 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << FileNameFromFID(fid) << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5706 throw INTERP_KERNEL::Exception(oss.str());
5709 int ncomp(MEDfieldnComponent(fid,fieldIdCFormat+1));
5710 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5711 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5712 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5713 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5714 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5717 MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep));
5718 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5719 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5720 infos.clear(); infos.resize(ncomp);
5721 for(int j=0;j<ncomp;j++)
5722 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5727 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5730 * \return in case of success the number of time steps available for the field with name \a fieldName.
5732 int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const std::string& fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
5734 int nbFields=MEDnField(fid);
5736 std::vector<std::string> fns(nbFields);
5738 for(int i=0;i<nbFields && !found;i++)
5741 nbOfStep2=LocateField2(fid,i,false,tmp,typcha,infos,dtunitOut);
5743 found=(tmp==fieldName);
5749 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available fields are : ";
5750 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5751 oss << "\"" << *it << "\" ";
5752 throw INTERP_KERNEL::Exception(oss.str());
5758 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5759 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5760 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5761 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5762 * to keep a valid instance.
5763 * 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.
5764 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5765 * 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.
5767 * \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.
5768 * \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.
5769 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5770 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5771 * \param [in] newLocName is the new localization name.
5772 * \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.
5773 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5775 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
5777 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5778 std::string oldPflName=disc->getProfile();
5779 std::vector<std::string> vv=getPflsReallyUsedMulti();
5780 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5781 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5783 disc->setProfile(newPflName);
5784 DataArrayInt *pfl=getProfile(oldPflName.c_str());
5785 pfl->setName(newPflName);
5789 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5790 throw INTERP_KERNEL::Exception(oss.str());
5795 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5796 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5797 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5798 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5799 * to keep a valid instance.
5800 * 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.
5801 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5802 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5803 * 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.
5805 * \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.
5806 * \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.
5807 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5808 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5809 * \param [in] newLocName is the new localization name.
5810 * \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.
5811 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
5813 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
5815 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5816 std::string oldLocName=disc->getLocalization();
5817 std::vector<std::string> vv=getLocsReallyUsedMulti();
5818 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
5819 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
5821 disc->setLocalization(newLocName);
5822 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
5823 loc.setName(newLocName);
5827 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
5828 throw INTERP_KERNEL::Exception(oss.str());
5832 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
5834 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5836 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
5840 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
5842 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5844 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
5849 * This method alloc the arrays and load potentially huge arrays contained in this field.
5850 * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
5851 * This method can be also called to refresh or reinit values from a file.
5853 * \throw If the fileName is not set or points to a non readable MED file.
5854 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5856 void MEDFileAnyTypeField1TS::loadArrays()
5858 if(getFileName().empty())
5859 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
5860 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
5861 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
5865 * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
5866 * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
5867 * this method does not throw if \a this does not come from file read.
5869 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
5871 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
5873 if(!getFileName().empty())
5875 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
5876 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
5881 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
5882 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
5883 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
5885 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
5887 void MEDFileAnyTypeField1TS::unloadArrays()
5889 contentNotNullBase()->unloadArrays();
5893 * 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.
5894 * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
5895 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
5897 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5899 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
5901 if(!getFileName().empty())
5902 contentNotNullBase()->unloadArrays();
5905 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
5907 int nbComp(getNumberOfComponents());
5908 INTERP_KERNEL::AutoPtr<char> comp(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
5909 INTERP_KERNEL::AutoPtr<char> unit(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
5910 for(int i=0;i<nbComp;i++)
5912 std::string info=getInfo()[i];
5914 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
5915 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
5916 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
5918 if(getName().empty())
5919 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
5920 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
5921 writeGlobals(fid,*this);
5922 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
5925 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
5927 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
5930 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
5932 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
5933 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
5938 * Returns a string describing \a this field. This string is outputted
5939 * by \c print Python command.
5941 std::string MEDFileAnyTypeField1TS::simpleRepr() const
5943 std::ostringstream oss;
5944 contentNotNullBase()->simpleRepr(0,oss,-1);
5945 simpleReprGlobs(oss);
5950 * This method returns all profiles whose name is non empty used.
5951 * \b WARNING If profile is used several times it will be reported \b only \b once.
5952 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
5954 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
5956 return contentNotNullBase()->getPflsReallyUsed2();
5960 * This method returns all localizations whose name is non empty used.
5961 * \b WARNING If localization is used several times it will be reported \b only \b once.
5963 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
5965 return contentNotNullBase()->getLocsReallyUsed2();
5969 * This method returns all profiles whose name is non empty used.
5970 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
5972 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
5974 return contentNotNullBase()->getPflsReallyUsedMulti2();
5978 * This method returns all localizations whose name is non empty used.
5979 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
5981 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
5983 return contentNotNullBase()->getLocsReallyUsedMulti2();
5986 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5988 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
5991 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5993 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
5996 int MEDFileAnyTypeField1TS::getDimension() const
5998 return contentNotNullBase()->getDimension();
6001 int MEDFileAnyTypeField1TS::getIteration() const
6003 return contentNotNullBase()->getIteration();
6006 int MEDFileAnyTypeField1TS::getOrder() const
6008 return contentNotNullBase()->getOrder();
6011 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
6013 return contentNotNullBase()->getTime(iteration,order);
6016 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
6018 contentNotNullBase()->setTime(iteration,order,val);
6021 std::string MEDFileAnyTypeField1TS::getName() const
6023 return contentNotNullBase()->getName();
6026 void MEDFileAnyTypeField1TS::setName(const std::string& name)
6028 contentNotNullBase()->setName(name);
6031 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
6033 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
6036 std::string MEDFileAnyTypeField1TS::getDtUnit() const
6038 return contentNotNullBase()->getDtUnit();
6041 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
6043 contentNotNullBase()->setDtUnit(dtUnit);
6046 std::string MEDFileAnyTypeField1TS::getMeshName() const
6048 return contentNotNullBase()->getMeshName();
6051 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
6053 contentNotNullBase()->setMeshName(newMeshName);
6056 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
6058 return contentNotNullBase()->changeMeshNames(modifTab);
6061 int MEDFileAnyTypeField1TS::getMeshIteration() const
6063 return contentNotNullBase()->getMeshIteration();
6066 int MEDFileAnyTypeField1TS::getMeshOrder() const
6068 return contentNotNullBase()->getMeshOrder();
6071 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
6073 return contentNotNullBase()->getNumberOfComponents();
6076 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
6078 return contentNotNullBase()->isDealingTS(iteration,order);
6081 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
6083 return contentNotNullBase()->getDtIt();
6086 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
6088 contentNotNullBase()->fillIteration(p);
6091 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
6093 contentNotNullBase()->fillTypesOfFieldAvailable(types);
6096 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
6098 contentNotNullBase()->setInfo(infos);
6101 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
6103 return contentNotNullBase()->getInfo();
6105 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
6107 return contentNotNullBase()->getInfo();
6110 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
6112 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
6115 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
6117 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6120 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
6122 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6125 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
6127 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
6130 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
6132 return contentNotNullBase()->getTypesOfFieldAvailable();
6135 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,
6136 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6138 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
6142 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
6143 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
6144 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
6146 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
6148 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6150 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
6151 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
6152 std::size_t sz(contentsSplit.size());
6153 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6154 for(std::size_t i=0;i<sz;i++)
6156 ret[i]=shallowCpy();
6157 ret[i]->_content=contentsSplit[i];
6163 * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
6164 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6166 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
6168 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6170 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
6171 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
6172 std::size_t sz(contentsSplit.size());
6173 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6174 for(std::size_t i=0;i<sz;i++)
6176 ret[i]=shallowCpy();
6177 ret[i]->_content=contentsSplit[i];
6183 * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this.
6184 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6186 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const
6188 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6190 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !");
6191 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
6192 std::size_t sz(contentsSplit.size());
6193 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6194 for(std::size_t i=0;i<sz;i++)
6196 ret[i]=shallowCpy();
6197 ret[i]->_content=contentsSplit[i];
6202 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCopy() const
6204 MCAuto<MEDFileAnyTypeField1TS> ret=shallowCpy();
6205 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
6206 ret->_content=_content->deepCopy();
6207 ret->deepCpyGlobs(*this);
6211 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
6213 return contentNotNullBase()->copyTinyInfoFrom(field,arr);
6219 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6220 * the first field that has been read from a specified MED file.
6221 * \param [in] fileName - the name of the MED file to read.
6222 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6223 * is to delete this field using decrRef() as it is no more needed.
6224 * \throw If reading the file fails.
6226 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll)
6228 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6229 return New(fid,loadAll);
6232 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, bool loadAll)
6234 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,loadAll,0));
6235 ret->contentNotNull();
6240 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6241 * a given field that has been read from a specified MED file.
6242 * \param [in] fileName - the name of the MED file to read.
6243 * \param [in] fieldName - the name of the field to read.
6244 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6245 * is to delete this field using decrRef() as it is no more needed.
6246 * \throw If reading the file fails.
6247 * \throw If there is no field named \a fieldName in the file.
6249 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6251 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6252 return New(fid,fieldName,loadAll);
6255 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
6257 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,fieldName,loadAll,0));
6258 ret->contentNotNull();
6263 * Returns a new instance of MEDFileField1TS holding data of a given time step of
6264 * a given field that has been read from a specified MED file.
6265 * \param [in] fileName - the name of the MED file to read.
6266 * \param [in] fieldName - the name of the field to read.
6267 * \param [in] iteration - the iteration number of a required time step.
6268 * \param [in] order - the iteration order number of required time step.
6269 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6270 * is to delete this field using decrRef() as it is no more needed.
6271 * \throw If reading the file fails.
6272 * \throw If there is no field named \a fieldName in the file.
6273 * \throw If the required time step is missing from the file.
6275 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6277 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6278 return New(fid,fieldName,iteration,order,loadAll);
6281 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
6283 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,fieldName,iteration,order,loadAll,0));
6284 ret->contentNotNull();
6289 * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6290 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6292 * Returns a new instance of MEDFileField1TS holding either a shallow copy
6293 * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
6294 * \warning this is a shallow copy constructor
6295 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
6296 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
6297 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6298 * is to delete this field using decrRef() as it is no more needed.
6300 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6302 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(other,shallowCopyOfContent));
6303 ret->contentNotNull();
6308 * Returns a new empty instance of MEDFileField1TS.
6309 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6310 * is to delete this field using decrRef() as it is no more needed.
6312 MEDFileField1TS *MEDFileField1TS::New()
6314 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS);
6315 ret->contentNotNull();
6320 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
6321 * following the given input policy.
6323 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6324 * By default (true) the globals are deeply copied.
6325 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
6327 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
6329 MCAuto<MEDFileIntField1TS> ret;
6330 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6333 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
6335 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
6336 MCAuto<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
6337 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc));
6340 ret=MEDFileIntField1TS::New();
6342 ret->deepCpyGlobs(*this);
6344 ret->shallowCpyGlobs(*this);
6348 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const
6350 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6352 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
6353 const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
6355 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 !");
6359 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull()
6361 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6363 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
6364 MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
6366 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 !");
6370 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
6373 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
6375 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
6376 DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6378 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6379 f->setArray(arrOutC);
6382 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MCAuto<DataArray>& arr)
6385 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
6386 DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6388 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6394 * Return an extraction of \a this using \a extractDef map to specify the extraction.
6395 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
6397 * \return A new object that the caller is responsible to deallocate.
6398 * \sa MEDFileUMesh::deduceNodeSubPartFromCellSubPart , MEDFileUMesh::extractPart
6400 MEDFileField1TS *MEDFileField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
6403 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : input mesh is NULL !");
6404 MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
6405 std::vector<TypeOfField> tof(getTypesOfFieldAvailable());
6406 for(std::vector<TypeOfField>::const_iterator it0=tof.begin();it0!=tof.end();it0++)
6408 if((*it0)!=ON_NODES)
6410 std::vector<int> levs;
6411 getNonEmptyLevels(mm->getName(),levs);
6412 for(std::vector<int>::const_iterator lev=levs.begin();lev!=levs.end();lev++)
6414 std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(*lev));
6415 if(it2!=extractDef.end())
6417 MCAuto<DataArrayInt> t((*it2).second);
6419 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6420 MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_CELLS,(*lev),mm));
6421 MCAuto<MEDCouplingFieldDouble> fOut(f->buildSubPart(t));
6422 ret->setFieldNoProfileSBT(fOut);
6428 std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(1));
6429 if(it2==extractDef.end())
6430 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a NODE field and no extract array available for NODE !");
6431 MCAuto<DataArrayInt> t((*it2).second);
6433 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6434 MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_NODES,0,mm));
6435 MCAuto<MEDCouplingFieldDouble> fOut(f->deepCopy());
6436 DataArrayDouble *arr(f->getArray());
6437 MCAuto<DataArrayDouble> newArr(arr->selectByTupleIdSafe(t->begin(),t->end()));
6438 fOut->setArray(newArr);
6439 ret->setFieldNoProfileSBT(fOut);
6445 MEDFileField1TS::MEDFileField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
6446 try:MEDFileAnyTypeField1TS(fid,loadAll,ms)
6449 catch(INTERP_KERNEL::Exception& e)
6452 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6453 try:MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms)
6456 catch(INTERP_KERNEL::Exception& e)
6459 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6460 try:MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms)
6463 catch(INTERP_KERNEL::Exception& e)
6467 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6468 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6470 * \warning this is a shallow copy constructor
6472 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6473 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6476 catch(INTERP_KERNEL::Exception& e)
6479 MEDFileField1TS::MEDFileField1TS()
6481 _content=new MEDFileField1TSWithoutSDA;
6485 * 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
6486 * method should be called (getFieldOnMeshAtLevel for example).
6487 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
6489 * \param [in] mesh - the mesh the field is lying on
6490 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6491 * caller is to delete this field using decrRef() as it is no more needed.
6493 MEDCouplingFieldDouble *MEDFileField1TS::field(const MEDFileMesh *mesh) const
6495 MCAuto<DataArray> arrOut;
6496 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
6497 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6502 * Returns a new MEDCouplingFieldDouble of a given type lying on
6503 * mesh entities of a given dimension of the first mesh in MED file. If \a this field
6504 * has not been constructed via file reading, an exception is thrown.
6505 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6506 * \param [in] type - a spatial discretization of interest.
6507 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6508 * \param [in] renumPol - specifies how to permute values of the result field according to
6509 * the optional numbers of cells and nodes, if any. The valid values are
6510 * - 0 - do not permute.
6511 * - 1 - permute cells.
6512 * - 2 - permute nodes.
6513 * - 3 - permute cells and nodes.
6515 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6516 * caller is to delete this field using decrRef() as it is no more needed.
6517 * \throw If \a this field has not been constructed via file reading.
6518 * \throw If the MED file is not readable.
6519 * \throw If there is no mesh in the MED file.
6520 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6521 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6522 * \sa getFieldOnMeshAtLevel()
6524 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6526 if(getFileName().empty())
6527 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6528 MCAuto<DataArray> arrOut;
6529 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
6530 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6535 * Returns a new MEDCouplingFieldDouble of a given type lying on
6536 * the top level cells of the first mesh in MED file. If \a this field
6537 * has not been constructed via file reading, an exception is thrown.
6538 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6539 * \param [in] type - a spatial discretization of interest.
6540 * \param [in] renumPol - specifies how to permute values of the result field according to
6541 * the optional numbers of cells and nodes, if any. The valid values are
6542 * - 0 - do not permute.
6543 * - 1 - permute cells.
6544 * - 2 - permute nodes.
6545 * - 3 - permute cells and nodes.
6547 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6548 * caller is to delete this field using decrRef() as it is no more needed.
6549 * \throw If \a this field has not been constructed via file reading.
6550 * \throw If the MED file is not readable.
6551 * \throw If there is no mesh in the MED file.
6552 * \throw If no field values of the given \a type.
6553 * \throw If no field values lying on the top level support.
6554 * \sa getFieldAtLevel()
6556 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
6558 if(getFileName().empty())
6559 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6560 MCAuto<DataArray> arrOut;
6561 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
6562 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6567 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6568 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6569 * \param [in] type - a spatial discretization of the new field.
6570 * \param [in] mesh - the supporting mesh.
6571 * \param [in] renumPol - specifies how to permute values of the result field according to
6572 * the optional numbers of cells and nodes, if any. The valid values are
6573 * - 0 - do not permute.
6574 * - 1 - permute cells.
6575 * - 2 - permute nodes.
6576 * - 3 - permute cells and nodes.
6578 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6579 * caller is to delete this field using decrRef() as it is no more needed.
6580 * \throw If no field of \a this is lying on \a mesh.
6581 * \throw If the mesh is empty.
6582 * \throw If no field values of the given \a type are available.
6583 * \sa getFieldAtLevel()
6584 * \sa getFieldOnMeshAtLevel()
6586 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
6588 MCAuto<DataArray> arrOut;
6589 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
6590 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6595 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6596 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6597 * \param [in] type - a spatial discretization of interest.
6598 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6599 * \param [in] mesh - the supporting mesh.
6600 * \param [in] renumPol - specifies how to permute values of the result field according to
6601 * the optional numbers of cells and nodes, if any. The valid values are
6602 * - 0 - do not permute.
6603 * - 1 - permute cells.
6604 * - 2 - permute nodes.
6605 * - 3 - permute cells and nodes.
6607 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6608 * caller is to delete this field using decrRef() as it is no more needed.
6609 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6610 * \throw If no field of \a this is lying on \a mesh.
6611 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6612 * \sa getFieldAtLevel()
6613 * \sa getFieldOnMeshAtLevel()
6615 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
6617 MCAuto<DataArray> arrOut;
6618 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
6619 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6624 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6625 * This method is called "Old" because in MED3 norm a field has only one meshName
6626 * attached, so this method is for readers of MED2 files. If \a this field
6627 * has not been constructed via file reading, an exception is thrown.
6628 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6629 * \param [in] type - a spatial discretization of interest.
6630 * \param [in] mName - a name of the supporting mesh.
6631 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6632 * \param [in] renumPol - specifies how to permute values of the result field according to
6633 * the optional numbers of cells and nodes, if any. The valid values are
6634 * - 0 - do not permute.
6635 * - 1 - permute cells.
6636 * - 2 - permute nodes.
6637 * - 3 - permute cells and nodes.
6639 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6640 * caller is to delete this field using decrRef() as it is no more needed.
6641 * \throw If the MED file is not readable.
6642 * \throw If there is no mesh named \a mName in the MED file.
6643 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6644 * \throw If \a this field has not been constructed via file reading.
6645 * \throw If no field of \a this is lying on the mesh named \a mName.
6646 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6647 * \sa getFieldAtLevel()
6649 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
6651 if(getFileName().empty())
6652 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6653 MCAuto<DataArray> arrOut;
6654 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull()));
6655 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6660 * Returns values and a profile of the field of a given type lying on a given support.
6661 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6662 * \param [in] type - a spatial discretization of the field.
6663 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6664 * \param [in] mesh - the supporting mesh.
6665 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6666 * field of interest lies on. If the field lies on all entities of the given
6667 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6668 * using decrRef() as it is no more needed.
6669 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6670 * field. The caller is to delete this array using decrRef() as it is no more needed.
6671 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6672 * \throw If no field of \a this is lying on \a mesh.
6673 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6675 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6677 MCAuto<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6678 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
6682 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6683 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6684 * "Sort By Type"), if not, an exception is thrown.
6685 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6686 * \param [in] field - the field to add to \a this.
6687 * \throw If the name of \a field is empty.
6688 * \throw If the data array of \a field is not set.
6689 * \throw If the data array is already allocated but has different number of components
6691 * \throw If the underlying mesh of \a field has no name.
6692 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6694 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
6697 contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
6701 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6702 * can be an aggregation of several MEDCouplingFieldDouble instances.
6703 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6704 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6707 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6708 * A new profile is added only if no equal profile is missing.
6709 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6710 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
6711 * \param [in] mesh - the supporting mesh of \a field.
6712 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6713 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6714 * \throw If either \a field or \a mesh or \a profile has an empty name.
6715 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6716 * \throw If the data array of \a field is not set.
6717 * \throw If the data array of \a this is already allocated but has different number of
6718 * components than \a field.
6719 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6720 * \sa setFieldNoProfileSBT()
6722 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6725 contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6728 MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const
6730 return new MEDFileField1TS(*this);
6733 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const
6735 return contentNotNull()->getUndergroundDataArrayTemplate();
6738 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
6740 return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
6743 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6744 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6746 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6749 //= MEDFileIntField1TS
6751 MEDFileIntField1TS *MEDFileIntField1TS::New()
6753 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS);
6754 ret->contentNotNull();
6758 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll)
6760 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6761 return MEDFileIntField1TS::New(fid,loadAll);
6764 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, bool loadAll)
6766 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,loadAll,0));
6767 ret->contentNotNull();
6771 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6773 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6774 return MEDFileIntField1TS::New(fid,fieldName,loadAll);
6777 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
6779 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,loadAll,0));
6780 ret->contentNotNull();
6784 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6786 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6787 return MEDFileIntField1TS::New(fid,fieldName,iteration,order,loadAll);
6790 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
6792 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,iteration,order,loadAll,0));
6793 ret->contentNotNull();
6797 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6799 MCAuto<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6800 ret->contentNotNull();
6804 MEDFileIntField1TS::MEDFileIntField1TS()
6806 _content=new MEDFileIntField1TSWithoutSDA;
6809 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
6810 try:MEDFileAnyTypeField1TS(fid,loadAll,ms)
6813 catch(INTERP_KERNEL::Exception& e)
6816 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6817 try:MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms)
6820 catch(INTERP_KERNEL::Exception& e)
6823 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6824 try:MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms)
6827 catch(INTERP_KERNEL::Exception& e)
6831 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6832 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6834 * \warning this is a shallow copy constructor
6836 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6840 MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const
6842 return new MEDFileIntField1TS(*this);
6846 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
6847 * following the given input policy.
6849 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6850 * By default (true) the globals are deeply copied.
6851 * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
6853 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const
6855 MCAuto<MEDFileField1TS> ret;
6856 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6859 const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
6861 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
6862 MCAuto<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
6863 ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc));
6866 ret=MEDFileField1TS::New();
6868 ret->deepCpyGlobs(*this);
6870 ret->shallowCpyGlobs(*this);
6875 * Adds a MEDCouplingFieldInt to \a this. The underlying mesh of the given field is
6876 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6877 * "Sort By Type"), if not, an exception is thrown.
6878 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6879 * \param [in] field - the field to add to \a this.
6880 * \throw If the name of \a field is empty.
6881 * \throw If the data array of \a field is not set.
6882 * \throw If the data array is already allocated but has different number of components
6884 * \throw If the underlying mesh of \a field has no name.
6885 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6887 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldInt *field)
6889 MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
6891 contentNotNull()->setFieldNoProfileSBT(field2,field->getArray(),*this,*contentNotNull());
6895 * Adds a MEDCouplingFieldInt to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6896 * can be an aggregation of several MEDCouplingFieldDouble instances.
6897 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6898 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6901 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6902 * A new profile is added only if no equal profile is missing.
6903 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6904 * \param [in] field - the field to add to \a this.
6905 * \param [in] mesh - the supporting mesh of \a field.
6906 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6907 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6908 * \throw If either \a field or \a mesh or \a profile has an empty name.
6909 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6910 * \throw If the data array of \a field is not set.
6911 * \throw If the data array of \a this is already allocated but has different number of
6912 * components than \a field.
6913 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6914 * \sa setFieldNoProfileSBT()
6916 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6918 MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
6920 contentNotNull()->setFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6923 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const
6925 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6927 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
6928 const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
6930 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 !");
6934 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6936 if(getFileName().empty())
6937 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6938 MCAuto<DataArray> arrOut;
6939 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
6940 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
6944 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MCAuto<DataArray>& arr)
6947 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
6948 DataArrayInt *arrC(dynamic_cast<DataArrayInt *>((DataArray *)arr));
6950 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
6955 MCAuto<MEDCouplingFieldInt> MEDFileIntField1TS::SetDataArrayDoubleInIntField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
6958 double t0(f->getTime(t1,t2));
6959 MCAuto<DataArrayInt> arr2(DynamicCastSafe<DataArray,DataArrayInt>(arr));
6960 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
6961 MCAuto<MEDCouplingFieldInt> ret(MEDCouplingFieldInt::New(*ft));
6962 ret->setTime(t0,t1,t2); ret->setArray(arr2);
6966 MCAuto<MEDCouplingFieldDouble> MEDFileIntField1TS::ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f)
6969 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ConvertFieldIntToFieldDouble : null input field !");
6971 double t0(f->getTime(t1,t2));
6972 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
6973 MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(*ft));
6974 ret->setTime(t0,t1,t2);
6978 MEDFileIntField1TS *MEDFileIntField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
6980 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::extractPart : not implemented yet !");
6984 * 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
6985 * method should be called (getFieldOnMeshAtLevel for example).
6986 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
6988 * \param [in] mesh - the mesh the field is lying on
6989 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
6990 * caller is to delete this field using decrRef() as it is no more needed.
6992 MEDCouplingFieldInt *MEDFileIntField1TS::field(const MEDFileMesh *mesh) const
6994 MCAuto<DataArray> arrOut;
6995 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
6996 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7001 * Returns a new MEDCouplingFieldInt of a given type lying on
7002 * the top level cells of the first mesh in MED file. If \a this field
7003 * has not been constructed via file reading, an exception is thrown.
7004 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7005 * \param [in] type - a spatial discretization of interest.
7006 * \param [in] renumPol - specifies how to permute values of the result field according to
7007 * the optional numbers of cells and nodes, if any. The valid values are
7008 * - 0 - do not permute.
7009 * - 1 - permute cells.
7010 * - 2 - permute nodes.
7011 * - 3 - permute cells and nodes.
7013 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7014 * caller is to delete this field using decrRef() as it is no more needed.
7015 * \throw If \a this field has not been constructed via file reading.
7016 * \throw If the MED file is not readable.
7017 * \throw If there is no mesh in the MED file.
7018 * \throw If no field values of the given \a type.
7019 * \throw If no field values lying on the top level support.
7020 * \sa getFieldAtLevel()
7022 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
7024 if(getFileName().empty())
7025 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
7026 MCAuto<DataArray> arrOut;
7027 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
7028 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7033 * Returns a new MEDCouplingFieldInt of given type lying on a given mesh.
7034 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7035 * \param [in] type - a spatial discretization of the new field.
7036 * \param [in] mesh - the supporting mesh.
7037 * \param [in] renumPol - specifies how to permute values of the result field according to
7038 * the optional numbers of cells and nodes, if any. The valid values are
7039 * - 0 - do not permute.
7040 * - 1 - permute cells.
7041 * - 2 - permute nodes.
7042 * - 3 - permute cells and nodes.
7044 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7045 * caller is to delete this field using decrRef() as it is no more needed.
7046 * \throw If no field of \a this is lying on \a mesh.
7047 * \throw If the mesh is empty.
7048 * \throw If no field values of the given \a type are available.
7049 * \sa getFieldAtLevel()
7050 * \sa getFieldOnMeshAtLevel()
7052 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
7054 MCAuto<DataArray> arrOut;
7055 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
7056 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7061 * Returns a new MEDCouplingFieldInt of a given type lying on a given support.
7062 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7063 * \param [in] type - a spatial discretization of interest.
7064 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7065 * \param [in] mesh - the supporting mesh.
7066 * \param [in] renumPol - specifies how to permute values of the result field according to
7067 * the optional numbers of cells and nodes, if any. The valid values are
7068 * - 0 - do not permute.
7069 * - 1 - permute cells.
7070 * - 2 - permute nodes.
7071 * - 3 - permute cells and nodes.
7073 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7074 * caller is to delete this field using decrRef() as it is no more needed.
7075 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7076 * \throw If no field of \a this is lying on \a mesh.
7077 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7078 * \sa getFieldAtLevel()
7079 * \sa getFieldOnMeshAtLevel()
7081 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
7083 MCAuto<DataArray> arrOut;
7084 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
7085 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7090 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
7091 * This method is called "Old" because in MED3 norm a field has only one meshName
7092 * attached, so this method is for readers of MED2 files. If \a this field
7093 * has not been constructed via file reading, an exception is thrown.
7094 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7095 * \param [in] type - a spatial discretization of interest.
7096 * \param [in] mName - a name of the supporting mesh.
7097 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7098 * \param [in] renumPol - specifies how to permute values of the result field according to
7099 * the optional numbers of cells and nodes, if any. The valid values are
7100 * - 0 - do not permute.
7101 * - 1 - permute cells.
7102 * - 2 - permute nodes.
7103 * - 3 - permute cells and nodes.
7105 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7106 * caller is to delete this field using decrRef() as it is no more needed.
7107 * \throw If the MED file is not readable.
7108 * \throw If there is no mesh named \a mName in the MED file.
7109 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7110 * \throw If \a this field has not been constructed via file reading.
7111 * \throw If no field of \a this is lying on the mesh named \a mName.
7112 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7113 * \sa getFieldAtLevel()
7115 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
7117 if(getFileName().empty())
7118 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7119 MCAuto<DataArray> arrOut;
7120 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
7121 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7126 * Returns values and a profile of the field of a given type lying on a given support.
7127 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7128 * \param [in] type - a spatial discretization of the field.
7129 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7130 * \param [in] mesh - the supporting mesh.
7131 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
7132 * field of interest lies on. If the field lies on all entities of the given
7133 * dimension, all ids in \a pfl are zero. The caller is to delete this array
7134 * using decrRef() as it is no more needed.
7135 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
7136 * field. The caller is to delete this array using decrRef() as it is no more needed.
7137 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7138 * \throw If no field of \a this is lying on \a mesh.
7139 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7141 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
7143 MCAuto<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
7144 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
7147 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull()
7149 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7151 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
7152 MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
7154 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 !");
7158 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const
7160 return contentNotNull()->getUndergroundDataArrayTemplate();
7163 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
7165 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
7169 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileFieldNameScope(fieldName)
7174 * \param [in] fieldId field id in C mode
7176 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7178 med_field_type typcha;
7179 std::string dtunitOut;
7180 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fieldId,false,_name,typcha,_infos,dtunitOut));
7181 setDtUnit(dtunitOut.c_str());
7182 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities);
7185 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)
7186 try:MEDFileFieldNameScope(fieldName),_infos(infos)
7188 setDtUnit(dtunit.c_str());
7189 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities);
7191 catch(INTERP_KERNEL::Exception& e)
7196 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
7198 std::size_t ret(_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MCAuto<MEDFileField1TSWithoutSDA>));
7199 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7200 ret+=(*it).capacity();
7204 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
7206 std::vector<const BigMemoryObject *> ret;
7207 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7208 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
7213 * 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
7216 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
7218 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7219 ret->setInfo(_infos);
7220 int sz=(int)_time_steps.size();
7221 for(const int *id=startIds;id!=endIds;id++)
7223 if(*id>=0 && *id<sz)
7225 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
7226 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7230 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7232 ret->pushBackTimeStep(tse2);
7236 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
7237 oss << " ! Should be in [0," << sz << ") !";
7238 throw INTERP_KERNEL::Exception(oss.str());
7241 if(ret->getNumberOfTS()>0)
7242 ret->synchronizeNameScope();
7243 ret->copyNameScope(*this);
7248 * 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
7251 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
7253 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
7254 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7255 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7256 ret->setInfo(_infos);
7257 int sz=(int)_time_steps.size();
7259 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
7263 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
7264 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7268 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7270 ret->pushBackTimeStep(tse2);
7274 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
7275 oss << " ! Should be in [0," << sz << ") !";
7276 throw INTERP_KERNEL::Exception(oss.str());
7279 if(ret->getNumberOfTS()>0)
7280 ret->synchronizeNameScope();
7281 ret->copyNameScope(*this);
7285 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7288 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7289 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7291 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7294 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7295 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
7296 ids->pushBackSilent(id);
7298 return buildFromTimeStepIds(ids->begin(),ids->end());
7301 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7304 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7305 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7307 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7310 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7311 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
7312 ids->pushBackSilent(id);
7314 return buildFromTimeStepIds(ids->begin(),ids->end());
7317 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
7319 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7321 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7324 if(cur->presenceOfMultiDiscPerGeoType())
7330 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
7335 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
7340 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
7343 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7345 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
7346 if(pt->isDealingTS(iteration,order))
7349 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
7350 std::vector< std::pair<int,int> > vp=getIterations();
7351 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
7352 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
7353 throw INTERP_KERNEL::Exception(oss.str());
7356 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
7358 return *_time_steps[getTimeStepPos(iteration,order)];
7361 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
7363 return *_time_steps[getTimeStepPos(iteration,order)];
7366 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const
7368 if(_time_steps.empty())
7369 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
7370 return _time_steps[0]->getMeshName();
7373 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const std::string& newMeshName)
7375 std::string oldName(getMeshName());
7376 std::vector< std::pair<std::string,std::string> > v(1);
7377 v[0].first=oldName; v[0].second=newMeshName;
7381 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
7384 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7386 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7388 ret=cur->changeMeshNames(modifTab) || ret;
7394 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
7396 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
7398 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
7402 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
7404 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7406 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
7409 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
7410 MEDFileFieldGlobsReal& glob)
7413 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7415 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
7417 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
7422 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7424 std::string startLine(bkOffset,' ');
7425 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
7427 oss << " (" << fmtsId << ")";
7428 oss << " has the following name: \"" << _name << "\"." << std::endl;
7429 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
7430 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7432 oss << startLine << " - \"" << *it << "\"" << std::endl;
7435 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7437 std::string chapter(17,'0'+i);
7438 oss << startLine << chapter << std::endl;
7439 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7441 cur->simpleRepr(bkOffset+2,oss,i);
7443 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
7444 oss << startLine << chapter << std::endl;
7448 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
7450 std::size_t sz=_time_steps.size();
7451 std::vector< std::pair<int,int> > ret(sz);
7453 for(std::size_t i=0;i<sz;i++)
7455 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
7458 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
7462 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
7463 throw INTERP_KERNEL::Exception(oss.str());
7469 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MCAuto<MEDFileAnyTypeField1TSWithoutSDA>& tse)
7471 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
7473 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
7474 checkCoherencyOfType(tse2);
7475 if(_time_steps.empty())
7477 setName(tse2->getName().c_str());
7478 setInfo(tse2->getInfo());
7480 checkThatComponentsMatch(tse2->getInfo());
7481 if(getDtUnit().empty() && !tse->getDtUnit().empty())
7482 setDtUnit(tse->getDtUnit());
7483 _time_steps.push_back(tse);
7486 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
7488 std::size_t nbOfCompo=_infos.size();
7489 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7491 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7494 if((cur->getInfo()).size()!=nbOfCompo)
7496 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
7497 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
7498 throw INTERP_KERNEL::Exception(oss.str());
7500 cur->copyNameScope(*this);
7505 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7507 _time_steps.resize(nbPdt);
7508 for(int i=0;i<nbPdt;i++)
7510 std::vector< std::pair<int,int> > ts;
7511 med_int numdt=0,numo=0;
7513 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt));
7518 _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7523 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7527 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
7530 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities);
7532 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entities);
7533 synchronizeNameScope();
7537 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
7539 if(_time_steps.empty())
7540 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
7541 checkThatNbOfCompoOfTSMatchThis();
7542 std::vector<std::string> infos(getInfo());
7543 int nbComp=infos.size();
7544 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7545 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7546 for(int i=0;i<nbComp;i++)
7548 std::string info=infos[i];
7550 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7551 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7552 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7555 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7556 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
7557 int nbOfTS=_time_steps.size();
7558 for(int i=0;i<nbOfTS;i++)
7559 _time_steps[i]->writeLL(fid,opts,*this);
7562 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
7564 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7566 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7568 elt->loadBigArraysRecursively(fid,nasc);
7572 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
7574 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7576 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7578 elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7582 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
7584 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7586 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7588 elt->unloadArrays();
7592 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7594 return _time_steps.size();
7597 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
7599 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7600 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7602 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7604 newTS.push_back(*it);
7609 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
7611 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7612 int maxId=(int)_time_steps.size();
7614 std::set<int> idsToDel;
7615 for(const int *id=startIds;id!=endIds;id++,ii++)
7617 if(*id>=0 && *id<maxId)
7619 idsToDel.insert(*id);
7623 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7624 throw INTERP_KERNEL::Exception(oss.str());
7627 for(int iii=0;iii<maxId;iii++)
7628 if(idsToDel.find(iii)==idsToDel.end())
7629 newTS.push_back(_time_steps[iii]);
7633 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
7635 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7636 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7637 if(nbOfEntriesToKill==0)
7639 std::size_t sz=_time_steps.size();
7640 std::vector<bool> b(sz,true);
7642 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7644 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7645 for(std::size_t i=0;i<sz;i++)
7647 newTS.push_back(_time_steps[i]);
7651 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
7654 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
7655 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7657 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7661 tmp->getTime(it2,ord);
7662 if(it2==iteration && order==ord)
7665 oss << "(" << it2 << "," << ord << "), ";
7668 throw INTERP_KERNEL::Exception(oss.str());
7671 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
7674 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
7676 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7678 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7682 double ti=tmp->getTime(it2,ord);
7683 if(fabs(time-ti)<eps)
7689 throw INTERP_KERNEL::Exception(oss.str());
7692 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
7694 int lgth=_time_steps.size();
7695 std::vector< std::pair<int,int> > ret(lgth);
7696 for(int i=0;i<lgth;i++)
7697 _time_steps[i]->fillIteration(ret[i]);
7702 * 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'
7703 * This method returns two things.
7704 * - The absolute dimension of 'this' in first parameter.
7705 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7706 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
7708 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7709 * Only these 3 discretizations will be taken into account here.
7711 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7712 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7713 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7715 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7716 * 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'.
7718 * Let's consider the typical following case :
7719 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7720 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7721 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7723 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7725 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7727 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7728 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7729 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7730 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7732 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
7734 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7737 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
7739 if(pos<0 || pos>=(int)_time_steps.size())
7741 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7742 throw INTERP_KERNEL::Exception(oss.str());
7744 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7747 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7748 oss << "\nTry to use following method eraseEmptyTS !";
7749 throw INTERP_KERNEL::Exception(oss.str());
7754 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
7756 if(pos<0 || pos>=(int)_time_steps.size())
7758 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7759 throw INTERP_KERNEL::Exception(oss.str());
7761 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7764 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7765 oss << "\nTry to use following method eraseEmptyTS !";
7766 throw INTERP_KERNEL::Exception(oss.str());
7771 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
7773 std::vector<std::string> ret;
7774 std::set<std::string> ret2;
7775 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7777 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
7778 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7779 if(ret2.find(*it2)==ret2.end())
7781 ret.push_back(*it2);
7788 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
7790 std::vector<std::string> ret;
7791 std::set<std::string> ret2;
7792 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7794 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
7795 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7796 if(ret2.find(*it2)==ret2.end())
7798 ret.push_back(*it2);
7805 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
7807 std::vector<std::string> ret;
7808 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7810 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
7811 ret.insert(ret.end(),tmp.begin(),tmp.end());
7816 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
7818 std::vector<std::string> ret;
7819 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7821 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
7822 ret.insert(ret.end(),tmp.begin(),tmp.end());
7827 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7829 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7830 (*it)->changePflsRefsNamesGen2(mapOfModif);
7833 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7835 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7836 (*it)->changeLocsRefsNamesGen2(mapOfModif);
7839 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
7841 int lgth=_time_steps.size();
7842 std::vector< std::vector<TypeOfField> > ret(lgth);
7843 for(int i=0;i<lgth;i++)
7844 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
7849 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
7851 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
7853 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
7856 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCopy() const
7858 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
7860 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7862 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
7863 ret->_time_steps[i]=(*it)->deepCopy();
7868 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
7870 std::size_t sz(_infos.size()),sz2(_time_steps.size());
7871 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7872 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7873 for(std::size_t i=0;i<sz;i++)
7875 ret[i]=shallowCpy();
7876 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7878 for(std::size_t i=0;i<sz2;i++)
7880 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7883 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7884 throw INTERP_KERNEL::Exception(oss.str());
7888 for(std::size_t i=0;i<sz;i++)
7889 for(std::size_t j=0;j<sz2;j++)
7890 ret[i]->_time_steps[j]=ts[j][i];
7895 * This method splits into discretization each time steps in \a this.
7896 * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
7898 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
7900 std::size_t sz(_time_steps.size());
7901 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7902 for(std::size_t i=0;i<sz;i++)
7904 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7907 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
7908 throw INTERP_KERNEL::Exception(oss.str());
7910 items[i]=timeStep->splitDiscretizations();
7913 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
7914 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
7915 std::vector< TypeOfField > types;
7916 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7917 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7919 std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
7921 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
7922 std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
7923 if(it2==types.end())
7924 types.push_back(ts[0]);
7926 ret.resize(types.size()); ret2.resize(types.size());
7927 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7928 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7930 TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
7931 std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
7932 ret2[pos].push_back(*it1);
7934 for(std::size_t i=0;i<types.size();i++)
7936 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7937 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
7938 elt->pushBackTimeStep(*it1);//also updates infos in elt
7940 elt->MEDFileFieldNameScope::operator=(*this);
7946 * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
7948 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
7950 std::size_t sz(_time_steps.size());
7951 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7952 std::size_t szOut(std::numeric_limits<std::size_t>::max());
7953 for(std::size_t i=0;i<sz;i++)
7955 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7958 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
7959 throw INTERP_KERNEL::Exception(oss.str());
7961 items[i]=timeStep->splitMultiDiscrPerGeoTypes();
7962 if(szOut==std::numeric_limits<std::size_t>::max())
7963 szOut=items[i].size();
7965 if(items[i].size()!=szOut)
7966 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
7968 if(szOut==std::numeric_limits<std::size_t>::max())
7969 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
7970 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
7971 for(std::size_t i=0;i<szOut;i++)
7973 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7974 for(std::size_t j=0;j<sz;j++)
7975 elt->pushBackTimeStep(items[j][i]);
7977 elt->MEDFileFieldNameScope::operator=(*this);
7982 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
7984 _name=field->getName();
7986 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
7988 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
7989 _infos=arr->getInfoOnComponents();
7992 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
7994 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
7995 if(_name!=field->getName())
7997 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
7998 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
7999 throw INTERP_KERNEL::Exception(oss.str());
8002 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
8003 checkThatComponentsMatch(arr->getInfoOnComponents());
8006 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
8008 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
8009 if(getInfo().size()!=compos.size())
8011 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
8012 oss << " number of components of element to append (" << compos.size() << ") !";
8013 throw INTERP_KERNEL::Exception(oss.str());
8017 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
8018 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
8019 oss << " But compo in input fields are : ";
8020 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
8022 throw INTERP_KERNEL::Exception(oss.str());
8026 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
8028 std::size_t sz=_infos.size();
8030 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
8032 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
8034 if(elt->getInfo().size()!=sz)
8036 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
8037 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
8038 throw INTERP_KERNEL::Exception(oss.str());
8043 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
8046 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8047 if(!_time_steps.empty())
8048 checkCoherencyOfTinyInfo(field,arr);
8049 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8050 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8051 objC->setFieldNoProfileSBT(field,arr,glob,*this);
8052 copyTinyInfoFrom(field,arr);
8053 _time_steps.push_back(obj);
8056 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
8059 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8060 if(!_time_steps.empty())
8061 checkCoherencyOfTinyInfo(field,arr);
8062 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8063 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8064 objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
8065 copyTinyInfoFrom(field,arr);
8066 _time_steps.push_back(obj);
8069 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ts)
8071 int sz=(int)_time_steps.size();
8074 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
8075 throw INTERP_KERNEL::Exception(oss.str());
8077 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
8080 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
8082 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
8083 throw INTERP_KERNEL::Exception(oss.str());
8089 //= MEDFileFieldMultiTSWithoutSDA
8091 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)
8093 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8096 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
8100 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8105 * \param [in] fieldId field id in C mode
8107 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8108 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8111 catch(INTERP_KERNEL::Exception& e)
8114 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)
8115 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8118 catch(INTERP_KERNEL::Exception& e)
8121 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8123 return new MEDFileField1TSWithoutSDA;
8126 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8129 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8130 const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
8132 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8135 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const
8137 return MEDFileField1TSWithoutSDA::TYPE_STR;
8140 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const
8142 return new MEDFileFieldMultiTSWithoutSDA(*this);
8145 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const
8147 return new MEDFileFieldMultiTSWithoutSDA;
8151 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
8152 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
8154 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
8156 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
8157 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8159 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
8160 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
8163 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
8165 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
8166 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8168 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8170 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8173 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
8175 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
8176 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
8177 ret->setIteration(i,elt);
8183 //= MEDFileAnyTypeFieldMultiTS
8185 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
8189 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8190 try:MEDFileFieldGlobsReal(fid)
8192 _content=BuildContentFrom(fid,loadAll,ms);
8195 catch(INTERP_KERNEL::Exception& e)
8200 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8202 med_field_type typcha;
8203 std::vector<std::string> infos;
8206 MEDFileAnyTypeField1TS::LocateField(fid,fieldName,i,typcha,infos,dtunit);
8207 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8212 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8217 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8222 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] !";
8223 throw INTERP_KERNEL::Exception(oss.str());
8226 ret->setDtUnit(dtunit.c_str());
8230 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8232 med_field_type typcha;
8234 std::vector<std::string> infos;
8235 std::string dtunit,fieldName;
8236 MEDFileAnyTypeField1TS::LocateField2(fid,0,true,fieldName,typcha,infos,dtunit);
8237 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8242 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8247 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8252 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] !";
8253 throw INTERP_KERNEL::Exception(oss.str());
8256 ret->setDtUnit(dtunit.c_str());
8260 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c)
8263 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
8264 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
8266 MCAuto<MEDFileFieldMultiTS> ret(MEDFileFieldMultiTS::New());
8267 ret->_content=c; c->incrRef();
8270 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
8272 MCAuto<MEDFileIntFieldMultiTS> ret(MEDFileIntFieldMultiTS::New());
8273 ret->_content=c; c->incrRef();
8276 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
8279 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, med_idt fid)
8281 MEDFileAnyTypeFieldMultiTS *ret(BuildNewInstanceFromContent(c));
8282 std::string fileName(FileNameFromFID(fid));
8283 ret->setFileName(fileName);
8287 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8288 try:MEDFileFieldGlobsReal(fid)
8290 _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
8293 catch(INTERP_KERNEL::Exception& e)
8298 //= MEDFileIntFieldMultiTSWithoutSDA
8300 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)
8302 return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8305 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
8309 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8313 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)
8314 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8317 catch(INTERP_KERNEL::Exception& e)
8321 * \param [in] fieldId field id in C mode
8323 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8324 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8327 catch(INTERP_KERNEL::Exception& e)
8330 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8332 return new MEDFileIntField1TSWithoutSDA;
8335 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8338 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8339 const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
8341 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8344 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const
8346 return MEDFileIntField1TSWithoutSDA::TYPE_STR;
8349 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const
8351 return new MEDFileIntFieldMultiTSWithoutSDA(*this);
8354 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const
8356 return new MEDFileIntFieldMultiTSWithoutSDA;
8359 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const
8361 MCAuto<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
8362 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8364 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8366 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8369 const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
8371 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
8372 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
8373 ret->setIteration(i,elt);
8379 //= MEDFileAnyTypeFieldMultiTS
8382 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
8383 * that has been read from a specified MED file.
8384 * \param [in] fileName - the name of the MED file to read.
8385 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8386 * is to delete this field using decrRef() as it is no more needed.
8387 * \throw If reading the file fails.
8389 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
8391 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8392 return New(fid,loadAll);
8395 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, bool loadAll)
8397 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
8398 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8399 ret->loadGlobals(fid);
8404 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
8405 * that has been read from a specified MED file.
8406 * \param [in] fileName - the name of the MED file to read.
8407 * \param [in] fieldName - the name of the field to read.
8408 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8409 * is to delete this field using decrRef() as it is no more needed.
8410 * \throw If reading the file fails.
8411 * \throw If there is no field named \a fieldName in the file.
8413 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8415 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8416 return New(fid,fieldName,loadAll);
8419 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
8421 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
8422 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8423 ret->loadGlobals(fid);
8428 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8429 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8431 * \warning this is a shallow copy constructor
8433 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8435 if(!shallowCopyOfContent)
8437 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
8438 otherPtr->incrRef();
8439 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
8443 _content=other.shallowCpy();
8447 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
8449 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8451 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
8455 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
8457 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8459 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
8463 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
8465 return contentNotNullBase()->getPflsReallyUsed2();
8468 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
8470 return contentNotNullBase()->getLocsReallyUsed2();
8473 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
8475 return contentNotNullBase()->getPflsReallyUsedMulti2();
8478 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
8480 return contentNotNullBase()->getLocsReallyUsedMulti2();
8483 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8485 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
8488 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8490 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
8493 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
8495 return contentNotNullBase()->getNumberOfTS();
8498 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
8500 contentNotNullBase()->eraseEmptyTS();
8503 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
8505 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
8508 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
8510 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
8513 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
8515 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
8516 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8521 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
8523 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
8524 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8529 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
8531 return contentNotNullBase()->getIterations();
8534 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
8536 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
8537 pushBackTimeStep(*it);
8540 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
8543 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
8544 int nbOfTS(fmts->getNumberOfTS());
8545 for(int i=0;i<nbOfTS;i++)
8547 MCAuto<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
8548 pushBackTimeStep(elt);
8552 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
8555 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
8556 checkCoherencyOfType(f1ts);
8558 MCAuto<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
8559 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
8561 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
8562 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
8563 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
8564 _content->pushBackTimeStep(cSafe);
8565 appendGlobs(*f1ts,1e-12);
8568 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
8570 contentNotNullBase()->synchronizeNameScope();
8573 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
8575 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
8578 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
8580 return contentNotNullBase()->getPosGivenTime(time,eps);
8583 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8585 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
8588 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
8590 return contentNotNullBase()->getTypesOfFieldAvailable();
8593 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
8595 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
8598 std::string MEDFileAnyTypeFieldMultiTS::getName() const
8600 return contentNotNullBase()->getName();
8603 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
8605 contentNotNullBase()->setName(name);
8608 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
8610 return contentNotNullBase()->getDtUnit();
8613 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
8615 contentNotNullBase()->setDtUnit(dtUnit);
8618 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8620 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
8623 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
8625 return contentNotNullBase()->getTimeSteps(ret1);
8628 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
8630 return contentNotNullBase()->getMeshName();
8633 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
8635 contentNotNullBase()->setMeshName(newMeshName);
8638 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
8640 return contentNotNullBase()->changeMeshNames(modifTab);
8643 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
8645 return contentNotNullBase()->getInfo();
8648 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
8650 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
8653 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
8655 return contentNotNullBase()->setInfo(info);
8658 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
8660 const std::vector<std::string> ret=getInfo();
8661 return (int)ret.size();
8664 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
8666 writeGlobals(fid,*this);
8667 contentNotNullBase()->writeLL(fid,*this);
8671 * This method alloc the arrays and load potentially huge arrays contained in this field.
8672 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
8673 * This method can be also called to refresh or reinit values from a file.
8675 * \throw If the fileName is not set or points to a non readable MED file.
8677 void MEDFileAnyTypeFieldMultiTS::loadArrays()
8679 if(getFileName().empty())
8680 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
8681 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
8682 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
8686 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
8687 * But once data loaded once, this method does nothing.
8689 * \throw If the fileName is not set or points to a non readable MED file.
8690 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
8692 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
8694 if(!getFileName().empty())
8696 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
8697 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
8702 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
8703 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
8704 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
8706 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
8708 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
8710 contentNotNullBase()->unloadArrays();
8714 * 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.
8715 * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
8716 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
8718 * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
8720 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
8722 if(!getFileName().empty())
8723 contentNotNullBase()->unloadArrays();
8726 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
8728 std::ostringstream oss;
8729 contentNotNullBase()->simpleRepr(0,oss,-1);
8730 simpleReprGlobs(oss);
8734 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
8736 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
8739 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
8741 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
8742 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
8747 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
8748 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8749 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
8751 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
8753 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8755 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
8756 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
8757 std::size_t sz(contentsSplit.size());
8758 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8759 for(std::size_t i=0;i<sz;i++)
8761 ret[i]=shallowCpy();
8762 ret[i]->_content=contentsSplit[i];
8768 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
8769 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8771 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
8773 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8775 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
8776 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
8777 std::size_t sz(contentsSplit.size());
8778 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8779 for(std::size_t i=0;i<sz;i++)
8781 ret[i]=shallowCpy();
8782 ret[i]->_content=contentsSplit[i];
8788 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
8789 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8791 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
8793 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8795 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
8796 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
8797 std::size_t sz(contentsSplit.size());
8798 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8799 for(std::size_t i=0;i<sz;i++)
8801 ret[i]=shallowCpy();
8802 ret[i]->_content=contentsSplit[i];
8807 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCopy() const
8809 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8810 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
8811 ret->_content=_content->deepCopy();
8812 ret->deepCpyGlobs(*this);
8816 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
8822 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8823 * \param [in] iteration - the iteration number of a required time step.
8824 * \param [in] order - the iteration order number of required time step.
8825 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
8826 * delete this field using decrRef() as it is no more needed.
8827 * \throw If there is no required time step in \a this field.
8829 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
8831 int pos=getPosOfTimeStep(iteration,order);
8832 return getTimeStepAtPos(pos);
8836 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8837 * \param [in] time - the time of the time step of interest.
8838 * \param [in] eps - a precision used to compare time values.
8839 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8840 * delete this field using decrRef() as it is no more needed.
8841 * \throw If there is no required time step in \a this field.
8843 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
8845 int pos=getPosGivenTime(time,eps);
8846 return getTimeStepAtPos(pos);
8850 * 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.
8851 * The float64 value of time attached to the pair of integers are not considered here.
8852 * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
8854 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
8855 * \throw If there is a null pointer in \a vectFMTS.
8857 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
8859 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
8860 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8861 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8862 while(!lstFMTS.empty())
8864 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8865 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8867 throw INTERP_KERNEL::Exception(msg);
8868 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
8869 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8870 elt.push_back(curIt); it=lstFMTS.erase(it);
8871 while(it!=lstFMTS.end())
8875 throw INTERP_KERNEL::Exception(msg);
8876 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
8878 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8888 * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
8889 * All returned instances in a subvector can be safely loaded, rendered along time
8890 * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
8891 * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
8892 * 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).
8893 * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
8894 * 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.
8896 * \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().
8897 * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
8898 * \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.
8899 * \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.
8901 * \throw If an element in \a vectFMTS has not only one spatial discretization set.
8902 * \throw If an element in \a vectFMTS change of spatial discretization along time.
8903 * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
8904 * \thorw If some elements in \a vectFMTS do not have the same times steps.
8905 * \throw If mesh is null.
8906 * \throw If an element in \a vectFMTS is null.
8907 * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
8909 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& fsc)
8911 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
8913 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
8914 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8915 if(vectFMTS.empty())
8917 std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
8918 MEDFileAnyTypeFieldMultiTS *frstElt(*it);
8920 throw INTERP_KERNEL::Exception(msg);
8922 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
8923 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
8924 for(;it!=vectFMTS.end();it++,i++)
8927 throw INTERP_KERNEL::Exception(msg);
8928 TypeOfField tof0,tof1;
8929 if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
8932 vectFMTSNotNodes.push_back(*it);
8934 vectFMTSNodes.push_back(*it);
8937 vectFMTSNotNodes.push_back(*it);
8939 std::vector< MCAuto<MEDFileFastCellSupportComparator> > cmps;
8940 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
8942 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
8945 bool isFetched(false);
8946 for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
8949 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
8950 if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
8951 { ret[i].push_back(*it2); isFetched=true; }
8955 std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
8956 MCAuto<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
8957 ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
8965 * 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.
8966 * \param [out] cmps - same size than the returned vector.
8968 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& cmps)
8970 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8971 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8972 while(!lstFMTS.empty())
8974 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8975 MEDFileAnyTypeFieldMultiTS *ref(*it);
8976 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8977 elt.push_back(ref); it=lstFMTS.erase(it);
8978 MCAuto<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
8979 MCAuto<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
8980 while(it!=lstFMTS.end())
8982 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8983 if(cmp->isEqual(curIt))
8984 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8988 ret.push_back(elt); cmps.push_back(cmp);
8994 * 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.
8995 * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
8997 * \throw If \a f0 or \a f1 has not only one spatial discretization set.
8998 * \throw If \a f0 or \a f1 change of spatial discretization along time.
8999 * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
9000 * \thorw If \a f0 and \a f1 do not have the same times steps.
9001 * \throw If mesh is null.
9002 * \throw If \a f0 or \a f1 is null.
9003 * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
9005 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
9008 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
9010 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
9011 if(f0->getMeshName()!=mesh->getName())
9013 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9014 throw INTERP_KERNEL::Exception(oss.str());
9016 if(f1->getMeshName()!=mesh->getName())
9018 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9019 throw INTERP_KERNEL::Exception(oss.str());
9021 int nts=f0->getNumberOfTS();
9022 if(nts!=f1->getNumberOfTS())
9023 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
9026 for(int i=0;i<nts;i++)
9028 MCAuto<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
9029 MCAuto<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
9030 std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
9031 if(tofs0.size()!=1 || tofs1.size()!=1)
9032 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
9035 if(tof0!=tofs0[0] || tof1!=tofs1[0])
9036 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
9039 { tof0=tofs0[0]; tof1=tofs1[0]; }
9040 if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
9042 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() << ") !";
9043 throw INTERP_KERNEL::Exception(oss.str());
9045 if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
9047 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() << ") !";
9048 throw INTERP_KERNEL::Exception(oss.str());
9050 if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
9052 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() << ") !";
9053 throw INTERP_KERNEL::Exception(oss.str());
9060 * Return an extraction of \a this using \a extractDef map to specify the extraction.
9061 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
9063 * \return A new object that the caller is responsible to deallocate.
9065 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
9068 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::extractPart : mesh is null !");
9069 MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(buildNewEmpty());
9070 int nbTS(getNumberOfTS());
9071 for(int i=0;i<nbTS;i++)
9073 MCAuto<MEDFileAnyTypeField1TS> f1ts(getTimeStepAtPos(i));
9074 MCAuto<MEDFileAnyTypeField1TS> f1tsOut(f1ts->extractPart(extractDef,mm));
9075 fmtsOut->pushBackTimeStep(f1tsOut);
9077 return fmtsOut.retn();
9081 MCAuto<MEDFileAnyTypeField1TS> AggregateHelperF1TS(const std::vector< typename MLFieldTraits<T>::F1TSType const *>& f1tss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9083 MCAuto< typename MLFieldTraits<T>::F1TSType > ret(MLFieldTraits<T>::F1TSType::New());
9085 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : empty vector !");
9086 std::size_t sz(f1tss.size()),i(0);
9087 std::vector< typename MLFieldTraits<T>::F1TSWSDAType const *> f1tsw(sz);
9088 for(typename std::vector< typename MLFieldTraits<T>::F1TSType const *>::const_iterator it=f1tss.begin();it!=f1tss.end();it++,i++)
9090 typename MLFieldTraits<T>::F1TSType const *elt(*it);
9092 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : presence of a null pointer !");
9093 f1tsw[i]=dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType const *>(elt->contentNotNullBase());
9095 typename MLFieldTraits<T>::F1TSWSDAType *retc(dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType *>(ret->contentNotNullBase()));
9097 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : internal error 1 !");
9098 retc->aggregate(f1tsw,dts);
9099 ret->setDtUnit(f1tss[0]->getDtUnit());
9100 return DynamicCast<typename MLFieldTraits<T>::F1TSType , MEDFileAnyTypeField1TS>(ret);
9104 MCAuto< MEDFileAnyTypeFieldMultiTS > AggregateHelperFMTS(const std::vector< typename MLFieldTraits<T>::FMTSType const *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9106 MCAuto< typename MLFieldTraits<T>::FMTSType > ret(MLFieldTraits<T>::FMTSType::New());
9108 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : empty vector !");
9109 std::size_t sz(fmtss.size());
9110 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9112 typename MLFieldTraits<T>::FMTSType const *elt(*it);
9114 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : presence of null pointer !");
9116 int nbTS(fmtss[0]->getNumberOfTS());
9117 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9118 if((*it)->getNumberOfTS()!=nbTS)
9119 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : all fields must have the same number of TS !");
9120 for(int iterTS=0;iterTS<nbTS;iterTS++)
9123 std::vector< typename MLFieldTraits<T>::F1TSType const *> f1tss(sz);
9124 std::vector< MCAuto<typename MLFieldTraits<T>::F1TSType> > f1tss2(sz);
9125 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++,i++)
9126 { f1tss2[i]=(*it)->getTimeStepAtPos(iterTS); f1tss[i]=f1tss2[i]; }
9127 MCAuto<MEDFileAnyTypeField1TS> f1ts(AggregateHelperF1TS<T>(f1tss,dts));
9128 ret->pushBackTimeStep(f1ts);
9129 ret->setDtUnit(f1ts->getDtUnit());
9131 return DynamicCast<typename MLFieldTraits<T>::FMTSType , MEDFileAnyTypeFieldMultiTS>(ret);
9135 * \a dts and \a ftmss are expected to have same size.
9137 MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileAnyTypeFieldMultiTS::Aggregate(const std::vector<const MEDFileAnyTypeFieldMultiTS *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9140 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : input vector is empty !");
9141 std::size_t sz(fmtss.size());
9142 std::vector<const MEDFileFieldMultiTS *> fmtss1;
9143 std::vector<const MEDFileIntFieldMultiTS *> fmtss2;
9144 for(std::vector<const MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9147 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : presence of null instance in input vector !");
9148 const MEDFileFieldMultiTS *elt1(dynamic_cast<const MEDFileFieldMultiTS *>(*it));
9151 fmtss1.push_back(elt1);
9154 const MEDFileIntFieldMultiTS *elt2(dynamic_cast<const MEDFileIntFieldMultiTS *>(*it));
9157 fmtss2.push_back(elt2);
9160 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not recognized type !");
9162 if(fmtss1.size()!=sz && fmtss2.size()!=sz)
9163 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : type of data is not homogeneous !");
9164 if(fmtss1.size()==sz)
9165 return AggregateHelperFMTS<double>(fmtss1,dts);
9166 if(fmtss2.size()!=sz)
9167 return AggregateHelperFMTS<int>(fmtss2,dts);
9168 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not implemented yet !");
9171 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
9173 return new MEDFileAnyTypeFieldMultiTSIterator(this);
9176 //= MEDFileFieldMultiTS
9179 * Returns a new empty instance of MEDFileFieldMultiTS.
9180 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9181 * is to delete this field using decrRef() as it is no more needed.
9183 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
9185 return new MEDFileFieldMultiTS;
9189 * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
9190 * that has been read from a specified MED file.
9191 * \param [in] fileName - the name of the MED file to read.
9192 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9193 * is to delete this field using decrRef() as it is no more needed.
9194 * \throw If reading the file fails.
9196 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll)
9198 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9199 return New(fid,loadAll);
9202 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, bool loadAll)
9204 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,loadAll,0));
9205 ret->contentNotNull();//to check that content type matches with \a this type.
9210 * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
9211 * that has been read from a specified MED file.
9212 * \param [in] fileName - the name of the MED file to read.
9213 * \param [in] fieldName - the name of the field to read.
9214 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9215 * is to delete this field using decrRef() as it is no more needed.
9216 * \throw If reading the file fails.
9217 * \throw If there is no field named \a fieldName in the file.
9219 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9221 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9222 return New(fid,fieldName,loadAll);
9225 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
9227 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0));
9228 ret->contentNotNull();//to check that content type matches with \a this type.
9233 * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9234 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9236 * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
9237 * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9238 * \warning this is a shallow copy constructor
9239 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
9240 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9241 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9242 * is to delete this field using decrRef() as it is no more needed.
9244 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9246 return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
9249 MEDFileFieldMultiTS *MEDFileFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9251 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9252 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
9253 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0,ent));
9254 ret->contentNotNull();//to check that content type matches with \a this type.
9258 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
9260 return new MEDFileFieldMultiTS(*this);
9263 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9266 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9267 const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
9269 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
9273 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
9274 * following the given input policy.
9276 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9277 * By default (true) the globals are deeply copied.
9278 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
9280 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
9282 MCAuto<MEDFileIntFieldMultiTS> ret;
9283 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9286 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
9288 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
9289 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
9290 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc));
9293 ret=MEDFileIntFieldMultiTS::New();
9295 ret->deepCpyGlobs(*this);
9297 ret->shallowCpyGlobs(*this);
9302 * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
9303 * \param [in] pos - a time step id.
9304 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9305 * delete this field using decrRef() as it is no more needed.
9306 * \throw If \a pos is not a valid time step id.
9308 MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const
9310 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9313 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9314 throw INTERP_KERNEL::Exception(oss.str());
9316 const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
9319 MCAuto<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
9320 ret->shallowCpyGlobs(*this);
9323 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
9324 throw INTERP_KERNEL::Exception(oss.str());
9328 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9329 * mesh entities of a given dimension of the first mesh in MED file.
9330 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9331 * \param [in] type - a spatial discretization of interest.
9332 * \param [in] iteration - the iteration number of a required time step.
9333 * \param [in] order - the iteration order number of required time step.
9334 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9335 * \param [in] renumPol - specifies how to permute values of the result field according to
9336 * the optional numbers of cells and nodes, if any. The valid values are
9337 * - 0 - do not permute.
9338 * - 1 - permute cells.
9339 * - 2 - permute nodes.
9340 * - 3 - permute cells and nodes.
9342 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9343 * caller is to delete this field using decrRef() as it is no more needed.
9344 * \throw If the MED file is not readable.
9345 * \throw If there is no mesh in the MED file.
9346 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9347 * \throw If no field values of the required parameters are available.
9349 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9351 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9352 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9354 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
9355 MCAuto<DataArray> arrOut;
9356 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9357 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9362 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9363 * the top level cells of the first mesh in MED file.
9364 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9365 * \param [in] type - a spatial discretization of interest.
9366 * \param [in] iteration - the iteration number of a required time step.
9367 * \param [in] order - the iteration order number of required time step.
9368 * \param [in] renumPol - specifies how to permute values of the result field according to
9369 * the optional numbers of cells and nodes, if any. The valid values are
9370 * - 0 - do not permute.
9371 * - 1 - permute cells.
9372 * - 2 - permute nodes.
9373 * - 3 - permute cells and nodes.
9375 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9376 * caller is to delete this field using decrRef() as it is no more needed.
9377 * \throw If the MED file is not readable.
9378 * \throw If there is no mesh in the MED file.
9379 * \throw If no field values of the required parameters are available.
9381 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9383 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9384 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9386 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
9387 MCAuto<DataArray> arrOut;
9388 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9389 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9394 * 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
9395 * method should be called (getFieldOnMeshAtLevel for example).
9396 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
9398 * \param [in] iteration - the iteration number of a required time step.
9399 * \param [in] order - the iteration order number of required time step.
9400 * \param [in] mesh - the mesh the field is lying on
9401 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9402 * caller is to delete this field using decrRef() as it is no more needed.
9404 MEDCouplingFieldDouble *MEDFileFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
9406 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9407 MCAuto<DataArray> arrOut;
9408 MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
9409 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9414 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9416 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9417 * \param [in] type - a spatial discretization of interest.
9418 * \param [in] iteration - the iteration number of a required time step.
9419 * \param [in] order - the iteration order number of required time step.
9420 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9421 * \param [in] mesh - the supporting mesh.
9422 * \param [in] renumPol - specifies how to permute values of the result field according to
9423 * the optional numbers of cells and nodes, if any. The valid values are
9424 * - 0 - do not permute.
9425 * - 1 - permute cells.
9426 * - 2 - permute nodes.
9427 * - 3 - permute cells and nodes.
9429 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9430 * caller is to delete this field using decrRef() as it is no more needed.
9431 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9432 * \throw If no field of \a this is lying on \a mesh.
9433 * \throw If no field values of the required parameters are available.
9435 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9437 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9438 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9440 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9441 MCAuto<DataArray> arrOut;
9442 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
9443 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9448 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9450 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9451 * \param [in] type - a spatial discretization of the new field.
9452 * \param [in] iteration - the iteration number of a required time step.
9453 * \param [in] order - the iteration order number of required time step.
9454 * \param [in] mesh - the supporting mesh.
9455 * \param [in] renumPol - specifies how to permute values of the result field according to
9456 * the optional numbers of cells and nodes, if any. The valid values are
9457 * - 0 - do not permute.
9458 * - 1 - permute cells.
9459 * - 2 - permute nodes.
9460 * - 3 - permute cells and nodes.
9462 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9463 * caller is to delete this field using decrRef() as it is no more needed.
9464 * \throw If no field of \a this is lying on \a mesh.
9465 * \throw If no field values of the required parameters are available.
9467 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
9469 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9470 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9472 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9473 MCAuto<DataArray> arrOut;
9474 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
9475 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9480 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
9481 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9482 * This method is useful for MED2 file format when field on different mesh was autorized.
9484 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
9486 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9487 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9489 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
9490 MCAuto<DataArray> arrOut;
9491 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
9492 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9497 * Returns values and a profile of the field of a given type, of a given time step,
9498 * lying on a given support.
9499 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9500 * \param [in] type - a spatial discretization of the field.
9501 * \param [in] iteration - the iteration number of a required time step.
9502 * \param [in] order - the iteration order number of required time step.
9503 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9504 * \param [in] mesh - the supporting mesh.
9505 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9506 * field of interest lies on. If the field lies on all entities of the given
9507 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9508 * using decrRef() as it is no more needed.
9509 * \param [in] glob - the global data storing profiles and localization.
9510 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
9511 * field. The caller is to delete this array using decrRef() as it is no more needed.
9512 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9513 * \throw If no field of \a this is lying on \a mesh.
9514 * \throw If no field values of the required parameters are available.
9516 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9518 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9519 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9521 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
9522 MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9523 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
9526 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const
9528 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9530 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
9531 const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
9533 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 !");
9537 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull()
9539 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9541 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
9542 MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
9544 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 !");
9549 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9550 * the given field is checked if its elements are sorted suitable for writing to MED file
9551 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9552 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9553 * \param [in] field - the field to add to \a this.
9554 * \throw If the name of \a field is empty.
9555 * \throw If the data array of \a field is not set.
9556 * \throw If existing time steps have different name or number of components than \a field.
9557 * \throw If the underlying mesh of \a field has no name.
9558 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9560 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
9562 const DataArrayDouble *arr=0;
9564 arr=field->getArray();
9565 contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
9569 * Adds a MEDCouplingFieldDouble to \a this as another time step.
9570 * The mesh support of input parameter \a field is ignored here, it can be NULL.
9571 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9574 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9575 * A new profile is added only if no equal profile is missing.
9576 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9577 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
9578 * \param [in] mesh - the supporting mesh of \a field.
9579 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9580 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
9581 * \throw If either \a field or \a mesh or \a profile has an empty name.
9582 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9583 * \throw If the data array of \a field is not set.
9584 * \throw If the data array of \a this is already allocated but has different number of
9585 * components than \a field.
9586 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9587 * \sa setFieldNoProfileSBT()
9589 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9591 const DataArrayDouble *arr=0;
9593 arr=field->getArray();
9594 contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
9597 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
9599 _content=new MEDFileFieldMultiTSWithoutSDA;
9602 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
9603 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
9606 catch(INTERP_KERNEL::Exception& e)
9609 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
9610 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
9613 catch(INTERP_KERNEL::Exception& e)
9616 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9620 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
9622 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
9625 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9627 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9630 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
9632 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
9635 MEDFileFieldMultiTS *MEDFileFieldMultiTS::buildNewEmpty() const
9637 return MEDFileFieldMultiTS::New();
9640 //= MEDFileAnyTypeFieldMultiTSIterator
9642 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
9647 _nb_iter=fmts->getNumberOfTS();
9651 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
9655 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
9657 if(_iter_id<_nb_iter)
9659 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
9661 return fmts->getTimeStepAtPos(_iter_id++);
9669 //= MEDFileIntFieldMultiTS
9672 * Returns a new empty instance of MEDFileFieldMultiTS.
9673 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9674 * is to delete this field using decrRef() as it is no more needed.
9676 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
9678 return new MEDFileIntFieldMultiTS;
9682 * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
9683 * that has been read from a specified MED file.
9684 * \param [in] fileName - the name of the MED file to read.
9685 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9686 * is to delete this field using decrRef() as it is no more needed.
9687 * \throw If reading the file fails.
9689 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll)
9691 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9692 return New(fid,loadAll);
9695 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, bool loadAll)
9697 MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,loadAll,0));
9698 ret->contentNotNull();//to check that content type matches with \a this type.
9703 * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
9704 * that has been read from a specified MED file.
9705 * \param [in] fileName - the name of the MED file to read.
9706 * \param [in] fieldName - the name of the field to read.
9707 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9708 * is to delete this field using decrRef() as it is no more needed.
9709 * \throw If reading the file fails.
9710 * \throw If there is no field named \a fieldName in the file.
9712 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9714 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9715 return New(fid,fieldName,loadAll);
9718 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
9720 MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0));
9721 ret->contentNotNull();//to check that content type matches with \a this type.
9726 * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9727 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9729 * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
9730 * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9731 * \warning this is a shallow copy constructor
9732 * \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
9733 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9734 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9735 * is to delete this field using decrRef() as it is no more needed.
9737 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9739 return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
9742 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9744 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9745 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
9746 MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0,ent));
9747 ret->contentNotNull();//to check that content type matches with \a this type.
9752 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
9753 * following the given input policy.
9755 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9756 * By default (true) the globals are deeply copied.
9757 * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
9759 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const
9761 MCAuto<MEDFileFieldMultiTS> ret;
9762 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9765 const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
9767 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
9768 MCAuto<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
9769 ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc));
9772 ret=MEDFileFieldMultiTS::New();
9774 ret->deepCpyGlobs(*this);
9776 ret->shallowCpyGlobs(*this);
9780 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const
9782 return new MEDFileIntFieldMultiTS(*this);
9785 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9788 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9789 const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
9791 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
9795 * 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
9796 * method should be called (getFieldOnMeshAtLevel for example).
9797 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
9799 * \param [in] iteration - the iteration number of a required time step.
9800 * \param [in] order - the iteration order number of required time step.
9801 * \param [in] mesh - the mesh the field is lying on
9802 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
9803 * caller is to delete this field using decrRef() as it is no more needed.
9805 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
9807 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9808 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9810 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::field : mismatch of type of field expecting INT32 !");
9811 MCAuto<DataArray> arrOut;
9812 MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
9813 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arrOut));
9818 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
9819 * mesh entities of a given dimension of the first mesh in MED file.
9820 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9821 * \param [in] type - a spatial discretization of interest.
9822 * \param [in] iteration - the iteration number of a required time step.
9823 * \param [in] order - the iteration order number of required time step.
9824 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9825 * \param [in] renumPol - specifies how to permute values of the result field according to
9826 * the optional numbers of cells and nodes, if any. The valid values are
9827 * - 0 - do not permute.
9828 * - 1 - permute cells.
9829 * - 2 - permute nodes.
9830 * - 3 - permute cells and nodes.
9832 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9833 * caller is to delete this field using decrRef() as it is no more needed.
9834 * \throw If the MED file is not readable.
9835 * \throw If there is no mesh in the MED file.
9836 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9837 * \throw If no field values of the required parameters are available.
9839 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9841 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9842 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9844 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
9845 MCAuto<DataArray> arr;
9846 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase()));
9847 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9852 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
9853 * the top level cells of the first mesh in MED file.
9854 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9855 * \param [in] type - a spatial discretization of interest.
9856 * \param [in] iteration - the iteration number of a required time step.
9857 * \param [in] order - the iteration order number of required time step.
9858 * \param [in] renumPol - specifies how to permute values of the result field according to
9859 * the optional numbers of cells and nodes, if any. The valid values are
9860 * - 0 - do not permute.
9861 * - 1 - permute cells.
9862 * - 2 - permute nodes.
9863 * - 3 - permute cells and nodes.
9865 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9866 * caller is to delete this field using decrRef() as it is no more needed.
9867 * \throw If the MED file is not readable.
9868 * \throw If there is no mesh in the MED file.
9869 * \throw If no field values of the required parameters are available.
9871 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9873 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9874 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9876 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
9877 MCAuto<DataArray> arr;
9878 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase()));
9879 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9884 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
9886 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9887 * \param [in] type - a spatial discretization of interest.
9888 * \param [in] iteration - the iteration number of a required time step.
9889 * \param [in] order - the iteration order number of required time step.
9890 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9891 * \param [in] mesh - the supporting mesh.
9892 * \param [in] renumPol - specifies how to permute values of the result field according to
9893 * the optional numbers of cells and nodes, if any. The valid values are
9894 * - 0 - do not permute.
9895 * - 1 - permute cells.
9896 * - 2 - permute nodes.
9897 * - 3 - permute cells and nodes.
9899 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9900 * caller is to delete this field using decrRef() as it is no more needed.
9901 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9902 * \throw If no field of \a this is lying on \a mesh.
9903 * \throw If no field values of the required parameters are available.
9905 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9907 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9908 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9910 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9911 MCAuto<DataArray> arr;
9912 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase()));
9913 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9918 * Returns a new MEDCouplingFieldInt of given type, of a given time step, lying on a
9920 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9921 * \param [in] type - a spatial discretization of the new field.
9922 * \param [in] iteration - the iteration number of a required time step.
9923 * \param [in] order - the iteration order number of required time step.
9924 * \param [in] mesh - the supporting mesh.
9925 * \param [out] arrOut - the DataArrayInt containing values of field.
9926 * \param [in] renumPol - specifies how to permute values of the result field according to
9927 * the optional numbers of cells and nodes, if any. The valid values are
9928 * - 0 - do not permute.
9929 * - 1 - permute cells.
9930 * - 2 - permute nodes.
9931 * - 3 - permute cells and nodes.
9933 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9934 * caller is to delete this field using decrRef() as it is no more needed.
9935 * \throw If no field of \a this is lying on \a mesh.
9936 * \throw If no field values of the required parameters are available.
9938 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
9940 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9941 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9943 throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9944 MCAuto<DataArray> arr;
9945 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase()));
9946 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9951 * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
9952 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9953 * This method is useful for MED2 file format when field on different mesh was autorized.
9955 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol) const
9957 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9958 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9960 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9961 MCAuto<DataArray> arr;
9962 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase()));
9963 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9968 * Returns values and a profile of the field of a given type, of a given time step,
9969 * lying on a given support.
9970 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9971 * \param [in] type - a spatial discretization of the field.
9972 * \param [in] iteration - the iteration number of a required time step.
9973 * \param [in] order - the iteration order number of required time step.
9974 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9975 * \param [in] mesh - the supporting mesh.
9976 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9977 * field of interest lies on. If the field lies on all entities of the given
9978 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9979 * using decrRef() as it is no more needed.
9980 * \param [in] glob - the global data storing profiles and localization.
9981 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
9982 * field. The caller is to delete this array using decrRef() as it is no more needed.
9983 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9984 * \throw If no field of \a this is lying on \a mesh.
9985 * \throw If no field values of the required parameters are available.
9987 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9989 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9990 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9992 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
9993 MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9994 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
9998 * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
9999 * \param [in] pos - a time step id.
10000 * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
10001 * delete this field using decrRef() as it is no more needed.
10002 * \throw If \a pos is not a valid time step id.
10004 MEDFileIntField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
10006 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
10009 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
10010 throw INTERP_KERNEL::Exception(oss.str());
10012 const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
10015 MCAuto<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
10016 ret->shallowCpyGlobs(*this);
10019 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
10020 throw INTERP_KERNEL::Exception(oss.str());
10024 * Adds a MEDCouplingFieldInt to \a this as another time step. The underlying mesh of
10025 * the given field is checked if its elements are sorted suitable for writing to MED file
10026 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
10027 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10028 * \param [in] field - the field to add to \a this.
10029 * \throw If the name of \a field is empty.
10030 * \throw If the data array of \a field is not set.
10031 * \throw If existing time steps have different name or number of components than \a field.
10032 * \throw If the underlying mesh of \a field has no name.
10033 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
10035 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldInt *field)
10037 MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
10038 contentNotNull()->appendFieldNoProfileSBT(field2,field->getArray(),*this);
10042 * Adds a MEDCouplingFieldDouble to \a this as another time step.
10043 * The mesh support of input parameter \a field is ignored here, it can be NULL.
10044 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
10047 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
10048 * A new profile is added only if no equal profile is missing.
10049 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10050 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
10051 * \param [in] arrOfVals - the values of the field \a field used.
10052 * \param [in] mesh - the supporting mesh of \a field.
10053 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
10054 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
10055 * \throw If either \a field or \a mesh or \a profile has an empty name.
10056 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10057 * \throw If the data array of \a field is not set.
10058 * \throw If the data array of \a this is already allocated but has different number of
10059 * components than \a field.
10060 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
10061 * \sa setFieldNoProfileSBT()
10063 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
10065 MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
10066 contentNotNull()->appendFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this);
10069 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const
10071 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10073 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
10074 const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10076 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 !");
10080 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull()
10082 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10084 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
10085 MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10087 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 !");
10091 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
10093 _content=new MEDFileIntFieldMultiTSWithoutSDA;
10096 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
10100 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
10101 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
10104 catch(INTERP_KERNEL::Exception& e)
10107 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10108 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
10111 catch(INTERP_KERNEL::Exception& e)
10114 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
10116 return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
10119 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::buildNewEmpty() const
10121 return MEDFileIntFieldMultiTS::New();
10126 MEDFileFields *MEDFileFields::New()
10128 return new MEDFileFields;
10131 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
10133 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10134 return New(fid,loadAll);
10137 MEDFileFields *MEDFileFields::NewWithDynGT(const std::string& fileName, const MEDFileStructureElements *se, bool loadAll)
10139 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10141 throw INTERP_KERNEL::Exception("MEDFileFields::NewWithDynGT : null struct element pointer !");
10142 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> entities(MEDFileEntities::BuildFrom(*se));
10143 return new MEDFileFields(fid,loadAll,0,entities);
10146 MEDFileFields *MEDFileFields::New(med_idt fid, bool loadAll)
10148 return new MEDFileFields(fid,loadAll,0,0);
10151 MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
10153 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10154 return new MEDFileFields(fid,loadAll,ms,0);
10157 MEDFileFields *MEDFileFields::LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
10159 MEDFileUtilities::CheckFileForRead(fileName);
10160 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
10161 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10162 return new MEDFileFields(fid,loadAll,0,ent);
10165 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
10167 std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
10168 ret+=_fields.capacity()*sizeof(MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
10172 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
10174 std::vector<const BigMemoryObject *> ret;
10175 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10176 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
10180 MEDFileFields *MEDFileFields::deepCopy() const
10182 MCAuto<MEDFileFields> ret(shallowCpy());
10184 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10186 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10187 ret->_fields[i]=(*it)->deepCopy();
10189 ret->deepCpyGlobs(*this);
10193 MEDFileFields *MEDFileFields::shallowCpy() const
10195 return new MEDFileFields(*this);
10199 * 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
10200 * 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.
10201 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
10203 * \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.
10204 * \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.
10206 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10208 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
10210 std::set< std::pair<int,int> > s;
10211 bool firstShot=true;
10212 areThereSomeForgottenTS=false;
10213 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10215 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10217 std::vector< std::pair<int,int> > v=(*it)->getIterations();
10218 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
10220 { s=s1; firstShot=false; }
10223 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
10225 areThereSomeForgottenTS=true;
10229 std::vector< std::pair<int,int> > ret;
10230 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
10234 int MEDFileFields::getNumberOfFields() const
10236 return _fields.size();
10239 std::vector<std::string> MEDFileFields::getFieldsNames() const
10241 std::vector<std::string> ret(_fields.size());
10243 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10245 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
10248 ret[i]=f->getName();
10252 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
10253 throw INTERP_KERNEL::Exception(oss.str());
10259 std::vector<std::string> MEDFileFields::getMeshesNames() const
10261 std::vector<std::string> ret;
10262 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10264 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10266 ret.push_back(cur->getMeshName());
10271 std::string MEDFileFields::simpleRepr() const
10273 std::ostringstream oss;
10274 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
10279 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
10281 int nbOfFields(getNumberOfFields());
10282 std::string startLine(bkOffset,' ');
10283 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
10285 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10287 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10290 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
10294 oss << startLine << " - not defined !" << std::endl;
10298 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10300 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10301 std::string chapter(17,'0'+i);
10302 oss << startLine << chapter << std::endl;
10305 cur->simpleRepr(bkOffset+2,oss,i);
10309 oss << startLine << " - not defined !" << std::endl;
10311 oss << startLine << chapter << std::endl;
10313 simpleReprGlobs(oss);
10316 MEDFileFields::MEDFileFields()
10320 MEDFileFields::MEDFileFields(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10321 try:MEDFileFieldGlobsReal(fid)
10323 int nbFields(MEDnField(fid));
10324 _fields.resize(nbFields);
10325 med_field_type typcha;
10326 for(int i=0;i<nbFields;i++)
10328 std::vector<std::string> infos;
10329 std::string fieldName,dtunit;
10330 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,i,false,fieldName,typcha,infos,dtunit));
10335 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10340 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10345 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] !";
10346 throw INTERP_KERNEL::Exception(oss.str());
10350 loadAllGlobals(fid);
10352 catch(INTERP_KERNEL::Exception& e)
10357 void MEDFileFields::writeLL(med_idt fid) const
10360 writeGlobals(fid,*this);
10361 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10363 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
10366 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
10367 throw INTERP_KERNEL::Exception(oss.str());
10369 elt->writeLL(fid,*this);
10374 * This method alloc the arrays and load potentially huge arrays contained in this field.
10375 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
10376 * This method can be also called to refresh or reinit values from a file.
10378 * \throw If the fileName is not set or points to a non readable MED file.
10380 void MEDFileFields::loadArrays()
10382 if(getFileName().empty())
10383 throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
10384 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
10385 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10387 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10389 elt->loadBigArraysRecursively(fid,*elt);
10394 * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
10395 * But once data loaded once, this method does nothing.
10397 * \throw If the fileName is not set or points to a non readable MED file.
10398 * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
10400 void MEDFileFields::loadArraysIfNecessary()
10402 if(!getFileName().empty())
10404 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
10405 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10407 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10409 elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
10415 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
10416 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
10417 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
10419 * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
10421 void MEDFileFields::unloadArrays()
10423 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10425 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10427 elt->unloadArrays();
10432 * 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.
10433 * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
10434 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
10436 * \sa MEDFileFields::loadArraysIfNecessary
10438 void MEDFileFields::unloadArraysWithoutDataLoss()
10440 if(!getFileName().empty())
10444 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
10446 std::vector<std::string> ret;
10447 std::set<std::string> ret2;
10448 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10450 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
10451 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10452 if(ret2.find(*it2)==ret2.end())
10454 ret.push_back(*it2);
10461 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
10463 std::vector<std::string> ret;
10464 std::set<std::string> ret2;
10465 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10467 std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
10468 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10469 if(ret2.find(*it2)==ret2.end())
10471 ret.push_back(*it2);
10478 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
10480 std::vector<std::string> ret;
10481 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10483 std::vector<std::string> tmp((*it)->getPflsReallyUsedMulti2());
10484 ret.insert(ret.end(),tmp.begin(),tmp.end());
10489 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
10491 std::vector<std::string> ret;
10492 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10494 std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
10495 ret.insert(ret.end(),tmp.begin(),tmp.end());
10500 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10502 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10503 (*it)->changePflsRefsNamesGen2(mapOfModif);
10506 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10508 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10509 (*it)->changeLocsRefsNamesGen2(mapOfModif);
10512 void MEDFileFields::resize(int newSize)
10514 _fields.resize(newSize);
10517 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
10519 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
10523 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
10526 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
10527 _fields.push_back(field->getContent());
10528 appendGlobs(*field,1e-12);
10531 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
10534 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
10535 if(i>=(int)_fields.size())
10536 _fields.resize(i+1);
10537 _fields[i]=field->getContent();
10538 appendGlobs(*field,1e-12);
10541 void MEDFileFields::destroyFieldAtPos(int i)
10543 destroyFieldsAtPos(&i,&i+1);
10546 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
10548 std::vector<bool> b(_fields.size(),true);
10549 for(const int *i=startIds;i!=endIds;i++)
10551 if(*i<0 || *i>=(int)_fields.size())
10553 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10554 throw INTERP_KERNEL::Exception(oss.str());
10558 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10560 for(std::size_t i=0;i<_fields.size();i++)
10562 fields[j++]=_fields[i];
10566 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
10568 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
10569 int nbOfEntriesToKill(DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg));
10570 std::vector<bool> b(_fields.size(),true);
10572 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
10574 if(k<0 || k>=(int)_fields.size())
10576 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
10577 throw INTERP_KERNEL::Exception(oss.str());
10581 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10583 for(std::size_t i=0;i<_fields.size();i++)
10585 fields[j++]=_fields[i];
10589 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
10592 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10594 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10596 ret=cur->changeMeshNames(modifTab) || ret;
10602 * \param [in] meshName the name of the mesh that will be renumbered.
10603 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
10604 * This code corresponds to the distribution of types in the corresponding mesh.
10605 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
10606 * \param [in] renumO2N the old to new renumber array.
10607 * \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
10608 * field in \a this.
10610 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
10613 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10615 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
10618 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
10625 * Return an extraction of \a this using \a extractDef map to specify the extraction.
10626 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
10628 * \return A new object that the caller is responsible to deallocate.
10630 MEDFileFields *MEDFileFields::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
10633 throw INTERP_KERNEL::Exception("MEDFileFields::extractPart : input mesh is NULL !");
10634 MCAuto<MEDFileFields> fsOut(MEDFileFields::New());
10635 int nbFields(getNumberOfFields());
10636 for(int i=0;i<nbFields;i++)
10638 MCAuto<MEDFileAnyTypeFieldMultiTS> fmts(getFieldAtPos(i));
10641 std::ostringstream oss; oss << "MEDFileFields::extractPart : at pos #" << i << " field is null !";
10642 throw INTERP_KERNEL::Exception(oss.str());
10644 MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(fmts->extractPart(extractDef,mm));
10645 fsOut->pushField(fmtsOut);
10647 return fsOut.retn();
10650 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
10652 if(i<0 || i>=(int)_fields.size())
10654 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
10655 throw INTERP_KERNEL::Exception(oss.str());
10657 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
10660 MCAuto<MEDFileAnyTypeFieldMultiTS> ret;
10661 const MEDFileFieldMultiTSWithoutSDA *fmtsC(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts));
10662 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts));
10664 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
10666 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
10669 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
10670 throw INTERP_KERNEL::Exception(oss.str());
10672 ret->shallowCpyGlobs(*this);
10677 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
10678 * This method is accessible in python using __getitem__ with a list in input.
10679 * \return a new object that the caller should deal with.
10681 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
10683 MCAuto<MEDFileFields> ret=shallowCpy();
10684 std::size_t sz=std::distance(startIds,endIds);
10685 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
10687 for(const int *i=startIds;i!=endIds;i++,j++)
10689 if(*i<0 || *i>=(int)_fields.size())
10691 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10692 throw INTERP_KERNEL::Exception(oss.str());
10694 fields[j]=_fields[*i];
10696 ret->_fields=fields;
10700 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
10702 return getFieldAtPos(getPosFromFieldName(fieldName));
10706 * This method removes, if any, fields in \a this having no time steps.
10707 * 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.
10709 * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
10711 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
10713 std::vector<MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
10714 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10716 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10719 if(elt->getNumberOfTS()>0)
10720 newFields.push_back(*it);
10723 if(_fields.size()==newFields.size())
10730 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
10731 * This method can be seen as a filter applied on \a this, that returns an object containing
10732 * 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
10733 * shallow copied from \a this.
10735 * \param [in] meshName - the name of the mesh on w
10736 * \return a new object that the caller should deal with.
10738 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
10740 MCAuto<MEDFileFields> ret(MEDFileFields::New());
10741 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10743 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10746 if(cur->getMeshName()==meshName)
10749 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
10750 ret->_fields.push_back(cur2);
10753 ret->shallowCpyOnlyUsedGlobs(*this);
10758 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
10759 * Input time steps are specified using a pair of integer (iteration, order).
10760 * 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,
10761 * but for each multitimestep only the time steps in \a timeSteps are kept.
10762 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
10764 * The returned object points to shallow copy of elements in \a this.
10766 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
10767 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
10768 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10770 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10772 MCAuto<MEDFileFields> ret(MEDFileFields::New());
10773 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10775 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10778 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
10779 ret->_fields.push_back(elt);
10781 ret->shallowCpyOnlyUsedGlobs(*this);
10786 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
10788 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10790 MCAuto<MEDFileFields> ret=MEDFileFields::New();
10791 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10793 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10796 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
10797 if(elt->getNumberOfTS()!=0)
10798 ret->_fields.push_back(elt);
10800 ret->shallowCpyOnlyUsedGlobs(*this);
10804 MEDFileFieldsIterator *MEDFileFields::iterator()
10806 return new MEDFileFieldsIterator(this);
10809 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
10811 std::string tmp(fieldName);
10812 std::vector<std::string> poss;
10813 for(std::size_t i=0;i<_fields.size();i++)
10815 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f(_fields[i]);
10818 std::string fname(f->getName());
10822 poss.push_back(fname);
10825 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
10826 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
10828 throw INTERP_KERNEL::Exception(oss.str());
10831 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
10836 _nb_iter=fs->getNumberOfFields();
10840 MEDFileFieldsIterator::~MEDFileFieldsIterator()
10844 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
10846 if(_iter_id<_nb_iter)
10848 MEDFileFields *fs(_fs);
10850 return fs->getFieldAtPos(_iter_id++);