1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (CEA/DEN)
21 #include "MEDFileField.txx"
22 #include "MEDFileMesh.hxx"
23 #include "MEDLoaderBase.hxx"
24 #include "MEDLoaderTraits.hxx"
25 #include "MEDFileSafeCaller.txx"
26 #include "MEDFileFieldOverView.hxx"
28 #include "MEDCouplingFieldDouble.hxx"
29 #include "MEDCouplingFieldTemplate.hxx"
30 #include "MEDCouplingFieldDiscretization.hxx"
32 #include "InterpKernelAutoPtr.hxx"
33 #include "CellModel.hxx"
38 extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
39 extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
40 extern med_geometry_type typmainoeud[1];
41 extern med_geometry_type typmai3[34];
43 using namespace MEDCoupling;
45 template class MEDFileField1TSTemplateWithoutSDA<int>;
46 template class MEDFileField1TSTemplateWithoutSDA<double>;
48 const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64";
49 const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32";
51 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const std::string& locName)
53 return new MEDFileFieldLoc(fid,locName);
56 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, int id)
58 return new MEDFileFieldLoc(fid,id);
61 MEDFileFieldLoc *MEDFileFieldLoc::New(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
63 return new MEDFileFieldLoc(locName,geoType,refCoo,gsCoo,w);
66 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, const std::string& locName):_name(locName)
68 med_geometry_type geotype;
69 med_geometry_type sectiongeotype;
71 INTERP_KERNEL::AutoPtr<char> geointerpname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
72 INTERP_KERNEL::AutoPtr<char> sectionmeshname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
73 MEDlocalizationInfoByName(fid,locName.c_str(),&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
74 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
75 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
76 _nb_node_per_cell=cm.getNumberOfNodes();
77 _ref_coo.resize(_dim*_nb_node_per_cell);
78 _gs_coo.resize(_dim*_nb_gauss_pt);
79 _w.resize(_nb_gauss_pt);
80 MEDlocalizationRd(fid,locName.c_str(),MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
83 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id)
85 med_geometry_type geotype;
86 med_geometry_type sectiongeotype;
88 INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
89 INTERP_KERNEL::AutoPtr<char> geointerpname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
90 INTERP_KERNEL::AutoPtr<char> sectionmeshname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
91 MEDlocalizationInfo(fid,id+1,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
93 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
94 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
95 _nb_node_per_cell=cm.getNumberOfNodes();
96 _ref_coo.resize(_dim*_nb_node_per_cell);
97 _gs_coo.resize(_dim*_nb_gauss_pt);
98 _w.resize(_nb_gauss_pt);
99 MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
102 MEDFileFieldLoc::MEDFileFieldLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType,
103 const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w):_name(locName),_geo_type(geoType),_ref_coo(refCoo),_gs_coo(gsCoo),
106 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
107 _dim=cm.getDimension();
108 _nb_node_per_cell=cm.getNumberOfNodes();
109 _nb_gauss_pt=_w.size();
112 MEDFileFieldLoc *MEDFileFieldLoc::deepCopy() const
114 return new MEDFileFieldLoc(*this);
117 std::size_t MEDFileFieldLoc::getHeapMemorySizeWithoutChildren() const
119 return (_ref_coo.capacity()+_gs_coo.capacity()+_w.capacity())*sizeof(double)+_name.capacity();
122 std::vector<const BigMemoryObject *> MEDFileFieldLoc::getDirectChildrenWithNull() const
124 return std::vector<const BigMemoryObject *>();
127 void MEDFileFieldLoc::simpleRepr(std::ostream& oss) const
129 static const char OFF7[]="\n ";
130 oss << "\"" << _name << "\"" << OFF7;
131 oss << "GeoType=" << INTERP_KERNEL::CellModel::GetCellModel(_geo_type).getRepr() << OFF7;
132 oss << "Dimension=" << _dim << OFF7;
133 oss << "Number of Gauss points=" << _nb_gauss_pt << OFF7;
134 oss << "Number of nodes per cell=" << _nb_node_per_cell << OFF7;
135 oss << "RefCoords="; std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
136 oss << "Weights="; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
137 oss << "GaussPtsCoords="; std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," ")); oss << std::endl;
140 void MEDFileFieldLoc::setName(const std::string& name)
145 bool MEDFileFieldLoc::isEqual(const MEDFileFieldLoc& other, double eps) const
147 if(_name!=other._name)
151 if(_nb_gauss_pt!=other._nb_gauss_pt)
153 if(_nb_node_per_cell!=other._nb_node_per_cell)
155 if(_geo_type!=other._geo_type)
157 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_ref_coo,other._ref_coo,eps))
159 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_gs_coo,other._gs_coo,eps))
161 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_w,other._w,eps))
167 void MEDFileFieldLoc::writeLL(med_idt fid) const
169 MEDlocalizationWr(fid,_name.c_str(),typmai3[(int)_geo_type],_dim,&_ref_coo[0],MED_FULL_INTERLACE,_nb_gauss_pt,&_gs_coo[0],&_w[0],MED_NO_INTERPOLATION,MED_NO_MESH_SUPPORT);
172 std::string MEDFileFieldLoc::repr() const
174 std::ostringstream oss; oss.precision(15);
175 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
176 oss << "Localization \"" << _name << "\" :\n" << " - Geometric Type : " << cm.getRepr();
177 oss << "\n - Dimension : " << _dim << "\n - Number of gauss points : ";
178 oss << _nb_gauss_pt << "\n - Number of nodes in cell : " << _nb_node_per_cell;
179 oss << "\n - Ref coords are : ";
180 int sz=_ref_coo.size();
183 int nbOfTuples=sz/_dim;
184 for(int i=0;i<nbOfTuples;i++)
187 for(int j=0;j<_dim;j++)
188 { oss << _ref_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
193 std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," "));
194 oss << "\n - Gauss coords in reference element : ";
198 int nbOfTuples=sz/_dim;
199 for(int i=0;i<nbOfTuples;i++)
202 for(int j=0;j<_dim;j++)
203 { oss << _gs_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
208 std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," "));
209 oss << "\n - Weights of Gauss coords are : "; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," "));
213 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
215 _type=field->getTypeOfField();
221 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,offset,offset+nbOfCells,1);
222 _end=_start+nbOfCells;
228 MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
229 const int *arrPtr=arr->getConstPointer();
230 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,arrPtr[offset],arrPtr[offset+nbOfCells],1);
231 _end=_start+(arrPtr[offset+nbOfCells]-arrPtr[offset]);
237 const MEDCouplingFieldDiscretization *disc(field->getDiscretization());
238 const MEDCouplingGaussLocalization& gsLoc(field->getGaussLocalization(_loc_id));
239 const MEDCouplingFieldDiscretizationGauss *disc2(dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc));
241 throw INTERP_KERNEL::Exception("assignFieldNoProfile : invalid call to this method ! Internal Error !");
242 const DataArrayInt *dai(disc2->getArrayOfDiscIds());
243 MCAuto<DataArrayInt> dai2(disc2->getOffsetArr(field->getMesh()));
244 const int *dai2Ptr(dai2->getConstPointer());
245 int nbi(gsLoc.getWeights().size());
246 MCAuto<DataArrayInt> da2(dai->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1));
247 MCAuto<DataArrayInt> da3(da2->findIdsEqual(_loc_id));
248 const int *da3Ptr(da3->getConstPointer());
249 if(da3->getNumberOfTuples()!=nbOfCells)
250 {//profile : for gauss even in NoProfile !!!
251 std::ostringstream oss; oss << "Pfl_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
253 da3->setName(_profile.c_str());
254 glob.appendProfile(da3);
256 MCAuto<DataArrayInt> da4(DataArrayInt::New());
257 _nval=da3->getNbOfElems();
258 da4->alloc(_nval*nbi,1);
259 int *da4Ptr(da4->getPointer());
260 for(int i=0;i<_nval;i++)
262 int ref=dai2Ptr[offset+da3Ptr[i]];
263 for(int j=0;j<nbi;j++)
266 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
267 _localization=oss2.str();
268 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,da4);
269 _end=_start+_nval*nbi;
270 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
274 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile : not implemented yet for such discretization type of field !");
280 * Leaf method of field with profile assignement. This method is the most general one. No optimization is done here.
281 * \param [in] pflName input containing name of profile if any. 0 if no profile (except for GAUSS_PT where a no profile can hide a profile when splitted by loc_id).
282 * \param [in] multiTypePfl is the end user profile specified in high level API
283 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
284 * \param [in] locIds is the profile needed to be created for MED file format. It can be null if all cells of current geometric type are fetched in \a multiTypePfl.
285 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
286 * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
288 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arrr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
291 _type=field->getTypeOfField();
292 std::string pflName(multiTypePfl->getName());
293 std::ostringstream oss; oss << pflName;
297 { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType()); oss << "_" << cm.getRepr(); }
304 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : existing profile with empty name !");
305 if(_type!=ON_GAUSS_PT)
307 locIds->setName(oss.str());
308 glob.appendProfile(locIds);
317 _nval=idsInPfl->getNumberOfTuples();
318 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,0,arrr->getNumberOfTuples(),1);
324 _nval=idsInPfl->getNumberOfTuples();
325 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,idsInPfl);
331 MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
332 MCAuto<DataArrayInt> arr2=arr->deltaShiftIndex();
333 MCAuto<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->begin(),multiTypePfl->end());
334 arr3->computeOffsetsFull();
335 MCAuto<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
336 int trueNval=tmp->getNumberOfTuples();
337 _nval=idsInPfl->getNumberOfTuples();
338 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
339 _end=_start+trueNval;
344 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(field->getDiscretization());
346 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
347 const DataArrayInt *da1=disc2->getArrayOfDiscIds();
348 const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
349 MCAuto<DataArrayInt> da2=da1->selectByTupleId(idsInPfl->begin(),idsInPfl->end());
350 MCAuto<DataArrayInt> da3=da2->findIdsEqual(_loc_id);
351 MCAuto<DataArrayInt> da4=idsInPfl->selectByTupleId(da3->begin(),da3->end());
353 MCAuto<MEDCouplingMesh> mesh2=mesh->buildPart(multiTypePfl->begin(),multiTypePfl->end());
354 MCAuto<DataArrayInt> arr=disc2->getOffsetArr(mesh2);
356 MCAuto<DataArrayInt> tmp=DataArrayInt::New();
358 for(const int *pt=da4->begin();pt!=da4->end();pt++)
359 trueNval+=arr->getIJ(*pt+1,0)-arr->getIJ(*pt,0);
360 tmp->alloc(trueNval,1);
361 int *tmpPtr=tmp->getPointer();
362 for(const int *pt=da4->begin();pt!=da4->end();pt++)
363 for(int j=arr->getIJ(*pt,0);j<arr->getIJ(*pt+1,0);j++)
366 _nval=da4->getNumberOfTuples();
367 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
368 _end=_start+trueNval;
369 oss << "_loc_" << _loc_id;
372 MCAuto<DataArrayInt> da5=locIds->selectByTupleId(da3->begin(),da3->end());
373 da5->setName(oss.str());
374 glob.appendProfile(da5);
379 if(!da3->isIota(nbOfEltsInWholeMesh))
381 da3->setName(oss.str());
382 glob.appendProfile(da3);
386 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
387 _localization=oss2.str();
388 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
392 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for such discretization type of field !");
397 void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob)
400 _nval=arrr->getNumberOfTuples();
401 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,0,_nval,1);
406 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int profileIt, const PartDefinition *pd)
408 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt,pd);
411 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int locId)
413 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string());
416 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(const MEDFileFieldPerMeshPerTypePerDisc& other)
418 return new MEDFileFieldPerMeshPerTypePerDisc(other);
421 std::size_t MEDFileFieldPerMeshPerTypePerDisc::getHeapMemorySizeWithoutChildren() const
423 return _profile.capacity()+_localization.capacity()+sizeof(MEDFileFieldPerMeshPerTypePerDisc);
426 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypePerDisc::getDirectChildrenWithNull() const
428 std::vector<const BigMemoryObject *> ret(1);
429 ret[0]=(const PartDefinition*)_pd;
433 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCopy(MEDFileFieldPerMeshPerTypeCommon *father) const
435 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret=new MEDFileFieldPerMeshPerTypePerDisc(*this);
440 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField atype, int profileIt, const PartDefinition *pd)
441 try:_type(atype),_father(fath),_profile_it(profileIt),_pd(const_cast<PartDefinition *>(pd))
446 catch(INTERP_KERNEL::Exception& e)
451 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
455 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(const MEDFileFieldPerMeshPerTypePerDisc& other):RefCountObject(other),_type(other._type),_father(0),_start(other._start),_end(other._end),_nval(other._nval),_profile(other._profile),_localization(other._localization),_loc_id(other._loc_id),_profile_it(other._profile_it),_pd(other._pd),_tmp_work1(other._tmp_work1)
459 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(0),_start(-std::numeric_limits<int>::max()),_end(-std::numeric_limits<int>::max()),
460 _nval(-std::numeric_limits<int>::max()),_loc_id(-std::numeric_limits<int>::max())
464 void MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile(med_idt fid, const std::string& fieldName, int nbOfCompo, int iteration, int order, med_entity_type menti, med_geometry_type mgeoti, unsigned char *startFeedingPtr)
466 const PartDefinition *pd(_pd);
469 INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
471 med_int nbValsInFile(MEDfieldnValueWithProfileByName(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile.c_str(),MED_COMPACT_PFLMODE,&tmp1,locname,&nbi));
472 if(_end-_start!=nbValsInFile*nbi)
474 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : The number of tuples to read is " << nbValsInFile << "*" << nbi << " (nb integration points) ! But in data structure it values " << _end-_start << " is expected !";
475 throw INTERP_KERNEL::Exception(oss.str());
477 MEDFILESAFECALLERRD0(MEDfieldValueWithProfileRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,_profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,startFeedingPtr));
481 if(!_profile.empty())
482 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : not implemented !");
483 INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)),locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
485 int overallNval(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
486 const SlicePartDefinition *spd(dynamic_cast<const SlicePartDefinition *>(pd));
490 spd->getSlice(start,stop,step);
491 int nbOfEltsToLoad(DataArray::GetNumberOfItemGivenBES(start,stop,step,"MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile"));
492 med_filter filter=MED_FILTER_INIT;
493 MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
494 MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
495 /*start*/start+1,/*stride*/step,/*count*/1,/*blocksize*/nbOfEltsToLoad,
496 /*lastblocksize=useless because count=1*/0,&filter);
497 MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,startFeedingPtr));
498 MEDfilterClose(&filter);
501 const DataArrayPartDefinition *dpd(dynamic_cast<const DataArrayPartDefinition *>(pd));
504 dpd->checkConsistencyLight();
505 MCAuto<DataArrayInt> myIds(dpd->toDAI());
506 int a(myIds->getMinValueInArray()),b(myIds->getMaxValueInArray());
507 myIds=myIds->deepCopy();// WARNING deep copy here because _pd is modified by applyLin !!!
508 myIds->applyLin(1,-a);
509 int nbOfEltsToLoad(b-a+1);
510 med_filter filter=MED_FILTER_INIT;
511 {//TODO : manage int32 !
512 MCAuto<DataArrayDouble> tmp(DataArrayDouble::New());
513 tmp->alloc(nbOfEltsToLoad,nbOfCompo);
514 MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
515 MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
516 /*start*/a+1,/*stride*/1,/*count*/1,/*blocksize*/nbOfEltsToLoad,
517 /*lastblocksize=useless because count=1*/0,&filter);
518 MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,reinterpret_cast<unsigned char *>(tmp->getPointer())));
519 MCAuto<DataArrayDouble> feeder(DataArrayDouble::New());
520 feeder->useExternalArrayWithRWAccess(reinterpret_cast<double *>(startFeedingPtr),_nval,nbOfCompo);
521 feeder->setContigPartOfSelectedValues(0,tmp,myIds);
523 MEDfilterClose(&filter);
526 throw INTERP_KERNEL::Exception("Not implemented yet for not slices!");
530 const MEDFileFieldPerMeshPerTypeCommon *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
535 void MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
537 INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
538 INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
539 std::string fieldName(nasc.getName()),meshName(getMeshName());
540 int iteration(getIteration()),order(getOrder()),profilesize,nbi;
541 TypeOfField type(getType());
542 med_geometry_type mgeoti;
543 med_entity_type menti;
544 _father->entriesForMEDfile(type,mgeoti,menti);
545 int zeNVal(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
546 _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
547 _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
548 const PartDefinition *pd(_pd);
555 if(!_profile.empty())
556 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively : profiles are not managed yet with part of def !");
557 _nval=pd->getNumberOfElems();
560 _end=start+_nval*nbi;
562 if(type==ON_CELLS && !_localization.empty())
564 if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
565 setType(ON_GAUSS_PT);
568 setType(ON_GAUSS_NE);
569 _localization.clear();
574 void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, const MEDFileFieldNameScope& nasc)
576 std::string fieldName(nasc.getName()),meshName(getMeshName());
577 int iteration(getIteration()),order(getOrder());
578 TypeOfField type(getType());
579 med_geometry_type mgeoti;
580 med_entity_type menti;
581 _father->entriesForMEDfile(type,mgeoti,menti);
583 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !");
586 DataArray *arr(getOrCreateAndGetArray());//arr is not null due to the spec of getOrCreateAndGetArray
587 if(_start<0 || _start>=arr->getNumberOfTuples())
589 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << ") !";
590 throw INTERP_KERNEL::Exception(oss.str());
592 if(_end<0 || _end>arr->getNumberOfTuples())
594 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !";
595 throw INTERP_KERNEL::Exception(oss.str());
597 int nbOfCompo(arr->getNumberOfComponents());
598 DataArrayDouble *arrD(dynamic_cast<DataArrayDouble *>(arr));
601 double *startFeeding(arrD->getPointer()+_start*nbOfCompo);
602 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
605 DataArrayInt *arrI(dynamic_cast<DataArrayInt *>(arr));
608 int *startFeeding(arrI->getPointer()+_start*nbOfCompo);
609 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
612 throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
616 * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
618 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart)
620 int delta=_end-_start;
621 _start=newValueOfStart;
625 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
627 return _father->getIteration();
630 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
632 return _father->getOrder();
635 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
637 return _father->getTime();
640 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
642 return _father->getMeshName();
645 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
647 const char startLine[]=" ## ";
648 std::string startLine2(bkOffset,' ');
649 startLine2+=startLine;
650 INTERP_KERNEL::AutoCppPtr<MEDCouplingFieldDiscretization> tmp(MEDCouplingFieldDiscretization::New(_type));
651 oss << startLine2 << "Localization #" << id << "." << std::endl;
652 oss << startLine2 << " Type=" << tmp->getRepr() << "." << std::endl;
653 oss << startLine2 << " This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
654 oss << startLine2 << " This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
655 oss << startLine2 << " This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
658 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
663 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
665 return _father->getGeoType();
668 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
673 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
678 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
680 return _father->getNumberOfComponents();
683 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
688 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray()
690 return _father->getOrCreateAndGetArray();
693 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const
695 const MEDFileFieldPerMeshPerTypeCommon *fath=_father;
696 return fath->getOrCreateAndGetArray();
699 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
701 return _father->getInfo();
704 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
709 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const std::string& newPflName)
714 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
716 return _localization;
719 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const std::string& newLocName)
721 _localization=newLocName;
724 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
726 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
728 if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
730 _profile=(*it2).second;
736 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
738 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
740 if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
742 _localization=(*it2).second;
748 void MEDFileFieldPerMeshPerTypePerDisc::getFieldAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
752 dads.push_back(std::pair<int,int>(_start,_end));
753 geoTypes.push_back(getGeoType());
758 pfls.push_back(glob->getProfile(_profile.c_str()));
760 if(_localization.empty())
764 locs.push_back(glob->getLocalizationId(_localization.c_str()));
768 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
770 entries[startEntryId]=std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int> ,std::pair<int,int> >(std::pair<INTERP_KERNEL::NormalizedCellType,int>(getGeoType(),discId),std::pair<int,int>(_start,_end));
774 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
776 TypeOfField type=getType();
777 INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
778 med_geometry_type mgeoti;
779 med_entity_type menti;
780 _father->entriesForMEDfile(getType(),mgeoti,menti);
781 const DataArray *arr(getOrCreateAndGetArray());
783 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
784 if(!arr->isAllocated())
785 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : the array to be written is not allocated !");
786 const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
787 const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
788 const unsigned char *locToWrite=0;
790 locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
792 locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
794 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
795 MEDFILESAFECALLERWR0(MEDfieldValueWithProfileWr,(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
796 MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
800 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const
805 dad.first=_start; dad.second=_end;
809 * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
810 * This code corresponds to the distribution of types in the corresponding mesh.
811 * \param [out] ptToFill memory zone where the output will be stored.
812 * \return the size of data pushed into output param \a ptToFill
814 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const
817 std::ostringstream oss;
818 std::size_t nbOfType=codeOfMesh.size()/3;
820 for(std::size_t i=0;i<nbOfType && found==-1;i++)
821 if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
825 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
826 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
827 throw INTERP_KERNEL::Exception(oss.str());
832 if(_nval!=codeOfMesh[3*found+1])
834 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
835 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
836 oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
837 throw INTERP_KERNEL::Exception(oss.str());
839 for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
844 const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
845 if(pfl->getNumberOfTuples()!=_nval)
847 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
848 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
850 oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
851 throw INTERP_KERNEL::Exception(oss.str());
853 int offset2=codeOfMesh[3*found+2];
854 for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
856 if(*pflId<codeOfMesh[3*found+1])
857 *work++=offset2+*pflId;
863 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const
865 for(int i=_start;i<_end;i++)
870 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId)
881 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
885 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
888 std::map<std::pair<std::string,TypeOfField>,int> m;
889 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
890 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
891 if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
892 m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
894 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
895 ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
900 * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
902 * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
903 * \param [in] entriesOnSameDisc some entries **on same localization** if not the result can be invalid. The _start and _end on them are relative to \a arr parameter.
904 * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
905 * \param [in] newCode one of the input parameter to explicit the new geo type dispatch (in classical format same than those asked by MEDFileFields::renumberEntitiesLyingOnMesh)
906 * \param [in,out] glob if necessary by the method, new profiles can be added to it
907 * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
908 * \param [out] result All new entries will be appended on it.
909 * \return false if the configuration of renumbering leads to an unnecessary resplit of input \a entriesOnSameDisc. If not true is returned (the most general case !)
911 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
912 const DataArrayInt *explicitIdsInMesh,
913 const std::vector<int>& newCode,
914 MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
915 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >& result)
917 if(entriesOnSameDisc.empty())
919 TypeOfField type=entriesOnSameDisc[0]->getType();
920 int szEntities=0,szTuples=0;
921 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
922 { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
923 int nbi=szTuples/szEntities;
924 if(szTuples%szEntities!=0)
925 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
926 MCAuto<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
927 MCAuto<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
928 std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
929 std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
930 std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
931 std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
932 MCAuto<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
934 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
936 int startOfEltIdOfChunk=(*it)->_start;
937 MCAuto<DataArrayInt> newEltIds=explicitIdsInMesh->subArray(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
938 MCAuto<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
939 MCAuto<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
941 MCAuto<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
942 newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
944 newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
945 newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
947 MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
948 MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
949 MCAuto<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
950 MCAuto<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
952 MCAuto<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
954 MCAuto<DataArrayDouble> arrPart=arr->subArray(offset,offset+szTuples);
955 arrPart->renumberInPlace(renumTupleIds->begin());
956 arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
958 const int *idIt=diffVals->begin();
959 std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
961 for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
963 MCAuto<DataArrayInt> ids=newGeoTypesEltIdsAllGather->findIdsEqual(*idIt);
964 MCAuto<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
965 int nbEntityElts=subIds->getNumberOfTuples();
967 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
968 NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIota(newCode[3*(*idIt)+1]),nbi,
972 result.push_back(eltToAdd);
973 offset2+=nbEntityElts*nbi;
975 ret=ret || li.empty();
980 * \param [in] typeF type of field of new chunk
981 * \param [in] geoType the geometric type of the chunk
982 * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
983 * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
984 * \param [in] nbi number of integration points
985 * \param [in] offset The offset in the **global array of data**.
986 * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
987 * to the new chunk to create.
988 * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
989 * \param [out] notInExisting If false the return newly allocated entry is not coming from \a entriesOnSameDisc. If true the output comes from copy of \a entriesOnSameDisc
990 * and corresponding entry erased from \a entriesOnSameDisc.
991 * \return a newly allocated chunk
993 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
994 bool isPfl, int nbi, int offset,
995 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
996 MEDFileFieldGlobsReal& glob,
999 int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
1000 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
1001 for(;it!=entriesOnSameDisc.end();it++)
1003 if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
1007 if((*it)->_profile.empty())
1010 if(!(*it)->_profile.empty())
1012 const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
1013 if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
1019 if(it==entriesOnSameDisc.end())
1022 MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
1024 ret->_loc_id=(int)geoType;
1025 ret->_nval=nbMeshEntities;
1027 ret->_end=ret->_start+ret->_nval*nbi;
1030 idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
1031 glob.appendProfile(idsOfMeshElt);
1032 ret->_profile=idsOfMeshElt->getName();
1034 //tony treatment of localization
1039 notInExisting=false;
1040 MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1041 ret->_loc_id=(int)geoType;
1042 ret->setNewStart(offset);
1043 entriesOnSameDisc.erase(it);
1049 ////////////////////////////////////
1051 MEDFileFieldPerMeshPerTypeCommon::~MEDFileFieldPerMeshPerTypeCommon()
1055 void MEDFileFieldPerMeshPerTypeCommon::setFather(MEDFileFieldPerMesh *father)
1060 void MEDFileFieldPerMeshPerTypeCommon::deepCopyElements()
1063 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1065 if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
1066 _field_pm_pt_pd[i]=(*it)->deepCopy(this);
1070 std::size_t MEDFileFieldPerMeshPerTypeCommon::getHeapMemorySizeWithoutChildren() const
1072 return _field_pm_pt_pd.capacity()*sizeof(MCAuto<MEDFileFieldPerMeshPerTypePerDisc>);
1075 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypeCommon::getDirectChildrenWithNull() const
1077 std::vector<const BigMemoryObject *> ret;
1078 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1079 ret.push_back((const MEDFileFieldPerMeshPerTypePerDisc *)*it);
1083 void MEDFileFieldPerMeshPerTypeCommon::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1085 std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
1086 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1087 _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1091 * This method is the most general one. No optimization is done here.
1092 * \param [in] multiTypePfl is the end user profile specified in high level API
1093 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1094 * \param [in] locIds is the profile needed to be created for MED file format. It can be null if all cells of current geometric type are fetched in \a multiTypePfl.
1095 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1096 * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1097 * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
1099 void MEDFileFieldPerMeshPerTypeCommon::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1101 std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1102 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1103 _field_pm_pt_pd[*it]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1106 void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1108 _field_pm_pt_pd.resize(1);
1109 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1110 _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1113 void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1115 MCAuto<DataArrayInt> pfl2=pfl->deepCopy();
1116 if(!arr || !arr->isAllocated())
1117 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile : input array is null, or not allocated !");
1118 _field_pm_pt_pd.resize(1);
1119 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1120 _field_pm_pt_pd[0]->assignFieldProfile(true,start,pfl,pfl2,pfl2,-1,field,arr,0,glob,nasc);//mesh is not requested so 0 is send.
1123 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1125 TypeOfField type=field->getTypeOfField();
1126 if(type!=ON_GAUSS_PT)
1128 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1129 int sz=_field_pm_pt_pd.size();
1131 for(int j=0;j<sz && !found;j++)
1133 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1135 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1141 _field_pm_pt_pd.resize(sz+1);
1142 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1144 std::vector<int> ret(1,(int)sz);
1149 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1150 int sz2=ret2.size();
1151 std::vector<int> ret3(sz2);
1153 for(int i=0;i<sz2;i++)
1155 int sz=_field_pm_pt_pd.size();
1156 int locIdToFind=ret2[i];
1158 for(int j=0;j<sz && !found;j++)
1160 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1162 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1169 _field_pm_pt_pd.resize(sz+1);
1170 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1178 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1180 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1181 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1183 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1184 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1186 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1187 MCAuto<DataArrayInt> da2=da->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1);
1188 MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1189 if(retTmp->presenceOfValue(-1))
1190 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1191 std::vector<int> ret(retTmp->begin(),retTmp->end());
1195 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1197 TypeOfField type=field->getTypeOfField();
1198 if(type!=ON_GAUSS_PT)
1200 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1201 int sz=_field_pm_pt_pd.size();
1203 for(int j=0;j<sz && !found;j++)
1205 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1207 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1213 _field_pm_pt_pd.resize(sz+1);
1214 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1216 std::vector<int> ret(1,0);
1221 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1222 int sz2=ret2.size();
1223 std::vector<int> ret3(sz2);
1225 for(int i=0;i<sz2;i++)
1227 int sz=_field_pm_pt_pd.size();
1228 int locIdToFind=ret2[i];
1230 for(int j=0;j<sz && !found;j++)
1232 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1234 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1241 _field_pm_pt_pd.resize(sz+1);
1242 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1250 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1252 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1253 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1255 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1256 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1258 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1259 MCAuto<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1260 MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1261 if(retTmp->presenceOfValue(-1))
1262 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1263 std::vector<int> ret(retTmp->begin(),retTmp->end());
1267 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerTypeCommon::getFather() const
1272 bool MEDFileFieldPerMeshPerTypeCommon::isUniqueLevel(int& dim) const
1274 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
1275 int curDim((int)cm.getDimension());
1276 if(dim!=std::numeric_limits<int>::max())
1286 void MEDFileFieldPerMeshPerTypeCommon::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1288 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1290 (*it)->fillTypesOfFieldAvailable(types);
1294 void MEDFileFieldPerMeshPerTypeCommon::fillFieldSplitedByType(std::vector< std::pair<int,int> >& dads, std::vector<TypeOfField>& types, std::vector<std::string>& pfls, std::vector<std::string>& locs) const
1296 int sz=_field_pm_pt_pd.size();
1297 dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1298 for(int i=0;i<sz;i++)
1300 _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1304 int MEDFileFieldPerMeshPerTypeCommon::getIteration() const
1306 return _father->getIteration();
1309 int MEDFileFieldPerMeshPerTypeCommon::getOrder() const
1311 return _father->getOrder();
1314 double MEDFileFieldPerMeshPerTypeCommon::getTime() const
1316 return _father->getTime();
1319 std::string MEDFileFieldPerMeshPerTypeCommon::getMeshName() const
1321 return _father->getMeshName();
1324 void MEDFileFieldPerMeshPerTypeCommon::getSizes(int& globalSz, int& nbOfEntries) const
1326 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1328 globalSz+=(*it)->getNumberOfTuples();
1330 nbOfEntries+=(int)_field_pm_pt_pd.size();
1333 int MEDFileFieldPerMeshPerTypeCommon::getNumberOfComponents() const
1335 return _father->getNumberOfComponents();
1338 bool MEDFileFieldPerMeshPerTypeCommon::presenceOfMultiDiscPerGeoType() const
1341 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1343 const MEDFileFieldPerMeshPerTypePerDisc *fmtd(*it);
1350 DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray()
1352 return _father->getOrCreateAndGetArray();
1355 const DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray() const
1357 const MEDFileFieldPerMesh *fath=_father;
1358 return fath->getOrCreateAndGetArray();
1361 const std::vector<std::string>& MEDFileFieldPerMeshPerTypeCommon::getInfo() const
1363 return _father->getInfo();
1366 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsed() const
1368 std::vector<std::string> ret;
1369 std::set<std::string> ret2;
1370 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1372 std::string tmp=(*it1)->getProfile();
1374 if(ret2.find(tmp)==ret2.end())
1383 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsed() const
1385 std::vector<std::string> ret;
1386 std::set<std::string> ret2;
1387 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1389 std::string tmp=(*it1)->getLocalization();
1390 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1391 if(ret2.find(tmp)==ret2.end())
1400 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsedMulti() const
1402 std::vector<std::string> ret;
1403 std::set<std::string> ret2;
1404 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1406 std::string tmp=(*it1)->getProfile();
1413 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsedMulti() const
1415 std::vector<std::string> ret;
1416 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1418 std::string tmp=(*it1)->getLocalization();
1419 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1425 void MEDFileFieldPerMeshPerTypeCommon::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1427 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1428 (*it1)->changePflsRefsNamesGen(mapOfModif);
1431 void MEDFileFieldPerMeshPerTypeCommon::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1433 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1434 (*it1)->changeLocsRefsNamesGen(mapOfModif);
1437 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId)
1439 if(_field_pm_pt_pd.empty())
1441 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << getGeoTypeRepr() << "\" !";
1442 throw INTERP_KERNEL::Exception(oss.str());
1444 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1445 return _field_pm_pt_pd[locId];
1446 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
1447 oss2 << ") for geometric type \"" << getGeoTypeRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1448 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1449 return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1452 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId) const
1454 if(_field_pm_pt_pd.empty())
1456 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << getGeoTypeRepr() << "\" !";
1457 throw INTERP_KERNEL::Exception(oss.str());
1459 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1460 return _field_pm_pt_pd[locId];
1461 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
1462 oss2 << ") for geometric type \"" << getGeoTypeRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1463 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1464 return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1467 void MEDFileFieldPerMeshPerTypeCommon::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1470 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1472 (*it)->fillValues(i,startEntryId,entries);
1476 void MEDFileFieldPerMeshPerTypeCommon::setLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
1478 _field_pm_pt_pd=leaves;
1479 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1480 (*it)->setFather(this);
1484 * \param [in,out] globalNum a global numbering counter for the renumbering.
1485 * \param [out] its - list of pair (start,stop) kept
1486 * \return bool - false if the type of field \a tof is not contained in \a this.
1488 bool MEDFileFieldPerMeshPerTypeCommon::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
1491 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1492 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1493 if((*it)->getType()==tof)
1495 newPmPtPd.push_back(*it);
1496 std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1497 (*it)->setNewStart(globalNum);
1498 globalNum=(*it)->getEnd();
1499 its.push_back(bgEnd);
1503 _field_pm_pt_pd=newPmPtPd;
1508 * \param [in,out] globalNum a global numbering counter for the renumbering.
1509 * \param [out] its - list of pair (start,stop) kept
1510 * \return bool - false if the type of field \a tof is not contained in \a this.
1512 bool MEDFileFieldPerMeshPerTypeCommon::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
1514 if(_field_pm_pt_pd.size()<=idOfDisc)
1516 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt(_field_pm_pt_pd[idOfDisc]);
1517 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd(1,elt);
1518 std::pair<int,int> bgEnd; bgEnd.first=_field_pm_pt_pd[idOfDisc]->getStart(); bgEnd.second=_field_pm_pt_pd[idOfDisc]->getEnd();
1519 elt->setNewStart(globalNum);
1520 globalNum=elt->getEnd();
1521 its.push_back(bgEnd);
1522 _field_pm_pt_pd=newPmPtPd;
1526 void MEDFileFieldPerMeshPerTypeCommon::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
1528 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1529 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1532 void MEDFileFieldPerMeshPerTypeCommon::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1534 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1535 (*it)->loadBigArray(fid,nasc);
1538 void MEDFileFieldPerMeshPerTypeCommon::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1540 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1542 (*it)->copyOptionsFrom(*this);
1543 (*it)->writeLL(fid,nasc);
1547 med_entity_type MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1552 medfGeoType=typmai3[(int)ikGeoType];
1555 medfGeoType=MED_NONE;
1558 medfGeoType=typmai3[(int)ikGeoType];
1559 return MED_NODE_ELEMENT;
1561 medfGeoType=typmai3[(int)ikGeoType];
1564 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1566 return MED_UNDEF_ENTITY_TYPE;
1569 //////////////////////////////////////////////////
1571 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd)
1573 return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc,pd);
1576 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType)
1578 return new MEDFileFieldPerMeshPerType(fath,geoType);
1581 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCopy(MEDFileFieldPerMesh *father) const
1583 MCAuto<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
1584 ret->setFather(father);
1585 ret->deepCopyElements();
1589 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
1591 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1593 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1594 if(meshDim!=(int)cm.getDimension())
1597 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1598 (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1601 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1606 void MEDFileFieldPerMeshPerType::entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const
1608 ent=MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(mct,_geo_type,gt);
1611 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1613 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1614 int curDim((int)cm.getDimension());
1615 dim=std::max(dim,curDim);
1618 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1620 const char startLine[]=" ## ";
1621 std::string startLine2(bkOffset,' ');
1622 std::string startLine3(startLine2);
1623 startLine3+=startLine;
1624 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1626 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1627 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1630 oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1631 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1633 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1635 const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1637 cur->simpleRepr(bkOffset,oss,i);
1640 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1645 std::string MEDFileFieldPerMeshPerType::getGeoTypeRepr() const
1647 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1648 return std::string(cm.getRepr());
1651 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *father, INTERP_KERNEL::NormalizedCellType gt):MEDFileFieldPerMeshPerTypeCommon(father),_geo_type(gt)
1655 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):MEDFileFieldPerMeshPerTypeCommon(fath),_geo_type(geoType)
1657 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1658 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1659 med_geometry_type mgeoti;
1660 med_entity_type menti(ConvertIntoMEDFileType(type,geoType,mgeoti));
1661 int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName));
1662 _field_pm_pt_pd.resize(nbProfiles);
1663 for(int i=0;i<nbProfiles;i++)
1665 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i,pd);
1669 int nbProfiles2(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName));
1670 for(int i=0;i<nbProfiles2;i++)
1671 _field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i,pd));
1675 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)
1677 MCAuto<MEDFileFieldPerMeshPerType> ret(MEDFileFieldPerMeshPerType::New(father,gt));
1678 std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > > m;
1679 for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerType *> >::const_iterator it=pms.begin();it!=pms.end();it++)
1681 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it2=(*it).second->_field_pm_pt_pd.begin();it2!=(*it).second->_field_pm_pt_pd.end();it2++)
1682 m[(*it2)->getType()].push_back(std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * >((*it).first,*it2));
1684 for(std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > >::const_iterator it=m.begin();it!=m.end();it++)
1686 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> agg(MEDFileFieldPerMeshPerTypePerDisc::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
1687 ret->_field_pm_pt_pd.push_back(agg);
1692 //////////////////////////////////////////////////
1694 MEDFileFieldPerMeshPerTypeDyn *MEDFileFieldPerMeshPerTypeDyn::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileEntities *entities, int idGT, const MEDFileFieldNameScope& nasc)
1697 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeDyn::NewOnRead : null pointer !");
1698 const MEDFileAllStaticEntitiesPlusDyn *entities2(dynamic_cast<const MEDFileAllStaticEntitiesPlusDyn *>(entities));
1700 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeDyn::NewOnRead : invalid type of entities !");
1701 const MEDFileStructureElement *se(entities2->getWithGT(idGT));
1702 return new MEDFileFieldPerMeshPerTypeDyn(fid,fath,se,nasc);
1705 MEDFileFieldPerMeshPerTypeDyn::MEDFileFieldPerMeshPerTypeDyn(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileStructureElement *se, const MEDFileFieldNameScope& nasc):MEDFileFieldPerMeshPerTypeCommon(fath)
1708 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1709 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1710 int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,_se->getDynGT(),pflName,locName));
1711 _field_pm_pt_pd.resize(nbProfiles);
1712 for(int i=0;i<nbProfiles;i++)
1714 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,_se->getEntity(),i,NULL);
1718 int MEDFileFieldPerMeshPerTypeDyn::getDynGT() const
1720 return _se->getDynGT();
1723 void MEDFileFieldPerMeshPerTypeDyn::getDimension(int& dim) const
1725 throw INTERP_KERNEL::Exception("not implemented yet !");
1728 void MEDFileFieldPerMeshPerTypeDyn::entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const
1731 ent=MED_STRUCT_ELEMENT;
1734 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypeDyn::getGeoType() const
1736 throw INTERP_KERNEL::Exception("not implemented yet !");
1739 void MEDFileFieldPerMeshPerTypeDyn::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1741 const char startLine[]=" ## ";
1742 std::string startLine2(bkOffset,' ');
1743 std::string startLine3(startLine2);
1744 startLine3+=startLine;
1745 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry STRUCTURE_ELEMENT type " << getDynGT() << "." << std::endl;
1746 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1748 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1750 if((*it).isNotNull())
1751 (*it)->simpleRepr(bkOffset,oss,i);
1754 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1759 std::string MEDFileFieldPerMeshPerTypeDyn::getGeoTypeRepr() const
1761 throw INTERP_KERNEL::Exception("not implemented yet !");
1764 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerTypeDyn::deepCopy(MEDFileFieldPerMesh *father) const
1766 throw INTERP_KERNEL::Exception("not implemented yet !");
1769 void MEDFileFieldPerMeshPerTypeDyn::getFieldAtLevel(int meshDim, TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
1771 throw INTERP_KERNEL::Exception("not implemented yet !");
1774 //////////////////////////////////////////////////
1776 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const MEDFileEntities *entities)
1778 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm,entities);
1781 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1783 return new MEDFileFieldPerMesh(fath,mesh);
1786 std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
1788 return _mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MCAuto< MEDFileFieldPerMeshPerType >);
1791 std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildrenWithNull() const
1793 std::vector<const BigMemoryObject *> ret;
1794 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1799 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCopy(MEDFileAnyTypeField1TSWithoutSDA *father) const
1801 MCAuto< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1802 ret->_father=father;
1804 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1806 if((*it).isNotNull())
1807 ret->_field_pm_pt[i]=(*it)->deepCopy((MEDFileFieldPerMesh *)(ret));
1812 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1814 std::string startLine(bkOffset,' ');
1815 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1816 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1818 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1820 if((*it).isNotNull())
1821 (*it)->simpleRepr(bkOffset,oss,i);
1824 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1829 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh)
1831 _mesh_name=mesh->getName();
1832 mesh->getTime(_mesh_iteration,_mesh_order);
1835 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1837 int nbOfTypes=code.size()/3;
1839 for(int i=0;i<nbOfTypes;i++)
1841 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1842 int nbOfCells=code[3*i+1];
1843 int pos=addNewEntryIfNecessary(type);
1844 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1850 * This method is the most general one. No optimization is done here.
1851 * \param [in] multiTypePfl is the end user profile specified in high level API
1852 * \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].
1853 * \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.
1854 * \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.
1855 * \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.
1856 * \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.
1858 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)
1860 int nbOfTypes(code.size()/3);
1861 for(int i=0;i<nbOfTypes;i++)
1863 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1864 int pos=addNewEntryIfNecessary(type);
1865 DataArrayInt *pfl=0;
1867 pfl=idsPerType[code[3*i+2]];
1868 int nbOfTupes2=code2.size()/3;
1870 for(;found<nbOfTupes2;found++)
1871 if(code[3*i]==code2[3*found])
1873 if(found==nbOfTupes2)
1874 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1875 _field_pm_pt[pos]->assignFieldProfile(nbOfTypes==1,start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1879 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1881 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1882 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1885 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1887 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1888 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1891 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
1893 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1894 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1897 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1899 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1900 (*it)->loadBigArraysRecursively(fid,nasc);
1903 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1905 int nbOfTypes=_field_pm_pt.size();
1906 for(int i=0;i<nbOfTypes;i++)
1908 _field_pm_pt[i]->copyOptionsFrom(*this);
1909 _field_pm_pt[i]->writeLL(fid,nasc);
1913 void MEDFileFieldPerMesh::getDimension(int& dim) const
1915 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1916 (*it)->getDimension(dim);
1919 bool MEDFileFieldPerMesh::isUniqueLevel(int& dim) const
1921 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1922 if(!(*it)->isUniqueLevel(dim))
1927 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1929 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1930 (*it)->fillTypesOfFieldAvailable(types);
1933 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
1935 int sz=_field_pm_pt.size();
1936 std::vector< std::vector<std::pair<int,int> > > ret(sz);
1937 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1938 for(int i=0;i<sz;i++)
1940 types[i]=_field_pm_pt[i]->getGeoType();
1941 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1946 double MEDFileFieldPerMesh::getTime() const
1949 return _father->getTime(tmp1,tmp2);
1952 int MEDFileFieldPerMesh::getIteration() const
1954 return _father->getIteration();
1957 int MEDFileFieldPerMesh::getOrder() const
1959 return _father->getOrder();
1962 int MEDFileFieldPerMesh::getNumberOfComponents() const
1964 return _father->getNumberOfComponents();
1967 bool MEDFileFieldPerMesh::presenceOfMultiDiscPerGeoType() const
1969 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1973 if((*it)->presenceOfMultiDiscPerGeoType())
1979 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
1982 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1983 return _father->getOrCreateAndGetArray();
1986 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
1989 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1990 return _father->getOrCreateAndGetArray();
1993 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1995 return _father->getInfo();
1999 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
2000 * 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.
2001 * It returns 2 output vectors :
2002 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
2003 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
2004 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
2006 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)
2008 int notNullPflsSz=0;
2009 int nbOfArrs=geoTypes.size();
2010 for(int i=0;i<nbOfArrs;i++)
2013 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
2014 int nbOfDiffGeoTypes=geoTypes3.size();
2015 code.resize(3*nbOfDiffGeoTypes);
2016 notNullPfls.resize(notNullPflsSz);
2019 for(int i=0;i<nbOfDiffGeoTypes;i++)
2022 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
2023 std::vector<const DataArrayInt *> notNullTmp;
2025 notNullTmp.push_back(pfls[j]);
2027 for(;j<nbOfArrs;j++)
2028 if(geoTypes[j]==refType)
2031 notNullTmp.push_back(pfls[j]);
2035 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
2036 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
2037 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
2038 code[3*i]=(int)refType;
2039 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
2040 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
2041 if(notNullTmp.empty())
2045 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
2046 code[3*i+2]=notNullPflsSz++;
2052 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
2054 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)
2058 for(int i=0;i<sz;i++)
2062 if(type!=ON_GAUSS_NE)
2063 ret+=dads[i].second-dads[i].first;
2066 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
2067 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
2072 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
2073 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
2079 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
2081 std::vector<std::string> ret;
2082 std::set<std::string> ret2;
2083 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2085 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
2086 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
2087 if(ret2.find(*it2)==ret2.end())
2089 ret.push_back(*it2);
2096 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
2098 std::vector<std::string> ret;
2099 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2101 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
2102 ret.insert(ret.end(),tmp.begin(),tmp.end());
2107 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
2109 std::vector<std::string> ret;
2110 std::set<std::string> ret2;
2111 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2113 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
2114 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
2115 if(ret2.find(*it2)==ret2.end())
2117 ret.push_back(*it2);
2124 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
2126 std::vector<std::string> ret;
2127 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2129 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
2130 ret.insert(ret.end(),tmp.begin(),tmp.end());
2135 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
2137 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
2139 if((*it).first==_mesh_name)
2141 _mesh_name=(*it).second;
2148 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
2149 MEDFileFieldGlobsReal& glob)
2151 if(_mesh_name!=meshName)
2153 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
2154 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
2155 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
2156 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
2157 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
2158 getUndergroundDataArrayExt(entries);
2159 DataArray *arr0(getOrCreateAndGetArray());//tony
2161 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
2162 DataArrayDouble *arr(dynamic_cast<DataArrayDouble *>(arr0));//tony
2164 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
2167 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
2168 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
2170 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
2172 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2173 sz+=(*it).second.second-(*it).second.first;
2176 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2178 MCAuto<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
2179 ////////////////////
2180 MCAuto<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
2181 int *workI2=explicitIdsOldInMesh->getPointer();
2182 int sz1=0,sz2=0,sid=1;
2183 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
2184 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
2185 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
2187 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
2188 MCAuto<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
2189 int *workI=explicitIdsOldInArr->getPointer();
2190 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
2192 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
2193 (*itL2)->setLocId(sz2);
2194 (*itL2)->_tmp_work1=(*itL2)->getStart();
2195 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
2197 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
2199 explicitIdsOldInMesh->reAlloc(sz2);
2200 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
2201 ////////////////////
2202 MCAuto<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
2203 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
2204 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
2205 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
2207 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
2208 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
2209 otherEntriesNew.back()->setLocId((*it)->getGeoType());
2211 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
2212 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
2213 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
2215 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
2216 int newStart=elt->getLocId();
2217 elt->setLocId((*it)->getGeoType());
2218 elt->setNewStart(newStart);
2219 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
2220 entriesKeptNew.push_back(elt);
2221 entriesKeptNew2.push_back(elt);
2223 MCAuto<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
2224 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
2225 MCAuto<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
2226 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
2228 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
2231 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
2233 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
2234 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
2236 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
2237 glob,arr2,otherEntriesNew) || ret;
2241 // Assign new dispatching
2242 assignNewLeaves(otherEntriesNew);
2243 arr->deepCopyFrom(*arr2);
2248 * \param [in,out] globalNum a global numbering counter for the renumbering.
2249 * \param [out] its - list of pair (start,stop) kept
2251 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
2253 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > ret;
2254 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2256 std::vector< std::pair<int,int> > its2;
2257 if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
2260 its.insert(its.end(),its2.begin(),its2.end());
2267 * \param [in,out] globalNum a global numbering counter for the renumbering.
2268 * \param [out] its - list of pair (start,stop) kept
2270 void MEDFileFieldPerMesh::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
2272 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > ret;
2273 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2275 std::vector< std::pair<int,int> > its2;
2276 if((*it)->keepOnlyGaussDiscretization(idOfDisc,globalNum,its2))
2279 its.insert(its.end(),its2.begin(),its2.end());
2285 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
2287 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > > types;
2288 for( std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
2289 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
2291 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > fieldPmPt(types.size());
2292 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
2293 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it2=fieldPmPt.begin();
2294 for(;it1!=types.end();it1++,it2++)
2296 MCAuto<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
2297 elt->setLeaves((*it1).second);
2298 MCAuto<MEDFileFieldPerMeshPerTypeCommon> elt2(DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(elt));
2301 _field_pm_pt=fieldPmPt;
2304 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2306 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2307 (*it)->changePflsRefsNamesGen(mapOfModif);
2310 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2312 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2313 (*it)->changeLocsRefsNamesGen(mapOfModif);
2317 * \param [in] mesh is the whole mesh
2319 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2321 if(_field_pm_pt.empty())
2322 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2324 std::vector< std::pair<int,int> > dads;
2325 std::vector<const DataArrayInt *> pfls;
2326 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2327 std::vector<int> locs,code;
2328 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2329 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2330 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2332 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2335 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2336 throw INTERP_KERNEL::Exception(oss.str());
2339 std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2340 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2343 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2345 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2348 MCAuto<DataArrayInt> arr2(arr);
2349 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2355 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2359 if(nb!=mesh->getNumberOfNodes())
2361 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2362 oss << " nodes in mesh !";
2363 throw INTERP_KERNEL::Exception(oss.str());
2365 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2368 return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2372 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
2374 if(_field_pm_pt.empty())
2375 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2377 std::vector<std::pair<int,int> > dads;
2378 std::vector<const DataArrayInt *> pfls;
2379 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2380 std::vector<int> locs,code;
2381 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2382 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2383 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2385 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2388 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2389 throw INTERP_KERNEL::Exception(oss.str());
2391 std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2392 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2395 MCAuto<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2396 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2401 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2405 if(nb!=mesh->getNumberOfNodes())
2407 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2408 oss << " nodes in mesh !";
2409 throw INTERP_KERNEL::Exception(oss.str());
2412 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2418 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
2422 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2424 (*it)->getSizes(globalSz,nbOfEntries);
2426 entries.resize(nbOfEntries);
2428 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2430 (*it)->fillValues(nbOfEntries,entries);
2434 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
2436 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2438 if((*it)->getGeoType()==typ)
2439 return (*it)->getLeafGivenLocId(locId);
2441 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2442 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2443 oss << "Possiblities are : ";
2444 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2446 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2447 oss << "\"" << cm2.getRepr() << "\", ";
2449 throw INTERP_KERNEL::Exception(oss.str());
2452 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
2454 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2456 if((*it)->getGeoType()==typ)
2457 return (*it)->getLeafGivenLocId(locId);
2459 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2460 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2461 oss << "Possiblities are : ";
2462 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2464 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2465 oss << "\"" << cm2.getRepr() << "\", ";
2467 throw INTERP_KERNEL::Exception(oss.str());
2471 * \param [in,out] start - Integer that gives the current position in the final aggregated array
2472 * \param [in] pms - list of elements to aggregate. integer gives the mesh id
2473 * \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.
2474 * \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.
2476 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)
2478 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret(new MEDFileFieldPerMeshPerTypePerDisc(father,tof));
2480 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : empty input vector !");
2481 for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it=pms.begin();it!=pms.end();it++)
2484 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : presence of null pointer !");
2485 if(!(*it).second->getProfile().empty())
2486 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for profiles !");
2487 if(!(*it).second->getLocalization().empty())
2488 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for gauss pts !");
2490 INTERP_KERNEL::NormalizedCellType gt(pms[0].second->getGeoType());
2492 std::vector< std::pair<int,int> > filteredDTS;
2493 for(std::vector< std::vector< std::pair<int,int> > >::const_iterator it=dts.begin();it!=dts.end();it++,i++)
2494 for(std::vector< std::pair<int,int> >::const_iterator it2=(*it).begin();it2!=(*it).end();it2++)
2495 if((*it2).first==gt)
2496 filteredDTS.push_back(std::pair<int,int>(i,(*it2).second));
2497 if(pms.size()!=filteredDTS.size())
2498 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles !");
2499 std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it1(pms.begin());
2500 std::vector< std::pair<int,int> >::const_iterator it2(filteredDTS.begin());
2501 int zeStart(start),nval(0);
2502 for(;it1!=pms.end();it1++,it2++)
2504 if((*it1).first!=(*it2).first)
2505 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles 2 !");
2506 int s1((*it1).second->getStart()),e1((*it1).second->getEnd());
2507 extractInfo.push_back(std::pair<int, std::pair<int,int> >((*it1).first,std::pair<int,int>(s1,e1)));
2509 nval+=((*it1).second)->getNumberOfVals();
2511 ret->_start=zeStart; ret->_end=start; ret->_nval=nval;
2515 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)
2517 MCAuto<MEDFileFieldPerMesh> ret(new MEDFileFieldPerMesh(father,pms[0]->getMeshName(),pms[0]->getMeshIteration(),pms[0]->getMeshOrder()));
2518 std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > > m;
2520 for(std::vector<const MEDFileFieldPerMesh *>::const_iterator it=pms.begin();it!=pms.end();it++,i++)
2522 const std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >& v((*it)->_field_pm_pt);
2523 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it2=v.begin();it2!=v.end();it2++)
2525 INTERP_KERNEL::NormalizedCellType gt((*it2)->getGeoType());
2526 const MEDFileFieldPerMeshPerType *elt(dynamic_cast<const MEDFileFieldPerMeshPerType *>((const MEDFileFieldPerMeshPerTypeCommon *)(*it2)));
2528 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::Aggregate : not managed for structelement !");
2529 m[gt].push_back(std::pair<int,const MEDFileFieldPerMeshPerType *>(i,elt));
2532 for(std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > >::const_iterator it=m.begin();it!=m.end();it++)
2534 MCAuto<MEDFileFieldPerMeshPerType> agg(MEDFileFieldPerMeshPerType::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
2535 MCAuto<MEDFileFieldPerMeshPerTypeCommon> agg2(DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(agg));
2536 ret->_field_pm_pt.push_back(agg2);
2541 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2544 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2545 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it2=_field_pm_pt.begin();
2546 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2548 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2553 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2558 int ret=std::distance(_field_pm_pt.begin(),it2);
2559 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2564 * 'dads' and 'locs' input parameters have the same number of elements
2565 * \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
2567 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2568 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2569 const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2572 MCAuto<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2573 ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2574 MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2575 const std::vector<std::string>& infos=getInfo();
2576 da->setInfoOnComponents(infos);
2578 if(type==ON_GAUSS_PT)
2581 int nbOfArrs=dads.size();
2582 for(int i=0;i<nbOfArrs;i++)
2584 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2585 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2586 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2587 MCAuto<DataArrayInt> di=DataArrayInt::New();
2588 di->alloc(nbOfElems,1);
2590 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2591 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2600 * 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.
2601 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2602 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2603 * The order of cells in the returned field is those imposed by the profile.
2604 * \param [in] mesh is the global mesh.
2606 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2607 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2608 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2609 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2611 if(da->isIota(mesh->getNumberOfCells()))
2612 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2613 MCAuto<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2614 m2->setName(mesh->getName().c_str());
2615 MCAuto<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2621 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2623 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2624 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2625 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2627 if(da->isIota(mesh->getNumberOfNodes()))
2628 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2629 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2630 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2633 if(meshu->getNodalConnectivity()==0)
2635 MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2636 int nb=da->getNbOfElems();
2637 const int *ptr=da->getConstPointer();
2638 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2639 meshuc->allocateCells(nb);
2640 for(int i=0;i<nb;i++)
2641 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2642 meshuc->finishInsertingCells();
2643 ret->setMesh(meshuc);
2644 const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2645 if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2646 disc->checkCoherencyBetween(meshuc,arrOut);
2651 MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2653 DataArrayInt *arr2=0;
2654 MCAuto<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2655 MCAuto<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2656 MCAuto<DataArrayInt> arr3(arr2);
2657 int nnodes=mesh2->getNumberOfNodes();
2658 if(nnodes==(int)da->getNbOfElems())
2660 MCAuto<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2661 arrOut->renumberInPlace(da3->getConstPointer());
2662 mesh2->setName(mesh->getName().c_str());
2663 ret->setMesh(mesh2);
2668 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 !!!";
2669 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2670 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2671 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2672 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2673 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2674 throw INTERP_KERNEL::Exception(oss.str());
2680 * This method is the most light method of field retrieving.
2682 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
2686 pflOut=DataArrayInt::New();
2687 pflOut->alloc(nbOfElems,1);
2692 pflOut=const_cast<DataArrayInt*>(pflIn);
2695 MCAuto<DataArrayInt> safePfl(pflOut);
2696 MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2697 const std::vector<std::string>& infos=getInfo();
2698 int nbOfComp=infos.size();
2699 for(int i=0;i<nbOfComp;i++)
2700 da->setInfoOnComponent(i,infos[i].c_str());
2711 static MFFPMIter *NewCell(const MEDFileEntities *entities);
2712 static bool IsPresenceOfNode(const MEDFileEntities *entities);
2713 virtual ~MFFPMIter() { }
2714 virtual void begin() = 0;
2715 virtual bool finished() const = 0;
2716 virtual void next() = 0;
2717 virtual int current() const = 0;
2720 class MFFPMIterSimple : public MFFPMIter
2723 MFFPMIterSimple():_pos(0) { }
2724 void begin() { _pos=0; }
2725 bool finished() const { return _pos>=MED_N_CELL_FIXED_GEO; }
2726 void next() { _pos++; }
2727 int current() const { return _pos; }
2732 class MFFPMIter2 : public MFFPMIter
2735 MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts);
2736 void begin() { _it=_ids.begin(); }
2737 bool finished() const { return _it==_ids.end(); }
2738 void next() { _it++; }
2739 int current() const { return *_it; }
2741 std::vector<int> _ids;
2742 std::vector<int>::const_iterator _it;
2745 MFFPMIter *MFFPMIter::NewCell(const MEDFileEntities *entities)
2748 return new MFFPMIterSimple;
2751 const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
2754 std::vector<INTERP_KERNEL::NormalizedCellType> tmp;
2755 const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
2756 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
2758 if((*it).first==ON_CELLS || (*it).first==ON_GAUSS_NE || (*it).first==ON_GAUSS_PT)
2759 tmp.push_back((*it).second);
2761 return new MFFPMIter2(tmp);
2763 return new MFFPMIterSimple;// for MEDFileAllStaticEntites and MEDFileAllStaticEntitiesPlusDyn cells are in
2767 bool MFFPMIter::IsPresenceOfNode(const MEDFileEntities *entities)
2773 const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
2776 const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
2777 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
2778 if((*it).first==ON_NODES)
2782 return true;// for MEDFileAllStaticEntites and MEDFileAllStaticEntitiesPlusDyn nodes are in
2786 MFFPMIter2::MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts)
2788 std::size_t sz(cts.size());
2790 for(std::size_t i=0;i<sz;i++)
2792 INTERP_KERNEL::NormalizedCellType *loc(std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,cts[i]));
2793 if(loc!=typmai2+MED_N_CELL_FIXED_GEO)
2794 _ids[i]=(int)std::distance(typmai2,loc);
2796 throw INTERP_KERNEL::Exception("MFFPMIter2 : The specified geo type does not exists !");
2802 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),
2805 INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2806 INTERP_KERNEL::AutoPtr<char> pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2807 INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2808 const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
2809 INTERP_KERNEL::AutoCppPtr<MFFPMIter> iter0(MFFPMIter::NewCell(entities));
2810 for(iter0->begin();!iter0->finished();iter0->next())
2812 int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL ,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2813 std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2814 int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2815 std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2816 if(nbProfile>0 || nbProfile2>0)
2818 const PartDefinition *pd(0);
2820 pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[iter0->current()]),typmai2[iter0->current()]);
2821 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nasc,pd));
2828 if(MFFPMIter::IsPresenceOfNode(entities))
2830 int nbProfile(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName));
2833 const PartDefinition *pd(0);
2835 pd=mmu->getPartDefAtLevel(1,INTERP_KERNEL::NORM_ERROR);
2836 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd));
2837 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2842 std::vector<int> dynGT(entities->getDynGTAvail());
2843 for(std::vector<int>::const_iterator it=dynGT.begin();it!=dynGT.end();it++)
2845 int nbPfl(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,*it,pflName,locName));
2848 _field_pm_pt.push_back(MEDFileFieldPerMeshPerTypeDyn::NewOnRead(fid,this,entities,*it,nasc));
2849 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2854 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2856 copyTinyInfoFrom(mesh);
2859 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
2861 if(id>=(int)_pfls.size())
2863 _pfls[id]=DataArrayInt::New();
2864 int lgth(MEDprofileSizeByName(fid,pflName.c_str()));
2865 _pfls[id]->setName(pflName);
2866 _pfls[id]->alloc(lgth,1);
2867 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName.c_str(),_pfls[id]->getPointer()));
2868 _pfls[id]->applyLin(1,-1,0);//Converting into C format
2871 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2873 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2875 MEDFILESAFECALLERRD0(MEDprofileInfo,(fid,i+1,pflName,&sz));
2876 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2877 if(i>=(int)_pfls.size())
2879 _pfls[i]=DataArrayInt::New();
2880 _pfls[i]->alloc(sz,1);
2881 _pfls[i]->setName(pflCpp.c_str());
2882 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName,_pfls[i]->getPointer()));
2883 _pfls[i]->applyLin(1,-1,0);//Converting into C format
2886 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
2888 int nbOfPfls=_pfls.size();
2889 for(int i=0;i<nbOfPfls;i++)
2891 MCAuto<DataArrayInt> cpy=_pfls[i]->deepCopy();
2892 cpy->applyLin(1,1,0);
2893 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2894 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2895 MEDFILESAFECALLERWR0(MEDprofileWr,(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer()));
2898 int nbOfLocs=_locs.size();
2899 for(int i=0;i<nbOfLocs;i++)
2900 _locs[i]->writeLL(fid);
2903 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
2905 std::vector<std::string> pfls=getPfls();
2906 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2908 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2911 _pfls.push_back(*it);
2915 int id=std::distance(pfls.begin(),it2);
2916 if(!(*it)->isEqual(*_pfls[id]))
2918 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2919 throw INTERP_KERNEL::Exception(oss.str());
2923 std::vector<std::string> locs=getLocs();
2924 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
2926 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2929 _locs.push_back(*it);
2933 int id=std::distance(locs.begin(),it2);
2934 if(!(*it)->isEqual(*_locs[id],eps))
2936 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2937 throw INTERP_KERNEL::Exception(oss.str());
2943 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
2945 for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
2946 getProfile((*it).c_str());
2949 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
2951 for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
2952 getLocalization((*it).c_str());
2955 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
2957 std::vector<std::string> profiles=real.getPflsReallyUsed();
2958 int sz=profiles.size();
2960 for(int i=0;i<sz;i++)
2961 loadProfileInFile(fid,i,profiles[i].c_str());
2963 std::vector<std::string> locs=real.getLocsReallyUsed();
2966 for(int i=0;i<sz;i++)
2967 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2970 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid)
2972 int nProfil=MEDnProfile(fid);
2973 for(int i=0;i<nProfil;i++)
2974 loadProfileInFile(fid,i);
2975 int sz=MEDnLocalization(fid);
2977 for(int i=0;i<sz;i++)
2979 _locs[i]=MEDFileFieldLoc::New(fid,i);
2983 MEDFileFieldGlobs *MEDFileFieldGlobs::New(med_idt fid)
2985 return new MEDFileFieldGlobs(fid);
2988 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2990 return new MEDFileFieldGlobs;
2993 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
2995 return _file_name.capacity()+_pfls.capacity()*sizeof(MCAuto<DataArrayInt>)+_locs.capacity()*sizeof(MCAuto<MEDFileFieldLoc>);
2998 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildrenWithNull() const
3000 std::vector<const BigMemoryObject *> ret;
3001 for(std::vector< MCAuto< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3002 ret.push_back((const DataArrayInt *)*it);
3003 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3004 ret.push_back((const MEDFileFieldLoc *)*it);
3008 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCopy() const
3010 MCAuto<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
3012 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3014 if((const DataArrayInt *)*it)
3015 ret->_pfls[i]=(*it)->deepCopy();
3018 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3020 if((const MEDFileFieldLoc*)*it)
3021 ret->_locs[i]=(*it)->deepCopy();
3027 * \throw if a profile in \a pfls in not in \a this.
3028 * \throw if a localization in \a locs in not in \a this.
3029 * \sa MEDFileFieldGlobs::deepCpyPart
3031 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
3033 MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
3034 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
3036 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
3038 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
3040 MCAuto<DataArrayInt> pfl2(pfl);
3041 ret->_pfls.push_back(pfl2);
3043 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
3045 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
3047 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
3049 MCAuto<MEDFileFieldLoc> loc2(loc);
3050 ret->_locs.push_back(loc2);
3052 ret->setFileName(getFileName());
3057 * \throw if a profile in \a pfls in not in \a this.
3058 * \throw if a localization in \a locs in not in \a this.
3059 * \sa MEDFileFieldGlobs::shallowCpyPart
3061 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
3063 MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
3064 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
3066 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
3068 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
3069 ret->_pfls.push_back(pfl->deepCopy());
3071 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
3073 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
3075 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
3076 ret->_locs.push_back(loc->deepCopy());
3078 ret->setFileName(getFileName());
3082 MEDFileFieldGlobs::MEDFileFieldGlobs(med_idt fid):_file_name(MEDFileWritable::FileNameFromFID(fid))
3086 MEDFileFieldGlobs::MEDFileFieldGlobs()
3090 MEDFileFieldGlobs::~MEDFileFieldGlobs()
3094 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
3096 oss << "Profiles :\n";
3097 std::size_t n=_pfls.size();
3098 for(std::size_t i=0;i<n;i++)
3100 oss << " - #" << i << " ";
3101 const DataArrayInt *pfl=_pfls[i];
3103 oss << "\"" << pfl->getName() << "\"\n";
3108 oss << "Localizations :\n";
3109 for(std::size_t i=0;i<n;i++)
3111 oss << " - #" << i << " ";
3112 const MEDFileFieldLoc *loc=_locs[i];
3114 loc->simpleRepr(oss);
3120 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3122 for(std::vector< MCAuto<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
3124 DataArrayInt *elt(*it);
3127 std::string name(elt->getName());
3128 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3130 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3132 elt->setName((*it2).second.c_str());
3140 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3142 for(std::vector< MCAuto<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
3144 MEDFileFieldLoc *elt(*it);
3147 std::string name(elt->getName());
3148 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3150 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3152 elt->setName((*it2).second.c_str());
3160 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
3162 if(locId<0 || locId>=(int)_locs.size())
3163 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
3164 return _locs[locId]->getNbOfGaussPtPerCell();
3167 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
3169 return getLocalizationFromId(getLocalizationId(locName));
3172 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
3174 if(locId<0 || locId>=(int)_locs.size())
3175 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3176 return *_locs[locId];
3180 namespace MEDCouplingImpl
3185 LocFinder(const std::string& loc):_loc(loc) { }
3186 bool operator() (const MCAuto<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
3188 const std::string &_loc;
3194 PflFinder(const std::string& pfl):_pfl(pfl) { }
3195 bool operator() (const MCAuto<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
3197 const std::string& _pfl;
3202 int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
3204 std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),MEDCouplingImpl::LocFinder(loc));
3207 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
3208 for(it=_locs.begin();it!=_locs.end();it++)
3209 oss << "\"" << (*it)->getName() << "\", ";
3210 throw INTERP_KERNEL::Exception(oss.str());
3212 return std::distance(_locs.begin(),it);
3216 * The returned value is never null.
3218 const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
3220 std::string pflNameCpp(pflName);
3221 std::vector< MCAuto<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3224 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3225 for(it=_pfls.begin();it!=_pfls.end();it++)
3226 oss << "\"" << (*it)->getName() << "\", ";
3227 throw INTERP_KERNEL::Exception(oss.str());
3232 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
3234 if(pflId<0 || pflId>=(int)_pfls.size())
3235 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3236 return _pfls[pflId];
3239 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
3241 if(locId<0 || locId>=(int)_locs.size())
3242 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3243 return *_locs[locId];
3246 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
3248 return getLocalizationFromId(getLocalizationId(locName));
3252 * The returned value is never null.
3254 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
3256 std::string pflNameCpp(pflName);
3257 std::vector< MCAuto<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3260 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3261 for(it=_pfls.begin();it!=_pfls.end();it++)
3262 oss << "\"" << (*it)->getName() << "\", ";
3263 throw INTERP_KERNEL::Exception(oss.str());
3268 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
3270 if(pflId<0 || pflId>=(int)_pfls.size())
3271 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3272 return _pfls[pflId];
3275 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
3277 std::vector< MCAuto<DataArrayInt> > newPfls;
3279 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3281 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
3282 newPfls.push_back(*it);
3287 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
3289 std::vector< MCAuto<MEDFileFieldLoc> > newLocs;
3291 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3293 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
3294 newLocs.push_back(*it);
3299 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
3301 int sz=_pfls.size();
3302 std::vector<std::string> ret(sz);
3303 for(int i=0;i<sz;i++)
3304 ret[i]=_pfls[i]->getName();
3308 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
3310 int sz=_locs.size();
3311 std::vector<std::string> ret(sz);
3312 for(int i=0;i<sz;i++)
3313 ret[i]=_locs[i]->getName();
3317 bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
3319 std::vector<std::string> v=getPfls();
3320 std::string s(pflName);
3321 return std::find(v.begin(),v.end(),s)!=v.end();
3324 bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
3326 std::vector<std::string> v=getLocs();
3327 std::string s(locName);
3328 return std::find(v.begin(),v.end(),s)!=v.end();
3331 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
3333 std::map<int,std::vector<int> > m;
3335 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3337 const DataArrayInt *tmp=(*it);
3340 m[tmp->getHashCode()].push_back(i);
3343 std::vector< std::vector<int> > ret;
3344 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
3346 if((*it2).second.size()>1)
3348 std::vector<int> ret0;
3349 bool equalityOrNot=false;
3350 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
3352 std::vector<int>::const_iterator it4=it3; it4++;
3353 for(;it4!=(*it2).second.end();it4++)
3355 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
3358 ret0.push_back(*it3);
3359 ret0.push_back(*it4);
3365 ret.push_back(ret0);
3371 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
3373 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
3376 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
3378 std::string name(pfl->getName());
3380 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
3381 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3382 if(name==(*it)->getName())
3384 if(!pfl->isEqual(*(*it)))
3386 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
3387 throw INTERP_KERNEL::Exception(oss.str());
3391 _pfls.push_back(pfl);
3394 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)
3396 std::string name(locName);
3398 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
3399 MCAuto<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
3400 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3401 if((*it)->isName(locName))
3403 if(!(*it)->isEqual(*obj,1e-12))
3405 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
3406 throw INTERP_KERNEL::Exception(oss.str());
3409 _locs.push_back(obj);
3412 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
3414 std::vector<std::string> names=getPfls();
3415 return CreateNewNameNotIn("NewPfl_",names);
3418 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
3420 std::vector<std::string> names=getLocs();
3421 return CreateNewNameNotIn("NewLoc_",names);
3424 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
3426 for(std::size_t sz=0;sz<100000;sz++)
3428 std::ostringstream tryName;
3429 tryName << prefix << sz;
3430 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
3431 return tryName.str();
3433 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
3437 * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
3438 * \param [in] fname - the file name.
3440 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(med_idt fid):_globals(MEDFileFieldGlobs::New(fid))
3445 * Creates an empty MEDFileFieldGlobsReal.
3447 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
3451 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
3456 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildrenWithNull() const
3458 std::vector<const BigMemoryObject *> ret;
3459 ret.push_back((const MEDFileFieldGlobs *)_globals);
3464 * Returns a string describing profiles and Gauss points held in \a this.
3465 * \return std::string - the description string.
3467 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
3469 const MEDFileFieldGlobs *glob=_globals;
3470 std::ostringstream oss2; oss2 << glob;
3471 std::string stars(oss2.str().length(),'*');
3472 oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n";
3474 glob->simpleRepr(oss);
3476 oss << "NO GLOBAL INFORMATION !\n";
3479 void MEDFileFieldGlobsReal::resetContent()
3481 _globals=MEDFileFieldGlobs::New();
3484 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
3489 * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
3490 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3492 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3494 _globals=other._globals;
3498 * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3499 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3501 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3503 const MEDFileFieldGlobs *otherg(other._globals);
3506 _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3510 * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3511 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3513 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3515 const MEDFileFieldGlobs *otherg(other._globals);
3518 _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3521 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3523 _globals=other._globals;
3524 if((const MEDFileFieldGlobs *)_globals)
3525 _globals=other._globals->deepCopy();
3529 * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3530 * \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3531 * \param [in] eps - a precision used to compare Gauss points with same name held by
3532 * \a this and \a other MEDFileFieldGlobsReal.
3533 * \throw If \a this and \a other hold profiles with equal names but different ids.
3534 * \throw If \a this and \a other hold different Gauss points with equal names.
3536 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
3538 const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3539 if(thisGlobals==otherGlobals)
3543 _globals=other._globals;
3546 _globals->appendGlobs(*other._globals,eps);
3549 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
3551 checkGlobsPflsPartCoherency();
3552 checkGlobsLocsPartCoherency();
3555 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
3557 contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3560 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
3562 contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3565 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3567 contentNotNull()->loadProfileInFile(fid,id,pflName);
3570 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3572 contentNotNull()->loadProfileInFile(fid,id);
3575 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
3577 contentNotNull()->loadGlobals(fid,*this);
3580 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid)
3582 contentNotNull()->loadAllGlobals(fid);
3585 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3587 contentNotNull()->writeGlobals(fid,opt);
3591 * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3592 * or getPflsReallyUsedMulti().
3593 * \return std::vector<std::string> - a sequence of names of all profiles.
3595 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3597 return contentNotNull()->getPfls();
3601 * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3602 * or getLocsReallyUsedMulti().
3603 * \return std::vector<std::string> - a sequence of names of all localizations.
3605 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3607 return contentNotNull()->getLocs();
3611 * Checks if the profile with a given name exists.
3612 * \param [in] pflName - the profile name of interest.
3613 * \return bool - \c true if the profile named \a pflName exists.
3615 bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
3617 return contentNotNull()->existsPfl(pflName);
3621 * Checks if the localization with a given name exists.
3622 * \param [in] locName - the localization name of interest.
3623 * \return bool - \c true if the localization named \a locName exists.
3625 bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
3627 return contentNotNull()->existsLoc(locName);
3630 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
3632 return contentNotNull()->createNewNameOfPfl();
3635 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
3637 return contentNotNull()->createNewNameOfLoc();
3641 * Sets the name of a MED file.
3642 * \param [inout] fileName - the file name.
3644 void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
3646 contentNotNull()->setFileName(fileName);
3650 * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3651 * in the same order.
3652 * \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3653 * Each item of this sequence is a vector containing ids of equal profiles.
3655 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3657 return contentNotNull()->whichAreEqualProfiles();
3661 * Finds equal localizations.
3662 * \param [in] eps - a precision used to compare real values of the localizations.
3663 * \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3664 * Each item of this sequence is a vector containing ids of equal localizations.
3666 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3668 return contentNotNull()->whichAreEqualLocs(eps);
3672 * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3673 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3674 * this sequence is a pair whose
3675 * - the first item is a vector of profile names to replace by the second item,
3676 * - the second item is a profile name to replace every profile name of the first item.
3678 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3680 contentNotNull()->changePflsNamesInStruct(mapOfModif);
3684 * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3685 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3686 * this sequence is a pair whose
3687 * - the first item is a vector of localization names to replace by the second item,
3688 * - the second item is a localization name to replace every localization name of the first item.
3690 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3692 contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3696 * Replaces references to some profiles (a reference is a profile name) by references
3697 * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3698 * them-selves accordingly. <br>
3699 * This method is a generalization of changePflName().
3700 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3701 * this sequence is a pair whose
3702 * - the first item is a vector of profile names to replace by the second item,
3703 * - the second item is a profile name to replace every profile of the first item.
3704 * \sa changePflsRefsNamesGen()
3705 * \sa changePflName()
3707 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3709 changePflsRefsNamesGen(mapOfModif);
3710 changePflsNamesInStruct(mapOfModif);
3714 * Replaces references to some localizations (a reference is a localization name) by references
3715 * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3716 * them-selves accordingly. <br>
3717 * This method is a generalization of changeLocName().
3718 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3719 * this sequence is a pair whose
3720 * - the first item is a vector of localization names to replace by the second item,
3721 * - the second item is a localization name to replace every localization of the first item.
3722 * \sa changeLocsRefsNamesGen()
3723 * \sa changeLocName()
3725 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3727 changeLocsRefsNamesGen(mapOfModif);
3728 changeLocsNamesInStruct(mapOfModif);
3732 * Renames the profile having a given name and updates references to this profile.
3733 * \param [in] oldName - the name of the profile to rename.
3734 * \param [in] newName - a new name of the profile.
3735 * \sa changePflsNames().
3737 void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
3739 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3740 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3742 changePflsNames(mapOfModif);
3746 * Renames the localization having a given name and updates references to this localization.
3747 * \param [in] oldName - the name of the localization to rename.
3748 * \param [in] newName - a new name of the localization.
3749 * \sa changeLocsNames().
3751 void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
3753 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3754 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3756 changeLocsNames(mapOfModif);
3760 * Removes duplicated profiles. Returns a map used to update references to removed
3761 * profiles via changePflsRefsNamesGen().
3762 * Equal profiles are found using whichAreEqualProfiles().
3763 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3764 * a sequence describing the performed replacements of profiles. Each element of
3765 * this sequence is a pair whose
3766 * - the first item is a vector of profile names replaced by the second item,
3767 * - the second item is a profile name replacing every profile of the first item.
3769 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
3771 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3772 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3774 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3776 std::vector< std::string > tmp((*it).size());
3778 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3779 tmp[j]=std::string(getProfileFromId(*it2)->getName());
3780 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3782 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3783 killProfileIds(tmp2);
3785 changePflsRefsNamesGen(ret);
3790 * Removes duplicated localizations. Returns a map used to update references to removed
3791 * localizations via changeLocsRefsNamesGen().
3792 * Equal localizations are found using whichAreEqualLocs().
3793 * \param [in] eps - a precision used to compare real values of the localizations.
3794 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3795 * a sequence describing the performed replacements of localizations. Each element of
3796 * this sequence is a pair whose
3797 * - the first item is a vector of localization names replaced by the second item,
3798 * - the second item is a localization name replacing every localization of the first item.
3800 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
3802 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3803 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3805 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3807 std::vector< std::string > tmp((*it).size());
3809 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3810 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3811 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3813 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3814 killLocalizationIds(tmp2);
3816 changeLocsRefsNamesGen(ret);
3821 * Returns number of Gauss points per cell in a given localization.
3822 * \param [in] locId - an id of the localization of interest.
3823 * \return int - the number of the Gauss points per cell.
3825 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
3827 return contentNotNull()->getNbOfGaussPtPerCell(locId);
3831 * Returns an id of a localization by its name.
3832 * \param [in] loc - the localization name of interest.
3833 * \return int - the id of the localization.
3834 * \throw If there is no a localization named \a loc.
3836 int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
3838 return contentNotNull()->getLocalizationId(loc);
3842 * Returns the name of the MED file.
3843 * \return const std::string& - the MED file name.
3845 std::string MEDFileFieldGlobsReal::getFileName() const
3847 return contentNotNull()->getFileName();
3851 * Returns a localization object by its name.
3852 * \param [in] locName - the name of the localization of interest.
3853 * \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3854 * \throw If there is no a localization named \a locName.
3856 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
3858 return contentNotNull()->getLocalization(locName);
3862 * Returns a localization object by its id.
3863 * \param [in] locId - the id of the localization of interest.
3864 * \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3865 * \throw If there is no a localization with id \a locId.
3867 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
3869 return contentNotNull()->getLocalizationFromId(locId);
3873 * Returns a profile array by its name.
3874 * \param [in] pflName - the name of the profile of interest.
3875 * \return const DataArrayInt * - the profile array having the name \a pflName.
3876 * \throw If there is no a profile named \a pflName.
3878 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
3880 return contentNotNull()->getProfile(pflName);
3884 * Returns a profile array by its id.
3885 * \param [in] pflId - the id of the profile of interest.
3886 * \return const DataArrayInt * - the profile array having the id \a pflId.
3887 * \throw If there is no a profile with id \a pflId.
3889 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
3891 return contentNotNull()->getProfileFromId(pflId);
3895 * Returns a localization object, apt for modification, by its id.
3896 * \param [in] locId - the id of the localization of interest.
3897 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3898 * having the id \a locId.
3899 * \throw If there is no a localization with id \a locId.
3901 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
3903 return contentNotNull()->getLocalizationFromId(locId);
3907 * Returns a localization object, apt for modification, by its name.
3908 * \param [in] locName - the name of the localization of interest.
3909 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3910 * having the name \a locName.
3911 * \throw If there is no a localization named \a locName.
3913 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
3915 return contentNotNull()->getLocalization(locName);
3919 * Returns a profile array, apt for modification, by its name.
3920 * \param [in] pflName - the name of the profile of interest.
3921 * \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3922 * \throw If there is no a profile named \a pflName.
3924 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
3926 return contentNotNull()->getProfile(pflName);
3930 * Returns a profile array, apt for modification, by its id.
3931 * \param [in] pflId - the id of the profile of interest.
3932 * \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3933 * \throw If there is no a profile with id \a pflId.
3935 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
3937 return contentNotNull()->getProfileFromId(pflId);
3941 * Removes profiles given by their ids. No data is updated to track this removal.
3942 * \param [in] pflIds - a sequence of ids of the profiles to remove.
3944 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
3946 contentNotNull()->killProfileIds(pflIds);
3950 * Removes localizations given by their ids. No data is updated to track this removal.
3951 * \param [in] locIds - a sequence of ids of the localizations to remove.
3953 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
3955 contentNotNull()->killLocalizationIds(locIds);
3959 * Stores a profile array.
3960 * \param [in] pfl - the profile array to store.
3961 * \throw If the name of \a pfl is empty.
3962 * \throw If a profile with the same name as that of \a pfl already exists but contains
3965 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
3967 contentNotNull()->appendProfile(pfl);
3971 * Adds a new localization of Gauss points.
3972 * \param [in] locName - the name of the new localization.
3973 * \param [in] geoType - a geometrical type of the reference cell.
3974 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
3975 * must be \c nbOfNodesPerCell * \c dimOfType.
3976 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
3977 * must be _wg_.size() * \c dimOfType.
3978 * \param [in] w - the weights of Gauss points.
3979 * \throw If \a locName is empty.
3980 * \throw If a localization with the name \a locName already exists but is
3981 * different form the new one.
3983 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)
3985 contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
3988 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
3990 MEDFileFieldGlobs *g(_globals);
3992 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
3996 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
3998 const MEDFileFieldGlobs *g(_globals);
4000 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
4004 //= MEDFileFieldNameScope
4006 MEDFileFieldNameScope::MEDFileFieldNameScope()
4010 MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName):_name(fieldName)
4015 * Returns the name of \a this field.
4016 * \return std::string - a string containing the field name.
4018 std::string MEDFileFieldNameScope::getName() const
4024 * Sets name of \a this field
4025 * \param [in] name - the new field name.
4027 void MEDFileFieldNameScope::setName(const std::string& fieldName)
4032 std::string MEDFileFieldNameScope::getDtUnit() const
4037 void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
4042 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
4045 _dt_unit=other._dt_unit;
4048 //= MEDFileAnyTypeField1TSWithoutSDA
4050 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
4052 _field_per_mesh.resize(other._field_per_mesh.size());
4054 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
4056 if((const MEDFileFieldPerMesh *)*it)
4057 _field_per_mesh[i]=(*it)->deepCopy(this);
4062 * Prints a string describing \a this field into a stream. This string is outputted
4063 * by \c print Python command.
4064 * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
4065 * \param [in,out] oss - the out stream.
4066 * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
4067 * info id printed, else, not.
4069 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
4071 std::string startOfLine(bkOffset,' ');
4072 oss << startOfLine << "Field ";
4074 oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
4075 oss << "on one time Step ";
4077 oss << "(" << f1tsId << ") ";
4078 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
4079 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
4080 const DataArray *arr=getUndergroundDataArray();
4083 const std::vector<std::string> &comps=arr->getInfoOnComponents();
4086 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
4087 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
4088 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
4090 if(arr->isAllocated())
4092 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
4095 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
4099 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
4101 oss << startOfLine << "----------------------" << std::endl;
4102 if(!_field_per_mesh.empty())
4105 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
4107 const MEDFileFieldPerMesh *cur=(*it2);
4109 cur->simpleRepr(bkOffset,oss,i);
4111 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
4116 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
4118 oss << startOfLine << "----------------------" << std::endl;
4121 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
4123 const DataArray *arr(getUndergroundDataArray());
4125 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
4126 int nbOfCompo=arr->getNumberOfComponents();
4127 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
4128 for(int i=0;i<nbOfCompo;i++)
4131 std::vector<int> v(1,i);
4132 MCAuto<DataArray> arr2=arr->keepSelectedComponents(v);
4133 ret[i]->setArray(arr2);
4138 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)
4142 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
4147 * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
4148 * empty. Returns -1 if this in on nodes.
4149 * \return int - the dimension of \a this.
4151 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
4154 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4155 (*it)->getDimension(ret);
4160 * Returns the mesh name.
4161 * \return std::string - a string holding the mesh name.
4162 * \throw If \c _field_per_mesh.empty()
4164 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const
4166 if(_field_per_mesh.empty())
4167 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
4168 return _field_per_mesh[0]->getMeshName();
4171 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const std::string& newMeshName)
4173 std::string oldName(getMeshName());
4174 std::vector< std::pair<std::string,std::string> > v(1);
4175 v[0].first=oldName; v[0].second=newMeshName;
4179 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
4182 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4184 MEDFileFieldPerMesh *cur(*it);
4186 ret=cur->changeMeshNames(modifTab) || ret;
4192 * Returns the number of iteration of the state of underlying mesh.
4193 * \return int - the iteration number.
4194 * \throw If \c _field_per_mesh.empty()
4196 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
4198 if(_field_per_mesh.empty())
4199 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
4200 return _field_per_mesh[0]->getMeshIteration();
4204 * Returns the order number of iteration of the state of underlying mesh.
4205 * \return int - the order number.
4206 * \throw If \c _field_per_mesh.empty()
4208 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
4210 if(_field_per_mesh.empty())
4211 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
4212 return _field_per_mesh[0]->getMeshOrder();
4216 * Checks if \a this field is tagged by a given iteration number and a given
4217 * iteration order number.
4218 * \param [in] iteration - the iteration number of interest.
4219 * \param [in] order - the iteration order number of interest.
4220 * \return bool - \c true if \a this->getIteration() == \a iteration &&
4221 * \a this->getOrder() == \a order.
4223 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
4225 return iteration==_iteration && order==_order;
4229 * Returns number of iteration and order number of iteration when
4230 * \a this field has been calculated.
4231 * \return std::pair<int,int> - a pair of the iteration number and the iteration
4234 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
4236 std::pair<int,int> p;
4242 * Returns number of iteration and order number of iteration when
4243 * \a this field has been calculated.
4244 * \param [in,out] p - a pair returning the iteration number and the iteration
4247 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
4254 * Returns all types of spatial discretization of \a this field.
4255 * \param [in,out] types - a sequence of types of \a this field.
4257 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
4259 std::set<TypeOfField> types2;
4260 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4262 (*it)->fillTypesOfFieldAvailable(types2);
4264 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
4265 std::copy(types2.begin(),types2.end(),bi);
4269 * Returns all types of spatial discretization of \a this field.
4270 * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
4273 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
4275 std::vector<TypeOfField> ret;
4276 fillTypesOfFieldAvailable(ret);
4280 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
4282 std::vector<std::string> ret;
4283 std::set<std::string> ret2;
4284 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4286 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
4287 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4288 if(ret2.find(*it2)==ret2.end())
4290 ret.push_back(*it2);
4297 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
4299 std::vector<std::string> ret;
4300 std::set<std::string> ret2;
4301 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4303 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
4304 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4305 if(ret2.find(*it2)==ret2.end())
4307 ret.push_back(*it2);
4314 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
4316 std::vector<std::string> ret;
4317 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4319 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
4320 ret.insert(ret.end(),tmp.begin(),tmp.end());
4325 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
4327 std::vector<std::string> ret;
4328 std::set<std::string> ret2;
4329 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4331 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
4332 ret.insert(ret.end(),tmp.begin(),tmp.end());
4337 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4339 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4340 (*it)->changePflsRefsNamesGen(mapOfModif);
4343 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4345 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4346 (*it)->changeLocsRefsNamesGen(mapOfModif);
4350 * Returns all attributes of parts of \a this field lying on a given mesh.
4351 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4352 * item of every of returned sequences refers to the _i_-th part of \a this field.
4353 * Thus all sequences returned by this method are of the same length equal to number
4354 * of different types of supporting entities.<br>
4355 * A field part can include sub-parts with several different spatial discretizations,
4356 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
4357 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4358 * of a nested sequence corresponds to a type of spatial discretization.<br>
4359 * This method allows for iteration over MEDFile DataStructure without any overhead.
4360 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4361 * for the case with only one underlying mesh. (Actually, the number of meshes is
4362 * not checked if \a mname == \c NULL).
4363 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4364 * a field part is returned.
4365 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4366 * This sequence is of the same length as \a types.
4367 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4368 * discretization. A profile name can be empty.
4369 * Length of this and of nested sequences is the same as that of \a typesF.
4370 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4371 * discretization. A localization name can be empty.
4372 * Length of this and of nested sequences is the same as that of \a typesF.
4373 * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
4374 * of ids of tuples within the data array, per each type of spatial
4375 * discretization within one mesh entity type.
4376 * Length of this and of nested sequences is the same as that of \a typesF.
4377 * \throw If no field is lying on \a mname.
4379 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
4383 meshId=getMeshIdFromMeshName(mname);
4385 if(_field_per_mesh.empty())
4386 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4387 return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4391 * Returns dimensions of mesh elements \a this field lies on. The returned value is a
4392 * maximal absolute dimension and values returned via the out parameter \a levs are
4393 * dimensions relative to the maximal absolute dimension. <br>
4394 * This method is designed for MEDFileField1TS instances that have a discretization
4395 * \ref MEDCoupling::ON_CELLS "ON_CELLS",
4396 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT",
4397 * \ref MEDCoupling::ON_GAUSS_NE "ON_GAUSS_NE".
4398 * Only these 3 discretizations will be taken into account here. If \a this is
4399 * \ref MEDCoupling::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
4400 * This method is useful to make the link between the dimension of the underlying mesh
4401 * and the levels of \a this, because it is possible that the highest dimension of \a this
4402 * field is not equal to the dimension of the underlying mesh.
4404 * Let's consider the following case:
4405 * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
4406 * TETRA4, HEXA8, TRI3 and SEG2.
4407 * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
4408 * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
4410 * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
4411 * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
4412 * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
4413 * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
4414 * parameter of getFieldAtLevel() is computed basing on the returned values as this:
4415 * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
4417 * to retrieve the highest level of
4418 * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br>
4419 * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
4420 * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
4421 * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
4422 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4423 * for the case with only one underlying mesh. (Actually, the number of meshes is
4424 * not checked if \a mname == \c NULL).
4425 * \param [in,out] levs - a sequence returning the dimensions relative to the maximal
4426 * absolute one. They are in decreasing order. This sequence is cleared before
4428 * \return int - the maximal absolute dimension of elements \a this fields lies on.
4429 * \throw If no field is lying on \a mname.
4431 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
4434 int meshId=getMeshIdFromMeshName(mname);
4435 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4436 std::vector< std::vector<TypeOfField> > typesF;
4437 std::vector< std::vector<std::string> > pfls, locs;
4438 _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4440 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
4441 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
4442 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
4444 st.erase(INTERP_KERNEL::NORM_ERROR);
4446 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
4448 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
4449 ret1.insert((int)cm.getDimension());
4451 int ret=*std::max_element(ret1.begin(),ret1.end());
4452 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
4453 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
4458 * \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.
4459 * \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.
4460 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4461 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4463 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
4465 int mid=getMeshIdFromMeshName(mName);
4466 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4470 * \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.
4471 * \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.
4472 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4473 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4475 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
4477 int mid=getMeshIdFromMeshName(mName);
4478 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4482 * \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.
4484 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
4486 if(_field_per_mesh.empty())
4487 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4490 std::string mName2(mName);
4492 std::vector<std::string> msg;
4493 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4494 if(mName2==(*it)->getMeshName())
4497 msg.push_back((*it)->getMeshName());
4498 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4499 oss << "Possible meshes are : ";
4500 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4501 oss << "\"" << (*it2) << "\" ";
4502 throw INTERP_KERNEL::Exception(oss.str());
4505 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
4508 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4509 std::string tmp(mesh->getName());
4511 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4512 std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4514 for(;it!=_field_per_mesh.end();it++,i++)
4516 if((*it)->getMeshName()==tmp)
4519 int sz=_field_per_mesh.size();
4520 _field_per_mesh.resize(sz+1);
4521 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4525 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4526 MEDFileFieldGlobsReal& glob)
4529 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4531 MEDFileFieldPerMesh *fpm(*it);
4533 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4539 * This method splits \a this into several sub-parts so that each sub parts have exactly one spatial discretization. This method implements the minimal
4540 * splitting that leads to single spatial discretization of this.
4542 * \sa splitMultiDiscrPerGeoTypes
4544 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
4546 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4547 std::vector< std::vector<TypeOfField> > typesF;
4548 std::vector< std::vector<std::string> > pfls,locs;
4549 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4550 std::set<TypeOfField> allEnt;
4551 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4552 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4553 allEnt.insert(*it2);
4554 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4555 std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4556 for(std::size_t i=0;i<allEnt.size();i++,it3++)
4558 std::vector< std::pair<int,int> > its;
4559 ret[i]=shallowCpy();
4560 int newLgth(ret[i]->keepOnlySpatialDiscretization(*it3,its));
4561 ret[i]->updateData(newLgth,its);
4567 * This method performs a sub splitting as splitDiscretizations does but finer. This is the finest spliting level that can be done.
4568 * This method implements the minimal splitting so that each returned elements are mono Gauss discretization per geometric type.
4570 * \sa splitDiscretizations
4572 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes() const
4574 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4575 std::vector< std::vector<TypeOfField> > typesF;
4576 std::vector< std::vector<std::string> > pfls,locs;
4577 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4578 std::set<TypeOfField> allEnt;
4579 std::size_t nbOfMDPGT(0),ii(0);
4580 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++,ii++)
4582 nbOfMDPGT=std::max(nbOfMDPGT,locs[ii].size());
4583 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4584 allEnt.insert(*it2);
4586 if(allEnt.size()!=1)
4587 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : this field is expected to be defined only on one spatial discretization !");
4589 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
4592 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret0(1);
4593 ret0[0]=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(this); this->incrRef();
4596 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfMDPGT);
4597 for(std::size_t i=0;i<nbOfMDPGT;i++)
4599 std::vector< std::pair<int,int> > its;
4600 ret[i]=shallowCpy();
4601 int newLgth(ret[i]->keepOnlyGaussDiscretization(i,its));
4602 ret[i]->updateData(newLgth,its);
4607 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
4609 int globalCounter(0);
4610 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4611 (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4612 return globalCounter;
4615 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlyGaussDiscretization(std::size_t idOfDisc, std::vector< std::pair<int,int> >& its)
4617 int globalCounter(0);
4618 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4619 (*it)->keepOnlyGaussDiscretization(idOfDisc,globalCounter,its);
4620 return globalCounter;
4623 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
4625 if(_nb_of_tuples_to_be_allocated>=0)
4627 _nb_of_tuples_to_be_allocated=newLgth;
4628 const DataArray *oldArr(getUndergroundDataArray());
4631 MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4632 newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
4634 _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
4638 if(_nb_of_tuples_to_be_allocated==-1)
4640 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4642 const DataArray *oldArr(getUndergroundDataArray());
4643 if(!oldArr || !oldArr->isAllocated())
4644 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4645 MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4646 newArr->alloc(newLgth,getNumberOfComponents());
4648 newArr->copyStringInfoFrom(*oldArr);
4650 for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4652 if((*it).second<(*it).first)
4653 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4654 newArr->setContigPartOfSelectedValuesSlice(pos,oldArr,(*it).first,(*it).second,1);
4655 pos+=(*it).second-(*it).first;
4660 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4663 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
4665 if(_field_per_mesh.empty())
4666 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4667 if(_field_per_mesh.size()>1)
4668 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4669 _field_per_mesh[0]->copyOptionsFrom(opts);
4670 _field_per_mesh[0]->writeLL(fid,nasc);
4674 * 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.
4675 * If false is returned the memory allocation is not required.
4677 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
4679 if(_nb_of_tuples_to_be_allocated>=0)
4681 getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4682 _nb_of_tuples_to_be_allocated=-2;
4685 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4687 if(_nb_of_tuples_to_be_allocated==-1)
4688 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4689 if(_nb_of_tuples_to_be_allocated<-3)
4690 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4691 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4694 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
4696 med_int numdt,numit;
4700 med_int meshnumdt,meshnumit;
4701 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4702 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt));
4703 MEDFILESAFECALLERRD0(MEDfield23ComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit));
4704 if(_iteration!=numdt || _order!=numit)
4705 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4706 _field_per_mesh.resize(nmesh);
4711 std::string meshNameCpp(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
4712 mm=ms->getMeshWithName(meshNameCpp);
4715 for(int i=0;i<nmesh;i++)
4716 _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i,meshnumdt,meshnumit,nasc,mm,entities);
4717 _nb_of_tuples_to_be_allocated=0;
4718 for(int i=0;i<nmesh;i++)
4719 _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4722 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
4724 allocIfNecessaryTheArrayToReceiveDataFromFile();
4725 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4726 (*it)->loadBigArraysRecursively(fid,nasc);
4729 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
4731 if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4732 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4733 (*it)->loadBigArraysRecursively(fid,nasc);
4736 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
4738 loadOnlyStructureOfDataRecursively(fid,nasc,ms,entities);
4739 loadBigArraysRecursively(fid,nasc);
4742 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
4744 DataArray *thisArr(getUndergroundDataArray());
4745 if(thisArr && thisArr->isAllocated())
4747 _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
4748 thisArr->desallocate();
4752 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
4754 return _dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MCAuto< MEDFileFieldPerMesh >);
4757 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
4759 std::vector<const BigMemoryObject *> ret;
4760 if(getUndergroundDataArray())
4761 ret.push_back(getUndergroundDataArray());
4762 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4763 ret.push_back((const MEDFileFieldPerMesh *)*it);
4768 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4769 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4770 * "Sort By Type"), if not, an exception is thrown.
4771 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
4772 * \param [in] arr - the array of values.
4773 * \param [in,out] glob - the global data where profiles and localization present in
4774 * \a field, if any, are added.
4775 * \throw If the name of \a field is empty.
4776 * \throw If the data array of \a field is not set.
4777 * \throw If \a this->_arr is already allocated but has different number of components
4779 * \throw If the underlying mesh of \a field has no name.
4780 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4782 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4784 const MEDCouplingMesh *mesh=field->getMesh();
4786 TypeOfField type=field->getTypeOfField();
4787 std::vector<DataArrayInt *> dummy;
4788 int start=copyTinyInfoFrom(field,arr);
4789 int pos=addNewEntryIfNecessary(mesh);
4792 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4793 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4796 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4800 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4801 * of a given mesh are used as the support of the given field (a real support is not used).
4802 * Elements of the given mesh must be sorted suitable for writing to MED file.
4803 * Order of underlying mesh entities of the given field specified by \a profile parameter
4804 * is not prescribed; this method permutes field values to have them sorted by element
4805 * type as required for writing to MED file. A new profile is added only if no equal
4806 * profile is missing.
4807 * \param [in] field - the field to add to \a this. The field double values are ignored.
4808 * \param [in] arrOfVals - the values of the field \a field used.
4809 * \param [in] mesh - the supporting mesh of \a field.
4810 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4811 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
4812 * \param [in,out] glob - the global data where profiles and localization present in
4813 * \a field, if any, are added.
4814 * \throw If either \a field or \a mesh or \a profile has an empty name.
4815 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4816 * \throw If the data array of \a field is not set.
4817 * \throw If \a this->_arr is already allocated but has different number of components
4819 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4820 * \sa setFieldNoProfileSBT()
4822 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4825 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
4826 if(!arrOfVals || !arrOfVals->isAllocated())
4827 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
4828 TypeOfField type=field->getTypeOfField();
4829 std::vector<DataArrayInt *> idsInPflPerType;
4830 std::vector<DataArrayInt *> idsPerType;
4831 std::vector<int> code,code2;
4832 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
4835 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4836 std::vector< MCAuto<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
4837 std::vector< MCAuto<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin());
4838 std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
4840 MCAuto<MEDCouplingFieldDouble> field2=field->clone(false);
4841 int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
4842 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4844 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4845 throw INTERP_KERNEL::Exception(oss.str());
4848 int start=copyTinyInfoFrom(field,arrOfVals);
4849 code2=m->getDistributionOfTypes();
4851 int pos=addNewEntryIfNecessary(m);
4852 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4856 if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
4857 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
4858 std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
4859 std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
4860 int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
4861 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4863 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4864 throw INTERP_KERNEL::Exception(oss.str());
4866 int start=copyTinyInfoFrom(field,arrOfVals);
4867 int pos=addNewEntryIfNecessary(m);
4868 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4873 * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
4875 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
4877 if(_nb_of_tuples_to_be_allocated>=0)
4878 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 !");
4879 DataArray *arr(getOrCreateAndGetArray());
4880 arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
4881 _nb_of_tuples_to_be_allocated=-3;
4885 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4886 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4887 * larger by the size of \a field. Returns an id of the first not filled
4888 * tuple of \a this->_arr.
4889 * \param [in] field - the field to copy the info on components and the name from.
4890 * \return int - the id of first not initialized tuple of \a this->_arr.
4891 * \throw If the name of \a field is empty.
4892 * \throw If the data array of \a field is not set.
4893 * \throw If \a this->_arr is already allocated but has different number of components
4896 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
4899 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4900 std::string name(field->getName());
4901 setName(name.c_str());
4902 setDtUnit(field->getTimeUnit());
4904 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4906 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4907 if(!arr->isAllocated())
4908 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
4909 _dt=field->getTime(_iteration,_order);
4910 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4911 if(!getOrCreateAndGetArray()->isAllocated())
4913 allocNotFromFile(arr->getNumberOfTuples());
4918 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4919 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4920 getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
4921 _nb_of_tuples_to_be_allocated=-3;
4922 return oldNbOfTuples;
4927 * Returns number of components in \a this field
4928 * \return int - the number of components.
4930 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4932 return getOrCreateAndGetArray()->getNumberOfComponents();
4936 * Change info on components in \a this.
4937 * \throw If size of \a infos is not equal to the number of components already in \a this.
4939 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
4941 DataArray *arr=getOrCreateAndGetArray();
4942 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
4946 * Returns info on components of \a this field.
4947 * \return const std::vector<std::string>& - a sequence of strings each being an
4948 * information on _i_-th component.
4950 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
4952 const DataArray *arr=getOrCreateAndGetArray();
4953 return arr->getInfoOnComponents();
4957 * Returns a mutable info on components of \a this field.
4958 * \return std::vector<std::string>& - a sequence of strings each being an
4959 * information on _i_-th component.
4961 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
4963 DataArray *arr=getOrCreateAndGetArray();
4964 return arr->getInfoOnComponents();
4967 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const
4969 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4971 const MEDFileFieldPerMesh *fpm(*it);
4974 if(fpm->presenceOfMultiDiscPerGeoType())
4980 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh(const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4982 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 !";
4983 if(_field_per_mesh.empty())
4984 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is empty ! Nothing to extract !");
4985 if(_field_per_mesh.size()>1)
4986 throw INTERP_KERNEL::Exception(MSG0);
4987 if(_field_per_mesh[0].isNull())
4988 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is inconsistent !");
4989 const MEDFileFieldPerMesh *pm(_field_per_mesh[0]);
4990 std::set<TypeOfField> types;
4991 pm->fillTypesOfFieldAvailable(types);
4993 throw INTERP_KERNEL::Exception(MSG0);
4994 TypeOfField type(*types.begin());
4995 int meshDimRelToMax(0);
5000 int myDim(std::numeric_limits<int>::max());
5001 bool isUnique(pm->isUniqueLevel(myDim));
5003 throw INTERP_KERNEL::Exception(MSG0);
5004 meshDimRelToMax=myDim-mesh->getMeshDimension();
5005 if(meshDimRelToMax>0)
5006 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the mesh attached to field is not compatible with the field !");
5008 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,0/*renumPol*/,glob,mesh,arrOut,nasc);
5012 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5013 * \param [in] type - a spatial discretization of the new field.
5014 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5015 * \param [in] mName - a name of the supporting mesh.
5016 * \param [in] renumPol - specifies how to permute values of the result field according to
5017 * the optional numbers of cells and nodes, if any. The valid values are
5018 * - 0 - do not permute.
5019 * - 1 - permute cells.
5020 * - 2 - permute nodes.
5021 * - 3 - permute cells and nodes.
5023 * \param [in] glob - the global data storing profiles and localization.
5024 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5025 * caller is to delete this field using decrRef() as it is no more needed.
5026 * \throw If the MED file is not readable.
5027 * \throw If there is no mesh named \a mName in the MED file.
5028 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5029 * \throw If no field of \a this is lying on the mesh \a mName.
5030 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5032 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5034 MCAuto<MEDFileMesh> mm;
5036 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
5038 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
5039 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
5043 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5044 * \param [in] type - a spatial discretization of the new field.
5045 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5046 * \param [in] renumPol - specifies how to permute values of the result field according to
5047 * the optional numbers of cells and nodes, if any. The valid values are
5048 * - 0 - do not permute.
5049 * - 1 - permute cells.
5050 * - 2 - permute nodes.
5051 * - 3 - permute cells and nodes.
5053 * \param [in] glob - the global data storing profiles and localization.
5054 * \param [in] mesh - the supporting mesh.
5055 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5056 * caller is to delete this field using decrRef() as it is no more needed.
5057 * \throw If the MED file is not readable.
5058 * \throw If no field of \a this is lying on \a mesh.
5059 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5060 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5062 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5064 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax,false));
5065 const DataArrayInt *d(mesh->getNumberFieldAtLevel(meshDimRelToMax)),*e(mesh->getNumberFieldAtLevel(1));
5066 if(meshDimRelToMax==1)
5067 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
5068 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
5072 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
5074 * \param [in] type - a spatial discretization of the new field.
5075 * \param [in] mName - a name of the supporting mesh.
5076 * \param [in] renumPol - specifies how to permute values of the result field according to
5077 * the optional numbers of cells and nodes, if any. The valid values are
5078 * - 0 - do not permute.
5079 * - 1 - permute cells.
5080 * - 2 - permute nodes.
5081 * - 3 - permute cells and nodes.
5083 * \param [in] glob - the global data storing profiles and localization.
5084 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5085 * caller is to delete this field using decrRef() as it is no more needed.
5086 * \throw If the MED file is not readable.
5087 * \throw If there is no mesh named \a mName in the MED file.
5088 * \throw If there are no mesh entities in the mesh.
5089 * \throw If no field values of the given \a type are available.
5091 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5093 MCAuto<MEDFileMesh> mm;
5095 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
5097 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
5098 int absDim=getDimension();
5099 int meshDimRelToMax=absDim-mm->getMeshDimension();
5100 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
5104 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5105 * \param [in] type - a spatial discretization of the new field.
5106 * \param [in] renumPol - specifies how to permute values of the result field according to
5107 * the optional numbers of cells and nodes, if any. The valid values are
5108 * - 0 - do not permute.
5109 * - 1 - permute cells.
5110 * - 2 - permute nodes.
5111 * - 3 - permute cells and nodes.
5113 * \param [in] glob - the global data storing profiles and localization.
5114 * \param [in] mesh - the supporting mesh.
5115 * \param [in] cellRenum - the cell numbers array used for permutation of the result
5116 * field according to \a renumPol.
5117 * \param [in] nodeRenum - the node numbers array used for permutation of the result
5118 * field according to \a renumPol.
5119 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5120 * caller is to delete this field using decrRef() as it is no more needed.
5121 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5122 * \throw If no field of \a this is lying on \a mesh.
5123 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5125 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
5127 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
5128 int meshId=getMeshIdFromMeshName(mesh->getName());
5130 MCAuto<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
5135 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5142 throw INTERP_KERNEL::Exception(msg1);
5143 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5146 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
5148 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5149 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
5150 throw INTERP_KERNEL::Exception(oss.str());
5152 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
5153 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
5154 std::vector<DataArray *> arrOut2(1,arrOut);
5155 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
5156 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
5157 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
5164 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5166 throw INTERP_KERNEL::Exception(msg1);
5169 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
5171 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5172 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
5173 throw INTERP_KERNEL::Exception(oss.str());
5175 MCAuto<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
5176 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
5177 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
5178 ret->renumberNodes(nodeRenumSafe->getConstPointer());
5183 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
5188 * Returns values and a profile of the field of a given type lying on a given support.
5189 * \param [in] type - a spatial discretization of the field.
5190 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5191 * \param [in] mesh - the supporting mesh.
5192 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
5193 * field of interest lies on. If the field lies on all entities of the given
5194 * dimension, all ids in \a pfl are zero. The caller is to delete this array
5195 * using decrRef() as it is no more needed.
5196 * \param [in] glob - the global data storing profiles and localization.
5197 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
5198 * field. The caller is to delete this array using decrRef() as it is no more needed.
5199 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
5200 * \throw If no field of \a this is lying on \a mesh.
5201 * \throw If no field values of the given \a type are available.
5203 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
5205 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
5206 int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
5207 MCAuto<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
5208 ret->setName(nasc.getName().c_str());
5212 //= MEDFileField1TSWithoutSDA
5215 * Throws if a given value is not a valid (non-extended) relative dimension.
5216 * \param [in] meshDimRelToMax - the relative dimension value.
5217 * \throw If \a meshDimRelToMax > 0.
5219 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
5221 if(meshDimRelToMax>0)
5222 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
5226 * Checks if elements of a given mesh are in the order suitable for writing
5227 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
5228 * vector describing types of elements and their number.
5229 * \param [in] mesh - the mesh to check.
5230 * \return std::vector<int> - a vector holding for each element type (1) item of
5231 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
5232 * These values are in full-interlace mode.
5233 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
5235 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
5238 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
5239 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
5240 int nbOfTypes=geoTypes.size();
5241 std::vector<int> code(3*nbOfTypes);
5242 MCAuto<DataArrayInt> arr1=DataArrayInt::New();
5243 arr1->alloc(nbOfTypes,1);
5244 int *arrPtr=arr1->getPointer();
5245 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
5246 for(int i=0;i<nbOfTypes;i++,it++)
5247 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
5248 MCAuto<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
5249 const int *arrPtr2=arr2->getConstPointer();
5251 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
5254 int nbCells=mesh->getNumberOfCellsWithType(*it);
5255 code[3*pos]=(int)(*it);
5256 code[3*pos+1]=nbCells;
5257 code[3*pos+2]=-1;//no profiles
5259 std::vector<const DataArrayInt *> idsPerType;//no profiles
5260 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
5264 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
5269 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5271 return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5275 * Returns all attributes and values of parts of \a this field lying on a given mesh.
5276 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
5277 * item of every of returned sequences refers to the _i_-th part of \a this field.
5278 * Thus all sequences returned by this method are of the same length equal to number
5279 * of different types of supporting entities.<br>
5280 * A field part can include sub-parts with several different spatial discretizations,
5281 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
5282 * for example. Hence, some of the returned sequences contains nested sequences, and an item
5283 * of a nested sequence corresponds to a type of spatial discretization.<br>
5284 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
5285 * The overhead is due to selecting values into new instances of DataArrayDouble.
5286 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
5287 * for the case with only one underlying mesh. (Actually, the number of meshes is
5288 * not checked if \a mname == \c NULL).
5289 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
5290 * a field part is returned.
5291 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
5292 * A field part can include sub-parts with several different spatial discretizations,
5293 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and
5294 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT" for example.
5295 * This sequence is of the same length as \a types.
5296 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
5297 * discretization. A profile name can be empty.
5298 * Length of this and of nested sequences is the same as that of \a typesF.
5299 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
5300 * discretization. A localization name can be empty.
5301 * Length of this and of nested sequences is the same as that of \a typesF.
5302 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
5303 * per each type of spatial discretization within one mesh entity type.
5304 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
5305 * Length of this and of nested sequences is the same as that of \a typesF.
5306 * \throw If no field is lying on \a mname.
5308 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
5312 meshId=getMeshIdFromMeshName(mname);
5314 if(_field_per_mesh.empty())
5315 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
5316 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
5317 int nbOfRet=ret0.size();
5318 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
5319 for(int i=0;i<nbOfRet;i++)
5321 const std::vector< std::pair<int,int> >& p=ret0[i];
5322 int nbOfRet1=p.size();
5323 ret[i].resize(nbOfRet1);
5324 for(int j=0;j<nbOfRet1;j++)
5326 DataArrayDouble *tmp=_arr->selectByTupleIdSafeSlice(p[j].first,p[j].second,1);
5333 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
5338 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
5340 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
5341 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5342 ret->deepCpyLeavesFrom(*this);
5343 const DataArrayDouble *arr(_arr);
5346 MCAuto<DataArrayInt> arr2(arr->convertToIntArr());
5347 ret->setArray(arr2);
5353 * Returns a pointer to the underground DataArrayDouble instance and a
5354 * sequence describing parameters of a support of each part of \a this field. The
5355 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5356 * direct access to the field values. This method is intended for the field lying on one
5358 * \param [in,out] entries - the sequence describing parameters of a support of each
5359 * part of \a this field. Each item of this sequence consists of two parts. The
5360 * first part describes a type of mesh entity and an id of discretization of a
5361 * current field part. The second part describes a range of values [begin,end)
5362 * within the returned array relating to the current field part.
5363 * \return DataArrayDouble * - the pointer to the field values array.
5364 * \throw If the number of underlying meshes is not equal to 1.
5365 * \throw If no field values are available.
5366 * \sa getUndergroundDataArray()
5368 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5370 if(_field_per_mesh.size()!=1)
5371 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5372 if(_field_per_mesh[0]==0)
5373 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5374 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5375 return getUndergroundDataArrayTemplate();
5379 * Returns a pointer to the underground DataArrayDouble instance and a
5380 * sequence describing parameters of a support of each part of \a this field. The
5381 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5382 * direct access to the field values. This method is intended for the field lying on one
5384 * \param [in,out] entries - the sequence describing parameters of a support of each
5385 * part of \a this field. Each item of this sequence consists of two parts. The
5386 * first part describes a type of mesh entity and an id of discretization of a
5387 * current field part. The second part describes a range of values [begin,end)
5388 * within the returned array relating to the current field part.
5389 * \return DataArrayDouble * - the pointer to the field values array.
5390 * \throw If the number of underlying meshes is not equal to 1.
5391 * \throw If no field values are available.
5392 * \sa getUndergroundDataArray()
5394 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5396 return getUndergroundDataArrayDoubleExt(entries);
5399 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<double>(fieldName,csit,iteration,order)
5401 DataArrayDouble *arr(getOrCreateAndGetArrayTemplate());
5402 arr->setInfoAndChangeNbOfCompo(infos);
5405 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<double>()
5409 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
5411 MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
5412 ret->deepCpyLeavesFrom(*this);
5416 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCopy() const
5418 MCAuto<MEDFileField1TSWithoutSDA> ret=static_cast<MEDFileField1TSWithoutSDA *>(shallowCpy());
5419 if((const DataArrayDouble *)_arr)
5420 ret->_arr=_arr->deepCopy();
5424 //= MEDFileIntField1TSWithoutSDA
5426 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5428 return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5431 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<int>()
5435 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order,
5436 const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<int>(fieldName,csit,iteration,order)
5438 DataArrayInt *arr(getOrCreateAndGetArrayTemplate());
5439 arr->setInfoAndChangeNbOfCompo(infos);
5442 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
5447 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const
5449 MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
5450 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5451 ret->deepCpyLeavesFrom(*this);
5452 const DataArrayInt *arr(_arr);
5455 MCAuto<DataArrayDouble> arr2(arr->convertToDblArr());
5456 ret->setArray(arr2);
5462 * Returns a pointer to the underground DataArrayInt instance and a
5463 * sequence describing parameters of a support of each part of \a this field. The
5464 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5465 * direct access to the field values. This method is intended for the field lying on one
5467 * \param [in,out] entries - the sequence describing parameters of a support of each
5468 * part of \a this field. Each item of this sequence consists of two parts. The
5469 * first part describes a type of mesh entity and an id of discretization of a
5470 * current field part. The second part describes a range of values [begin,end)
5471 * within the returned array relating to the current field part.
5472 * \return DataArrayInt * - the pointer to the field values array.
5473 * \throw If the number of underlying meshes is not equal to 1.
5474 * \throw If no field values are available.
5475 * \sa getUndergroundDataArray()
5477 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5479 return getUndergroundDataArrayIntExt(entries);
5483 * Returns a pointer to the underground DataArrayInt instance and a
5484 * sequence describing parameters of a support of each part of \a this field. The
5485 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5486 * direct access to the field values. This method is intended for the field lying on one
5488 * \param [in,out] entries - the sequence describing parameters of a support of each
5489 * part of \a this field. Each item of this sequence consists of two parts. The
5490 * first part describes a type of mesh entity and an id of discretization of a
5491 * current field part. The second part describes a range of values [begin,end)
5492 * within the returned array relating to the current field part.
5493 * \return DataArrayInt * - the pointer to the field values array.
5494 * \throw If the number of underlying meshes is not equal to 1.
5495 * \throw If no field values are available.
5496 * \sa getUndergroundDataArray()
5498 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5500 if(_field_per_mesh.size()!=1)
5501 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5502 if(_field_per_mesh[0]==0)
5503 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5504 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5505 return getUndergroundDataArrayTemplate();
5508 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5510 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5511 ret->deepCpyLeavesFrom(*this);
5515 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCopy() const
5517 MCAuto<MEDFileIntField1TSWithoutSDA> ret=static_cast<MEDFileIntField1TSWithoutSDA *>(shallowCpy());
5518 if((const DataArrayInt *)_arr)
5519 ret->_arr=_arr->deepCopy();
5523 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5527 //= MEDFileAnyTypeField1TS
5529 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
5531 med_field_type typcha;
5533 std::vector<std::string> infos;
5534 std::string dtunit,fieldName;
5535 LocateField2(fid,0,true,fieldName,typcha,infos,dtunit);
5536 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5541 ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5546 ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5551 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] !";
5552 throw INTERP_KERNEL::Exception(oss.str());
5555 ret->setDtUnit(dtunit.c_str());
5556 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5558 med_int numdt,numit;
5560 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5561 ret->setTime(numdt,numit,dt);
5564 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5566 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5570 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
5571 try:MEDFileFieldGlobsReal(fid)
5573 _content=BuildContentFrom(fid,loadAll,ms);
5576 catch(INTERP_KERNEL::Exception& e)
5581 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5583 med_field_type typcha;
5584 std::vector<std::string> infos;
5587 int nbSteps=LocateField(fid,fieldName,iii,typcha,infos,dtunit);
5588 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5593 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5598 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5603 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] !";
5604 throw INTERP_KERNEL::Exception(oss.str());
5607 ret->setDtUnit(dtunit.c_str());
5608 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5612 std::ostringstream oss; oss << "MEDFileField1TS(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5613 throw INTERP_KERNEL::Exception(oss.str());
5616 med_int numdt,numit;
5618 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5619 ret->setTime(numdt,numit,dt);
5622 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5624 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5628 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5629 try:MEDFileFieldGlobsReal(fid)
5631 _content=BuildContentFrom(fid,fieldName,loadAll,ms);
5634 catch(INTERP_KERNEL::Exception& e)
5639 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c)
5642 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5643 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5645 MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
5646 ret->_content=c; c->incrRef();
5649 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5651 MCAuto<MEDFileIntField1TS> ret(MEDFileIntField1TS::New());
5652 ret->_content=c; c->incrRef();
5655 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5658 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, med_idt fid)
5660 MEDFileAnyTypeField1TS *ret(BuildNewInstanceFromContent(c));
5661 ret->setFileName(FileNameFromFID(fid));
5665 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
5667 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5668 return New(fid,loadAll);
5671 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, bool loadAll)
5673 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
5674 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5675 ret->loadGlobals(fid);
5679 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
5681 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5682 return New(fid,fieldName,loadAll);
5685 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
5687 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0));
5688 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5689 ret->loadGlobals(fid);
5693 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
5695 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5696 return New(fid,fieldName,iteration,order,loadAll);
5699 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
5701 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0));
5702 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5703 ret->loadGlobals(fid);
5707 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5709 med_field_type typcha;
5710 std::vector<std::string> infos;
5713 int nbOfStep2(LocateField(fid,fieldName,iii,typcha,infos,dtunit));
5714 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5719 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5724 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5729 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] !";
5730 throw INTERP_KERNEL::Exception(oss.str());
5733 ret->setDtUnit(dtunit.c_str());
5734 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5737 std::vector< std::pair<int,int> > dtits(nbOfStep2);
5738 for(int i=0;i<nbOfStep2 && !found;i++)
5740 med_int numdt,numit;
5742 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt));
5743 if(numdt==iteration && numit==order)
5749 dtits[i]=std::pair<int,int>(numdt,numit);
5753 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available iterations are : ";
5754 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5755 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5756 throw INTERP_KERNEL::Exception(oss.str());
5759 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5761 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5765 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5766 try:MEDFileFieldGlobsReal(fid)
5768 _content=BuildContentFrom(fid,fieldName,iteration,order,loadAll,ms);
5771 catch(INTERP_KERNEL::Exception& e)
5777 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5778 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5780 * \warning this is a shallow copy constructor
5782 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5784 if(!shallowCopyOfContent)
5786 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5787 otherPtr->incrRef();
5788 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5792 _content=other.shallowCpy();
5796 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)
5800 int nbFields=MEDnField(fid);
5801 if(fieldIdCFormat>=nbFields)
5803 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << FileNameFromFID(fid) << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5804 throw INTERP_KERNEL::Exception(oss.str());
5807 int ncomp(MEDfieldnComponent(fid,fieldIdCFormat+1));
5808 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5809 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5810 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5811 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5812 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5815 MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep));
5816 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5817 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5818 infos.clear(); infos.resize(ncomp);
5819 for(int j=0;j<ncomp;j++)
5820 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5825 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5828 * \return in case of success the number of time steps available for the field with name \a fieldName.
5830 int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const std::string& fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
5832 int nbFields=MEDnField(fid);
5834 std::vector<std::string> fns(nbFields);
5836 for(int i=0;i<nbFields && !found;i++)
5839 nbOfStep2=LocateField2(fid,i,false,tmp,typcha,infos,dtunitOut);
5841 found=(tmp==fieldName);
5847 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available fields are : ";
5848 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5849 oss << "\"" << *it << "\" ";
5850 throw INTERP_KERNEL::Exception(oss.str());
5856 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5857 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5858 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5859 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5860 * to keep a valid instance.
5861 * 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.
5862 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5863 * 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.
5865 * \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.
5866 * \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.
5867 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5868 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5869 * \param [in] newLocName is the new localization name.
5870 * \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.
5871 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5873 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
5875 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5876 std::string oldPflName=disc->getProfile();
5877 std::vector<std::string> vv=getPflsReallyUsedMulti();
5878 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5879 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5881 disc->setProfile(newPflName);
5882 DataArrayInt *pfl=getProfile(oldPflName.c_str());
5883 pfl->setName(newPflName);
5887 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5888 throw INTERP_KERNEL::Exception(oss.str());
5893 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5894 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5895 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5896 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5897 * to keep a valid instance.
5898 * 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.
5899 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5900 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5901 * 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.
5903 * \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.
5904 * \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.
5905 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5906 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5907 * \param [in] newLocName is the new localization name.
5908 * \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.
5909 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
5911 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
5913 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5914 std::string oldLocName=disc->getLocalization();
5915 std::vector<std::string> vv=getLocsReallyUsedMulti();
5916 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
5917 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
5919 disc->setLocalization(newLocName);
5920 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
5921 loc.setName(newLocName);
5925 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
5926 throw INTERP_KERNEL::Exception(oss.str());
5930 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
5932 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5934 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
5938 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
5940 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5942 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
5947 * This method alloc the arrays and load potentially huge arrays contained in this field.
5948 * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
5949 * This method can be also called to refresh or reinit values from a file.
5951 * \throw If the fileName is not set or points to a non readable MED file.
5952 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5954 void MEDFileAnyTypeField1TS::loadArrays()
5956 if(getFileName().empty())
5957 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
5958 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
5959 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
5963 * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
5964 * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
5965 * this method does not throw if \a this does not come from file read.
5967 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
5969 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
5971 if(!getFileName().empty())
5973 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
5974 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
5979 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
5980 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
5981 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
5983 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
5985 void MEDFileAnyTypeField1TS::unloadArrays()
5987 contentNotNullBase()->unloadArrays();
5991 * 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.
5992 * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
5993 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
5995 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5997 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
5999 if(!getFileName().empty())
6000 contentNotNullBase()->unloadArrays();
6003 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
6005 int nbComp(getNumberOfComponents());
6006 INTERP_KERNEL::AutoPtr<char> comp(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
6007 INTERP_KERNEL::AutoPtr<char> unit(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
6008 for(int i=0;i<nbComp;i++)
6010 std::string info=getInfo()[i];
6012 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
6013 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
6014 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
6016 if(getName().empty())
6017 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
6018 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
6019 writeGlobals(fid,*this);
6020 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
6023 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
6025 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
6028 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
6030 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
6031 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
6036 * Returns a string describing \a this field. This string is outputted
6037 * by \c print Python command.
6039 std::string MEDFileAnyTypeField1TS::simpleRepr() const
6041 std::ostringstream oss;
6042 contentNotNullBase()->simpleRepr(0,oss,-1);
6043 simpleReprGlobs(oss);
6048 * This method returns all profiles whose name is non empty used.
6049 * \b WARNING If profile is used several times it will be reported \b only \b once.
6050 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
6052 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
6054 return contentNotNullBase()->getPflsReallyUsed2();
6058 * This method returns all localizations whose name is non empty used.
6059 * \b WARNING If localization is used several times it will be reported \b only \b once.
6061 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
6063 return contentNotNullBase()->getLocsReallyUsed2();
6067 * This method returns all profiles whose name is non empty used.
6068 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
6070 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
6072 return contentNotNullBase()->getPflsReallyUsedMulti2();
6076 * This method returns all localizations whose name is non empty used.
6077 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
6079 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
6081 return contentNotNullBase()->getLocsReallyUsedMulti2();
6084 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6086 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
6089 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6091 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
6094 int MEDFileAnyTypeField1TS::getDimension() const
6096 return contentNotNullBase()->getDimension();
6099 int MEDFileAnyTypeField1TS::getIteration() const
6101 return contentNotNullBase()->getIteration();
6104 int MEDFileAnyTypeField1TS::getOrder() const
6106 return contentNotNullBase()->getOrder();
6109 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
6111 return contentNotNullBase()->getTime(iteration,order);
6114 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
6116 contentNotNullBase()->setTime(iteration,order,val);
6119 std::string MEDFileAnyTypeField1TS::getName() const
6121 return contentNotNullBase()->getName();
6124 void MEDFileAnyTypeField1TS::setName(const std::string& name)
6126 contentNotNullBase()->setName(name);
6129 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
6131 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
6134 std::string MEDFileAnyTypeField1TS::getDtUnit() const
6136 return contentNotNullBase()->getDtUnit();
6139 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
6141 contentNotNullBase()->setDtUnit(dtUnit);
6144 std::string MEDFileAnyTypeField1TS::getMeshName() const
6146 return contentNotNullBase()->getMeshName();
6149 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
6151 contentNotNullBase()->setMeshName(newMeshName);
6154 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
6156 return contentNotNullBase()->changeMeshNames(modifTab);
6159 int MEDFileAnyTypeField1TS::getMeshIteration() const
6161 return contentNotNullBase()->getMeshIteration();
6164 int MEDFileAnyTypeField1TS::getMeshOrder() const
6166 return contentNotNullBase()->getMeshOrder();
6169 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
6171 return contentNotNullBase()->getNumberOfComponents();
6174 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
6176 return contentNotNullBase()->isDealingTS(iteration,order);
6179 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
6181 return contentNotNullBase()->getDtIt();
6184 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
6186 contentNotNullBase()->fillIteration(p);
6189 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
6191 contentNotNullBase()->fillTypesOfFieldAvailable(types);
6194 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
6196 contentNotNullBase()->setInfo(infos);
6199 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
6201 return contentNotNullBase()->getInfo();
6203 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
6205 return contentNotNullBase()->getInfo();
6208 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
6210 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
6213 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
6215 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6218 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
6220 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6223 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
6225 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
6228 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
6230 return contentNotNullBase()->getTypesOfFieldAvailable();
6233 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,
6234 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6236 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
6240 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
6241 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
6242 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
6244 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
6246 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6248 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
6249 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
6250 std::size_t sz(contentsSplit.size());
6251 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6252 for(std::size_t i=0;i<sz;i++)
6254 ret[i]=shallowCpy();
6255 ret[i]->_content=contentsSplit[i];
6261 * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
6262 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6264 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
6266 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6268 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
6269 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
6270 std::size_t sz(contentsSplit.size());
6271 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6272 for(std::size_t i=0;i<sz;i++)
6274 ret[i]=shallowCpy();
6275 ret[i]->_content=contentsSplit[i];
6281 * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this.
6282 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6284 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const
6286 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6288 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !");
6289 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
6290 std::size_t sz(contentsSplit.size());
6291 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6292 for(std::size_t i=0;i<sz;i++)
6294 ret[i]=shallowCpy();
6295 ret[i]->_content=contentsSplit[i];
6300 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCopy() const
6302 MCAuto<MEDFileAnyTypeField1TS> ret=shallowCpy();
6303 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
6304 ret->_content=_content->deepCopy();
6305 ret->deepCpyGlobs(*this);
6309 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
6311 return contentNotNullBase()->copyTinyInfoFrom(field,arr);
6317 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6318 * the first field that has been read from a specified MED file.
6319 * \param [in] fileName - the name of the MED file to read.
6320 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6321 * is to delete this field using decrRef() as it is no more needed.
6322 * \throw If reading the file fails.
6324 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll)
6326 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6327 return New(fid,loadAll);
6330 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, bool loadAll)
6332 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,loadAll,0));
6333 ret->contentNotNull();
6338 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6339 * a given field that has been read from a specified MED file.
6340 * \param [in] fileName - the name of the MED file to read.
6341 * \param [in] fieldName - the name of the field to read.
6342 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6343 * is to delete this field using decrRef() as it is no more needed.
6344 * \throw If reading the file fails.
6345 * \throw If there is no field named \a fieldName in the file.
6347 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6349 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6350 return New(fid,fieldName,loadAll);
6353 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
6355 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,fieldName,loadAll,0));
6356 ret->contentNotNull();
6361 * Returns a new instance of MEDFileField1TS holding data of a given time step of
6362 * a given field that has been read from a specified MED file.
6363 * \param [in] fileName - the name of the MED file to read.
6364 * \param [in] fieldName - the name of the field to read.
6365 * \param [in] iteration - the iteration number of a required time step.
6366 * \param [in] order - the iteration order number of required time step.
6367 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6368 * is to delete this field using decrRef() as it is no more needed.
6369 * \throw If reading the file fails.
6370 * \throw If there is no field named \a fieldName in the file.
6371 * \throw If the required time step is missing from the file.
6373 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6375 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6376 return New(fid,fieldName,iteration,order,loadAll);
6379 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
6381 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,fieldName,iteration,order,loadAll,0));
6382 ret->contentNotNull();
6387 * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6388 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6390 * Returns a new instance of MEDFileField1TS holding either a shallow copy
6391 * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
6392 * \warning this is a shallow copy constructor
6393 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
6394 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
6395 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6396 * is to delete this field using decrRef() as it is no more needed.
6398 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6400 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(other,shallowCopyOfContent));
6401 ret->contentNotNull();
6406 * Returns a new empty instance of MEDFileField1TS.
6407 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6408 * is to delete this field using decrRef() as it is no more needed.
6410 MEDFileField1TS *MEDFileField1TS::New()
6412 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS);
6413 ret->contentNotNull();
6418 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
6419 * following the given input policy.
6421 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6422 * By default (true) the globals are deeply copied.
6423 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
6425 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
6427 MCAuto<MEDFileIntField1TS> ret;
6428 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6431 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
6433 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
6434 MCAuto<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
6435 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc));
6438 ret=MEDFileIntField1TS::New();
6440 ret->deepCpyGlobs(*this);
6442 ret->shallowCpyGlobs(*this);
6446 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const
6448 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6450 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
6451 const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
6453 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 !");
6457 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull()
6459 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6461 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
6462 MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
6464 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 !");
6468 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
6471 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
6473 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
6474 DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6476 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6477 f->setArray(arrOutC);
6480 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MCAuto<DataArray>& arr)
6483 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
6484 DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6486 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6492 * Return an extraction of \a this using \a extractDef map to specify the extraction.
6493 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
6495 * \return A new object that the caller is responsible to deallocate.
6496 * \sa MEDFileUMesh::deduceNodeSubPartFromCellSubPart , MEDFileUMesh::extractPart
6498 MEDFileField1TS *MEDFileField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
6501 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : input mesh is NULL !");
6502 MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
6503 std::vector<TypeOfField> tof(getTypesOfFieldAvailable());
6504 for(std::vector<TypeOfField>::const_iterator it0=tof.begin();it0!=tof.end();it0++)
6506 if((*it0)!=ON_NODES)
6508 std::vector<int> levs;
6509 getNonEmptyLevels(mm->getName(),levs);
6510 for(std::vector<int>::const_iterator lev=levs.begin();lev!=levs.end();lev++)
6512 std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(*lev));
6513 if(it2!=extractDef.end())
6515 MCAuto<DataArrayInt> t((*it2).second);
6517 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6518 MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_CELLS,(*lev),mm));
6519 MCAuto<MEDCouplingFieldDouble> fOut(f->buildSubPart(t));
6520 ret->setFieldNoProfileSBT(fOut);
6526 std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(1));
6527 if(it2==extractDef.end())
6528 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a NODE field and no extract array available for NODE !");
6529 MCAuto<DataArrayInt> t((*it2).second);
6531 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6532 MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_NODES,0,mm));
6533 MCAuto<MEDCouplingFieldDouble> fOut(f->deepCopy());
6534 DataArrayDouble *arr(f->getArray());
6535 MCAuto<DataArrayDouble> newArr(arr->selectByTupleIdSafe(t->begin(),t->end()));
6536 fOut->setArray(newArr);
6537 ret->setFieldNoProfileSBT(fOut);
6543 MEDFileField1TS::MEDFileField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
6544 try:MEDFileAnyTypeField1TS(fid,loadAll,ms)
6547 catch(INTERP_KERNEL::Exception& e)
6550 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6551 try:MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms)
6554 catch(INTERP_KERNEL::Exception& e)
6557 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6558 try:MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms)
6561 catch(INTERP_KERNEL::Exception& e)
6565 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6566 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6568 * \warning this is a shallow copy constructor
6570 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6571 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6574 catch(INTERP_KERNEL::Exception& e)
6577 MEDFileField1TS::MEDFileField1TS()
6579 _content=new MEDFileField1TSWithoutSDA;
6583 * 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
6584 * method should be called (getFieldOnMeshAtLevel for example).
6585 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
6587 * \param [in] mesh - the mesh the field is lying on
6588 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6589 * caller is to delete this field using decrRef() as it is no more needed.
6591 MEDCouplingFieldDouble *MEDFileField1TS::field(const MEDFileMesh *mesh) const
6593 MCAuto<DataArray> arrOut;
6594 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
6595 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6600 * Returns a new MEDCouplingFieldDouble of a given type lying on
6601 * mesh entities of a given dimension of the first mesh in MED file. If \a this field
6602 * has not been constructed via file reading, an exception is thrown.
6603 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6604 * \param [in] type - a spatial discretization of interest.
6605 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6606 * \param [in] renumPol - specifies how to permute values of the result field according to
6607 * the optional numbers of cells and nodes, if any. The valid values are
6608 * - 0 - do not permute.
6609 * - 1 - permute cells.
6610 * - 2 - permute nodes.
6611 * - 3 - permute cells and nodes.
6613 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6614 * caller is to delete this field using decrRef() as it is no more needed.
6615 * \throw If \a this field has not been constructed via file reading.
6616 * \throw If the MED file is not readable.
6617 * \throw If there is no mesh in the MED file.
6618 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6619 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6620 * \sa getFieldOnMeshAtLevel()
6622 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6624 if(getFileName().empty())
6625 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6626 MCAuto<DataArray> arrOut;
6627 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
6628 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6633 * Returns a new MEDCouplingFieldDouble of a given type lying on
6634 * the top level cells of the first mesh in MED file. If \a this field
6635 * has not been constructed via file reading, an exception is thrown.
6636 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6637 * \param [in] type - a spatial discretization of interest.
6638 * \param [in] renumPol - specifies how to permute values of the result field according to
6639 * the optional numbers of cells and nodes, if any. The valid values are
6640 * - 0 - do not permute.
6641 * - 1 - permute cells.
6642 * - 2 - permute nodes.
6643 * - 3 - permute cells and nodes.
6645 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6646 * caller is to delete this field using decrRef() as it is no more needed.
6647 * \throw If \a this field has not been constructed via file reading.
6648 * \throw If the MED file is not readable.
6649 * \throw If there is no mesh in the MED file.
6650 * \throw If no field values of the given \a type.
6651 * \throw If no field values lying on the top level support.
6652 * \sa getFieldAtLevel()
6654 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
6656 if(getFileName().empty())
6657 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6658 MCAuto<DataArray> arrOut;
6659 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
6660 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6665 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6666 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6667 * \param [in] type - a spatial discretization of the new field.
6668 * \param [in] mesh - the supporting mesh.
6669 * \param [in] renumPol - specifies how to permute values of the result field according to
6670 * the optional numbers of cells and nodes, if any. The valid values are
6671 * - 0 - do not permute.
6672 * - 1 - permute cells.
6673 * - 2 - permute nodes.
6674 * - 3 - permute cells and nodes.
6676 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6677 * caller is to delete this field using decrRef() as it is no more needed.
6678 * \throw If no field of \a this is lying on \a mesh.
6679 * \throw If the mesh is empty.
6680 * \throw If no field values of the given \a type are available.
6681 * \sa getFieldAtLevel()
6682 * \sa getFieldOnMeshAtLevel()
6684 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
6686 MCAuto<DataArray> arrOut;
6687 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
6688 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6693 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6694 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6695 * \param [in] type - a spatial discretization of interest.
6696 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6697 * \param [in] mesh - the supporting mesh.
6698 * \param [in] renumPol - specifies how to permute values of the result field according to
6699 * the optional numbers of cells and nodes, if any. The valid values are
6700 * - 0 - do not permute.
6701 * - 1 - permute cells.
6702 * - 2 - permute nodes.
6703 * - 3 - permute cells and nodes.
6705 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6706 * caller is to delete this field using decrRef() as it is no more needed.
6707 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6708 * \throw If no field of \a this is lying on \a mesh.
6709 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6710 * \sa getFieldAtLevel()
6711 * \sa getFieldOnMeshAtLevel()
6713 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
6715 MCAuto<DataArray> arrOut;
6716 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
6717 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6722 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6723 * This method is called "Old" because in MED3 norm a field has only one meshName
6724 * attached, so this method is for readers of MED2 files. If \a this field
6725 * has not been constructed via file reading, an exception is thrown.
6726 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6727 * \param [in] type - a spatial discretization of interest.
6728 * \param [in] mName - a name of the supporting mesh.
6729 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6730 * \param [in] renumPol - specifies how to permute values of the result field according to
6731 * the optional numbers of cells and nodes, if any. The valid values are
6732 * - 0 - do not permute.
6733 * - 1 - permute cells.
6734 * - 2 - permute nodes.
6735 * - 3 - permute cells and nodes.
6737 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6738 * caller is to delete this field using decrRef() as it is no more needed.
6739 * \throw If the MED file is not readable.
6740 * \throw If there is no mesh named \a mName in the MED file.
6741 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6742 * \throw If \a this field has not been constructed via file reading.
6743 * \throw If no field of \a this is lying on the mesh named \a mName.
6744 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6745 * \sa getFieldAtLevel()
6747 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
6749 if(getFileName().empty())
6750 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6751 MCAuto<DataArray> arrOut;
6752 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull()));
6753 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6758 * Returns values and a profile of the field of a given type lying on a given support.
6759 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6760 * \param [in] type - a spatial discretization of the field.
6761 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6762 * \param [in] mesh - the supporting mesh.
6763 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6764 * field of interest lies on. If the field lies on all entities of the given
6765 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6766 * using decrRef() as it is no more needed.
6767 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6768 * field. The caller is to delete this array using decrRef() as it is no more needed.
6769 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6770 * \throw If no field of \a this is lying on \a mesh.
6771 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6773 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6775 MCAuto<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6776 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
6780 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6781 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6782 * "Sort By Type"), if not, an exception is thrown.
6783 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6784 * \param [in] field - the field to add to \a this.
6785 * \throw If the name of \a field is empty.
6786 * \throw If the data array of \a field is not set.
6787 * \throw If the data array is already allocated but has different number of components
6789 * \throw If the underlying mesh of \a field has no name.
6790 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6792 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
6795 contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
6799 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6800 * can be an aggregation of several MEDCouplingFieldDouble instances.
6801 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6802 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6805 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6806 * A new profile is added only if no equal profile is missing.
6807 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6808 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
6809 * \param [in] mesh - the supporting mesh of \a field.
6810 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6811 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6812 * \throw If either \a field or \a mesh or \a profile has an empty name.
6813 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6814 * \throw If the data array of \a field is not set.
6815 * \throw If the data array of \a this is already allocated but has different number of
6816 * components than \a field.
6817 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6818 * \sa setFieldNoProfileSBT()
6820 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6823 contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6826 MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const
6828 return new MEDFileField1TS(*this);
6831 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const
6833 return contentNotNull()->getUndergroundDataArrayTemplate();
6836 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
6838 return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
6841 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6842 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6844 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6847 //= MEDFileIntField1TS
6849 MEDFileIntField1TS *MEDFileIntField1TS::New()
6851 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS);
6852 ret->contentNotNull();
6856 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll)
6858 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6859 return MEDFileIntField1TS::New(fid,loadAll);
6862 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, bool loadAll)
6864 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,loadAll,0));
6865 ret->contentNotNull();
6869 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6871 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6872 return MEDFileIntField1TS::New(fid,fieldName,loadAll);
6875 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
6877 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,loadAll,0));
6878 ret->contentNotNull();
6882 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6884 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6885 return MEDFileIntField1TS::New(fid,fieldName,iteration,order,loadAll);
6888 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
6890 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,iteration,order,loadAll,0));
6891 ret->contentNotNull();
6895 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6897 MCAuto<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6898 ret->contentNotNull();
6902 MEDFileIntField1TS::MEDFileIntField1TS()
6904 _content=new MEDFileIntField1TSWithoutSDA;
6907 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
6908 try:MEDFileAnyTypeField1TS(fid,loadAll,ms)
6911 catch(INTERP_KERNEL::Exception& e)
6914 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6915 try:MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms)
6918 catch(INTERP_KERNEL::Exception& e)
6921 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6922 try:MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms)
6925 catch(INTERP_KERNEL::Exception& e)
6929 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6930 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6932 * \warning this is a shallow copy constructor
6934 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6938 MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const
6940 return new MEDFileIntField1TS(*this);
6944 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
6945 * following the given input policy.
6947 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6948 * By default (true) the globals are deeply copied.
6949 * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
6951 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const
6953 MCAuto<MEDFileField1TS> ret;
6954 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6957 const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
6959 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
6960 MCAuto<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
6961 ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc));
6964 ret=MEDFileField1TS::New();
6966 ret->deepCpyGlobs(*this);
6968 ret->shallowCpyGlobs(*this);
6973 * Adds a MEDCouplingFieldInt to \a this. The underlying mesh of the given field is
6974 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6975 * "Sort By Type"), if not, an exception is thrown.
6976 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6977 * \param [in] field - the field to add to \a this.
6978 * \throw If the name of \a field is empty.
6979 * \throw If the data array of \a field is not set.
6980 * \throw If the data array is already allocated but has different number of components
6982 * \throw If the underlying mesh of \a field has no name.
6983 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6985 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldInt *field)
6987 MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
6989 contentNotNull()->setFieldNoProfileSBT(field2,field->getArray(),*this,*contentNotNull());
6993 * Adds a MEDCouplingFieldInt to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6994 * can be an aggregation of several MEDCouplingFieldDouble instances.
6995 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6996 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6999 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
7000 * A new profile is added only if no equal profile is missing.
7001 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7002 * \param [in] field - the field to add to \a this.
7003 * \param [in] mesh - the supporting mesh of \a field.
7004 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
7005 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
7006 * \throw If either \a field or \a mesh or \a profile has an empty name.
7007 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7008 * \throw If the data array of \a field is not set.
7009 * \throw If the data array of \a this is already allocated but has different number of
7010 * components than \a field.
7011 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
7012 * \sa setFieldNoProfileSBT()
7014 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
7016 MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
7018 contentNotNull()->setFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
7021 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const
7023 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7025 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
7026 const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
7028 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 !");
7032 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
7034 if(getFileName().empty())
7035 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7036 MCAuto<DataArray> arrOut;
7037 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
7038 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7042 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MCAuto<DataArray>& arr)
7045 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
7046 DataArrayInt *arrC(dynamic_cast<DataArrayInt *>((DataArray *)arr));
7048 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
7053 MCAuto<MEDCouplingFieldInt> MEDFileIntField1TS::SetDataArrayDoubleInIntField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
7056 double t0(f->getTime(t1,t2));
7057 MCAuto<DataArrayInt> arr2(DynamicCastSafe<DataArray,DataArrayInt>(arr));
7058 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
7059 MCAuto<MEDCouplingFieldInt> ret(MEDCouplingFieldInt::New(*ft));
7060 ret->setTime(t0,t1,t2); ret->setArray(arr2);
7064 MCAuto<MEDCouplingFieldDouble> MEDFileIntField1TS::ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f)
7067 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ConvertFieldIntToFieldDouble : null input field !");
7069 double t0(f->getTime(t1,t2));
7070 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
7071 MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(*ft));
7072 ret->setTime(t0,t1,t2);
7076 MEDFileIntField1TS *MEDFileIntField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
7078 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::extractPart : not implemented yet !");
7082 * 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
7083 * method should be called (getFieldOnMeshAtLevel for example).
7084 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
7086 * \param [in] mesh - the mesh the field is lying on
7087 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
7088 * caller is to delete this field using decrRef() as it is no more needed.
7090 MEDCouplingFieldInt *MEDFileIntField1TS::field(const MEDFileMesh *mesh) const
7092 MCAuto<DataArray> arrOut;
7093 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
7094 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7099 * Returns a new MEDCouplingFieldInt of a given type lying on
7100 * the top level cells of the first mesh in MED file. If \a this field
7101 * has not been constructed via file reading, an exception is thrown.
7102 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7103 * \param [in] type - a spatial discretization of interest.
7104 * \param [in] renumPol - specifies how to permute values of the result field according to
7105 * the optional numbers of cells and nodes, if any. The valid values are
7106 * - 0 - do not permute.
7107 * - 1 - permute cells.
7108 * - 2 - permute nodes.
7109 * - 3 - permute cells and nodes.
7111 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7112 * caller is to delete this field using decrRef() as it is no more needed.
7113 * \throw If \a this field has not been constructed via file reading.
7114 * \throw If the MED file is not readable.
7115 * \throw If there is no mesh in the MED file.
7116 * \throw If no field values of the given \a type.
7117 * \throw If no field values lying on the top level support.
7118 * \sa getFieldAtLevel()
7120 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
7122 if(getFileName().empty())
7123 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
7124 MCAuto<DataArray> arrOut;
7125 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
7126 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7131 * Returns a new MEDCouplingFieldInt of given type lying on a given mesh.
7132 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7133 * \param [in] type - a spatial discretization of the new field.
7134 * \param [in] mesh - the supporting mesh.
7135 * \param [in] renumPol - specifies how to permute values of the result field according to
7136 * the optional numbers of cells and nodes, if any. The valid values are
7137 * - 0 - do not permute.
7138 * - 1 - permute cells.
7139 * - 2 - permute nodes.
7140 * - 3 - permute cells and nodes.
7142 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7143 * caller is to delete this field using decrRef() as it is no more needed.
7144 * \throw If no field of \a this is lying on \a mesh.
7145 * \throw If the mesh is empty.
7146 * \throw If no field values of the given \a type are available.
7147 * \sa getFieldAtLevel()
7148 * \sa getFieldOnMeshAtLevel()
7150 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
7152 MCAuto<DataArray> arrOut;
7153 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
7154 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7159 * Returns a new MEDCouplingFieldInt of a given type lying on a given support.
7160 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7161 * \param [in] type - a spatial discretization of interest.
7162 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7163 * \param [in] mesh - the supporting mesh.
7164 * \param [in] renumPol - specifies how to permute values of the result field according to
7165 * the optional numbers of cells and nodes, if any. The valid values are
7166 * - 0 - do not permute.
7167 * - 1 - permute cells.
7168 * - 2 - permute nodes.
7169 * - 3 - permute cells and nodes.
7171 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7172 * caller is to delete this field using decrRef() as it is no more needed.
7173 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7174 * \throw If no field of \a this is lying on \a mesh.
7175 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7176 * \sa getFieldAtLevel()
7177 * \sa getFieldOnMeshAtLevel()
7179 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
7181 MCAuto<DataArray> arrOut;
7182 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
7183 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7188 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
7189 * This method is called "Old" because in MED3 norm a field has only one meshName
7190 * attached, so this method is for readers of MED2 files. If \a this field
7191 * has not been constructed via file reading, an exception is thrown.
7192 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7193 * \param [in] type - a spatial discretization of interest.
7194 * \param [in] mName - a name of the supporting mesh.
7195 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7196 * \param [in] renumPol - specifies how to permute values of the result field according to
7197 * the optional numbers of cells and nodes, if any. The valid values are
7198 * - 0 - do not permute.
7199 * - 1 - permute cells.
7200 * - 2 - permute nodes.
7201 * - 3 - permute cells and nodes.
7203 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7204 * caller is to delete this field using decrRef() as it is no more needed.
7205 * \throw If the MED file is not readable.
7206 * \throw If there is no mesh named \a mName in the MED file.
7207 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7208 * \throw If \a this field has not been constructed via file reading.
7209 * \throw If no field of \a this is lying on the mesh named \a mName.
7210 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7211 * \sa getFieldAtLevel()
7213 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
7215 if(getFileName().empty())
7216 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7217 MCAuto<DataArray> arrOut;
7218 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
7219 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7224 * Returns values and a profile of the field of a given type lying on a given support.
7225 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7226 * \param [in] type - a spatial discretization of the field.
7227 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7228 * \param [in] mesh - the supporting mesh.
7229 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
7230 * field of interest lies on. If the field lies on all entities of the given
7231 * dimension, all ids in \a pfl are zero. The caller is to delete this array
7232 * using decrRef() as it is no more needed.
7233 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
7234 * field. The caller is to delete this array using decrRef() as it is no more needed.
7235 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7236 * \throw If no field of \a this is lying on \a mesh.
7237 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7239 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
7241 MCAuto<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
7242 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
7245 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull()
7247 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7249 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
7250 MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
7252 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 !");
7256 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const
7258 return contentNotNull()->getUndergroundDataArrayTemplate();
7261 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
7263 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
7267 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileFieldNameScope(fieldName)
7272 * \param [in] fieldId field id in C mode
7274 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7276 med_field_type typcha;
7277 std::string dtunitOut;
7278 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fieldId,false,_name,typcha,_infos,dtunitOut));
7279 setDtUnit(dtunitOut.c_str());
7280 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities);
7283 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)
7284 try:MEDFileFieldNameScope(fieldName),_infos(infos)
7286 setDtUnit(dtunit.c_str());
7287 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities);
7289 catch(INTERP_KERNEL::Exception& e)
7294 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
7296 std::size_t ret(_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MCAuto<MEDFileField1TSWithoutSDA>));
7297 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7298 ret+=(*it).capacity();
7302 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
7304 std::vector<const BigMemoryObject *> ret;
7305 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7306 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
7311 * 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
7314 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
7316 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7317 ret->setInfo(_infos);
7318 int sz=(int)_time_steps.size();
7319 for(const int *id=startIds;id!=endIds;id++)
7321 if(*id>=0 && *id<sz)
7323 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
7324 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7328 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7330 ret->pushBackTimeStep(tse2);
7334 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
7335 oss << " ! Should be in [0," << sz << ") !";
7336 throw INTERP_KERNEL::Exception(oss.str());
7339 if(ret->getNumberOfTS()>0)
7340 ret->synchronizeNameScope();
7341 ret->copyNameScope(*this);
7346 * 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
7349 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
7351 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
7352 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7353 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7354 ret->setInfo(_infos);
7355 int sz=(int)_time_steps.size();
7357 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
7361 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
7362 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7366 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7368 ret->pushBackTimeStep(tse2);
7372 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
7373 oss << " ! Should be in [0," << sz << ") !";
7374 throw INTERP_KERNEL::Exception(oss.str());
7377 if(ret->getNumberOfTS()>0)
7378 ret->synchronizeNameScope();
7379 ret->copyNameScope(*this);
7383 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7386 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7387 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7389 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7392 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7393 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
7394 ids->pushBackSilent(id);
7396 return buildFromTimeStepIds(ids->begin(),ids->end());
7399 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7402 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7403 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7405 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7408 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7409 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
7410 ids->pushBackSilent(id);
7412 return buildFromTimeStepIds(ids->begin(),ids->end());
7415 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
7417 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7419 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7422 if(cur->presenceOfMultiDiscPerGeoType())
7428 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
7433 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
7438 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
7441 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7443 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
7444 if(pt->isDealingTS(iteration,order))
7447 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
7448 std::vector< std::pair<int,int> > vp=getIterations();
7449 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
7450 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
7451 throw INTERP_KERNEL::Exception(oss.str());
7454 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
7456 return *_time_steps[getTimeStepPos(iteration,order)];
7459 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
7461 return *_time_steps[getTimeStepPos(iteration,order)];
7464 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const
7466 if(_time_steps.empty())
7467 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
7468 return _time_steps[0]->getMeshName();
7471 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const std::string& newMeshName)
7473 std::string oldName(getMeshName());
7474 std::vector< std::pair<std::string,std::string> > v(1);
7475 v[0].first=oldName; v[0].second=newMeshName;
7479 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
7482 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7484 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7486 ret=cur->changeMeshNames(modifTab) || ret;
7492 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
7494 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
7496 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
7500 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
7502 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7504 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
7507 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
7508 MEDFileFieldGlobsReal& glob)
7511 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7513 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
7515 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
7520 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7522 std::string startLine(bkOffset,' ');
7523 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
7525 oss << " (" << fmtsId << ")";
7526 oss << " has the following name: \"" << _name << "\"." << std::endl;
7527 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
7528 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7530 oss << startLine << " - \"" << *it << "\"" << std::endl;
7533 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7535 std::string chapter(17,'0'+i);
7536 oss << startLine << chapter << std::endl;
7537 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7539 cur->simpleRepr(bkOffset+2,oss,i);
7541 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
7542 oss << startLine << chapter << std::endl;
7546 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
7548 std::size_t sz=_time_steps.size();
7549 std::vector< std::pair<int,int> > ret(sz);
7551 for(std::size_t i=0;i<sz;i++)
7553 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
7556 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
7560 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
7561 throw INTERP_KERNEL::Exception(oss.str());
7567 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MCAuto<MEDFileAnyTypeField1TSWithoutSDA>& tse)
7569 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
7571 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
7572 checkCoherencyOfType(tse2);
7573 if(_time_steps.empty())
7575 setName(tse2->getName().c_str());
7576 setInfo(tse2->getInfo());
7578 checkThatComponentsMatch(tse2->getInfo());
7579 if(getDtUnit().empty() && !tse->getDtUnit().empty())
7580 setDtUnit(tse->getDtUnit());
7581 _time_steps.push_back(tse);
7584 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
7586 std::size_t nbOfCompo=_infos.size();
7587 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7589 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7592 if((cur->getInfo()).size()!=nbOfCompo)
7594 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
7595 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
7596 throw INTERP_KERNEL::Exception(oss.str());
7598 cur->copyNameScope(*this);
7603 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7605 _time_steps.resize(nbPdt);
7606 for(int i=0;i<nbPdt;i++)
7608 std::vector< std::pair<int,int> > ts;
7609 med_int numdt=0,numo=0;
7611 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt));
7616 _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7621 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7625 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
7628 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities);
7630 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entities);
7631 synchronizeNameScope();
7635 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
7637 if(_time_steps.empty())
7638 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
7639 checkThatNbOfCompoOfTSMatchThis();
7640 std::vector<std::string> infos(getInfo());
7641 int nbComp=infos.size();
7642 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7643 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7644 for(int i=0;i<nbComp;i++)
7646 std::string info=infos[i];
7648 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7649 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7650 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7653 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7654 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
7655 int nbOfTS=_time_steps.size();
7656 for(int i=0;i<nbOfTS;i++)
7657 _time_steps[i]->writeLL(fid,opts,*this);
7660 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
7662 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7664 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7666 elt->loadBigArraysRecursively(fid,nasc);
7670 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
7672 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7674 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7676 elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7680 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
7682 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7684 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7686 elt->unloadArrays();
7690 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7692 return _time_steps.size();
7695 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
7697 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7698 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7700 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7702 newTS.push_back(*it);
7707 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
7709 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7710 int maxId=(int)_time_steps.size();
7712 std::set<int> idsToDel;
7713 for(const int *id=startIds;id!=endIds;id++,ii++)
7715 if(*id>=0 && *id<maxId)
7717 idsToDel.insert(*id);
7721 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7722 throw INTERP_KERNEL::Exception(oss.str());
7725 for(int iii=0;iii<maxId;iii++)
7726 if(idsToDel.find(iii)==idsToDel.end())
7727 newTS.push_back(_time_steps[iii]);
7731 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
7733 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7734 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7735 if(nbOfEntriesToKill==0)
7737 std::size_t sz=_time_steps.size();
7738 std::vector<bool> b(sz,true);
7740 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7742 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7743 for(std::size_t i=0;i<sz;i++)
7745 newTS.push_back(_time_steps[i]);
7749 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
7752 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
7753 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7755 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7759 tmp->getTime(it2,ord);
7760 if(it2==iteration && order==ord)
7763 oss << "(" << it2 << "," << ord << "), ";
7766 throw INTERP_KERNEL::Exception(oss.str());
7769 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
7772 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
7774 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7776 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7780 double ti=tmp->getTime(it2,ord);
7781 if(fabs(time-ti)<eps)
7787 throw INTERP_KERNEL::Exception(oss.str());
7790 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
7792 int lgth=_time_steps.size();
7793 std::vector< std::pair<int,int> > ret(lgth);
7794 for(int i=0;i<lgth;i++)
7795 _time_steps[i]->fillIteration(ret[i]);
7800 * 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'
7801 * This method returns two things.
7802 * - The absolute dimension of 'this' in first parameter.
7803 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7804 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
7806 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7807 * Only these 3 discretizations will be taken into account here.
7809 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7810 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7811 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7813 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7814 * 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'.
7816 * Let's consider the typical following case :
7817 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7818 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7819 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7821 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7823 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7825 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7826 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7827 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7828 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7830 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
7832 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7835 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
7837 if(pos<0 || pos>=(int)_time_steps.size())
7839 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7840 throw INTERP_KERNEL::Exception(oss.str());
7842 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7845 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7846 oss << "\nTry to use following method eraseEmptyTS !";
7847 throw INTERP_KERNEL::Exception(oss.str());
7852 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
7854 if(pos<0 || pos>=(int)_time_steps.size())
7856 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7857 throw INTERP_KERNEL::Exception(oss.str());
7859 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7862 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7863 oss << "\nTry to use following method eraseEmptyTS !";
7864 throw INTERP_KERNEL::Exception(oss.str());
7869 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
7871 std::vector<std::string> ret;
7872 std::set<std::string> ret2;
7873 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7875 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
7876 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7877 if(ret2.find(*it2)==ret2.end())
7879 ret.push_back(*it2);
7886 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
7888 std::vector<std::string> ret;
7889 std::set<std::string> ret2;
7890 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7892 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
7893 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7894 if(ret2.find(*it2)==ret2.end())
7896 ret.push_back(*it2);
7903 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
7905 std::vector<std::string> ret;
7906 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7908 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
7909 ret.insert(ret.end(),tmp.begin(),tmp.end());
7914 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
7916 std::vector<std::string> ret;
7917 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7919 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
7920 ret.insert(ret.end(),tmp.begin(),tmp.end());
7925 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7927 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7928 (*it)->changePflsRefsNamesGen2(mapOfModif);
7931 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7933 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7934 (*it)->changeLocsRefsNamesGen2(mapOfModif);
7937 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
7939 int lgth=_time_steps.size();
7940 std::vector< std::vector<TypeOfField> > ret(lgth);
7941 for(int i=0;i<lgth;i++)
7942 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
7947 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
7949 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
7951 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
7954 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCopy() const
7956 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
7958 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7960 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
7961 ret->_time_steps[i]=(*it)->deepCopy();
7966 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
7968 std::size_t sz(_infos.size()),sz2(_time_steps.size());
7969 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7970 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7971 for(std::size_t i=0;i<sz;i++)
7973 ret[i]=shallowCpy();
7974 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7976 for(std::size_t i=0;i<sz2;i++)
7978 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7981 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7982 throw INTERP_KERNEL::Exception(oss.str());
7986 for(std::size_t i=0;i<sz;i++)
7987 for(std::size_t j=0;j<sz2;j++)
7988 ret[i]->_time_steps[j]=ts[j][i];
7993 * This method splits into discretization each time steps in \a this.
7994 * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
7996 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
7998 std::size_t sz(_time_steps.size());
7999 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
8000 for(std::size_t i=0;i<sz;i++)
8002 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
8005 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
8006 throw INTERP_KERNEL::Exception(oss.str());
8008 items[i]=timeStep->splitDiscretizations();
8011 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
8012 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
8013 std::vector< TypeOfField > types;
8014 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
8015 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
8017 std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
8019 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
8020 std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
8021 if(it2==types.end())
8022 types.push_back(ts[0]);
8024 ret.resize(types.size()); ret2.resize(types.size());
8025 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
8026 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
8028 TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
8029 std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
8030 ret2[pos].push_back(*it1);
8032 for(std::size_t i=0;i<types.size();i++)
8034 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
8035 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
8036 elt->pushBackTimeStep(*it1);//also updates infos in elt
8038 elt->MEDFileFieldNameScope::operator=(*this);
8044 * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
8046 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
8048 std::size_t sz(_time_steps.size());
8049 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
8050 std::size_t szOut(std::numeric_limits<std::size_t>::max());
8051 for(std::size_t i=0;i<sz;i++)
8053 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
8056 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
8057 throw INTERP_KERNEL::Exception(oss.str());
8059 items[i]=timeStep->splitMultiDiscrPerGeoTypes();
8060 if(szOut==std::numeric_limits<std::size_t>::max())
8061 szOut=items[i].size();
8063 if(items[i].size()!=szOut)
8064 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
8066 if(szOut==std::numeric_limits<std::size_t>::max())
8067 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
8068 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
8069 for(std::size_t i=0;i<szOut;i++)
8071 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
8072 for(std::size_t j=0;j<sz;j++)
8073 elt->pushBackTimeStep(items[j][i]);
8075 elt->MEDFileFieldNameScope::operator=(*this);
8080 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
8082 _name=field->getName();
8084 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
8086 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
8087 _infos=arr->getInfoOnComponents();
8090 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
8092 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
8093 if(_name!=field->getName())
8095 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
8096 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
8097 throw INTERP_KERNEL::Exception(oss.str());
8100 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
8101 checkThatComponentsMatch(arr->getInfoOnComponents());
8104 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
8106 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
8107 if(getInfo().size()!=compos.size())
8109 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
8110 oss << " number of components of element to append (" << compos.size() << ") !";
8111 throw INTERP_KERNEL::Exception(oss.str());
8115 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
8116 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
8117 oss << " But compo in input fields are : ";
8118 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
8120 throw INTERP_KERNEL::Exception(oss.str());
8124 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
8126 std::size_t sz=_infos.size();
8128 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
8130 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
8132 if(elt->getInfo().size()!=sz)
8134 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
8135 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
8136 throw INTERP_KERNEL::Exception(oss.str());
8141 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
8144 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8145 if(!_time_steps.empty())
8146 checkCoherencyOfTinyInfo(field,arr);
8147 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8148 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8149 objC->setFieldNoProfileSBT(field,arr,glob,*this);
8150 copyTinyInfoFrom(field,arr);
8151 _time_steps.push_back(obj);
8154 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
8157 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8158 if(!_time_steps.empty())
8159 checkCoherencyOfTinyInfo(field,arr);
8160 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8161 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8162 objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
8163 copyTinyInfoFrom(field,arr);
8164 _time_steps.push_back(obj);
8167 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ts)
8169 int sz=(int)_time_steps.size();
8172 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
8173 throw INTERP_KERNEL::Exception(oss.str());
8175 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
8178 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
8180 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
8181 throw INTERP_KERNEL::Exception(oss.str());
8187 //= MEDFileFieldMultiTSWithoutSDA
8189 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)
8191 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8194 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
8198 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8203 * \param [in] fieldId field id in C mode
8205 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8206 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8209 catch(INTERP_KERNEL::Exception& e)
8212 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)
8213 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8216 catch(INTERP_KERNEL::Exception& e)
8219 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8221 return new MEDFileField1TSWithoutSDA;
8224 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8227 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8228 const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
8230 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8233 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const
8235 return MEDFileField1TSWithoutSDA::TYPE_STR;
8238 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const
8240 return new MEDFileFieldMultiTSWithoutSDA(*this);
8243 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const
8245 return new MEDFileFieldMultiTSWithoutSDA;
8249 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
8250 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
8252 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
8254 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
8255 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8257 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
8258 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
8261 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
8263 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
8264 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8266 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8268 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8271 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
8273 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
8274 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
8275 ret->setIteration(i,elt);
8281 //= MEDFileAnyTypeFieldMultiTS
8283 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
8287 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8288 try:MEDFileFieldGlobsReal(fid)
8290 _content=BuildContentFrom(fid,loadAll,ms);
8293 catch(INTERP_KERNEL::Exception& e)
8298 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8300 med_field_type typcha;
8301 std::vector<std::string> infos;
8304 MEDFileAnyTypeField1TS::LocateField(fid,fieldName,i,typcha,infos,dtunit);
8305 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8310 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8315 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8320 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] !";
8321 throw INTERP_KERNEL::Exception(oss.str());
8324 ret->setDtUnit(dtunit.c_str());
8328 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8330 med_field_type typcha;
8332 std::vector<std::string> infos;
8333 std::string dtunit,fieldName;
8334 MEDFileAnyTypeField1TS::LocateField2(fid,0,true,fieldName,typcha,infos,dtunit);
8335 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8340 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8345 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8350 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] !";
8351 throw INTERP_KERNEL::Exception(oss.str());
8354 ret->setDtUnit(dtunit.c_str());
8358 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c)
8361 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
8362 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
8364 MCAuto<MEDFileFieldMultiTS> ret(MEDFileFieldMultiTS::New());
8365 ret->_content=c; c->incrRef();
8368 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
8370 MCAuto<MEDFileIntFieldMultiTS> ret(MEDFileIntFieldMultiTS::New());
8371 ret->_content=c; c->incrRef();
8374 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
8377 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, med_idt fid)
8379 MEDFileAnyTypeFieldMultiTS *ret(BuildNewInstanceFromContent(c));
8380 std::string fileName(FileNameFromFID(fid));
8381 ret->setFileName(fileName);
8385 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8386 try:MEDFileFieldGlobsReal(fid)
8388 _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
8391 catch(INTERP_KERNEL::Exception& e)
8396 //= MEDFileIntFieldMultiTSWithoutSDA
8398 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)
8400 return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8403 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
8407 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8411 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)
8412 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8415 catch(INTERP_KERNEL::Exception& e)
8419 * \param [in] fieldId field id in C mode
8421 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8422 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8425 catch(INTERP_KERNEL::Exception& e)
8428 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8430 return new MEDFileIntField1TSWithoutSDA;
8433 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8436 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8437 const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
8439 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8442 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const
8444 return MEDFileIntField1TSWithoutSDA::TYPE_STR;
8447 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const
8449 return new MEDFileIntFieldMultiTSWithoutSDA(*this);
8452 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const
8454 return new MEDFileIntFieldMultiTSWithoutSDA;
8457 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const
8459 MCAuto<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
8460 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8462 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8464 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8467 const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
8469 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
8470 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
8471 ret->setIteration(i,elt);
8477 //= MEDFileAnyTypeFieldMultiTS
8480 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
8481 * that has been read from a specified MED file.
8482 * \param [in] fileName - the name of the MED file to read.
8483 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8484 * is to delete this field using decrRef() as it is no more needed.
8485 * \throw If reading the file fails.
8487 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
8489 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8490 return New(fid,loadAll);
8493 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, bool loadAll)
8495 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
8496 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8497 ret->loadGlobals(fid);
8502 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
8503 * that has been read from a specified MED file.
8504 * \param [in] fileName - the name of the MED file to read.
8505 * \param [in] fieldName - the name of the field to read.
8506 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8507 * is to delete this field using decrRef() as it is no more needed.
8508 * \throw If reading the file fails.
8509 * \throw If there is no field named \a fieldName in the file.
8511 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8513 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8514 return New(fid,fieldName,loadAll);
8517 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
8519 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
8520 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8521 ret->loadGlobals(fid);
8526 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8527 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8529 * \warning this is a shallow copy constructor
8531 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8533 if(!shallowCopyOfContent)
8535 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
8536 otherPtr->incrRef();
8537 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
8541 _content=other.shallowCpy();
8545 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
8547 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8549 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
8553 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
8555 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8557 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
8561 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
8563 return contentNotNullBase()->getPflsReallyUsed2();
8566 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
8568 return contentNotNullBase()->getLocsReallyUsed2();
8571 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
8573 return contentNotNullBase()->getPflsReallyUsedMulti2();
8576 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
8578 return contentNotNullBase()->getLocsReallyUsedMulti2();
8581 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8583 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
8586 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8588 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
8591 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
8593 return contentNotNullBase()->getNumberOfTS();
8596 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
8598 contentNotNullBase()->eraseEmptyTS();
8601 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
8603 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
8606 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
8608 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
8611 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
8613 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
8614 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8619 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
8621 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
8622 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8627 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
8629 return contentNotNullBase()->getIterations();
8632 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
8634 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
8635 pushBackTimeStep(*it);
8638 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
8641 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
8642 int nbOfTS(fmts->getNumberOfTS());
8643 for(int i=0;i<nbOfTS;i++)
8645 MCAuto<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
8646 pushBackTimeStep(elt);
8650 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
8653 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
8654 checkCoherencyOfType(f1ts);
8656 MCAuto<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
8657 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
8659 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
8660 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
8661 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
8662 _content->pushBackTimeStep(cSafe);
8663 appendGlobs(*f1ts,1e-12);
8666 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
8668 contentNotNullBase()->synchronizeNameScope();
8671 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
8673 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
8676 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
8678 return contentNotNullBase()->getPosGivenTime(time,eps);
8681 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8683 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
8686 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
8688 return contentNotNullBase()->getTypesOfFieldAvailable();
8691 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
8693 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
8696 std::string MEDFileAnyTypeFieldMultiTS::getName() const
8698 return contentNotNullBase()->getName();
8701 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
8703 contentNotNullBase()->setName(name);
8706 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
8708 return contentNotNullBase()->getDtUnit();
8711 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
8713 contentNotNullBase()->setDtUnit(dtUnit);
8716 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8718 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
8721 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
8723 return contentNotNullBase()->getTimeSteps(ret1);
8726 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
8728 return contentNotNullBase()->getMeshName();
8731 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
8733 contentNotNullBase()->setMeshName(newMeshName);
8736 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
8738 return contentNotNullBase()->changeMeshNames(modifTab);
8741 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
8743 return contentNotNullBase()->getInfo();
8746 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
8748 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
8751 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
8753 return contentNotNullBase()->setInfo(info);
8756 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
8758 const std::vector<std::string> ret=getInfo();
8759 return (int)ret.size();
8762 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
8764 writeGlobals(fid,*this);
8765 contentNotNullBase()->writeLL(fid,*this);
8769 * This method alloc the arrays and load potentially huge arrays contained in this field.
8770 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
8771 * This method can be also called to refresh or reinit values from a file.
8773 * \throw If the fileName is not set or points to a non readable MED file.
8775 void MEDFileAnyTypeFieldMultiTS::loadArrays()
8777 if(getFileName().empty())
8778 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
8779 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
8780 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
8784 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
8785 * But once data loaded once, this method does nothing.
8787 * \throw If the fileName is not set or points to a non readable MED file.
8788 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
8790 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
8792 if(!getFileName().empty())
8794 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
8795 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
8800 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
8801 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
8802 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
8804 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
8806 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
8808 contentNotNullBase()->unloadArrays();
8812 * 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.
8813 * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
8814 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
8816 * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
8818 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
8820 if(!getFileName().empty())
8821 contentNotNullBase()->unloadArrays();
8824 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
8826 std::ostringstream oss;
8827 contentNotNullBase()->simpleRepr(0,oss,-1);
8828 simpleReprGlobs(oss);
8832 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
8834 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
8837 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
8839 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
8840 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
8845 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
8846 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8847 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
8849 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
8851 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8853 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
8854 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
8855 std::size_t sz(contentsSplit.size());
8856 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8857 for(std::size_t i=0;i<sz;i++)
8859 ret[i]=shallowCpy();
8860 ret[i]->_content=contentsSplit[i];
8866 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
8867 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8869 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
8871 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8873 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
8874 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
8875 std::size_t sz(contentsSplit.size());
8876 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8877 for(std::size_t i=0;i<sz;i++)
8879 ret[i]=shallowCpy();
8880 ret[i]->_content=contentsSplit[i];
8886 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
8887 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8889 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
8891 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8893 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
8894 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
8895 std::size_t sz(contentsSplit.size());
8896 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8897 for(std::size_t i=0;i<sz;i++)
8899 ret[i]=shallowCpy();
8900 ret[i]->_content=contentsSplit[i];
8905 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCopy() const
8907 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8908 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
8909 ret->_content=_content->deepCopy();
8910 ret->deepCpyGlobs(*this);
8914 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
8920 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8921 * \param [in] iteration - the iteration number of a required time step.
8922 * \param [in] order - the iteration order number of required time step.
8923 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
8924 * delete this field using decrRef() as it is no more needed.
8925 * \throw If there is no required time step in \a this field.
8927 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
8929 int pos=getPosOfTimeStep(iteration,order);
8930 return getTimeStepAtPos(pos);
8934 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8935 * \param [in] time - the time of the time step of interest.
8936 * \param [in] eps - a precision used to compare time values.
8937 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8938 * delete this field using decrRef() as it is no more needed.
8939 * \throw If there is no required time step in \a this field.
8941 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
8943 int pos=getPosGivenTime(time,eps);
8944 return getTimeStepAtPos(pos);
8948 * 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.
8949 * The float64 value of time attached to the pair of integers are not considered here.
8950 * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
8952 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
8953 * \throw If there is a null pointer in \a vectFMTS.
8955 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
8957 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
8958 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8959 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8960 while(!lstFMTS.empty())
8962 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8963 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8965 throw INTERP_KERNEL::Exception(msg);
8966 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
8967 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8968 elt.push_back(curIt); it=lstFMTS.erase(it);
8969 while(it!=lstFMTS.end())
8973 throw INTERP_KERNEL::Exception(msg);
8974 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
8976 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8986 * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
8987 * All returned instances in a subvector can be safely loaded, rendered along time
8988 * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
8989 * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
8990 * 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).
8991 * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
8992 * 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.
8994 * \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().
8995 * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
8996 * \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.
8997 * \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.
8999 * \throw If an element in \a vectFMTS has not only one spatial discretization set.
9000 * \throw If an element in \a vectFMTS change of spatial discretization along time.
9001 * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
9002 * \thorw If some elements in \a vectFMTS do not have the same times steps.
9003 * \throw If mesh is null.
9004 * \throw If an element in \a vectFMTS is null.
9005 * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
9007 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& fsc)
9009 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
9011 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
9012 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9013 if(vectFMTS.empty())
9015 std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
9016 MEDFileAnyTypeFieldMultiTS *frstElt(*it);
9018 throw INTERP_KERNEL::Exception(msg);
9020 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
9021 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
9022 for(;it!=vectFMTS.end();it++,i++)
9025 throw INTERP_KERNEL::Exception(msg);
9026 TypeOfField tof0,tof1;
9027 if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
9030 vectFMTSNotNodes.push_back(*it);
9032 vectFMTSNodes.push_back(*it);
9035 vectFMTSNotNodes.push_back(*it);
9037 std::vector< MCAuto<MEDFileFastCellSupportComparator> > cmps;
9038 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
9040 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
9043 bool isFetched(false);
9044 for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
9047 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
9048 if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
9049 { ret[i].push_back(*it2); isFetched=true; }
9053 std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
9054 MCAuto<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
9055 ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
9063 * 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.
9064 * \param [out] cmps - same size than the returned vector.
9066 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& cmps)
9068 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9069 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
9070 while(!lstFMTS.empty())
9072 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
9073 MEDFileAnyTypeFieldMultiTS *ref(*it);
9074 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
9075 elt.push_back(ref); it=lstFMTS.erase(it);
9076 MCAuto<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
9077 MCAuto<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
9078 while(it!=lstFMTS.end())
9080 MEDFileAnyTypeFieldMultiTS *curIt(*it);
9081 if(cmp->isEqual(curIt))
9082 { elt.push_back(curIt); it=lstFMTS.erase(it); }
9086 ret.push_back(elt); cmps.push_back(cmp);
9092 * 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.
9093 * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
9095 * \throw If \a f0 or \a f1 has not only one spatial discretization set.
9096 * \throw If \a f0 or \a f1 change of spatial discretization along time.
9097 * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
9098 * \thorw If \a f0 and \a f1 do not have the same times steps.
9099 * \throw If mesh is null.
9100 * \throw If \a f0 or \a f1 is null.
9101 * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
9103 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
9106 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
9108 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
9109 if(f0->getMeshName()!=mesh->getName())
9111 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9112 throw INTERP_KERNEL::Exception(oss.str());
9114 if(f1->getMeshName()!=mesh->getName())
9116 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9117 throw INTERP_KERNEL::Exception(oss.str());
9119 int nts=f0->getNumberOfTS();
9120 if(nts!=f1->getNumberOfTS())
9121 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
9124 for(int i=0;i<nts;i++)
9126 MCAuto<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
9127 MCAuto<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
9128 std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
9129 if(tofs0.size()!=1 || tofs1.size()!=1)
9130 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
9133 if(tof0!=tofs0[0] || tof1!=tofs1[0])
9134 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
9137 { tof0=tofs0[0]; tof1=tofs1[0]; }
9138 if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
9140 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() << ") !";
9141 throw INTERP_KERNEL::Exception(oss.str());
9143 if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
9145 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() << ") !";
9146 throw INTERP_KERNEL::Exception(oss.str());
9148 if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
9150 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() << ") !";
9151 throw INTERP_KERNEL::Exception(oss.str());
9158 * Return an extraction of \a this using \a extractDef map to specify the extraction.
9159 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
9161 * \return A new object that the caller is responsible to deallocate.
9163 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
9166 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::extractPart : mesh is null !");
9167 MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(buildNewEmpty());
9168 int nbTS(getNumberOfTS());
9169 for(int i=0;i<nbTS;i++)
9171 MCAuto<MEDFileAnyTypeField1TS> f1ts(getTimeStepAtPos(i));
9172 MCAuto<MEDFileAnyTypeField1TS> f1tsOut(f1ts->extractPart(extractDef,mm));
9173 fmtsOut->pushBackTimeStep(f1tsOut);
9175 return fmtsOut.retn();
9179 MCAuto<MEDFileAnyTypeField1TS> AggregateHelperF1TS(const std::vector< typename MLFieldTraits<T>::F1TSType const *>& f1tss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9181 MCAuto< typename MLFieldTraits<T>::F1TSType > ret(MLFieldTraits<T>::F1TSType::New());
9183 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : empty vector !");
9184 std::size_t sz(f1tss.size()),i(0);
9185 std::vector< typename MLFieldTraits<T>::F1TSWSDAType const *> f1tsw(sz);
9186 for(typename std::vector< typename MLFieldTraits<T>::F1TSType const *>::const_iterator it=f1tss.begin();it!=f1tss.end();it++,i++)
9188 typename MLFieldTraits<T>::F1TSType const *elt(*it);
9190 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : presence of a null pointer !");
9191 f1tsw[i]=dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType const *>(elt->contentNotNullBase());
9193 typename MLFieldTraits<T>::F1TSWSDAType *retc(dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType *>(ret->contentNotNullBase()));
9195 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : internal error 1 !");
9196 retc->aggregate(f1tsw,dts);
9197 ret->setDtUnit(f1tss[0]->getDtUnit());
9198 return DynamicCast<typename MLFieldTraits<T>::F1TSType , MEDFileAnyTypeField1TS>(ret);
9202 MCAuto< MEDFileAnyTypeFieldMultiTS > AggregateHelperFMTS(const std::vector< typename MLFieldTraits<T>::FMTSType const *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9204 MCAuto< typename MLFieldTraits<T>::FMTSType > ret(MLFieldTraits<T>::FMTSType::New());
9206 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : empty vector !");
9207 std::size_t sz(fmtss.size());
9208 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9210 typename MLFieldTraits<T>::FMTSType const *elt(*it);
9212 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : presence of null pointer !");
9214 int nbTS(fmtss[0]->getNumberOfTS());
9215 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9216 if((*it)->getNumberOfTS()!=nbTS)
9217 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : all fields must have the same number of TS !");
9218 for(int iterTS=0;iterTS<nbTS;iterTS++)
9221 std::vector< typename MLFieldTraits<T>::F1TSType const *> f1tss(sz);
9222 std::vector< MCAuto<typename MLFieldTraits<T>::F1TSType> > f1tss2(sz);
9223 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++,i++)
9224 { f1tss2[i]=(*it)->getTimeStepAtPos(iterTS); f1tss[i]=f1tss2[i]; }
9225 MCAuto<MEDFileAnyTypeField1TS> f1ts(AggregateHelperF1TS<T>(f1tss,dts));
9226 ret->pushBackTimeStep(f1ts);
9227 ret->setDtUnit(f1ts->getDtUnit());
9229 return DynamicCast<typename MLFieldTraits<T>::FMTSType , MEDFileAnyTypeFieldMultiTS>(ret);
9233 * \a dts and \a ftmss are expected to have same size.
9235 MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileAnyTypeFieldMultiTS::Aggregate(const std::vector<const MEDFileAnyTypeFieldMultiTS *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9238 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : input vector is empty !");
9239 std::size_t sz(fmtss.size());
9240 std::vector<const MEDFileFieldMultiTS *> fmtss1;
9241 std::vector<const MEDFileIntFieldMultiTS *> fmtss2;
9242 for(std::vector<const MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9245 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : presence of null instance in input vector !");
9246 const MEDFileFieldMultiTS *elt1(dynamic_cast<const MEDFileFieldMultiTS *>(*it));
9249 fmtss1.push_back(elt1);
9252 const MEDFileIntFieldMultiTS *elt2(dynamic_cast<const MEDFileIntFieldMultiTS *>(*it));
9255 fmtss2.push_back(elt2);
9258 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not recognized type !");
9260 if(fmtss1.size()!=sz && fmtss2.size()!=sz)
9261 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : type of data is not homogeneous !");
9262 if(fmtss1.size()==sz)
9263 return AggregateHelperFMTS<double>(fmtss1,dts);
9264 if(fmtss2.size()!=sz)
9265 return AggregateHelperFMTS<int>(fmtss2,dts);
9266 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not implemented yet !");
9269 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
9271 return new MEDFileAnyTypeFieldMultiTSIterator(this);
9274 //= MEDFileFieldMultiTS
9277 * Returns a new empty instance of MEDFileFieldMultiTS.
9278 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9279 * is to delete this field using decrRef() as it is no more needed.
9281 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
9283 return new MEDFileFieldMultiTS;
9287 * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
9288 * that has been read from a specified MED file.
9289 * \param [in] fileName - the name of the MED file to read.
9290 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9291 * is to delete this field using decrRef() as it is no more needed.
9292 * \throw If reading the file fails.
9294 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll)
9296 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9297 return New(fid,loadAll);
9300 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, bool loadAll)
9302 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,loadAll,0));
9303 ret->contentNotNull();//to check that content type matches with \a this type.
9308 * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
9309 * that has been read from a specified MED file.
9310 * \param [in] fileName - the name of the MED file to read.
9311 * \param [in] fieldName - the name of the field to read.
9312 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9313 * is to delete this field using decrRef() as it is no more needed.
9314 * \throw If reading the file fails.
9315 * \throw If there is no field named \a fieldName in the file.
9317 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9319 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9320 return New(fid,fieldName,loadAll);
9323 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
9325 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0));
9326 ret->contentNotNull();//to check that content type matches with \a this type.
9331 * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9332 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9334 * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
9335 * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9336 * \warning this is a shallow copy constructor
9337 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
9338 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9339 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9340 * is to delete this field using decrRef() as it is no more needed.
9342 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9344 return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
9347 MEDFileFieldMultiTS *MEDFileFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9349 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9350 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
9351 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0,ent));
9352 ret->contentNotNull();//to check that content type matches with \a this type.
9356 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
9358 return new MEDFileFieldMultiTS(*this);
9361 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9364 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9365 const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
9367 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
9371 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
9372 * following the given input policy.
9374 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9375 * By default (true) the globals are deeply copied.
9376 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
9378 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
9380 MCAuto<MEDFileIntFieldMultiTS> ret;
9381 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9384 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
9386 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
9387 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
9388 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc));
9391 ret=MEDFileIntFieldMultiTS::New();
9393 ret->deepCpyGlobs(*this);
9395 ret->shallowCpyGlobs(*this);
9400 * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
9401 * \param [in] pos - a time step id.
9402 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9403 * delete this field using decrRef() as it is no more needed.
9404 * \throw If \a pos is not a valid time step id.
9406 MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const
9408 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9411 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9412 throw INTERP_KERNEL::Exception(oss.str());
9414 const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
9417 MCAuto<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
9418 ret->shallowCpyGlobs(*this);
9421 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
9422 throw INTERP_KERNEL::Exception(oss.str());
9426 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9427 * mesh entities of a given dimension of the first mesh in MED file.
9428 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9429 * \param [in] type - a spatial discretization of interest.
9430 * \param [in] iteration - the iteration number of a required time step.
9431 * \param [in] order - the iteration order number of required time step.
9432 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9433 * \param [in] renumPol - specifies how to permute values of the result field according to
9434 * the optional numbers of cells and nodes, if any. The valid values are
9435 * - 0 - do not permute.
9436 * - 1 - permute cells.
9437 * - 2 - permute nodes.
9438 * - 3 - permute cells and nodes.
9440 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9441 * caller is to delete this field using decrRef() as it is no more needed.
9442 * \throw If the MED file is not readable.
9443 * \throw If there is no mesh in the MED file.
9444 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9445 * \throw If no field values of the required parameters are available.
9447 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9449 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9450 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9452 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
9453 MCAuto<DataArray> arrOut;
9454 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9455 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9460 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9461 * the top level cells of the first mesh in MED file.
9462 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9463 * \param [in] type - a spatial discretization of interest.
9464 * \param [in] iteration - the iteration number of a required time step.
9465 * \param [in] order - the iteration order number of required time step.
9466 * \param [in] renumPol - specifies how to permute values of the result field according to
9467 * the optional numbers of cells and nodes, if any. The valid values are
9468 * - 0 - do not permute.
9469 * - 1 - permute cells.
9470 * - 2 - permute nodes.
9471 * - 3 - permute cells and nodes.
9473 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9474 * caller is to delete this field using decrRef() as it is no more needed.
9475 * \throw If the MED file is not readable.
9476 * \throw If there is no mesh in the MED file.
9477 * \throw If no field values of the required parameters are available.
9479 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9481 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9482 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9484 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
9485 MCAuto<DataArray> arrOut;
9486 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9487 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9492 * 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
9493 * method should be called (getFieldOnMeshAtLevel for example).
9494 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
9496 * \param [in] iteration - the iteration number of a required time step.
9497 * \param [in] order - the iteration order number of required time step.
9498 * \param [in] mesh - the mesh the field is lying on
9499 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9500 * caller is to delete this field using decrRef() as it is no more needed.
9502 MEDCouplingFieldDouble *MEDFileFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
9504 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9505 MCAuto<DataArray> arrOut;
9506 MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
9507 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9512 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9514 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9515 * \param [in] type - a spatial discretization of interest.
9516 * \param [in] iteration - the iteration number of a required time step.
9517 * \param [in] order - the iteration order number of required time step.
9518 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9519 * \param [in] mesh - the supporting mesh.
9520 * \param [in] renumPol - specifies how to permute values of the result field according to
9521 * the optional numbers of cells and nodes, if any. The valid values are
9522 * - 0 - do not permute.
9523 * - 1 - permute cells.
9524 * - 2 - permute nodes.
9525 * - 3 - permute cells and nodes.
9527 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9528 * caller is to delete this field using decrRef() as it is no more needed.
9529 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9530 * \throw If no field of \a this is lying on \a mesh.
9531 * \throw If no field values of the required parameters are available.
9533 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9535 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9536 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9538 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9539 MCAuto<DataArray> arrOut;
9540 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
9541 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9546 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9548 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9549 * \param [in] type - a spatial discretization of the new field.
9550 * \param [in] iteration - the iteration number of a required time step.
9551 * \param [in] order - the iteration order number of required time step.
9552 * \param [in] mesh - the supporting mesh.
9553 * \param [in] renumPol - specifies how to permute values of the result field according to
9554 * the optional numbers of cells and nodes, if any. The valid values are
9555 * - 0 - do not permute.
9556 * - 1 - permute cells.
9557 * - 2 - permute nodes.
9558 * - 3 - permute cells and nodes.
9560 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9561 * caller is to delete this field using decrRef() as it is no more needed.
9562 * \throw If no field of \a this is lying on \a mesh.
9563 * \throw If no field values of the required parameters are available.
9565 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
9567 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9568 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9570 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9571 MCAuto<DataArray> arrOut;
9572 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
9573 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9578 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
9579 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9580 * This method is useful for MED2 file format when field on different mesh was autorized.
9582 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
9584 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9585 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9587 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
9588 MCAuto<DataArray> arrOut;
9589 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
9590 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9595 * Returns values and a profile of the field of a given type, of a given time step,
9596 * lying on a given support.
9597 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9598 * \param [in] type - a spatial discretization of the field.
9599 * \param [in] iteration - the iteration number of a required time step.
9600 * \param [in] order - the iteration order number of required time step.
9601 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9602 * \param [in] mesh - the supporting mesh.
9603 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9604 * field of interest lies on. If the field lies on all entities of the given
9605 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9606 * using decrRef() as it is no more needed.
9607 * \param [in] glob - the global data storing profiles and localization.
9608 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
9609 * field. The caller is to delete this array using decrRef() as it is no more needed.
9610 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9611 * \throw If no field of \a this is lying on \a mesh.
9612 * \throw If no field values of the required parameters are available.
9614 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9616 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9617 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9619 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
9620 MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9621 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
9624 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const
9626 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9628 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
9629 const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
9631 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 !");
9635 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull()
9637 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9639 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
9640 MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
9642 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 !");
9647 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9648 * the given field is checked if its elements are sorted suitable for writing to MED file
9649 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9650 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9651 * \param [in] field - the field to add to \a this.
9652 * \throw If the name of \a field is empty.
9653 * \throw If the data array of \a field is not set.
9654 * \throw If existing time steps have different name or number of components than \a field.
9655 * \throw If the underlying mesh of \a field has no name.
9656 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9658 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
9660 const DataArrayDouble *arr=0;
9662 arr=field->getArray();
9663 contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
9667 * Adds a MEDCouplingFieldDouble to \a this as another time step.
9668 * The mesh support of input parameter \a field is ignored here, it can be NULL.
9669 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9672 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9673 * A new profile is added only if no equal profile is missing.
9674 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9675 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
9676 * \param [in] mesh - the supporting mesh of \a field.
9677 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9678 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
9679 * \throw If either \a field or \a mesh or \a profile has an empty name.
9680 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9681 * \throw If the data array of \a field is not set.
9682 * \throw If the data array of \a this is already allocated but has different number of
9683 * components than \a field.
9684 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9685 * \sa setFieldNoProfileSBT()
9687 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9689 const DataArrayDouble *arr=0;
9691 arr=field->getArray();
9692 contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
9695 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
9697 _content=new MEDFileFieldMultiTSWithoutSDA;
9700 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
9701 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
9704 catch(INTERP_KERNEL::Exception& e)
9707 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
9708 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
9711 catch(INTERP_KERNEL::Exception& e)
9714 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9718 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
9720 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
9723 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9725 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9728 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
9730 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
9733 MEDFileFieldMultiTS *MEDFileFieldMultiTS::buildNewEmpty() const
9735 return MEDFileFieldMultiTS::New();
9738 //= MEDFileAnyTypeFieldMultiTSIterator
9740 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
9745 _nb_iter=fmts->getNumberOfTS();
9749 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
9753 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
9755 if(_iter_id<_nb_iter)
9757 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
9759 return fmts->getTimeStepAtPos(_iter_id++);
9767 //= MEDFileIntFieldMultiTS
9770 * Returns a new empty instance of MEDFileFieldMultiTS.
9771 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9772 * is to delete this field using decrRef() as it is no more needed.
9774 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
9776 return new MEDFileIntFieldMultiTS;
9780 * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
9781 * that has been read from a specified MED file.
9782 * \param [in] fileName - the name of the MED file to read.
9783 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9784 * is to delete this field using decrRef() as it is no more needed.
9785 * \throw If reading the file fails.
9787 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll)
9789 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9790 return New(fid,loadAll);
9793 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, bool loadAll)
9795 MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,loadAll,0));
9796 ret->contentNotNull();//to check that content type matches with \a this type.
9801 * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
9802 * that has been read from a specified MED file.
9803 * \param [in] fileName - the name of the MED file to read.
9804 * \param [in] fieldName - the name of the field to read.
9805 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9806 * is to delete this field using decrRef() as it is no more needed.
9807 * \throw If reading the file fails.
9808 * \throw If there is no field named \a fieldName in the file.
9810 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9812 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9813 return New(fid,fieldName,loadAll);
9816 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
9818 MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0));
9819 ret->contentNotNull();//to check that content type matches with \a this type.
9824 * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9825 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9827 * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
9828 * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9829 * \warning this is a shallow copy constructor
9830 * \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
9831 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9832 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9833 * is to delete this field using decrRef() as it is no more needed.
9835 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9837 return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
9840 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9842 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9843 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
9844 MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0,ent));
9845 ret->contentNotNull();//to check that content type matches with \a this type.
9850 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
9851 * following the given input policy.
9853 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9854 * By default (true) the globals are deeply copied.
9855 * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
9857 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const
9859 MCAuto<MEDFileFieldMultiTS> ret;
9860 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9863 const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
9865 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
9866 MCAuto<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
9867 ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc));
9870 ret=MEDFileFieldMultiTS::New();
9872 ret->deepCpyGlobs(*this);
9874 ret->shallowCpyGlobs(*this);
9878 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const
9880 return new MEDFileIntFieldMultiTS(*this);
9883 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9886 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9887 const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
9889 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
9893 * 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
9894 * method should be called (getFieldOnMeshAtLevel for example).
9895 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
9897 * \param [in] iteration - the iteration number of a required time step.
9898 * \param [in] order - the iteration order number of required time step.
9899 * \param [in] mesh - the mesh the field is lying on
9900 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
9901 * caller is to delete this field using decrRef() as it is no more needed.
9903 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
9905 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9906 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9908 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::field : mismatch of type of field expecting INT32 !");
9909 MCAuto<DataArray> arrOut;
9910 MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
9911 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arrOut));
9916 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
9917 * mesh entities of a given dimension of the first mesh in MED file.
9918 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9919 * \param [in] type - a spatial discretization of interest.
9920 * \param [in] iteration - the iteration number of a required time step.
9921 * \param [in] order - the iteration order number of required time step.
9922 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9923 * \param [in] renumPol - specifies how to permute values of the result field according to
9924 * the optional numbers of cells and nodes, if any. The valid values are
9925 * - 0 - do not permute.
9926 * - 1 - permute cells.
9927 * - 2 - permute nodes.
9928 * - 3 - permute cells and nodes.
9930 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9931 * caller is to delete this field using decrRef() as it is no more needed.
9932 * \throw If the MED file is not readable.
9933 * \throw If there is no mesh in the MED file.
9934 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9935 * \throw If no field values of the required parameters are available.
9937 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9939 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9940 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9942 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
9943 MCAuto<DataArray> arr;
9944 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase()));
9945 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9950 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
9951 * the top level cells of the first mesh in MED file.
9952 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9953 * \param [in] type - a spatial discretization of interest.
9954 * \param [in] iteration - the iteration number of a required time step.
9955 * \param [in] order - the iteration order number of required time step.
9956 * \param [in] renumPol - specifies how to permute values of the result field according to
9957 * the optional numbers of cells and nodes, if any. The valid values are
9958 * - 0 - do not permute.
9959 * - 1 - permute cells.
9960 * - 2 - permute nodes.
9961 * - 3 - permute cells and nodes.
9963 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9964 * caller is to delete this field using decrRef() as it is no more needed.
9965 * \throw If the MED file is not readable.
9966 * \throw If there is no mesh in the MED file.
9967 * \throw If no field values of the required parameters are available.
9969 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9971 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9972 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9974 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
9975 MCAuto<DataArray> arr;
9976 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase()));
9977 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9982 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
9984 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9985 * \param [in] type - a spatial discretization of interest.
9986 * \param [in] iteration - the iteration number of a required time step.
9987 * \param [in] order - the iteration order number of required time step.
9988 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9989 * \param [in] mesh - the supporting mesh.
9990 * \param [in] renumPol - specifies how to permute values of the result field according to
9991 * the optional numbers of cells and nodes, if any. The valid values are
9992 * - 0 - do not permute.
9993 * - 1 - permute cells.
9994 * - 2 - permute nodes.
9995 * - 3 - permute cells and nodes.
9997 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9998 * caller is to delete this field using decrRef() as it is no more needed.
9999 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
10000 * \throw If no field of \a this is lying on \a mesh.
10001 * \throw If no field values of the required parameters are available.
10003 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
10005 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10006 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10008 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10009 MCAuto<DataArray> arr;
10010 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase()));
10011 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10012 return ret2.retn();
10016 * Returns a new MEDCouplingFieldInt of given type, of a given time step, lying on a
10018 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10019 * \param [in] type - a spatial discretization of the new field.
10020 * \param [in] iteration - the iteration number of a required time step.
10021 * \param [in] order - the iteration order number of required time step.
10022 * \param [in] mesh - the supporting mesh.
10023 * \param [out] arrOut - the DataArrayInt containing values of field.
10024 * \param [in] renumPol - specifies how to permute values of the result field according to
10025 * the optional numbers of cells and nodes, if any. The valid values are
10026 * - 0 - do not permute.
10027 * - 1 - permute cells.
10028 * - 2 - permute nodes.
10029 * - 3 - permute cells and nodes.
10031 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10032 * caller is to delete this field using decrRef() as it is no more needed.
10033 * \throw If no field of \a this is lying on \a mesh.
10034 * \throw If no field values of the required parameters are available.
10036 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
10038 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10039 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10041 throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10042 MCAuto<DataArray> arr;
10043 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase()));
10044 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10045 return ret2.retn();
10049 * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
10050 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
10051 * This method is useful for MED2 file format when field on different mesh was autorized.
10053 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol) const
10055 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10056 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10058 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10059 MCAuto<DataArray> arr;
10060 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase()));
10061 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10062 return ret2.retn();
10066 * Returns values and a profile of the field of a given type, of a given time step,
10067 * lying on a given support.
10068 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10069 * \param [in] type - a spatial discretization of the field.
10070 * \param [in] iteration - the iteration number of a required time step.
10071 * \param [in] order - the iteration order number of required time step.
10072 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10073 * \param [in] mesh - the supporting mesh.
10074 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
10075 * field of interest lies on. If the field lies on all entities of the given
10076 * dimension, all ids in \a pfl are zero. The caller is to delete this array
10077 * using decrRef() as it is no more needed.
10078 * \param [in] glob - the global data storing profiles and localization.
10079 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
10080 * field. The caller is to delete this array using decrRef() as it is no more needed.
10081 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10082 * \throw If no field of \a this is lying on \a mesh.
10083 * \throw If no field values of the required parameters are available.
10085 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
10087 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
10088 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
10090 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
10091 MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
10092 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
10096 * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
10097 * \param [in] pos - a time step id.
10098 * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
10099 * delete this field using decrRef() as it is no more needed.
10100 * \throw If \a pos is not a valid time step id.
10102 MEDFileIntField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
10104 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
10107 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
10108 throw INTERP_KERNEL::Exception(oss.str());
10110 const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
10113 MCAuto<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
10114 ret->shallowCpyGlobs(*this);
10117 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
10118 throw INTERP_KERNEL::Exception(oss.str());
10122 * Adds a MEDCouplingFieldInt to \a this as another time step. The underlying mesh of
10123 * the given field is checked if its elements are sorted suitable for writing to MED file
10124 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
10125 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10126 * \param [in] field - the field to add to \a this.
10127 * \throw If the name of \a field is empty.
10128 * \throw If the data array of \a field is not set.
10129 * \throw If existing time steps have different name or number of components than \a field.
10130 * \throw If the underlying mesh of \a field has no name.
10131 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
10133 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldInt *field)
10135 MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
10136 contentNotNull()->appendFieldNoProfileSBT(field2,field->getArray(),*this);
10140 * Adds a MEDCouplingFieldDouble to \a this as another time step.
10141 * The mesh support of input parameter \a field is ignored here, it can be NULL.
10142 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
10145 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
10146 * A new profile is added only if no equal profile is missing.
10147 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10148 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
10149 * \param [in] arrOfVals - the values of the field \a field used.
10150 * \param [in] mesh - the supporting mesh of \a field.
10151 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
10152 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
10153 * \throw If either \a field or \a mesh or \a profile has an empty name.
10154 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10155 * \throw If the data array of \a field is not set.
10156 * \throw If the data array of \a this is already allocated but has different number of
10157 * components than \a field.
10158 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
10159 * \sa setFieldNoProfileSBT()
10161 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
10163 MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
10164 contentNotNull()->appendFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this);
10167 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const
10169 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10171 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
10172 const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10174 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 !");
10178 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull()
10180 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10182 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
10183 MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10185 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 !");
10189 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
10191 _content=new MEDFileIntFieldMultiTSWithoutSDA;
10194 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
10198 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
10199 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
10202 catch(INTERP_KERNEL::Exception& e)
10205 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10206 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
10209 catch(INTERP_KERNEL::Exception& e)
10212 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
10214 return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
10217 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::buildNewEmpty() const
10219 return MEDFileIntFieldMultiTS::New();
10224 MEDFileFields *MEDFileFields::New()
10226 return new MEDFileFields;
10229 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
10231 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10232 return New(fid,loadAll);
10235 MEDFileFields *MEDFileFields::NewWithDynGT(const std::string& fileName, const MEDFileStructureElements *se, bool loadAll)
10237 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10238 return NewWithDynGT(fid,se,loadAll);
10241 MEDFileFields *MEDFileFields::NewWithDynGT(med_idt fid, const MEDFileStructureElements *se, bool loadAll)
10244 throw INTERP_KERNEL::Exception("MEDFileFields::NewWithDynGT : null struct element pointer !");
10245 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> entities(MEDFileEntities::BuildFrom(*se));
10246 return new MEDFileFields(fid,loadAll,0,entities);
10249 MEDFileFields *MEDFileFields::New(med_idt fid, bool loadAll)
10251 return new MEDFileFields(fid,loadAll,0,0);
10254 MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
10256 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10257 return new MEDFileFields(fid,loadAll,ms,0);
10260 MEDFileFields *MEDFileFields::LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
10262 MEDFileUtilities::CheckFileForRead(fileName);
10263 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
10264 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10265 return new MEDFileFields(fid,loadAll,0,ent);
10268 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
10270 std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
10271 ret+=_fields.capacity()*sizeof(MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
10275 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
10277 std::vector<const BigMemoryObject *> ret;
10278 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10279 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
10283 MEDFileFields *MEDFileFields::deepCopy() const
10285 MCAuto<MEDFileFields> ret(shallowCpy());
10287 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10289 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10290 ret->_fields[i]=(*it)->deepCopy();
10292 ret->deepCpyGlobs(*this);
10296 MEDFileFields *MEDFileFields::shallowCpy() const
10298 return new MEDFileFields(*this);
10302 * 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
10303 * 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.
10304 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
10306 * \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.
10307 * \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.
10309 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10311 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
10313 std::set< std::pair<int,int> > s;
10314 bool firstShot=true;
10315 areThereSomeForgottenTS=false;
10316 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10318 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10320 std::vector< std::pair<int,int> > v=(*it)->getIterations();
10321 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
10323 { s=s1; firstShot=false; }
10326 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
10328 areThereSomeForgottenTS=true;
10332 std::vector< std::pair<int,int> > ret;
10333 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
10337 int MEDFileFields::getNumberOfFields() const
10339 return _fields.size();
10342 std::vector<std::string> MEDFileFields::getFieldsNames() const
10344 std::vector<std::string> ret(_fields.size());
10346 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10348 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
10351 ret[i]=f->getName();
10355 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
10356 throw INTERP_KERNEL::Exception(oss.str());
10362 std::vector<std::string> MEDFileFields::getMeshesNames() const
10364 std::vector<std::string> ret;
10365 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10367 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10369 ret.push_back(cur->getMeshName());
10374 std::string MEDFileFields::simpleRepr() const
10376 std::ostringstream oss;
10377 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
10382 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
10384 int nbOfFields(getNumberOfFields());
10385 std::string startLine(bkOffset,' ');
10386 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
10388 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10390 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10393 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
10397 oss << startLine << " - not defined !" << std::endl;
10401 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10403 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10404 std::string chapter(17,'0'+i);
10405 oss << startLine << chapter << std::endl;
10408 cur->simpleRepr(bkOffset+2,oss,i);
10412 oss << startLine << " - not defined !" << std::endl;
10414 oss << startLine << chapter << std::endl;
10416 simpleReprGlobs(oss);
10419 MEDFileFields::MEDFileFields()
10423 MEDFileFields::MEDFileFields(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10424 try:MEDFileFieldGlobsReal(fid)
10426 int nbFields(MEDnField(fid));
10427 _fields.resize(nbFields);
10428 med_field_type typcha;
10429 for(int i=0;i<nbFields;i++)
10431 std::vector<std::string> infos;
10432 std::string fieldName,dtunit;
10433 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,i,false,fieldName,typcha,infos,dtunit));
10438 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10443 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10448 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] !";
10449 throw INTERP_KERNEL::Exception(oss.str());
10453 loadAllGlobals(fid);
10455 catch(INTERP_KERNEL::Exception& e)
10460 void MEDFileFields::writeLL(med_idt fid) const
10463 writeGlobals(fid,*this);
10464 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10466 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
10469 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
10470 throw INTERP_KERNEL::Exception(oss.str());
10472 elt->writeLL(fid,*this);
10477 * This method alloc the arrays and load potentially huge arrays contained in this field.
10478 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
10479 * This method can be also called to refresh or reinit values from a file.
10481 * \throw If the fileName is not set or points to a non readable MED file.
10483 void MEDFileFields::loadArrays()
10485 if(getFileName().empty())
10486 throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
10487 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
10488 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10490 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10492 elt->loadBigArraysRecursively(fid,*elt);
10497 * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
10498 * But once data loaded once, this method does nothing.
10500 * \throw If the fileName is not set or points to a non readable MED file.
10501 * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
10503 void MEDFileFields::loadArraysIfNecessary()
10505 if(!getFileName().empty())
10507 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
10508 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10510 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10512 elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
10518 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
10519 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
10520 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
10522 * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
10524 void MEDFileFields::unloadArrays()
10526 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10528 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10530 elt->unloadArrays();
10535 * 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.
10536 * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
10537 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
10539 * \sa MEDFileFields::loadArraysIfNecessary
10541 void MEDFileFields::unloadArraysWithoutDataLoss()
10543 if(!getFileName().empty())
10547 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
10549 std::vector<std::string> ret;
10550 std::set<std::string> ret2;
10551 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10553 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
10554 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10555 if(ret2.find(*it2)==ret2.end())
10557 ret.push_back(*it2);
10564 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
10566 std::vector<std::string> ret;
10567 std::set<std::string> ret2;
10568 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10570 std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
10571 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10572 if(ret2.find(*it2)==ret2.end())
10574 ret.push_back(*it2);
10581 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
10583 std::vector<std::string> ret;
10584 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10586 std::vector<std::string> tmp((*it)->getPflsReallyUsedMulti2());
10587 ret.insert(ret.end(),tmp.begin(),tmp.end());
10592 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
10594 std::vector<std::string> ret;
10595 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10597 std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
10598 ret.insert(ret.end(),tmp.begin(),tmp.end());
10603 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10605 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10606 (*it)->changePflsRefsNamesGen2(mapOfModif);
10609 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10611 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10612 (*it)->changeLocsRefsNamesGen2(mapOfModif);
10615 void MEDFileFields::resize(int newSize)
10617 _fields.resize(newSize);
10620 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
10622 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
10626 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
10629 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
10630 _fields.push_back(field->getContent());
10631 appendGlobs(*field,1e-12);
10634 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
10637 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
10638 if(i>=(int)_fields.size())
10639 _fields.resize(i+1);
10640 _fields[i]=field->getContent();
10641 appendGlobs(*field,1e-12);
10644 void MEDFileFields::destroyFieldAtPos(int i)
10646 destroyFieldsAtPos(&i,&i+1);
10649 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
10651 std::vector<bool> b(_fields.size(),true);
10652 for(const int *i=startIds;i!=endIds;i++)
10654 if(*i<0 || *i>=(int)_fields.size())
10656 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10657 throw INTERP_KERNEL::Exception(oss.str());
10661 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10663 for(std::size_t i=0;i<_fields.size();i++)
10665 fields[j++]=_fields[i];
10669 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
10671 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
10672 int nbOfEntriesToKill(DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg));
10673 std::vector<bool> b(_fields.size(),true);
10675 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
10677 if(k<0 || k>=(int)_fields.size())
10679 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
10680 throw INTERP_KERNEL::Exception(oss.str());
10684 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10686 for(std::size_t i=0;i<_fields.size();i++)
10688 fields[j++]=_fields[i];
10692 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
10695 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10697 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10699 ret=cur->changeMeshNames(modifTab) || ret;
10705 * \param [in] meshName the name of the mesh that will be renumbered.
10706 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
10707 * This code corresponds to the distribution of types in the corresponding mesh.
10708 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
10709 * \param [in] renumO2N the old to new renumber array.
10710 * \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
10711 * field in \a this.
10713 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
10716 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10718 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
10721 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
10728 * Return an extraction of \a this using \a extractDef map to specify the extraction.
10729 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
10731 * \return A new object that the caller is responsible to deallocate.
10733 MEDFileFields *MEDFileFields::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
10736 throw INTERP_KERNEL::Exception("MEDFileFields::extractPart : input mesh is NULL !");
10737 MCAuto<MEDFileFields> fsOut(MEDFileFields::New());
10738 int nbFields(getNumberOfFields());
10739 for(int i=0;i<nbFields;i++)
10741 MCAuto<MEDFileAnyTypeFieldMultiTS> fmts(getFieldAtPos(i));
10744 std::ostringstream oss; oss << "MEDFileFields::extractPart : at pos #" << i << " field is null !";
10745 throw INTERP_KERNEL::Exception(oss.str());
10747 MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(fmts->extractPart(extractDef,mm));
10748 fsOut->pushField(fmtsOut);
10750 return fsOut.retn();
10753 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
10755 if(i<0 || i>=(int)_fields.size())
10757 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
10758 throw INTERP_KERNEL::Exception(oss.str());
10760 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
10763 MCAuto<MEDFileAnyTypeFieldMultiTS> ret;
10764 const MEDFileFieldMultiTSWithoutSDA *fmtsC(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts));
10765 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts));
10767 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
10769 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
10772 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
10773 throw INTERP_KERNEL::Exception(oss.str());
10775 ret->shallowCpyGlobs(*this);
10780 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
10781 * This method is accessible in python using __getitem__ with a list in input.
10782 * \return a new object that the caller should deal with.
10784 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
10786 MCAuto<MEDFileFields> ret=shallowCpy();
10787 std::size_t sz=std::distance(startIds,endIds);
10788 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
10790 for(const int *i=startIds;i!=endIds;i++,j++)
10792 if(*i<0 || *i>=(int)_fields.size())
10794 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10795 throw INTERP_KERNEL::Exception(oss.str());
10797 fields[j]=_fields[*i];
10799 ret->_fields=fields;
10803 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
10805 return getFieldAtPos(getPosFromFieldName(fieldName));
10809 * This method removes, if any, fields in \a this having no time steps.
10810 * 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.
10812 * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
10814 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
10816 std::vector<MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
10817 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10819 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10822 if(elt->getNumberOfTS()>0)
10823 newFields.push_back(*it);
10826 if(_fields.size()==newFields.size())
10833 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
10834 * This method can be seen as a filter applied on \a this, that returns an object containing
10835 * 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
10836 * shallow copied from \a this.
10838 * \param [in] meshName - the name of the mesh on w
10839 * \return a new object that the caller should deal with.
10841 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
10843 MCAuto<MEDFileFields> ret(MEDFileFields::New());
10844 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10846 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10849 if(cur->getMeshName()==meshName)
10852 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
10853 ret->_fields.push_back(cur2);
10856 ret->shallowCpyOnlyUsedGlobs(*this);
10861 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
10862 * Input time steps are specified using a pair of integer (iteration, order).
10863 * 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,
10864 * but for each multitimestep only the time steps in \a timeSteps are kept.
10865 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
10867 * The returned object points to shallow copy of elements in \a this.
10869 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
10870 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
10871 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10873 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10875 MCAuto<MEDFileFields> ret(MEDFileFields::New());
10876 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10878 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10881 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
10882 ret->_fields.push_back(elt);
10884 ret->shallowCpyOnlyUsedGlobs(*this);
10889 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
10891 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10893 MCAuto<MEDFileFields> ret=MEDFileFields::New();
10894 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10896 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10899 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
10900 if(elt->getNumberOfTS()!=0)
10901 ret->_fields.push_back(elt);
10903 ret->shallowCpyOnlyUsedGlobs(*this);
10907 MEDFileFieldsIterator *MEDFileFields::iterator()
10909 return new MEDFileFieldsIterator(this);
10912 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
10914 std::string tmp(fieldName);
10915 std::vector<std::string> poss;
10916 for(std::size_t i=0;i<_fields.size();i++)
10918 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f(_fields[i]);
10921 std::string fname(f->getName());
10925 poss.push_back(fname);
10928 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
10929 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
10931 throw INTERP_KERNEL::Exception(oss.str());
10934 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
10939 _nb_iter=fs->getNumberOfFields();
10943 MEDFileFieldsIterator::~MEDFileFieldsIterator()
10947 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
10949 if(_iter_id<_nb_iter)
10951 MEDFileFields *fs(_fs);
10953 return fs->getFieldAtPos(_iter_id++);