1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (CEA/DEN)
21 #include "MEDFileField.txx"
22 #include "MEDFileMesh.hxx"
23 #include "MEDLoaderBase.hxx"
24 #include "MEDLoaderTraits.hxx"
25 #include "MEDFileSafeCaller.txx"
26 #include "MEDFileFieldOverView.hxx"
28 #include "MEDCouplingFieldDouble.hxx"
29 #include "MEDCouplingFieldTemplate.hxx"
30 #include "MEDCouplingFieldDiscretization.hxx"
32 #include "InterpKernelAutoPtr.hxx"
33 #include "CellModel.hxx"
38 extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
39 extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
40 extern med_geometry_type typmainoeud[1];
41 extern med_geometry_type typmai3[34];
43 using namespace MEDCoupling;
45 template class MEDFileField1TSTemplateWithoutSDA<int>;
46 template class MEDFileField1TSTemplateWithoutSDA<double>;
48 const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64";
49 const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32";
51 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const std::string& locName)
53 return new MEDFileFieldLoc(fid,locName);
56 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, int id)
58 return new MEDFileFieldLoc(fid,id);
61 MEDFileFieldLoc *MEDFileFieldLoc::New(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
63 return new MEDFileFieldLoc(locName,geoType,refCoo,gsCoo,w);
66 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, const std::string& locName):_name(locName)
68 med_geometry_type geotype;
69 med_geometry_type sectiongeotype;
71 INTERP_KERNEL::AutoPtr<char> geointerpname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
72 INTERP_KERNEL::AutoPtr<char> sectionmeshname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
73 MEDlocalizationInfoByName(fid,locName.c_str(),&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
74 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
75 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
76 _nb_node_per_cell=cm.getNumberOfNodes();
77 _ref_coo.resize(_dim*_nb_node_per_cell);
78 _gs_coo.resize(_dim*_nb_gauss_pt);
79 _w.resize(_nb_gauss_pt);
80 MEDlocalizationRd(fid,locName.c_str(),MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
83 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id)
85 med_geometry_type geotype;
86 med_geometry_type sectiongeotype;
88 INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
89 INTERP_KERNEL::AutoPtr<char> geointerpname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
90 INTERP_KERNEL::AutoPtr<char> sectionmeshname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
91 MEDlocalizationInfo(fid,id+1,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
93 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
94 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
95 _nb_node_per_cell=cm.getNumberOfNodes();
96 _ref_coo.resize(_dim*_nb_node_per_cell);
97 _gs_coo.resize(_dim*_nb_gauss_pt);
98 _w.resize(_nb_gauss_pt);
99 MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
102 MEDFileFieldLoc::MEDFileFieldLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType,
103 const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w):_name(locName),_geo_type(geoType),_ref_coo(refCoo),_gs_coo(gsCoo),
106 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
107 _dim=cm.getDimension();
108 _nb_node_per_cell=cm.getNumberOfNodes();
109 _nb_gauss_pt=_w.size();
112 MEDFileFieldLoc *MEDFileFieldLoc::deepCopy() const
114 return new MEDFileFieldLoc(*this);
117 std::size_t MEDFileFieldLoc::getHeapMemorySizeWithoutChildren() const
119 return (_ref_coo.capacity()+_gs_coo.capacity()+_w.capacity())*sizeof(double)+_name.capacity();
122 std::vector<const BigMemoryObject *> MEDFileFieldLoc::getDirectChildrenWithNull() const
124 return std::vector<const BigMemoryObject *>();
127 void MEDFileFieldLoc::simpleRepr(std::ostream& oss) const
129 static const char OFF7[]="\n ";
130 oss << "\"" << _name << "\"" << OFF7;
131 oss << "GeoType=" << INTERP_KERNEL::CellModel::GetCellModel(_geo_type).getRepr() << OFF7;
132 oss << "Dimension=" << _dim << OFF7;
133 oss << "Number of Gauss points=" << _nb_gauss_pt << OFF7;
134 oss << "Number of nodes per cell=" << _nb_node_per_cell << OFF7;
135 oss << "RefCoords="; std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
136 oss << "Weights="; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
137 oss << "GaussPtsCoords="; std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," ")); oss << std::endl;
140 void MEDFileFieldLoc::setName(const std::string& name)
145 bool MEDFileFieldLoc::isEqual(const MEDFileFieldLoc& other, double eps) const
147 if(_name!=other._name)
151 if(_nb_gauss_pt!=other._nb_gauss_pt)
153 if(_nb_node_per_cell!=other._nb_node_per_cell)
155 if(_geo_type!=other._geo_type)
157 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_ref_coo,other._ref_coo,eps))
159 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_gs_coo,other._gs_coo,eps))
161 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_w,other._w,eps))
167 void MEDFileFieldLoc::writeLL(med_idt fid) const
169 MEDlocalizationWr(fid,_name.c_str(),typmai3[(int)_geo_type],_dim,&_ref_coo[0],MED_FULL_INTERLACE,_nb_gauss_pt,&_gs_coo[0],&_w[0],MED_NO_INTERPOLATION,MED_NO_MESH_SUPPORT);
172 std::string MEDFileFieldLoc::repr() const
174 std::ostringstream oss; oss.precision(15);
175 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
176 oss << "Localization \"" << _name << "\" :\n" << " - Geometric Type : " << cm.getRepr();
177 oss << "\n - Dimension : " << _dim << "\n - Number of gauss points : ";
178 oss << _nb_gauss_pt << "\n - Number of nodes in cell : " << _nb_node_per_cell;
179 oss << "\n - Ref coords are : ";
180 int sz=_ref_coo.size();
183 int nbOfTuples=sz/_dim;
184 for(int i=0;i<nbOfTuples;i++)
187 for(int j=0;j<_dim;j++)
188 { oss << _ref_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
193 std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," "));
194 oss << "\n - Gauss coords in reference element : ";
198 int nbOfTuples=sz/_dim;
199 for(int i=0;i<nbOfTuples;i++)
202 for(int j=0;j<_dim;j++)
203 { oss << _gs_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
208 std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," "));
209 oss << "\n - Weights of Gauss coords are : "; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," "));
213 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
215 _type=field->getTypeOfField();
221 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,offset,offset+nbOfCells,1);
222 _end=_start+nbOfCells;
228 MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
229 const int *arrPtr=arr->getConstPointer();
230 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,arrPtr[offset],arrPtr[offset+nbOfCells],1);
231 _end=_start+(arrPtr[offset+nbOfCells]-arrPtr[offset]);
237 const MEDCouplingFieldDiscretization *disc(field->getDiscretization());
238 const MEDCouplingGaussLocalization& gsLoc(field->getGaussLocalization(_loc_id));
239 const MEDCouplingFieldDiscretizationGauss *disc2(dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc));
241 throw INTERP_KERNEL::Exception("assignFieldNoProfile : invalid call to this method ! Internal Error !");
242 const DataArrayInt *dai(disc2->getArrayOfDiscIds());
243 MCAuto<DataArrayInt> dai2(disc2->getOffsetArr(field->getMesh()));
244 const int *dai2Ptr(dai2->getConstPointer());
245 int nbi(gsLoc.getWeights().size());
246 MCAuto<DataArrayInt> da2(dai->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1));
247 MCAuto<DataArrayInt> da3(da2->findIdsEqual(_loc_id));
248 const int *da3Ptr(da3->getConstPointer());
249 if(da3->getNumberOfTuples()!=nbOfCells)
250 {//profile : for gauss even in NoProfile !!!
251 std::ostringstream oss; oss << "Pfl_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
253 da3->setName(_profile.c_str());
254 glob.appendProfile(da3);
256 MCAuto<DataArrayInt> da4(DataArrayInt::New());
257 _nval=da3->getNbOfElems();
258 da4->alloc(_nval*nbi,1);
259 int *da4Ptr(da4->getPointer());
260 for(int i=0;i<_nval;i++)
262 int ref=dai2Ptr[offset+da3Ptr[i]];
263 for(int j=0;j<nbi;j++)
266 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
267 _localization=oss2.str();
268 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,da4);
269 _end=_start+_nval*nbi;
270 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
274 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile : not implemented yet for such discretization type of field !");
280 * Leaf method of field with profile assignement. This method is the most general one. No optimization is done here.
281 * \param [in] pflName input containing name of profile if any. 0 if no profile (except for GAUSS_PT where a no profile can hide a profile when splitted by loc_id).
282 * \param [in] multiTypePfl is the end user profile specified in high level API
283 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
284 * \param [in] locIds is the profile needed to be created for MED file format. It can be null if all cells of current geometric type are fetched in \a multiTypePfl.
285 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
286 * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
288 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arrr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
291 _type=field->getTypeOfField();
292 std::string pflName(multiTypePfl->getName());
293 std::ostringstream oss; oss << pflName;
297 { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType()); oss << "_" << cm.getRepr(); }
304 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : existing profile with empty name !");
305 if(_type!=ON_GAUSS_PT)
307 locIds->setName(oss.str());
308 glob.appendProfile(locIds);
317 _nval=idsInPfl->getNumberOfTuples();
318 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,0,arrr->getNumberOfTuples(),1);
324 _nval=idsInPfl->getNumberOfTuples();
325 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,idsInPfl);
331 MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
332 MCAuto<DataArrayInt> arr2=arr->deltaShiftIndex();
333 MCAuto<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->begin(),multiTypePfl->end());
334 arr3->computeOffsetsFull();
335 MCAuto<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
336 int trueNval=tmp->getNumberOfTuples();
337 _nval=idsInPfl->getNumberOfTuples();
338 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
339 _end=_start+trueNval;
344 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(field->getDiscretization());
346 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
347 const DataArrayInt *da1=disc2->getArrayOfDiscIds();
348 const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
349 MCAuto<DataArrayInt> da2=da1->selectByTupleId(idsInPfl->begin(),idsInPfl->end());
350 MCAuto<DataArrayInt> da3=da2->findIdsEqual(_loc_id);
351 MCAuto<DataArrayInt> da4=idsInPfl->selectByTupleId(da3->begin(),da3->end());
353 MCAuto<MEDCouplingMesh> mesh2=mesh->buildPart(multiTypePfl->begin(),multiTypePfl->end());
354 MCAuto<DataArrayInt> arr=disc2->getOffsetArr(mesh2);
356 MCAuto<DataArrayInt> tmp=DataArrayInt::New();
358 for(const int *pt=da4->begin();pt!=da4->end();pt++)
359 trueNval+=arr->getIJ(*pt+1,0)-arr->getIJ(*pt,0);
360 tmp->alloc(trueNval,1);
361 int *tmpPtr=tmp->getPointer();
362 for(const int *pt=da4->begin();pt!=da4->end();pt++)
363 for(int j=arr->getIJ(*pt,0);j<arr->getIJ(*pt+1,0);j++)
366 _nval=da4->getNumberOfTuples();
367 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
368 _end=_start+trueNval;
369 oss << "_loc_" << _loc_id;
372 MCAuto<DataArrayInt> da5=locIds->selectByTupleId(da3->begin(),da3->end());
373 da5->setName(oss.str());
374 glob.appendProfile(da5);
379 if(!da3->isIota(nbOfEltsInWholeMesh))
381 da3->setName(oss.str());
382 glob.appendProfile(da3);
386 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
387 _localization=oss2.str();
388 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
392 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for such discretization type of field !");
397 void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob)
400 _nval=arrr->getNumberOfTuples();
401 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,0,_nval,1);
406 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int profileIt, const PartDefinition *pd)
408 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt,pd);
411 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int locId)
413 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string());
416 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(const MEDFileFieldPerMeshPerTypePerDisc& other)
418 return new MEDFileFieldPerMeshPerTypePerDisc(other);
421 std::size_t MEDFileFieldPerMeshPerTypePerDisc::getHeapMemorySizeWithoutChildren() const
423 return _profile.capacity()+_localization.capacity()+sizeof(MEDFileFieldPerMeshPerTypePerDisc);
426 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypePerDisc::getDirectChildrenWithNull() const
428 std::vector<const BigMemoryObject *> ret(1);
429 ret[0]=(const PartDefinition*)_pd;
433 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCopy(MEDFileFieldPerMeshPerTypeCommon *father) const
435 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret=new MEDFileFieldPerMeshPerTypePerDisc(*this);
440 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField atype, int profileIt, const PartDefinition *pd)
441 try:_type(atype),_father(fath),_profile_it(profileIt),_pd(const_cast<PartDefinition *>(pd))
446 catch(INTERP_KERNEL::Exception& e)
451 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
455 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(const MEDFileFieldPerMeshPerTypePerDisc& other):RefCountObject(other),_type(other._type),_father(0),_start(other._start),_end(other._end),_nval(other._nval),_profile(other._profile),_localization(other._localization),_loc_id(other._loc_id),_profile_it(other._profile_it),_pd(other._pd),_tmp_work1(other._tmp_work1)
459 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(0),_start(-std::numeric_limits<int>::max()),_end(-std::numeric_limits<int>::max()),
460 _nval(-std::numeric_limits<int>::max()),_loc_id(-std::numeric_limits<int>::max())
464 void MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile(med_idt fid, const std::string& fieldName, int nbOfCompo, int iteration, int order, med_entity_type menti, med_geometry_type mgeoti, unsigned char *startFeedingPtr)
466 const PartDefinition *pd(_pd);
469 INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
471 med_int nbValsInFile(MEDfieldnValueWithProfileByName(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile.c_str(),MED_COMPACT_PFLMODE,&tmp1,locname,&nbi));
472 if(_end-_start!=nbValsInFile*nbi)
474 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : The number of tuples to read is " << nbValsInFile << "*" << nbi << " (nb integration points) ! But in data structure it values " << _end-_start << " is expected !";
475 throw INTERP_KERNEL::Exception(oss.str());
477 MEDFILESAFECALLERRD0(MEDfieldValueWithProfileRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,_profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,startFeedingPtr));
481 if(!_profile.empty())
482 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : not implemented !");
483 INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)),locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
485 int overallNval(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
486 const SlicePartDefinition *spd(dynamic_cast<const SlicePartDefinition *>(pd));
490 spd->getSlice(start,stop,step);
491 int nbOfEltsToLoad(DataArray::GetNumberOfItemGivenBES(start,stop,step,"MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile"));
492 med_filter filter=MED_FILTER_INIT;
493 MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
494 MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
495 /*start*/start+1,/*stride*/step,/*count*/1,/*blocksize*/nbOfEltsToLoad,
496 /*lastblocksize=useless because count=1*/0,&filter);
497 MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,startFeedingPtr));
498 MEDfilterClose(&filter);
501 const DataArrayPartDefinition *dpd(dynamic_cast<const DataArrayPartDefinition *>(pd));
504 dpd->checkConsistencyLight();
505 MCAuto<DataArrayInt> myIds(dpd->toDAI());
506 int a(myIds->getMinValueInArray()),b(myIds->getMaxValueInArray());
507 myIds=myIds->deepCopy();// WARNING deep copy here because _pd is modified by applyLin !!!
508 myIds->applyLin(1,-a);
509 int nbOfEltsToLoad(b-a+1);
510 med_filter filter=MED_FILTER_INIT;
511 {//TODO : manage int32 !
512 MCAuto<DataArrayDouble> tmp(DataArrayDouble::New());
513 tmp->alloc(nbOfEltsToLoad,nbOfCompo);
514 MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
515 MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
516 /*start*/a+1,/*stride*/1,/*count*/1,/*blocksize*/nbOfEltsToLoad,
517 /*lastblocksize=useless because count=1*/0,&filter);
518 MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,reinterpret_cast<unsigned char *>(tmp->getPointer())));
519 MCAuto<DataArrayDouble> feeder(DataArrayDouble::New());
520 feeder->useExternalArrayWithRWAccess(reinterpret_cast<double *>(startFeedingPtr),_nval,nbOfCompo);
521 feeder->setContigPartOfSelectedValues(0,tmp,myIds);
523 MEDfilterClose(&filter);
526 throw INTERP_KERNEL::Exception("Not implemented yet for not slices!");
530 const MEDFileFieldPerMeshPerTypeCommon *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
535 void MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
537 INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
538 INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
539 std::string fieldName(nasc.getName()),meshName(getMeshName());
540 int iteration(getIteration()),order(getOrder());
541 TypeOfField type(getType());
542 INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
544 med_geometry_type mgeoti;
545 med_entity_type menti(MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(type,geoType,mgeoti));
546 int zeNVal(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
547 _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
548 _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
549 const PartDefinition *pd(_pd);
556 if(!_profile.empty())
557 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively : profiles are not managed yet with part of def !");
558 _nval=pd->getNumberOfElems();
561 _end=start+_nval*nbi;
563 if(type==ON_CELLS && !_localization.empty())
565 if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
566 setType(ON_GAUSS_PT);
569 setType(ON_GAUSS_NE);
570 _localization.clear();
575 void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, const MEDFileFieldNameScope& nasc)
577 std::string fieldName(nasc.getName()),meshName(getMeshName());
578 int iteration(getIteration()),order(getOrder());
579 TypeOfField type(getType());
580 INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
581 med_geometry_type mgeoti;
582 med_entity_type menti(MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(type,geoType,mgeoti));
584 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !");
587 DataArray *arr(getOrCreateAndGetArray());//arr is not null due to the spec of getOrCreateAndGetArray
588 if(_start<0 || _start>=arr->getNumberOfTuples())
590 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << ") !";
591 throw INTERP_KERNEL::Exception(oss.str());
593 if(_end<0 || _end>arr->getNumberOfTuples())
595 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !";
596 throw INTERP_KERNEL::Exception(oss.str());
598 int nbOfCompo(arr->getNumberOfComponents());
599 DataArrayDouble *arrD(dynamic_cast<DataArrayDouble *>(arr));
602 double *startFeeding(arrD->getPointer()+_start*nbOfCompo);
603 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
606 DataArrayInt *arrI(dynamic_cast<DataArrayInt *>(arr));
609 int *startFeeding(arrI->getPointer()+_start*nbOfCompo);
610 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
613 throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
617 * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
619 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart)
621 int delta=_end-_start;
622 _start=newValueOfStart;
626 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
628 return _father->getIteration();
631 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
633 return _father->getOrder();
636 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
638 return _father->getTime();
641 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
643 return _father->getMeshName();
646 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
648 const char startLine[]=" ## ";
649 std::string startLine2(bkOffset,' ');
650 startLine2+=startLine;
651 MEDCouplingFieldDiscretization *tmp=MEDCouplingFieldDiscretization::New(_type);
652 oss << startLine2 << "Localization #" << id << "." << std::endl;
653 oss << startLine2 << " Type=" << tmp->getRepr() << "." << std::endl;
655 oss << startLine2 << " This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
656 oss << startLine2 << " This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
657 oss << startLine2 << " This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
660 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
665 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
667 return _father->getGeoType();
670 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
675 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
680 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
682 return _father->getNumberOfComponents();
685 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
690 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray()
692 return _father->getOrCreateAndGetArray();
695 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const
697 const MEDFileFieldPerMeshPerTypeCommon *fath=_father;
698 return fath->getOrCreateAndGetArray();
701 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
703 return _father->getInfo();
706 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
711 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const std::string& newPflName)
716 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
718 return _localization;
721 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const std::string& newLocName)
723 _localization=newLocName;
726 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
728 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
730 if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
732 _profile=(*it2).second;
738 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
740 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
742 if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
744 _localization=(*it2).second;
750 void MEDFileFieldPerMeshPerTypePerDisc::getFieldAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
754 dads.push_back(std::pair<int,int>(_start,_end));
755 geoTypes.push_back(getGeoType());
760 pfls.push_back(glob->getProfile(_profile.c_str()));
762 if(_localization.empty())
766 locs.push_back(glob->getLocalizationId(_localization.c_str()));
770 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
772 entries[startEntryId]=std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int> ,std::pair<int,int> >(std::pair<INTERP_KERNEL::NormalizedCellType,int>(getGeoType(),discId),std::pair<int,int>(_start,_end));
776 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
778 TypeOfField type=getType();
779 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
780 med_geometry_type mgeoti;
781 med_entity_type menti=MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(type,geoType,mgeoti);
782 const DataArray *arr=getOrCreateAndGetArray();
784 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
785 if(!arr->isAllocated())
786 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : the array to be written is not allocated !");
787 const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
788 const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
789 const unsigned char *locToWrite=0;
791 locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
793 locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
795 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
796 MEDFILESAFECALLERWR0(MEDfieldValueWithProfileWr,(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
797 MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
801 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const
806 dad.first=_start; dad.second=_end;
810 * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
811 * This code corresponds to the distribution of types in the corresponding mesh.
812 * \param [out] ptToFill memory zone where the output will be stored.
813 * \return the size of data pushed into output param \a ptToFill
815 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const
818 std::ostringstream oss;
819 std::size_t nbOfType=codeOfMesh.size()/3;
821 for(std::size_t i=0;i<nbOfType && found==-1;i++)
822 if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
826 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
827 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
828 throw INTERP_KERNEL::Exception(oss.str());
833 if(_nval!=codeOfMesh[3*found+1])
835 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
836 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
837 oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
838 throw INTERP_KERNEL::Exception(oss.str());
840 for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
845 const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
846 if(pfl->getNumberOfTuples()!=_nval)
848 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
849 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
851 oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
852 throw INTERP_KERNEL::Exception(oss.str());
854 int offset2=codeOfMesh[3*found+2];
855 for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
857 if(*pflId<codeOfMesh[3*found+1])
858 *work++=offset2+*pflId;
864 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const
866 for(int i=_start;i<_end;i++)
871 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId)
882 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
886 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
889 std::map<std::pair<std::string,TypeOfField>,int> m;
890 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
891 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
892 if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
893 m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
895 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
896 ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
901 * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
903 * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
904 * \param [in] entriesOnSameDisc some entries **on same localization** if not the result can be invalid. The _start and _end on them are relative to \a arr parameter.
905 * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
906 * \param [in] newCode one of the input parameter to explicit the new geo type dispatch (in classical format same than those asked by MEDFileFields::renumberEntitiesLyingOnMesh)
907 * \param [in,out] glob if necessary by the method, new profiles can be added to it
908 * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
909 * \param [out] result All new entries will be appended on it.
910 * \return false if the configuration of renumbering leads to an unnecessary resplit of input \a entriesOnSameDisc. If not true is returned (the most general case !)
912 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
913 const DataArrayInt *explicitIdsInMesh,
914 const std::vector<int>& newCode,
915 MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
916 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >& result)
918 if(entriesOnSameDisc.empty())
920 TypeOfField type=entriesOnSameDisc[0]->getType();
921 int szEntities=0,szTuples=0;
922 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
923 { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
924 int nbi=szTuples/szEntities;
925 if(szTuples%szEntities!=0)
926 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
927 MCAuto<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
928 MCAuto<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
929 std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
930 std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
931 std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
932 std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
933 MCAuto<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
935 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
937 int startOfEltIdOfChunk=(*it)->_start;
938 MCAuto<DataArrayInt> newEltIds=explicitIdsInMesh->subArray(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
939 MCAuto<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
940 MCAuto<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
942 MCAuto<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
943 newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
945 newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
946 newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
948 MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
949 MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
950 MCAuto<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
951 MCAuto<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
953 MCAuto<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
955 MCAuto<DataArrayDouble> arrPart=arr->subArray(offset,offset+szTuples);
956 arrPart->renumberInPlace(renumTupleIds->begin());
957 arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
959 const int *idIt=diffVals->begin();
960 std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
962 for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
964 MCAuto<DataArrayInt> ids=newGeoTypesEltIdsAllGather->findIdsEqual(*idIt);
965 MCAuto<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
966 int nbEntityElts=subIds->getNumberOfTuples();
968 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
969 NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIota(newCode[3*(*idIt)+1]),nbi,
973 result.push_back(eltToAdd);
974 offset2+=nbEntityElts*nbi;
976 ret=ret || li.empty();
981 * \param [in] typeF type of field of new chunk
982 * \param [in] geoType the geometric type of the chunk
983 * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
984 * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
985 * \param [in] nbi number of integration points
986 * \param [in] offset The offset in the **global array of data**.
987 * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
988 * to the new chunk to create.
989 * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
990 * \param [out] notInExisting If false the return newly allocated entry is not coming from \a entriesOnSameDisc. If true the output comes from copy of \a entriesOnSameDisc
991 * and corresponding entry erased from \a entriesOnSameDisc.
992 * \return a newly allocated chunk
994 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
995 bool isPfl, int nbi, int offset,
996 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
997 MEDFileFieldGlobsReal& glob,
1000 int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
1001 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
1002 for(;it!=entriesOnSameDisc.end();it++)
1004 if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
1008 if((*it)->_profile.empty())
1011 if(!(*it)->_profile.empty())
1013 const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
1014 if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
1020 if(it==entriesOnSameDisc.end())
1023 MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
1025 ret->_loc_id=(int)geoType;
1026 ret->_nval=nbMeshEntities;
1028 ret->_end=ret->_start+ret->_nval*nbi;
1031 idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
1032 glob.appendProfile(idsOfMeshElt);
1033 ret->_profile=idsOfMeshElt->getName();
1035 //tony treatment of localization
1040 notInExisting=false;
1041 MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1042 ret->_loc_id=(int)geoType;
1043 ret->setNewStart(offset);
1044 entriesOnSameDisc.erase(it);
1050 ////////////////////////////////////
1052 MEDFileFieldPerMeshPerTypeCommon::~MEDFileFieldPerMeshPerTypeCommon()
1056 void MEDFileFieldPerMeshPerTypeCommon::setFather(MEDFileFieldPerMesh *father)
1061 void MEDFileFieldPerMeshPerTypeCommon::deepCopyElements()
1064 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1066 if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
1067 _field_pm_pt_pd[i]=(*it)->deepCopy(this);
1071 std::size_t MEDFileFieldPerMeshPerTypeCommon::getHeapMemorySizeWithoutChildren() const
1073 return _field_pm_pt_pd.capacity()*sizeof(MCAuto<MEDFileFieldPerMeshPerTypePerDisc>);
1076 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypeCommon::getDirectChildrenWithNull() const
1078 std::vector<const BigMemoryObject *> ret;
1079 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1080 ret.push_back((const MEDFileFieldPerMeshPerTypePerDisc *)*it);
1084 void MEDFileFieldPerMeshPerTypeCommon::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1086 std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
1087 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1088 _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1092 * This method is the most general one. No optimization is done here.
1093 * \param [in] multiTypePfl is the end user profile specified in high level API
1094 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1095 * \param [in] locIds is the profile needed to be created for MED file format. It can be null if all cells of current geometric type are fetched in \a multiTypePfl.
1096 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1097 * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1098 * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
1100 void MEDFileFieldPerMeshPerTypeCommon::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1102 std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1103 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1104 _field_pm_pt_pd[*it]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1107 void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1109 _field_pm_pt_pd.resize(1);
1110 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1111 _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1114 void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1116 MCAuto<DataArrayInt> pfl2=pfl->deepCopy();
1117 if(!arr || !arr->isAllocated())
1118 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile : input array is null, or not allocated !");
1119 _field_pm_pt_pd.resize(1);
1120 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1121 _field_pm_pt_pd[0]->assignFieldProfile(true,start,pfl,pfl2,pfl2,-1,field,arr,0,glob,nasc);//mesh is not requested so 0 is send.
1124 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1126 TypeOfField type=field->getTypeOfField();
1127 if(type!=ON_GAUSS_PT)
1129 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1130 int sz=_field_pm_pt_pd.size();
1132 for(int j=0;j<sz && !found;j++)
1134 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1136 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1142 _field_pm_pt_pd.resize(sz+1);
1143 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1145 std::vector<int> ret(1,(int)sz);
1150 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1151 int sz2=ret2.size();
1152 std::vector<int> ret3(sz2);
1154 for(int i=0;i<sz2;i++)
1156 int sz=_field_pm_pt_pd.size();
1157 int locIdToFind=ret2[i];
1159 for(int j=0;j<sz && !found;j++)
1161 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1163 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1170 _field_pm_pt_pd.resize(sz+1);
1171 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1179 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1181 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1182 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1184 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1185 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1187 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1188 MCAuto<DataArrayInt> da2=da->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1);
1189 MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1190 if(retTmp->presenceOfValue(-1))
1191 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1192 std::vector<int> ret(retTmp->begin(),retTmp->end());
1196 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1198 TypeOfField type=field->getTypeOfField();
1199 if(type!=ON_GAUSS_PT)
1201 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1202 int sz=_field_pm_pt_pd.size();
1204 for(int j=0;j<sz && !found;j++)
1206 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1208 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1214 _field_pm_pt_pd.resize(sz+1);
1215 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1217 std::vector<int> ret(1,0);
1222 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1223 int sz2=ret2.size();
1224 std::vector<int> ret3(sz2);
1226 for(int i=0;i<sz2;i++)
1228 int sz=_field_pm_pt_pd.size();
1229 int locIdToFind=ret2[i];
1231 for(int j=0;j<sz && !found;j++)
1233 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1235 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1242 _field_pm_pt_pd.resize(sz+1);
1243 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1251 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1253 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1254 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1256 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1257 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1259 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1260 MCAuto<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1261 MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1262 if(retTmp->presenceOfValue(-1))
1263 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1264 std::vector<int> ret(retTmp->begin(),retTmp->end());
1268 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerTypeCommon::getFather() const
1273 bool MEDFileFieldPerMeshPerTypeCommon::isUniqueLevel(int& dim) const
1275 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
1276 int curDim((int)cm.getDimension());
1277 if(dim!=std::numeric_limits<int>::max())
1287 void MEDFileFieldPerMeshPerTypeCommon::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1289 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1291 (*it)->fillTypesOfFieldAvailable(types);
1295 void MEDFileFieldPerMeshPerTypeCommon::fillFieldSplitedByType(std::vector< std::pair<int,int> >& dads, std::vector<TypeOfField>& types, std::vector<std::string>& pfls, std::vector<std::string>& locs) const
1297 int sz=_field_pm_pt_pd.size();
1298 dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1299 for(int i=0;i<sz;i++)
1301 _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1305 int MEDFileFieldPerMeshPerTypeCommon::getIteration() const
1307 return _father->getIteration();
1310 int MEDFileFieldPerMeshPerTypeCommon::getOrder() const
1312 return _father->getOrder();
1315 double MEDFileFieldPerMeshPerTypeCommon::getTime() const
1317 return _father->getTime();
1320 std::string MEDFileFieldPerMeshPerTypeCommon::getMeshName() const
1322 return _father->getMeshName();
1325 void MEDFileFieldPerMeshPerTypeCommon::getSizes(int& globalSz, int& nbOfEntries) const
1327 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1329 globalSz+=(*it)->getNumberOfTuples();
1331 nbOfEntries+=(int)_field_pm_pt_pd.size();
1334 int MEDFileFieldPerMeshPerTypeCommon::getNumberOfComponents() const
1336 return _father->getNumberOfComponents();
1339 bool MEDFileFieldPerMeshPerTypeCommon::presenceOfMultiDiscPerGeoType() const
1342 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1344 const MEDFileFieldPerMeshPerTypePerDisc *fmtd(*it);
1351 DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray()
1353 return _father->getOrCreateAndGetArray();
1356 const DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray() const
1358 const MEDFileFieldPerMesh *fath=_father;
1359 return fath->getOrCreateAndGetArray();
1362 const std::vector<std::string>& MEDFileFieldPerMeshPerTypeCommon::getInfo() const
1364 return _father->getInfo();
1367 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsed() const
1369 std::vector<std::string> ret;
1370 std::set<std::string> ret2;
1371 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1373 std::string tmp=(*it1)->getProfile();
1375 if(ret2.find(tmp)==ret2.end())
1384 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsed() const
1386 std::vector<std::string> ret;
1387 std::set<std::string> ret2;
1388 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1390 std::string tmp=(*it1)->getLocalization();
1391 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1392 if(ret2.find(tmp)==ret2.end())
1401 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsedMulti() const
1403 std::vector<std::string> ret;
1404 std::set<std::string> ret2;
1405 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1407 std::string tmp=(*it1)->getProfile();
1414 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsedMulti() const
1416 std::vector<std::string> ret;
1417 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1419 std::string tmp=(*it1)->getLocalization();
1420 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1426 void MEDFileFieldPerMeshPerTypeCommon::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1428 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1429 (*it1)->changePflsRefsNamesGen(mapOfModif);
1432 void MEDFileFieldPerMeshPerTypeCommon::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1434 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1435 (*it1)->changeLocsRefsNamesGen(mapOfModif);
1438 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId)
1440 if(_field_pm_pt_pd.empty())
1442 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << getGeoTypeRepr() << "\" !";
1443 throw INTERP_KERNEL::Exception(oss.str());
1445 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1446 return _field_pm_pt_pd[locId];
1447 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
1448 oss2 << ") for geometric type \"" << getGeoTypeRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1449 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1450 return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1453 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId) const
1455 if(_field_pm_pt_pd.empty())
1457 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << getGeoTypeRepr() << "\" !";
1458 throw INTERP_KERNEL::Exception(oss.str());
1460 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1461 return _field_pm_pt_pd[locId];
1462 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
1463 oss2 << ") for geometric type \"" << getGeoTypeRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1464 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1465 return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1468 void MEDFileFieldPerMeshPerTypeCommon::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1471 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1473 (*it)->fillValues(i,startEntryId,entries);
1477 void MEDFileFieldPerMeshPerTypeCommon::setLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
1479 _field_pm_pt_pd=leaves;
1480 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1481 (*it)->setFather(this);
1485 * \param [in,out] globalNum a global numbering counter for the renumbering.
1486 * \param [out] its - list of pair (start,stop) kept
1487 * \return bool - false if the type of field \a tof is not contained in \a this.
1489 bool MEDFileFieldPerMeshPerTypeCommon::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
1492 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1493 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1494 if((*it)->getType()==tof)
1496 newPmPtPd.push_back(*it);
1497 std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1498 (*it)->setNewStart(globalNum);
1499 globalNum=(*it)->getEnd();
1500 its.push_back(bgEnd);
1504 _field_pm_pt_pd=newPmPtPd;
1509 * \param [in,out] globalNum a global numbering counter for the renumbering.
1510 * \param [out] its - list of pair (start,stop) kept
1511 * \return bool - false if the type of field \a tof is not contained in \a this.
1513 bool MEDFileFieldPerMeshPerTypeCommon::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
1515 if(_field_pm_pt_pd.size()<=idOfDisc)
1517 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt(_field_pm_pt_pd[idOfDisc]);
1518 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd(1,elt);
1519 std::pair<int,int> bgEnd; bgEnd.first=_field_pm_pt_pd[idOfDisc]->getStart(); bgEnd.second=_field_pm_pt_pd[idOfDisc]->getEnd();
1520 elt->setNewStart(globalNum);
1521 globalNum=elt->getEnd();
1522 its.push_back(bgEnd);
1523 _field_pm_pt_pd=newPmPtPd;
1527 void MEDFileFieldPerMeshPerTypeCommon::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
1529 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1530 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1533 void MEDFileFieldPerMeshPerTypeCommon::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1535 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1536 (*it)->loadBigArray(fid,nasc);
1539 void MEDFileFieldPerMeshPerTypeCommon::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1541 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1543 (*it)->copyOptionsFrom(*this);
1544 (*it)->writeLL(fid,nasc);
1548 med_entity_type MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1553 medfGeoType=typmai3[(int)ikGeoType];
1556 medfGeoType=MED_NONE;
1559 medfGeoType=typmai3[(int)ikGeoType];
1560 return MED_NODE_ELEMENT;
1562 medfGeoType=typmai3[(int)ikGeoType];
1565 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1567 return MED_UNDEF_ENTITY_TYPE;
1570 //////////////////////////////////////////////////
1572 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd)
1574 return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc,pd);
1577 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType)
1579 return new MEDFileFieldPerMeshPerType(fath,geoType);
1582 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCopy(MEDFileFieldPerMesh *father) const
1584 MCAuto<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
1585 ret->setFather(father);
1586 ret->deepCopyElements();
1590 void MEDFileFieldPerMeshPerType::getFieldAtLevel(int meshDim, TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
1592 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1594 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1595 if(meshDim!=(int)cm.getDimension())
1598 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1599 (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1602 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1607 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1609 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1610 int curDim((int)cm.getDimension());
1611 dim=std::max(dim,curDim);
1614 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1616 const char startLine[]=" ## ";
1617 std::string startLine2(bkOffset,' ');
1618 std::string startLine3(startLine2);
1619 startLine3+=startLine;
1620 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1622 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1623 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1626 oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1627 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1629 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1631 const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1633 cur->simpleRepr(bkOffset,oss,i);
1636 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1641 std::string MEDFileFieldPerMeshPerType::getGeoTypeRepr() const
1643 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1644 return std::string(cm.getRepr());
1647 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *father, INTERP_KERNEL::NormalizedCellType gt):MEDFileFieldPerMeshPerTypeCommon(father),_geo_type(gt)
1651 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):MEDFileFieldPerMeshPerTypeCommon(fath),_geo_type(geoType)
1653 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1654 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1655 med_geometry_type mgeoti;
1656 med_entity_type menti(ConvertIntoMEDFileType(type,geoType,mgeoti));
1657 int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName));
1658 _field_pm_pt_pd.resize(nbProfiles);
1659 for(int i=0;i<nbProfiles;i++)
1661 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i,pd);
1665 int nbProfiles2(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName));
1666 for(int i=0;i<nbProfiles2;i++)
1667 _field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i,pd));
1671 MCAuto<MEDFileFieldPerMeshPerType> MEDFileFieldPerMeshPerType::Aggregate(int &start, const std::vector<std::pair<int,const MEDFileFieldPerMeshPerType *> >& pms, const std::vector< std::vector< std::pair<int,int> > >& dts, INTERP_KERNEL::NormalizedCellType gt, MEDFileFieldPerMesh *father, std::vector<std::pair< int, std::pair<int,int> > >& extractInfo)
1673 MCAuto<MEDFileFieldPerMeshPerType> ret(MEDFileFieldPerMeshPerType::New(father,gt));
1674 std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > > m;
1675 for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerType *> >::const_iterator it=pms.begin();it!=pms.end();it++)
1677 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it2=(*it).second->_field_pm_pt_pd.begin();it2!=(*it).second->_field_pm_pt_pd.end();it2++)
1678 m[(*it2)->getType()].push_back(std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * >((*it).first,*it2));
1680 for(std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > >::const_iterator it=m.begin();it!=m.end();it++)
1682 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> agg(MEDFileFieldPerMeshPerTypePerDisc::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
1683 ret->_field_pm_pt_pd.push_back(agg);
1688 //////////////////////////////////////////////////
1690 MEDFileFieldPerMeshPerTypeDyn *MEDFileFieldPerMeshPerTypeDyn::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileEntities *entities, int idGT, const MEDFileFieldNameScope& nasc)
1693 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeDyn::NewOnRead : null pointer !");
1694 const MEDFileAllStaticEntitiesPlusDyn *entities2(dynamic_cast<const MEDFileAllStaticEntitiesPlusDyn *>(entities));
1696 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeDyn::NewOnRead : invalid type of entities !");
1697 const MEDFileStructureElement *se(entities2->getWithGT(idGT));
1698 return new MEDFileFieldPerMeshPerTypeDyn(fid,fath,se,nasc);
1701 MEDFileFieldPerMeshPerTypeDyn::MEDFileFieldPerMeshPerTypeDyn(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileStructureElement *se, const MEDFileFieldNameScope& nasc):MEDFileFieldPerMeshPerTypeCommon(fath)
1704 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1705 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1706 int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,_se->getDynGT(),pflName,locName));
1707 _field_pm_pt_pd.resize(nbProfiles);
1708 for(int i=0;i<nbProfiles;i++)
1710 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,_se->getEntity(),i,NULL);
1714 int MEDFileFieldPerMeshPerTypeDyn::getDynGT() const
1716 return _se->getDynGT();
1719 void MEDFileFieldPerMeshPerTypeDyn::getDimension(int& dim) const
1721 throw INTERP_KERNEL::Exception("not implemented yet !");
1724 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypeDyn::getGeoType() const
1726 throw INTERP_KERNEL::Exception("not implemented yet !");
1729 void MEDFileFieldPerMeshPerTypeDyn::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1731 const char startLine[]=" ## ";
1732 std::string startLine2(bkOffset,' ');
1733 std::string startLine3(startLine2);
1734 startLine3+=startLine;
1735 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry type " << getDynGT() << "." << std::endl;
1736 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1738 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1740 const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1742 cur->simpleRepr(bkOffset,oss,i);
1745 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1750 std::string MEDFileFieldPerMeshPerTypeDyn::getGeoTypeRepr() const
1752 throw INTERP_KERNEL::Exception("not implemented yet !");
1755 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerTypeDyn::deepCopy(MEDFileFieldPerMesh *father) const
1757 throw INTERP_KERNEL::Exception("not implemented yet !");
1760 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
1762 throw INTERP_KERNEL::Exception("not implemented yet !");
1765 //////////////////////////////////////////////////
1767 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const MEDFileEntities *entities)
1769 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm,entities);
1772 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1774 return new MEDFileFieldPerMesh(fath,mesh);
1777 std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
1779 return _mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MCAuto< MEDFileFieldPerMeshPerType >);
1782 std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildrenWithNull() const
1784 std::vector<const BigMemoryObject *> ret;
1785 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1790 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCopy(MEDFileAnyTypeField1TSWithoutSDA *father) const
1792 MCAuto< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1793 ret->_father=father;
1795 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1797 if((*it).isNotNull())
1798 ret->_field_pm_pt[i]=(*it)->deepCopy((MEDFileFieldPerMesh *)(ret));
1803 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1805 std::string startLine(bkOffset,' ');
1806 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1807 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1809 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1811 if((*it).isNotNull())
1812 (*it)->simpleRepr(bkOffset,oss,i);
1815 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1820 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh)
1822 _mesh_name=mesh->getName();
1823 mesh->getTime(_mesh_iteration,_mesh_order);
1826 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1828 int nbOfTypes=code.size()/3;
1830 for(int i=0;i<nbOfTypes;i++)
1832 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1833 int nbOfCells=code[3*i+1];
1834 int pos=addNewEntryIfNecessary(type);
1835 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1841 * This method is the most general one. No optimization is done here.
1842 * \param [in] multiTypePfl is the end user profile specified in high level API
1843 * \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].
1844 * \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.
1845 * \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.
1846 * \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.
1847 * \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.
1849 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)
1851 int nbOfTypes(code.size()/3);
1852 for(int i=0;i<nbOfTypes;i++)
1854 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1855 int pos=addNewEntryIfNecessary(type);
1856 DataArrayInt *pfl=0;
1858 pfl=idsPerType[code[3*i+2]];
1859 int nbOfTupes2=code2.size()/3;
1861 for(;found<nbOfTupes2;found++)
1862 if(code[3*i]==code2[3*found])
1864 if(found==nbOfTupes2)
1865 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1866 _field_pm_pt[pos]->assignFieldProfile(nbOfTypes==1,start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1870 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1872 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1873 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1876 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1878 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1879 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1882 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
1884 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1885 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1888 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1890 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1891 (*it)->loadBigArraysRecursively(fid,nasc);
1894 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1896 int nbOfTypes=_field_pm_pt.size();
1897 for(int i=0;i<nbOfTypes;i++)
1899 _field_pm_pt[i]->copyOptionsFrom(*this);
1900 _field_pm_pt[i]->writeLL(fid,nasc);
1904 void MEDFileFieldPerMesh::getDimension(int& dim) const
1906 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1907 (*it)->getDimension(dim);
1910 bool MEDFileFieldPerMesh::isUniqueLevel(int& dim) const
1912 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1913 if(!(*it)->isUniqueLevel(dim))
1918 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1920 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1921 (*it)->fillTypesOfFieldAvailable(types);
1924 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
1926 int sz=_field_pm_pt.size();
1927 std::vector< std::vector<std::pair<int,int> > > ret(sz);
1928 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1929 for(int i=0;i<sz;i++)
1931 types[i]=_field_pm_pt[i]->getGeoType();
1932 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1937 double MEDFileFieldPerMesh::getTime() const
1940 return _father->getTime(tmp1,tmp2);
1943 int MEDFileFieldPerMesh::getIteration() const
1945 return _father->getIteration();
1948 int MEDFileFieldPerMesh::getOrder() const
1950 return _father->getOrder();
1953 int MEDFileFieldPerMesh::getNumberOfComponents() const
1955 return _father->getNumberOfComponents();
1958 bool MEDFileFieldPerMesh::presenceOfMultiDiscPerGeoType() const
1960 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1964 if((*it)->presenceOfMultiDiscPerGeoType())
1970 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
1973 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1974 return _father->getOrCreateAndGetArray();
1977 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
1980 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1981 return _father->getOrCreateAndGetArray();
1984 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1986 return _father->getInfo();
1990 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
1991 * 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.
1992 * It returns 2 output vectors :
1993 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
1994 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
1995 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
1997 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)
1999 int notNullPflsSz=0;
2000 int nbOfArrs=geoTypes.size();
2001 for(int i=0;i<nbOfArrs;i++)
2004 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
2005 int nbOfDiffGeoTypes=geoTypes3.size();
2006 code.resize(3*nbOfDiffGeoTypes);
2007 notNullPfls.resize(notNullPflsSz);
2010 for(int i=0;i<nbOfDiffGeoTypes;i++)
2013 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
2014 std::vector<const DataArrayInt *> notNullTmp;
2016 notNullTmp.push_back(pfls[j]);
2018 for(;j<nbOfArrs;j++)
2019 if(geoTypes[j]==refType)
2022 notNullTmp.push_back(pfls[j]);
2026 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
2027 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
2028 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
2029 code[3*i]=(int)refType;
2030 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
2031 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
2032 if(notNullTmp.empty())
2036 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
2037 code[3*i+2]=notNullPflsSz++;
2043 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
2045 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)
2049 for(int i=0;i<sz;i++)
2053 if(type!=ON_GAUSS_NE)
2054 ret+=dads[i].second-dads[i].first;
2057 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
2058 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
2063 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
2064 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
2070 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
2072 std::vector<std::string> ret;
2073 std::set<std::string> ret2;
2074 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2076 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
2077 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
2078 if(ret2.find(*it2)==ret2.end())
2080 ret.push_back(*it2);
2087 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
2089 std::vector<std::string> ret;
2090 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2092 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
2093 ret.insert(ret.end(),tmp.begin(),tmp.end());
2098 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
2100 std::vector<std::string> ret;
2101 std::set<std::string> ret2;
2102 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2104 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
2105 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
2106 if(ret2.find(*it2)==ret2.end())
2108 ret.push_back(*it2);
2115 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
2117 std::vector<std::string> ret;
2118 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2120 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
2121 ret.insert(ret.end(),tmp.begin(),tmp.end());
2126 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
2128 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
2130 if((*it).first==_mesh_name)
2132 _mesh_name=(*it).second;
2139 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
2140 MEDFileFieldGlobsReal& glob)
2142 if(_mesh_name!=meshName)
2144 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
2145 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
2146 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
2147 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
2148 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
2149 getUndergroundDataArrayExt(entries);
2150 DataArray *arr0(getOrCreateAndGetArray());//tony
2152 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
2153 DataArrayDouble *arr(dynamic_cast<DataArrayDouble *>(arr0));//tony
2155 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
2158 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
2159 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
2161 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
2163 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2164 sz+=(*it).second.second-(*it).second.first;
2167 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2169 MCAuto<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
2170 ////////////////////
2171 MCAuto<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
2172 int *workI2=explicitIdsOldInMesh->getPointer();
2173 int sz1=0,sz2=0,sid=1;
2174 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
2175 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
2176 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
2178 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
2179 MCAuto<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
2180 int *workI=explicitIdsOldInArr->getPointer();
2181 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
2183 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
2184 (*itL2)->setLocId(sz2);
2185 (*itL2)->_tmp_work1=(*itL2)->getStart();
2186 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
2188 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
2190 explicitIdsOldInMesh->reAlloc(sz2);
2191 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
2192 ////////////////////
2193 MCAuto<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
2194 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
2195 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
2196 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
2198 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
2199 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
2200 otherEntriesNew.back()->setLocId((*it)->getGeoType());
2202 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
2203 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
2204 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
2206 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
2207 int newStart=elt->getLocId();
2208 elt->setLocId((*it)->getGeoType());
2209 elt->setNewStart(newStart);
2210 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
2211 entriesKeptNew.push_back(elt);
2212 entriesKeptNew2.push_back(elt);
2214 MCAuto<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
2215 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
2216 MCAuto<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
2217 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
2219 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
2222 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
2224 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
2225 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
2227 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
2228 glob,arr2,otherEntriesNew) || ret;
2232 // Assign new dispatching
2233 assignNewLeaves(otherEntriesNew);
2234 arr->deepCopyFrom(*arr2);
2239 * \param [in,out] globalNum a global numbering counter for the renumbering.
2240 * \param [out] its - list of pair (start,stop) kept
2242 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
2244 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > ret;
2245 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2247 std::vector< std::pair<int,int> > its2;
2248 if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
2251 its.insert(its.end(),its2.begin(),its2.end());
2258 * \param [in,out] globalNum a global numbering counter for the renumbering.
2259 * \param [out] its - list of pair (start,stop) kept
2261 void MEDFileFieldPerMesh::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
2263 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > ret;
2264 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2266 std::vector< std::pair<int,int> > its2;
2267 if((*it)->keepOnlyGaussDiscretization(idOfDisc,globalNum,its2))
2270 its.insert(its.end(),its2.begin(),its2.end());
2276 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
2278 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > > types;
2279 for( std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
2280 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
2282 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > fieldPmPt(types.size());
2283 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
2284 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it2=fieldPmPt.begin();
2285 for(;it1!=types.end();it1++,it2++)
2287 MCAuto<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
2288 elt->setLeaves((*it1).second);
2289 MCAuto<MEDFileFieldPerMeshPerTypeCommon> elt2(DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(elt));
2292 _field_pm_pt=fieldPmPt;
2295 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2297 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2298 (*it)->changePflsRefsNamesGen(mapOfModif);
2301 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2303 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2304 (*it)->changeLocsRefsNamesGen(mapOfModif);
2308 * \param [in] mesh is the whole mesh
2310 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2312 if(_field_pm_pt.empty())
2313 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2315 std::vector< std::pair<int,int> > dads;
2316 std::vector<const DataArrayInt *> pfls;
2317 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2318 std::vector<int> locs,code;
2319 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2320 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2321 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2323 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2326 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2327 throw INTERP_KERNEL::Exception(oss.str());
2330 std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2331 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2334 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2336 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2339 MCAuto<DataArrayInt> arr2(arr);
2340 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2346 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2350 if(nb!=mesh->getNumberOfNodes())
2352 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2353 oss << " nodes in mesh !";
2354 throw INTERP_KERNEL::Exception(oss.str());
2356 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2359 return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2363 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
2365 if(_field_pm_pt.empty())
2366 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2368 std::vector<std::pair<int,int> > dads;
2369 std::vector<const DataArrayInt *> pfls;
2370 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2371 std::vector<int> locs,code;
2372 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2373 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2374 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2376 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2379 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2380 throw INTERP_KERNEL::Exception(oss.str());
2382 std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2383 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2386 MCAuto<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2387 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2392 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2396 if(nb!=mesh->getNumberOfNodes())
2398 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2399 oss << " nodes in mesh !";
2400 throw INTERP_KERNEL::Exception(oss.str());
2403 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2409 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
2413 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2415 (*it)->getSizes(globalSz,nbOfEntries);
2417 entries.resize(nbOfEntries);
2419 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2421 (*it)->fillValues(nbOfEntries,entries);
2425 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
2427 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2429 if((*it)->getGeoType()==typ)
2430 return (*it)->getLeafGivenLocId(locId);
2432 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2433 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2434 oss << "Possiblities are : ";
2435 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2437 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2438 oss << "\"" << cm2.getRepr() << "\", ";
2440 throw INTERP_KERNEL::Exception(oss.str());
2443 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
2445 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2447 if((*it)->getGeoType()==typ)
2448 return (*it)->getLeafGivenLocId(locId);
2450 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2451 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2452 oss << "Possiblities are : ";
2453 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2455 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2456 oss << "\"" << cm2.getRepr() << "\", ";
2458 throw INTERP_KERNEL::Exception(oss.str());
2462 * \param [in,out] start - Integer that gives the current position in the final aggregated array
2463 * \param [in] pms - list of elements to aggregate. integer gives the mesh id
2464 * \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.
2465 * \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.
2467 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)
2469 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret(new MEDFileFieldPerMeshPerTypePerDisc(father,tof));
2471 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : empty input vector !");
2472 for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it=pms.begin();it!=pms.end();it++)
2475 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : presence of null pointer !");
2476 if(!(*it).second->getProfile().empty())
2477 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for profiles !");
2478 if(!(*it).second->getLocalization().empty())
2479 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for gauss pts !");
2481 INTERP_KERNEL::NormalizedCellType gt(pms[0].second->getGeoType());
2483 std::vector< std::pair<int,int> > filteredDTS;
2484 for(std::vector< std::vector< std::pair<int,int> > >::const_iterator it=dts.begin();it!=dts.end();it++,i++)
2485 for(std::vector< std::pair<int,int> >::const_iterator it2=(*it).begin();it2!=(*it).end();it2++)
2486 if((*it2).first==gt)
2487 filteredDTS.push_back(std::pair<int,int>(i,(*it2).second));
2488 if(pms.size()!=filteredDTS.size())
2489 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles !");
2490 std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it1(pms.begin());
2491 std::vector< std::pair<int,int> >::const_iterator it2(filteredDTS.begin());
2492 int zeStart(start),nval(0);
2493 for(;it1!=pms.end();it1++,it2++)
2495 if((*it1).first!=(*it2).first)
2496 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles 2 !");
2497 int s1((*it1).second->getStart()),e1((*it1).second->getEnd());
2498 extractInfo.push_back(std::pair<int, std::pair<int,int> >((*it1).first,std::pair<int,int>(s1,e1)));
2500 nval+=((*it1).second)->getNumberOfVals();
2502 ret->_start=zeStart; ret->_end=start; ret->_nval=nval;
2506 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)
2508 MCAuto<MEDFileFieldPerMesh> ret(new MEDFileFieldPerMesh(father,pms[0]->getMeshName(),pms[0]->getMeshIteration(),pms[0]->getMeshOrder()));
2509 std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > > m;
2511 for(std::vector<const MEDFileFieldPerMesh *>::const_iterator it=pms.begin();it!=pms.end();it++,i++)
2513 const std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >& v((*it)->_field_pm_pt);
2514 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it2=v.begin();it2!=v.end();it2++)
2516 INTERP_KERNEL::NormalizedCellType gt((*it2)->getGeoType());
2517 const MEDFileFieldPerMeshPerType *elt(dynamic_cast<const MEDFileFieldPerMeshPerType *>((const MEDFileFieldPerMeshPerTypeCommon *)(*it2)));
2519 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::Aggregate : not managed for structelement !");
2520 m[gt].push_back(std::pair<int,const MEDFileFieldPerMeshPerType *>(i,elt));
2523 for(std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > >::const_iterator it=m.begin();it!=m.end();it++)
2525 MCAuto<MEDFileFieldPerMeshPerType> agg(MEDFileFieldPerMeshPerType::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
2526 MCAuto<MEDFileFieldPerMeshPerTypeCommon> agg2(DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(agg));
2527 ret->_field_pm_pt.push_back(agg2);
2532 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2535 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2536 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it2=_field_pm_pt.begin();
2537 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2539 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2544 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2549 int ret=std::distance(_field_pm_pt.begin(),it2);
2550 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2555 * 'dads' and 'locs' input parameters have the same number of elements
2556 * \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
2558 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2559 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2560 const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2563 MCAuto<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2564 ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2565 MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2566 const std::vector<std::string>& infos=getInfo();
2567 da->setInfoOnComponents(infos);
2569 if(type==ON_GAUSS_PT)
2572 int nbOfArrs=dads.size();
2573 for(int i=0;i<nbOfArrs;i++)
2575 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2576 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2577 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2578 MCAuto<DataArrayInt> di=DataArrayInt::New();
2579 di->alloc(nbOfElems,1);
2581 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2582 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2591 * 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.
2592 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2593 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2594 * The order of cells in the returned field is those imposed by the profile.
2595 * \param [in] mesh is the global mesh.
2597 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2598 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2599 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2600 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2602 if(da->isIota(mesh->getNumberOfCells()))
2603 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2604 MCAuto<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2605 m2->setName(mesh->getName().c_str());
2606 MCAuto<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2612 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2614 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2615 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2616 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2618 if(da->isIota(mesh->getNumberOfNodes()))
2619 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2620 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2621 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2624 if(meshu->getNodalConnectivity()==0)
2626 MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2627 int nb=da->getNbOfElems();
2628 const int *ptr=da->getConstPointer();
2629 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2630 meshuc->allocateCells(nb);
2631 for(int i=0;i<nb;i++)
2632 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2633 meshuc->finishInsertingCells();
2634 ret->setMesh(meshuc);
2635 const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2636 if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2637 disc->checkCoherencyBetween(meshuc,arrOut);
2642 MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2644 DataArrayInt *arr2=0;
2645 MCAuto<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2646 MCAuto<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2647 MCAuto<DataArrayInt> arr3(arr2);
2648 int nnodes=mesh2->getNumberOfNodes();
2649 if(nnodes==(int)da->getNbOfElems())
2651 MCAuto<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2652 arrOut->renumberInPlace(da3->getConstPointer());
2653 mesh2->setName(mesh->getName().c_str());
2654 ret->setMesh(mesh2);
2659 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 !!!";
2660 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2661 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2662 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2663 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2664 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2665 throw INTERP_KERNEL::Exception(oss.str());
2671 * This method is the most light method of field retrieving.
2673 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
2677 pflOut=DataArrayInt::New();
2678 pflOut->alloc(nbOfElems,1);
2683 pflOut=const_cast<DataArrayInt*>(pflIn);
2686 MCAuto<DataArrayInt> safePfl(pflOut);
2687 MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2688 const std::vector<std::string>& infos=getInfo();
2689 int nbOfComp=infos.size();
2690 for(int i=0;i<nbOfComp;i++)
2691 da->setInfoOnComponent(i,infos[i].c_str());
2702 static MFFPMIter *NewCell(const MEDFileEntities *entities);
2703 static bool IsPresenceOfNode(const MEDFileEntities *entities);
2704 virtual ~MFFPMIter() { }
2705 virtual void begin() = 0;
2706 virtual bool finished() const = 0;
2707 virtual void next() = 0;
2708 virtual int current() const = 0;
2711 class MFFPMIterSimple : public MFFPMIter
2714 MFFPMIterSimple():_pos(0) { }
2715 void begin() { _pos=0; }
2716 bool finished() const { return _pos>=MED_N_CELL_FIXED_GEO; }
2717 void next() { _pos++; }
2718 int current() const { return _pos; }
2723 class MFFPMIter2 : public MFFPMIter
2726 MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts);
2727 void begin() { _it=_ids.begin(); }
2728 bool finished() const { return _it==_ids.end(); }
2729 void next() { _it++; }
2730 int current() const { return *_it; }
2732 std::vector<int> _ids;
2733 std::vector<int>::const_iterator _it;
2736 MFFPMIter *MFFPMIter::NewCell(const MEDFileEntities *entities)
2739 return new MFFPMIterSimple;
2742 const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
2745 std::vector<INTERP_KERNEL::NormalizedCellType> tmp;
2746 const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
2747 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
2749 if((*it).first==ON_CELLS || (*it).first==ON_GAUSS_NE || (*it).first==ON_GAUSS_PT)
2750 tmp.push_back((*it).second);
2752 return new MFFPMIter2(tmp);
2754 return new MFFPMIterSimple;// for MEDFileAllStaticEntites and MEDFileAllStaticEntitiesPlusDyn cells are in
2758 bool MFFPMIter::IsPresenceOfNode(const MEDFileEntities *entities)
2764 const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
2767 const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
2768 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
2769 if((*it).first==ON_NODES)
2773 return true;// for MEDFileAllStaticEntites and MEDFileAllStaticEntitiesPlusDyn nodes are in
2777 MFFPMIter2::MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts)
2779 std::size_t sz(cts.size());
2781 for(std::size_t i=0;i<sz;i++)
2783 INTERP_KERNEL::NormalizedCellType *loc(std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,cts[i]));
2784 if(loc!=typmai2+MED_N_CELL_FIXED_GEO)
2785 _ids[i]=(int)std::distance(typmai2,loc);
2787 throw INTERP_KERNEL::Exception("MFFPMIter2 : The specified geo type does not exists !");
2793 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),
2796 INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2797 INTERP_KERNEL::AutoPtr<char> pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2798 INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2799 const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
2800 INTERP_KERNEL::AutoCppPtr<MFFPMIter> iter0(MFFPMIter::NewCell(entities));
2801 for(iter0->begin();!iter0->finished();iter0->next())
2803 int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL ,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2804 std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2805 int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2806 std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2807 if(nbProfile>0 || nbProfile2>0)
2809 const PartDefinition *pd(0);
2811 pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[iter0->current()]),typmai2[iter0->current()]);
2812 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nasc,pd));
2819 if(MFFPMIter::IsPresenceOfNode(entities))
2821 int nbProfile(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName));
2824 const PartDefinition *pd(0);
2826 pd=mmu->getPartDefAtLevel(1,INTERP_KERNEL::NORM_ERROR);
2827 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd));
2828 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2833 std::vector<int> dynGT(entities->getDynGTAvail());
2834 for(std::vector<int>::const_iterator it=dynGT.begin();it!=dynGT.end();it++)
2836 int nbPfl(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,*it,pflName,locName));
2839 _field_pm_pt.push_back(MEDFileFieldPerMeshPerTypeDyn::NewOnRead(fid,this,entities,*it,nasc));
2844 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2846 copyTinyInfoFrom(mesh);
2849 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
2851 if(id>=(int)_pfls.size())
2853 _pfls[id]=DataArrayInt::New();
2854 int lgth(MEDprofileSizeByName(fid,pflName.c_str()));
2855 _pfls[id]->setName(pflName);
2856 _pfls[id]->alloc(lgth,1);
2857 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName.c_str(),_pfls[id]->getPointer()));
2858 _pfls[id]->applyLin(1,-1,0);//Converting into C format
2861 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2863 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2865 MEDFILESAFECALLERRD0(MEDprofileInfo,(fid,i+1,pflName,&sz));
2866 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2867 if(i>=(int)_pfls.size())
2869 _pfls[i]=DataArrayInt::New();
2870 _pfls[i]->alloc(sz,1);
2871 _pfls[i]->setName(pflCpp.c_str());
2872 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName,_pfls[i]->getPointer()));
2873 _pfls[i]->applyLin(1,-1,0);//Converting into C format
2876 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
2878 int nbOfPfls=_pfls.size();
2879 for(int i=0;i<nbOfPfls;i++)
2881 MCAuto<DataArrayInt> cpy=_pfls[i]->deepCopy();
2882 cpy->applyLin(1,1,0);
2883 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2884 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2885 MEDFILESAFECALLERWR0(MEDprofileWr,(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer()));
2888 int nbOfLocs=_locs.size();
2889 for(int i=0;i<nbOfLocs;i++)
2890 _locs[i]->writeLL(fid);
2893 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
2895 std::vector<std::string> pfls=getPfls();
2896 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2898 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2901 _pfls.push_back(*it);
2905 int id=std::distance(pfls.begin(),it2);
2906 if(!(*it)->isEqual(*_pfls[id]))
2908 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2909 throw INTERP_KERNEL::Exception(oss.str());
2913 std::vector<std::string> locs=getLocs();
2914 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
2916 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2919 _locs.push_back(*it);
2923 int id=std::distance(locs.begin(),it2);
2924 if(!(*it)->isEqual(*_locs[id],eps))
2926 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2927 throw INTERP_KERNEL::Exception(oss.str());
2933 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
2935 for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
2936 getProfile((*it).c_str());
2939 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
2941 for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
2942 getLocalization((*it).c_str());
2945 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
2947 std::vector<std::string> profiles=real.getPflsReallyUsed();
2948 int sz=profiles.size();
2950 for(int i=0;i<sz;i++)
2951 loadProfileInFile(fid,i,profiles[i].c_str());
2953 std::vector<std::string> locs=real.getLocsReallyUsed();
2956 for(int i=0;i<sz;i++)
2957 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2960 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid)
2962 int nProfil=MEDnProfile(fid);
2963 for(int i=0;i<nProfil;i++)
2964 loadProfileInFile(fid,i);
2965 int sz=MEDnLocalization(fid);
2967 for(int i=0;i<sz;i++)
2969 _locs[i]=MEDFileFieldLoc::New(fid,i);
2973 MEDFileFieldGlobs *MEDFileFieldGlobs::New(med_idt fid)
2975 return new MEDFileFieldGlobs(fid);
2978 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2980 return new MEDFileFieldGlobs;
2983 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
2985 return _file_name.capacity()+_pfls.capacity()*sizeof(MCAuto<DataArrayInt>)+_locs.capacity()*sizeof(MCAuto<MEDFileFieldLoc>);
2988 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildrenWithNull() const
2990 std::vector<const BigMemoryObject *> ret;
2991 for(std::vector< MCAuto< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2992 ret.push_back((const DataArrayInt *)*it);
2993 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2994 ret.push_back((const MEDFileFieldLoc *)*it);
2998 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCopy() const
3000 MCAuto<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
3002 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3004 if((const DataArrayInt *)*it)
3005 ret->_pfls[i]=(*it)->deepCopy();
3008 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3010 if((const MEDFileFieldLoc*)*it)
3011 ret->_locs[i]=(*it)->deepCopy();
3017 * \throw if a profile in \a pfls in not in \a this.
3018 * \throw if a localization in \a locs in not in \a this.
3019 * \sa MEDFileFieldGlobs::deepCpyPart
3021 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
3023 MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
3024 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
3026 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
3028 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
3030 MCAuto<DataArrayInt> pfl2(pfl);
3031 ret->_pfls.push_back(pfl2);
3033 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
3035 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
3037 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
3039 MCAuto<MEDFileFieldLoc> loc2(loc);
3040 ret->_locs.push_back(loc2);
3042 ret->setFileName(getFileName());
3047 * \throw if a profile in \a pfls in not in \a this.
3048 * \throw if a localization in \a locs in not in \a this.
3049 * \sa MEDFileFieldGlobs::shallowCpyPart
3051 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
3053 MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
3054 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
3056 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
3058 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
3059 ret->_pfls.push_back(pfl->deepCopy());
3061 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
3063 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
3065 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
3066 ret->_locs.push_back(loc->deepCopy());
3068 ret->setFileName(getFileName());
3072 MEDFileFieldGlobs::MEDFileFieldGlobs(med_idt fid):_file_name(MEDFileWritable::FileNameFromFID(fid))
3076 MEDFileFieldGlobs::MEDFileFieldGlobs()
3080 MEDFileFieldGlobs::~MEDFileFieldGlobs()
3084 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
3086 oss << "Profiles :\n";
3087 std::size_t n=_pfls.size();
3088 for(std::size_t i=0;i<n;i++)
3090 oss << " - #" << i << " ";
3091 const DataArrayInt *pfl=_pfls[i];
3093 oss << "\"" << pfl->getName() << "\"\n";
3098 oss << "Localizations :\n";
3099 for(std::size_t i=0;i<n;i++)
3101 oss << " - #" << i << " ";
3102 const MEDFileFieldLoc *loc=_locs[i];
3104 loc->simpleRepr(oss);
3110 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3112 for(std::vector< MCAuto<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
3114 DataArrayInt *elt(*it);
3117 std::string name(elt->getName());
3118 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3120 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3122 elt->setName((*it2).second.c_str());
3130 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3132 for(std::vector< MCAuto<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
3134 MEDFileFieldLoc *elt(*it);
3137 std::string name(elt->getName());
3138 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3140 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3142 elt->setName((*it2).second.c_str());
3150 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
3152 if(locId<0 || locId>=(int)_locs.size())
3153 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
3154 return _locs[locId]->getNbOfGaussPtPerCell();
3157 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
3159 return getLocalizationFromId(getLocalizationId(locName));
3162 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
3164 if(locId<0 || locId>=(int)_locs.size())
3165 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3166 return *_locs[locId];
3170 namespace MEDCouplingImpl
3175 LocFinder(const std::string& loc):_loc(loc) { }
3176 bool operator() (const MCAuto<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
3178 const std::string &_loc;
3184 PflFinder(const std::string& pfl):_pfl(pfl) { }
3185 bool operator() (const MCAuto<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
3187 const std::string& _pfl;
3192 int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
3194 std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),MEDCouplingImpl::LocFinder(loc));
3197 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
3198 for(it=_locs.begin();it!=_locs.end();it++)
3199 oss << "\"" << (*it)->getName() << "\", ";
3200 throw INTERP_KERNEL::Exception(oss.str());
3202 return std::distance(_locs.begin(),it);
3206 * The returned value is never null.
3208 const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
3210 std::string pflNameCpp(pflName);
3211 std::vector< MCAuto<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3214 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3215 for(it=_pfls.begin();it!=_pfls.end();it++)
3216 oss << "\"" << (*it)->getName() << "\", ";
3217 throw INTERP_KERNEL::Exception(oss.str());
3222 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
3224 if(pflId<0 || pflId>=(int)_pfls.size())
3225 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3226 return _pfls[pflId];
3229 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
3231 if(locId<0 || locId>=(int)_locs.size())
3232 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3233 return *_locs[locId];
3236 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
3238 return getLocalizationFromId(getLocalizationId(locName));
3242 * The returned value is never null.
3244 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
3246 std::string pflNameCpp(pflName);
3247 std::vector< MCAuto<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3250 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3251 for(it=_pfls.begin();it!=_pfls.end();it++)
3252 oss << "\"" << (*it)->getName() << "\", ";
3253 throw INTERP_KERNEL::Exception(oss.str());
3258 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
3260 if(pflId<0 || pflId>=(int)_pfls.size())
3261 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3262 return _pfls[pflId];
3265 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
3267 std::vector< MCAuto<DataArrayInt> > newPfls;
3269 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3271 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
3272 newPfls.push_back(*it);
3277 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
3279 std::vector< MCAuto<MEDFileFieldLoc> > newLocs;
3281 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3283 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
3284 newLocs.push_back(*it);
3289 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
3291 int sz=_pfls.size();
3292 std::vector<std::string> ret(sz);
3293 for(int i=0;i<sz;i++)
3294 ret[i]=_pfls[i]->getName();
3298 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
3300 int sz=_locs.size();
3301 std::vector<std::string> ret(sz);
3302 for(int i=0;i<sz;i++)
3303 ret[i]=_locs[i]->getName();
3307 bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
3309 std::vector<std::string> v=getPfls();
3310 std::string s(pflName);
3311 return std::find(v.begin(),v.end(),s)!=v.end();
3314 bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
3316 std::vector<std::string> v=getLocs();
3317 std::string s(locName);
3318 return std::find(v.begin(),v.end(),s)!=v.end();
3321 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
3323 std::map<int,std::vector<int> > m;
3325 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3327 const DataArrayInt *tmp=(*it);
3330 m[tmp->getHashCode()].push_back(i);
3333 std::vector< std::vector<int> > ret;
3334 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
3336 if((*it2).second.size()>1)
3338 std::vector<int> ret0;
3339 bool equalityOrNot=false;
3340 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
3342 std::vector<int>::const_iterator it4=it3; it4++;
3343 for(;it4!=(*it2).second.end();it4++)
3345 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
3348 ret0.push_back(*it3);
3349 ret0.push_back(*it4);
3355 ret.push_back(ret0);
3361 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
3363 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
3366 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
3368 std::string name(pfl->getName());
3370 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
3371 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3372 if(name==(*it)->getName())
3374 if(!pfl->isEqual(*(*it)))
3376 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
3377 throw INTERP_KERNEL::Exception(oss.str());
3381 _pfls.push_back(pfl);
3384 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)
3386 std::string name(locName);
3388 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
3389 MCAuto<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
3390 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3391 if((*it)->isName(locName))
3393 if(!(*it)->isEqual(*obj,1e-12))
3395 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
3396 throw INTERP_KERNEL::Exception(oss.str());
3399 _locs.push_back(obj);
3402 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
3404 std::vector<std::string> names=getPfls();
3405 return CreateNewNameNotIn("NewPfl_",names);
3408 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
3410 std::vector<std::string> names=getLocs();
3411 return CreateNewNameNotIn("NewLoc_",names);
3414 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
3416 for(std::size_t sz=0;sz<100000;sz++)
3418 std::ostringstream tryName;
3419 tryName << prefix << sz;
3420 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
3421 return tryName.str();
3423 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
3427 * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
3428 * \param [in] fname - the file name.
3430 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(med_idt fid):_globals(MEDFileFieldGlobs::New(fid))
3435 * Creates an empty MEDFileFieldGlobsReal.
3437 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
3441 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
3446 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildrenWithNull() const
3448 std::vector<const BigMemoryObject *> ret;
3449 ret.push_back((const MEDFileFieldGlobs *)_globals);
3454 * Returns a string describing profiles and Gauss points held in \a this.
3455 * \return std::string - the description string.
3457 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
3459 const MEDFileFieldGlobs *glob=_globals;
3460 std::ostringstream oss2; oss2 << glob;
3461 std::string stars(oss2.str().length(),'*');
3462 oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n";
3464 glob->simpleRepr(oss);
3466 oss << "NO GLOBAL INFORMATION !\n";
3469 void MEDFileFieldGlobsReal::resetContent()
3471 _globals=MEDFileFieldGlobs::New();
3474 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
3479 * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
3480 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3482 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3484 _globals=other._globals;
3488 * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3489 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3491 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3493 const MEDFileFieldGlobs *otherg(other._globals);
3496 _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3500 * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3501 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3503 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3505 const MEDFileFieldGlobs *otherg(other._globals);
3508 _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3511 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3513 _globals=other._globals;
3514 if((const MEDFileFieldGlobs *)_globals)
3515 _globals=other._globals->deepCopy();
3519 * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3520 * \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3521 * \param [in] eps - a precision used to compare Gauss points with same name held by
3522 * \a this and \a other MEDFileFieldGlobsReal.
3523 * \throw If \a this and \a other hold profiles with equal names but different ids.
3524 * \throw If \a this and \a other hold different Gauss points with equal names.
3526 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
3528 const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3529 if(thisGlobals==otherGlobals)
3533 _globals=other._globals;
3536 _globals->appendGlobs(*other._globals,eps);
3539 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
3541 checkGlobsPflsPartCoherency();
3542 checkGlobsLocsPartCoherency();
3545 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
3547 contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3550 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
3552 contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3555 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3557 contentNotNull()->loadProfileInFile(fid,id,pflName);
3560 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3562 contentNotNull()->loadProfileInFile(fid,id);
3565 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
3567 contentNotNull()->loadGlobals(fid,*this);
3570 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid)
3572 contentNotNull()->loadAllGlobals(fid);
3575 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3577 contentNotNull()->writeGlobals(fid,opt);
3581 * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3582 * or getPflsReallyUsedMulti().
3583 * \return std::vector<std::string> - a sequence of names of all profiles.
3585 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3587 return contentNotNull()->getPfls();
3591 * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3592 * or getLocsReallyUsedMulti().
3593 * \return std::vector<std::string> - a sequence of names of all localizations.
3595 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3597 return contentNotNull()->getLocs();
3601 * Checks if the profile with a given name exists.
3602 * \param [in] pflName - the profile name of interest.
3603 * \return bool - \c true if the profile named \a pflName exists.
3605 bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
3607 return contentNotNull()->existsPfl(pflName);
3611 * Checks if the localization with a given name exists.
3612 * \param [in] locName - the localization name of interest.
3613 * \return bool - \c true if the localization named \a locName exists.
3615 bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
3617 return contentNotNull()->existsLoc(locName);
3620 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
3622 return contentNotNull()->createNewNameOfPfl();
3625 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
3627 return contentNotNull()->createNewNameOfLoc();
3631 * Sets the name of a MED file.
3632 * \param [inout] fileName - the file name.
3634 void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
3636 contentNotNull()->setFileName(fileName);
3640 * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3641 * in the same order.
3642 * \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3643 * Each item of this sequence is a vector containing ids of equal profiles.
3645 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3647 return contentNotNull()->whichAreEqualProfiles();
3651 * Finds equal localizations.
3652 * \param [in] eps - a precision used to compare real values of the localizations.
3653 * \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3654 * Each item of this sequence is a vector containing ids of equal localizations.
3656 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3658 return contentNotNull()->whichAreEqualLocs(eps);
3662 * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3663 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3664 * this sequence is a pair whose
3665 * - the first item is a vector of profile names to replace by the second item,
3666 * - the second item is a profile name to replace every profile name of the first item.
3668 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3670 contentNotNull()->changePflsNamesInStruct(mapOfModif);
3674 * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3675 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3676 * this sequence is a pair whose
3677 * - the first item is a vector of localization names to replace by the second item,
3678 * - the second item is a localization name to replace every localization name of the first item.
3680 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3682 contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3686 * Replaces references to some profiles (a reference is a profile name) by references
3687 * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3688 * them-selves accordingly. <br>
3689 * This method is a generalization of changePflName().
3690 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3691 * this sequence is a pair whose
3692 * - the first item is a vector of profile names to replace by the second item,
3693 * - the second item is a profile name to replace every profile of the first item.
3694 * \sa changePflsRefsNamesGen()
3695 * \sa changePflName()
3697 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3699 changePflsRefsNamesGen(mapOfModif);
3700 changePflsNamesInStruct(mapOfModif);
3704 * Replaces references to some localizations (a reference is a localization name) by references
3705 * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3706 * them-selves accordingly. <br>
3707 * This method is a generalization of changeLocName().
3708 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3709 * this sequence is a pair whose
3710 * - the first item is a vector of localization names to replace by the second item,
3711 * - the second item is a localization name to replace every localization of the first item.
3712 * \sa changeLocsRefsNamesGen()
3713 * \sa changeLocName()
3715 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3717 changeLocsRefsNamesGen(mapOfModif);
3718 changeLocsNamesInStruct(mapOfModif);
3722 * Renames the profile having a given name and updates references to this profile.
3723 * \param [in] oldName - the name of the profile to rename.
3724 * \param [in] newName - a new name of the profile.
3725 * \sa changePflsNames().
3727 void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
3729 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3730 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3732 changePflsNames(mapOfModif);
3736 * Renames the localization having a given name and updates references to this localization.
3737 * \param [in] oldName - the name of the localization to rename.
3738 * \param [in] newName - a new name of the localization.
3739 * \sa changeLocsNames().
3741 void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
3743 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3744 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3746 changeLocsNames(mapOfModif);
3750 * Removes duplicated profiles. Returns a map used to update references to removed
3751 * profiles via changePflsRefsNamesGen().
3752 * Equal profiles are found using whichAreEqualProfiles().
3753 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3754 * a sequence describing the performed replacements of profiles. Each element of
3755 * this sequence is a pair whose
3756 * - the first item is a vector of profile names replaced by the second item,
3757 * - the second item is a profile name replacing every profile of the first item.
3759 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
3761 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3762 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3764 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3766 std::vector< std::string > tmp((*it).size());
3768 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3769 tmp[j]=std::string(getProfileFromId(*it2)->getName());
3770 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3772 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3773 killProfileIds(tmp2);
3775 changePflsRefsNamesGen(ret);
3780 * Removes duplicated localizations. Returns a map used to update references to removed
3781 * localizations via changeLocsRefsNamesGen().
3782 * Equal localizations are found using whichAreEqualLocs().
3783 * \param [in] eps - a precision used to compare real values of the localizations.
3784 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3785 * a sequence describing the performed replacements of localizations. Each element of
3786 * this sequence is a pair whose
3787 * - the first item is a vector of localization names replaced by the second item,
3788 * - the second item is a localization name replacing every localization of the first item.
3790 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
3792 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3793 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3795 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3797 std::vector< std::string > tmp((*it).size());
3799 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3800 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3801 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3803 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3804 killLocalizationIds(tmp2);
3806 changeLocsRefsNamesGen(ret);
3811 * Returns number of Gauss points per cell in a given localization.
3812 * \param [in] locId - an id of the localization of interest.
3813 * \return int - the number of the Gauss points per cell.
3815 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
3817 return contentNotNull()->getNbOfGaussPtPerCell(locId);
3821 * Returns an id of a localization by its name.
3822 * \param [in] loc - the localization name of interest.
3823 * \return int - the id of the localization.
3824 * \throw If there is no a localization named \a loc.
3826 int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
3828 return contentNotNull()->getLocalizationId(loc);
3832 * Returns the name of the MED file.
3833 * \return const std::string& - the MED file name.
3835 std::string MEDFileFieldGlobsReal::getFileName() const
3837 return contentNotNull()->getFileName();
3841 * Returns a localization object by its name.
3842 * \param [in] locName - the name of the localization of interest.
3843 * \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3844 * \throw If there is no a localization named \a locName.
3846 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
3848 return contentNotNull()->getLocalization(locName);
3852 * Returns a localization object by its id.
3853 * \param [in] locId - the id of the localization of interest.
3854 * \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3855 * \throw If there is no a localization with id \a locId.
3857 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
3859 return contentNotNull()->getLocalizationFromId(locId);
3863 * Returns a profile array by its name.
3864 * \param [in] pflName - the name of the profile of interest.
3865 * \return const DataArrayInt * - the profile array having the name \a pflName.
3866 * \throw If there is no a profile named \a pflName.
3868 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
3870 return contentNotNull()->getProfile(pflName);
3874 * Returns a profile array by its id.
3875 * \param [in] pflId - the id of the profile of interest.
3876 * \return const DataArrayInt * - the profile array having the id \a pflId.
3877 * \throw If there is no a profile with id \a pflId.
3879 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
3881 return contentNotNull()->getProfileFromId(pflId);
3885 * Returns a localization object, apt for modification, by its id.
3886 * \param [in] locId - the id of the localization of interest.
3887 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3888 * having the id \a locId.
3889 * \throw If there is no a localization with id \a locId.
3891 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
3893 return contentNotNull()->getLocalizationFromId(locId);
3897 * Returns a localization object, apt for modification, by its name.
3898 * \param [in] locName - the name of the localization of interest.
3899 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3900 * having the name \a locName.
3901 * \throw If there is no a localization named \a locName.
3903 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
3905 return contentNotNull()->getLocalization(locName);
3909 * Returns a profile array, apt for modification, by its name.
3910 * \param [in] pflName - the name of the profile of interest.
3911 * \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3912 * \throw If there is no a profile named \a pflName.
3914 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
3916 return contentNotNull()->getProfile(pflName);
3920 * Returns a profile array, apt for modification, by its id.
3921 * \param [in] pflId - the id of the profile of interest.
3922 * \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3923 * \throw If there is no a profile with id \a pflId.
3925 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
3927 return contentNotNull()->getProfileFromId(pflId);
3931 * Removes profiles given by their ids. No data is updated to track this removal.
3932 * \param [in] pflIds - a sequence of ids of the profiles to remove.
3934 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
3936 contentNotNull()->killProfileIds(pflIds);
3940 * Removes localizations given by their ids. No data is updated to track this removal.
3941 * \param [in] locIds - a sequence of ids of the localizations to remove.
3943 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
3945 contentNotNull()->killLocalizationIds(locIds);
3949 * Stores a profile array.
3950 * \param [in] pfl - the profile array to store.
3951 * \throw If the name of \a pfl is empty.
3952 * \throw If a profile with the same name as that of \a pfl already exists but contains
3955 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
3957 contentNotNull()->appendProfile(pfl);
3961 * Adds a new localization of Gauss points.
3962 * \param [in] locName - the name of the new localization.
3963 * \param [in] geoType - a geometrical type of the reference cell.
3964 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
3965 * must be \c nbOfNodesPerCell * \c dimOfType.
3966 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
3967 * must be _wg_.size() * \c dimOfType.
3968 * \param [in] w - the weights of Gauss points.
3969 * \throw If \a locName is empty.
3970 * \throw If a localization with the name \a locName already exists but is
3971 * different form the new one.
3973 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)
3975 contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
3978 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
3980 MEDFileFieldGlobs *g(_globals);
3982 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
3986 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
3988 const MEDFileFieldGlobs *g(_globals);
3990 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
3994 //= MEDFileFieldNameScope
3996 MEDFileFieldNameScope::MEDFileFieldNameScope()
4000 MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName):_name(fieldName)
4005 * Returns the name of \a this field.
4006 * \return std::string - a string containing the field name.
4008 std::string MEDFileFieldNameScope::getName() const
4014 * Sets name of \a this field
4015 * \param [in] name - the new field name.
4017 void MEDFileFieldNameScope::setName(const std::string& fieldName)
4022 std::string MEDFileFieldNameScope::getDtUnit() const
4027 void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
4032 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
4035 _dt_unit=other._dt_unit;
4038 //= MEDFileAnyTypeField1TSWithoutSDA
4040 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
4042 _field_per_mesh.resize(other._field_per_mesh.size());
4044 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
4046 if((const MEDFileFieldPerMesh *)*it)
4047 _field_per_mesh[i]=(*it)->deepCopy(this);
4052 * Prints a string describing \a this field into a stream. This string is outputted
4053 * by \c print Python command.
4054 * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
4055 * \param [in,out] oss - the out stream.
4056 * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
4057 * info id printed, else, not.
4059 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
4061 std::string startOfLine(bkOffset,' ');
4062 oss << startOfLine << "Field ";
4064 oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
4065 oss << "on one time Step ";
4067 oss << "(" << f1tsId << ") ";
4068 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
4069 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
4070 const DataArray *arr=getUndergroundDataArray();
4073 const std::vector<std::string> &comps=arr->getInfoOnComponents();
4076 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
4077 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
4078 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
4080 if(arr->isAllocated())
4082 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
4085 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
4089 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
4091 oss << startOfLine << "----------------------" << std::endl;
4092 if(!_field_per_mesh.empty())
4095 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
4097 const MEDFileFieldPerMesh *cur=(*it2);
4099 cur->simpleRepr(bkOffset,oss,i);
4101 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
4106 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
4108 oss << startOfLine << "----------------------" << std::endl;
4111 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
4113 const DataArray *arr(getUndergroundDataArray());
4115 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
4116 int nbOfCompo=arr->getNumberOfComponents();
4117 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
4118 for(int i=0;i<nbOfCompo;i++)
4121 std::vector<int> v(1,i);
4122 MCAuto<DataArray> arr2=arr->keepSelectedComponents(v);
4123 ret[i]->setArray(arr2);
4128 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)
4132 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
4137 * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
4138 * empty. Returns -1 if this in on nodes.
4139 * \return int - the dimension of \a this.
4141 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
4144 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4145 (*it)->getDimension(ret);
4150 * Returns the mesh name.
4151 * \return std::string - a string holding the mesh name.
4152 * \throw If \c _field_per_mesh.empty()
4154 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const
4156 if(_field_per_mesh.empty())
4157 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
4158 return _field_per_mesh[0]->getMeshName();
4161 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const std::string& newMeshName)
4163 std::string oldName(getMeshName());
4164 std::vector< std::pair<std::string,std::string> > v(1);
4165 v[0].first=oldName; v[0].second=newMeshName;
4169 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
4172 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4174 MEDFileFieldPerMesh *cur(*it);
4176 ret=cur->changeMeshNames(modifTab) || ret;
4182 * Returns the number of iteration of the state of underlying mesh.
4183 * \return int - the iteration number.
4184 * \throw If \c _field_per_mesh.empty()
4186 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
4188 if(_field_per_mesh.empty())
4189 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
4190 return _field_per_mesh[0]->getMeshIteration();
4194 * Returns the order number of iteration of the state of underlying mesh.
4195 * \return int - the order number.
4196 * \throw If \c _field_per_mesh.empty()
4198 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
4200 if(_field_per_mesh.empty())
4201 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
4202 return _field_per_mesh[0]->getMeshOrder();
4206 * Checks if \a this field is tagged by a given iteration number and a given
4207 * iteration order number.
4208 * \param [in] iteration - the iteration number of interest.
4209 * \param [in] order - the iteration order number of interest.
4210 * \return bool - \c true if \a this->getIteration() == \a iteration &&
4211 * \a this->getOrder() == \a order.
4213 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
4215 return iteration==_iteration && order==_order;
4219 * Returns number of iteration and order number of iteration when
4220 * \a this field has been calculated.
4221 * \return std::pair<int,int> - a pair of the iteration number and the iteration
4224 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
4226 std::pair<int,int> p;
4232 * Returns number of iteration and order number of iteration when
4233 * \a this field has been calculated.
4234 * \param [in,out] p - a pair returning the iteration number and the iteration
4237 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
4244 * Returns all types of spatial discretization of \a this field.
4245 * \param [in,out] types - a sequence of types of \a this field.
4247 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
4249 std::set<TypeOfField> types2;
4250 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4252 (*it)->fillTypesOfFieldAvailable(types2);
4254 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
4255 std::copy(types2.begin(),types2.end(),bi);
4259 * Returns all types of spatial discretization of \a this field.
4260 * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
4263 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
4265 std::vector<TypeOfField> ret;
4266 fillTypesOfFieldAvailable(ret);
4270 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
4272 std::vector<std::string> ret;
4273 std::set<std::string> ret2;
4274 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4276 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
4277 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4278 if(ret2.find(*it2)==ret2.end())
4280 ret.push_back(*it2);
4287 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
4289 std::vector<std::string> ret;
4290 std::set<std::string> ret2;
4291 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4293 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
4294 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4295 if(ret2.find(*it2)==ret2.end())
4297 ret.push_back(*it2);
4304 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
4306 std::vector<std::string> ret;
4307 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4309 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
4310 ret.insert(ret.end(),tmp.begin(),tmp.end());
4315 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
4317 std::vector<std::string> ret;
4318 std::set<std::string> ret2;
4319 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4321 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
4322 ret.insert(ret.end(),tmp.begin(),tmp.end());
4327 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4329 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4330 (*it)->changePflsRefsNamesGen(mapOfModif);
4333 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4335 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4336 (*it)->changeLocsRefsNamesGen(mapOfModif);
4340 * Returns all attributes of parts of \a this field lying on a given mesh.
4341 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4342 * item of every of returned sequences refers to the _i_-th part of \a this field.
4343 * Thus all sequences returned by this method are of the same length equal to number
4344 * of different types of supporting entities.<br>
4345 * A field part can include sub-parts with several different spatial discretizations,
4346 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
4347 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4348 * of a nested sequence corresponds to a type of spatial discretization.<br>
4349 * This method allows for iteration over MEDFile DataStructure without any overhead.
4350 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4351 * for the case with only one underlying mesh. (Actually, the number of meshes is
4352 * not checked if \a mname == \c NULL).
4353 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4354 * a field part is returned.
4355 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4356 * This sequence is of the same length as \a types.
4357 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4358 * discretization. A profile name can be empty.
4359 * Length of this and of nested sequences is the same as that of \a typesF.
4360 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4361 * discretization. A localization name can be empty.
4362 * Length of this and of nested sequences is the same as that of \a typesF.
4363 * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
4364 * of ids of tuples within the data array, per each type of spatial
4365 * discretization within one mesh entity type.
4366 * Length of this and of nested sequences is the same as that of \a typesF.
4367 * \throw If no field is lying on \a mname.
4369 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
4373 meshId=getMeshIdFromMeshName(mname);
4375 if(_field_per_mesh.empty())
4376 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4377 return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4381 * Returns dimensions of mesh elements \a this field lies on. The returned value is a
4382 * maximal absolute dimension and values returned via the out parameter \a levs are
4383 * dimensions relative to the maximal absolute dimension. <br>
4384 * This method is designed for MEDFileField1TS instances that have a discretization
4385 * \ref MEDCoupling::ON_CELLS "ON_CELLS",
4386 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT",
4387 * \ref MEDCoupling::ON_GAUSS_NE "ON_GAUSS_NE".
4388 * Only these 3 discretizations will be taken into account here. If \a this is
4389 * \ref MEDCoupling::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
4390 * This method is useful to make the link between the dimension of the underlying mesh
4391 * and the levels of \a this, because it is possible that the highest dimension of \a this
4392 * field is not equal to the dimension of the underlying mesh.
4394 * Let's consider the following case:
4395 * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
4396 * TETRA4, HEXA8, TRI3 and SEG2.
4397 * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
4398 * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
4400 * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
4401 * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
4402 * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
4403 * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
4404 * parameter of getFieldAtLevel() is computed basing on the returned values as this:
4405 * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
4407 * to retrieve the highest level of
4408 * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br>
4409 * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
4410 * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
4411 * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
4412 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4413 * for the case with only one underlying mesh. (Actually, the number of meshes is
4414 * not checked if \a mname == \c NULL).
4415 * \param [in,out] levs - a sequence returning the dimensions relative to the maximal
4416 * absolute one. They are in decreasing order. This sequence is cleared before
4418 * \return int - the maximal absolute dimension of elements \a this fields lies on.
4419 * \throw If no field is lying on \a mname.
4421 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
4424 int meshId=getMeshIdFromMeshName(mname);
4425 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4426 std::vector< std::vector<TypeOfField> > typesF;
4427 std::vector< std::vector<std::string> > pfls, locs;
4428 _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4430 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
4431 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
4432 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
4434 st.erase(INTERP_KERNEL::NORM_ERROR);
4436 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
4438 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
4439 ret1.insert((int)cm.getDimension());
4441 int ret=*std::max_element(ret1.begin(),ret1.end());
4442 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
4443 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
4448 * \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.
4449 * \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.
4450 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4451 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4453 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
4455 int mid=getMeshIdFromMeshName(mName);
4456 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4460 * \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.
4461 * \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.
4462 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4463 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4465 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
4467 int mid=getMeshIdFromMeshName(mName);
4468 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4472 * \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.
4474 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
4476 if(_field_per_mesh.empty())
4477 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4480 std::string mName2(mName);
4482 std::vector<std::string> msg;
4483 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4484 if(mName2==(*it)->getMeshName())
4487 msg.push_back((*it)->getMeshName());
4488 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4489 oss << "Possible meshes are : ";
4490 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4491 oss << "\"" << (*it2) << "\" ";
4492 throw INTERP_KERNEL::Exception(oss.str());
4495 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
4498 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4499 std::string tmp(mesh->getName());
4501 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4502 std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4504 for(;it!=_field_per_mesh.end();it++,i++)
4506 if((*it)->getMeshName()==tmp)
4509 int sz=_field_per_mesh.size();
4510 _field_per_mesh.resize(sz+1);
4511 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4515 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4516 MEDFileFieldGlobsReal& glob)
4519 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4521 MEDFileFieldPerMesh *fpm(*it);
4523 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4529 * This method splits \a this into several sub-parts so that each sub parts have exactly one spatial discretization. This method implements the minimal
4530 * splitting that leads to single spatial discretization of this.
4532 * \sa splitMultiDiscrPerGeoTypes
4534 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
4536 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4537 std::vector< std::vector<TypeOfField> > typesF;
4538 std::vector< std::vector<std::string> > pfls,locs;
4539 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4540 std::set<TypeOfField> allEnt;
4541 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4542 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4543 allEnt.insert(*it2);
4544 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4545 std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4546 for(std::size_t i=0;i<allEnt.size();i++,it3++)
4548 std::vector< std::pair<int,int> > its;
4549 ret[i]=shallowCpy();
4550 int newLgth(ret[i]->keepOnlySpatialDiscretization(*it3,its));
4551 ret[i]->updateData(newLgth,its);
4557 * This method performs a sub splitting as splitDiscretizations does but finer. This is the finest spliting level that can be done.
4558 * This method implements the minimal splitting so that each returned elements are mono Gauss discretization per geometric type.
4560 * \sa splitDiscretizations
4562 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes() const
4564 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4565 std::vector< std::vector<TypeOfField> > typesF;
4566 std::vector< std::vector<std::string> > pfls,locs;
4567 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4568 std::set<TypeOfField> allEnt;
4569 std::size_t nbOfMDPGT(0),ii(0);
4570 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++,ii++)
4572 nbOfMDPGT=std::max(nbOfMDPGT,locs[ii].size());
4573 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4574 allEnt.insert(*it2);
4576 if(allEnt.size()!=1)
4577 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : this field is expected to be defined only on one spatial discretization !");
4579 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
4582 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret0(1);
4583 ret0[0]=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(this); this->incrRef();
4586 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfMDPGT);
4587 for(std::size_t i=0;i<nbOfMDPGT;i++)
4589 std::vector< std::pair<int,int> > its;
4590 ret[i]=shallowCpy();
4591 int newLgth(ret[i]->keepOnlyGaussDiscretization(i,its));
4592 ret[i]->updateData(newLgth,its);
4597 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
4599 int globalCounter(0);
4600 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4601 (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4602 return globalCounter;
4605 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlyGaussDiscretization(std::size_t idOfDisc, std::vector< std::pair<int,int> >& its)
4607 int globalCounter(0);
4608 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4609 (*it)->keepOnlyGaussDiscretization(idOfDisc,globalCounter,its);
4610 return globalCounter;
4613 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
4615 if(_nb_of_tuples_to_be_allocated>=0)
4617 _nb_of_tuples_to_be_allocated=newLgth;
4618 const DataArray *oldArr(getUndergroundDataArray());
4621 MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4622 newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
4624 _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
4628 if(_nb_of_tuples_to_be_allocated==-1)
4630 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4632 const DataArray *oldArr(getUndergroundDataArray());
4633 if(!oldArr || !oldArr->isAllocated())
4634 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4635 MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4636 newArr->alloc(newLgth,getNumberOfComponents());
4638 newArr->copyStringInfoFrom(*oldArr);
4640 for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4642 if((*it).second<(*it).first)
4643 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4644 newArr->setContigPartOfSelectedValuesSlice(pos,oldArr,(*it).first,(*it).second,1);
4645 pos+=(*it).second-(*it).first;
4650 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4653 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
4655 if(_field_per_mesh.empty())
4656 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4657 if(_field_per_mesh.size()>1)
4658 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4659 _field_per_mesh[0]->copyOptionsFrom(opts);
4660 _field_per_mesh[0]->writeLL(fid,nasc);
4664 * 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.
4665 * If false is returned the memory allocation is not required.
4667 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
4669 if(_nb_of_tuples_to_be_allocated>=0)
4671 getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4672 _nb_of_tuples_to_be_allocated=-2;
4675 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4677 if(_nb_of_tuples_to_be_allocated==-1)
4678 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4679 if(_nb_of_tuples_to_be_allocated<-3)
4680 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4681 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4684 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
4686 med_int numdt,numit;
4690 med_int meshnumdt,meshnumit;
4691 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4692 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt));
4693 MEDFILESAFECALLERRD0(MEDfield23ComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit));
4694 if(_iteration!=numdt || _order!=numit)
4695 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4696 _field_per_mesh.resize(nmesh);
4701 std::string meshNameCpp(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
4702 mm=ms->getMeshWithName(meshNameCpp);
4705 for(int i=0;i<nmesh;i++)
4706 _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i,meshnumdt,meshnumit,nasc,mm,entities);
4707 _nb_of_tuples_to_be_allocated=0;
4708 for(int i=0;i<nmesh;i++)
4709 _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4712 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
4714 allocIfNecessaryTheArrayToReceiveDataFromFile();
4715 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4716 (*it)->loadBigArraysRecursively(fid,nasc);
4719 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
4721 if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4722 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4723 (*it)->loadBigArraysRecursively(fid,nasc);
4726 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
4728 loadOnlyStructureOfDataRecursively(fid,nasc,ms,entities);
4729 loadBigArraysRecursively(fid,nasc);
4732 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
4734 DataArray *thisArr(getUndergroundDataArray());
4735 if(thisArr && thisArr->isAllocated())
4737 _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
4738 thisArr->desallocate();
4742 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
4744 return _dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MCAuto< MEDFileFieldPerMesh >);
4747 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
4749 std::vector<const BigMemoryObject *> ret;
4750 if(getUndergroundDataArray())
4751 ret.push_back(getUndergroundDataArray());
4752 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4753 ret.push_back((const MEDFileFieldPerMesh *)*it);
4758 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4759 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4760 * "Sort By Type"), if not, an exception is thrown.
4761 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
4762 * \param [in] arr - the array of values.
4763 * \param [in,out] glob - the global data where profiles and localization present in
4764 * \a field, if any, are added.
4765 * \throw If the name of \a field is empty.
4766 * \throw If the data array of \a field is not set.
4767 * \throw If \a this->_arr is already allocated but has different number of components
4769 * \throw If the underlying mesh of \a field has no name.
4770 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4772 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4774 const MEDCouplingMesh *mesh=field->getMesh();
4776 TypeOfField type=field->getTypeOfField();
4777 std::vector<DataArrayInt *> dummy;
4778 int start=copyTinyInfoFrom(field,arr);
4779 int pos=addNewEntryIfNecessary(mesh);
4782 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4783 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4786 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4790 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4791 * of a given mesh are used as the support of the given field (a real support is not used).
4792 * Elements of the given mesh must be sorted suitable for writing to MED file.
4793 * Order of underlying mesh entities of the given field specified by \a profile parameter
4794 * is not prescribed; this method permutes field values to have them sorted by element
4795 * type as required for writing to MED file. A new profile is added only if no equal
4796 * profile is missing.
4797 * \param [in] field - the field to add to \a this. The field double values are ignored.
4798 * \param [in] arrOfVals - the values of the field \a field used.
4799 * \param [in] mesh - the supporting mesh of \a field.
4800 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4801 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
4802 * \param [in,out] glob - the global data where profiles and localization present in
4803 * \a field, if any, are added.
4804 * \throw If either \a field or \a mesh or \a profile has an empty name.
4805 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4806 * \throw If the data array of \a field is not set.
4807 * \throw If \a this->_arr is already allocated but has different number of components
4809 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4810 * \sa setFieldNoProfileSBT()
4812 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4815 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
4816 if(!arrOfVals || !arrOfVals->isAllocated())
4817 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
4818 TypeOfField type=field->getTypeOfField();
4819 std::vector<DataArrayInt *> idsInPflPerType;
4820 std::vector<DataArrayInt *> idsPerType;
4821 std::vector<int> code,code2;
4822 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
4825 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4826 std::vector< MCAuto<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
4827 std::vector< MCAuto<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin());
4828 std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
4830 MCAuto<MEDCouplingFieldDouble> field2=field->clone(false);
4831 int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
4832 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4834 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4835 throw INTERP_KERNEL::Exception(oss.str());
4838 int start=copyTinyInfoFrom(field,arrOfVals);
4839 code2=m->getDistributionOfTypes();
4841 int pos=addNewEntryIfNecessary(m);
4842 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4846 if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
4847 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
4848 std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
4849 std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
4850 int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
4851 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4853 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4854 throw INTERP_KERNEL::Exception(oss.str());
4856 int start=copyTinyInfoFrom(field,arrOfVals);
4857 int pos=addNewEntryIfNecessary(m);
4858 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4863 * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
4865 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
4867 if(_nb_of_tuples_to_be_allocated>=0)
4868 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 !");
4869 DataArray *arr(getOrCreateAndGetArray());
4870 arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
4871 _nb_of_tuples_to_be_allocated=-3;
4875 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4876 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4877 * larger by the size of \a field. Returns an id of the first not filled
4878 * tuple of \a this->_arr.
4879 * \param [in] field - the field to copy the info on components and the name from.
4880 * \return int - the id of first not initialized tuple of \a this->_arr.
4881 * \throw If the name of \a field is empty.
4882 * \throw If the data array of \a field is not set.
4883 * \throw If \a this->_arr is already allocated but has different number of components
4886 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
4889 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4890 std::string name(field->getName());
4891 setName(name.c_str());
4892 setDtUnit(field->getTimeUnit());
4894 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4896 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4897 if(!arr->isAllocated())
4898 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
4899 _dt=field->getTime(_iteration,_order);
4900 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4901 if(!getOrCreateAndGetArray()->isAllocated())
4903 allocNotFromFile(arr->getNumberOfTuples());
4908 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4909 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4910 getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
4911 _nb_of_tuples_to_be_allocated=-3;
4912 return oldNbOfTuples;
4917 * Returns number of components in \a this field
4918 * \return int - the number of components.
4920 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4922 return getOrCreateAndGetArray()->getNumberOfComponents();
4926 * Change info on components in \a this.
4927 * \throw If size of \a infos is not equal to the number of components already in \a this.
4929 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
4931 DataArray *arr=getOrCreateAndGetArray();
4932 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
4936 * Returns info on components of \a this field.
4937 * \return const std::vector<std::string>& - a sequence of strings each being an
4938 * information on _i_-th component.
4940 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
4942 const DataArray *arr=getOrCreateAndGetArray();
4943 return arr->getInfoOnComponents();
4947 * Returns a mutable info on components of \a this field.
4948 * \return std::vector<std::string>& - a sequence of strings each being an
4949 * information on _i_-th component.
4951 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
4953 DataArray *arr=getOrCreateAndGetArray();
4954 return arr->getInfoOnComponents();
4957 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const
4959 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4961 const MEDFileFieldPerMesh *fpm(*it);
4964 if(fpm->presenceOfMultiDiscPerGeoType())
4970 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh(const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4972 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 !";
4973 if(_field_per_mesh.empty())
4974 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is empty ! Nothing to extract !");
4975 if(_field_per_mesh.size()>1)
4976 throw INTERP_KERNEL::Exception(MSG0);
4977 if(_field_per_mesh[0].isNull())
4978 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is inconsistent !");
4979 const MEDFileFieldPerMesh *pm(_field_per_mesh[0]);
4980 std::set<TypeOfField> types;
4981 pm->fillTypesOfFieldAvailable(types);
4983 throw INTERP_KERNEL::Exception(MSG0);
4984 TypeOfField type(*types.begin());
4985 int meshDimRelToMax(0);
4990 int myDim(std::numeric_limits<int>::max());
4991 bool isUnique(pm->isUniqueLevel(myDim));
4993 throw INTERP_KERNEL::Exception(MSG0);
4994 meshDimRelToMax=myDim-mesh->getMeshDimension();
4995 if(meshDimRelToMax>0)
4996 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the mesh attached to field is not compatible with the field !");
4998 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,0/*renumPol*/,glob,mesh,arrOut,nasc);
5002 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5003 * \param [in] type - a spatial discretization of the new field.
5004 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5005 * \param [in] mName - a name of the supporting mesh.
5006 * \param [in] renumPol - specifies how to permute values of the result field according to
5007 * the optional numbers of cells and nodes, if any. The valid values are
5008 * - 0 - do not permute.
5009 * - 1 - permute cells.
5010 * - 2 - permute nodes.
5011 * - 3 - permute cells and nodes.
5013 * \param [in] glob - the global data storing profiles and localization.
5014 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5015 * caller is to delete this field using decrRef() as it is no more needed.
5016 * \throw If the MED file is not readable.
5017 * \throw If there is no mesh named \a mName in the MED file.
5018 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5019 * \throw If no field of \a this is lying on the mesh \a mName.
5020 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5022 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5024 MCAuto<MEDFileMesh> mm;
5026 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
5028 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
5029 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
5033 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5034 * \param [in] type - a spatial discretization of the new field.
5035 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5036 * \param [in] renumPol - specifies how to permute values of the result field according to
5037 * the optional numbers of cells and nodes, if any. The valid values are
5038 * - 0 - do not permute.
5039 * - 1 - permute cells.
5040 * - 2 - permute nodes.
5041 * - 3 - permute cells and nodes.
5043 * \param [in] glob - the global data storing profiles and localization.
5044 * \param [in] mesh - the supporting mesh.
5045 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5046 * caller is to delete this field using decrRef() as it is no more needed.
5047 * \throw If the MED file is not readable.
5048 * \throw If no field of \a this is lying on \a mesh.
5049 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5050 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5052 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5054 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax,false));
5055 const DataArrayInt *d(mesh->getNumberFieldAtLevel(meshDimRelToMax)),*e(mesh->getNumberFieldAtLevel(1));
5056 if(meshDimRelToMax==1)
5057 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
5058 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
5062 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
5064 * \param [in] type - a spatial discretization of the new field.
5065 * \param [in] mName - a name of the supporting mesh.
5066 * \param [in] renumPol - specifies how to permute values of the result field according to
5067 * the optional numbers of cells and nodes, if any. The valid values are
5068 * - 0 - do not permute.
5069 * - 1 - permute cells.
5070 * - 2 - permute nodes.
5071 * - 3 - permute cells and nodes.
5073 * \param [in] glob - the global data storing profiles and localization.
5074 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5075 * caller is to delete this field using decrRef() as it is no more needed.
5076 * \throw If the MED file is not readable.
5077 * \throw If there is no mesh named \a mName in the MED file.
5078 * \throw If there are no mesh entities in the mesh.
5079 * \throw If no field values of the given \a type are available.
5081 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5083 MCAuto<MEDFileMesh> mm;
5085 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
5087 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
5088 int absDim=getDimension();
5089 int meshDimRelToMax=absDim-mm->getMeshDimension();
5090 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
5094 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5095 * \param [in] type - a spatial discretization of the new field.
5096 * \param [in] renumPol - specifies how to permute values of the result field according to
5097 * the optional numbers of cells and nodes, if any. The valid values are
5098 * - 0 - do not permute.
5099 * - 1 - permute cells.
5100 * - 2 - permute nodes.
5101 * - 3 - permute cells and nodes.
5103 * \param [in] glob - the global data storing profiles and localization.
5104 * \param [in] mesh - the supporting mesh.
5105 * \param [in] cellRenum - the cell numbers array used for permutation of the result
5106 * field according to \a renumPol.
5107 * \param [in] nodeRenum - the node numbers array used for permutation of the result
5108 * field according to \a renumPol.
5109 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5110 * caller is to delete this field using decrRef() as it is no more needed.
5111 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5112 * \throw If no field of \a this is lying on \a mesh.
5113 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5115 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
5117 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
5118 int meshId=getMeshIdFromMeshName(mesh->getName());
5120 MCAuto<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
5125 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5132 throw INTERP_KERNEL::Exception(msg1);
5133 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5136 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
5138 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5139 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
5140 throw INTERP_KERNEL::Exception(oss.str());
5142 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
5143 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
5144 std::vector<DataArray *> arrOut2(1,arrOut);
5145 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
5146 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
5147 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
5154 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5156 throw INTERP_KERNEL::Exception(msg1);
5159 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
5161 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5162 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
5163 throw INTERP_KERNEL::Exception(oss.str());
5165 MCAuto<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
5166 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
5167 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
5168 ret->renumberNodes(nodeRenumSafe->getConstPointer());
5173 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
5178 * Returns values and a profile of the field of a given type lying on a given support.
5179 * \param [in] type - a spatial discretization of the field.
5180 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5181 * \param [in] mesh - the supporting mesh.
5182 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
5183 * field of interest lies on. If the field lies on all entities of the given
5184 * dimension, all ids in \a pfl are zero. The caller is to delete this array
5185 * using decrRef() as it is no more needed.
5186 * \param [in] glob - the global data storing profiles and localization.
5187 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
5188 * field. The caller is to delete this array using decrRef() as it is no more needed.
5189 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
5190 * \throw If no field of \a this is lying on \a mesh.
5191 * \throw If no field values of the given \a type are available.
5193 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
5195 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
5196 int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
5197 MCAuto<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
5198 ret->setName(nasc.getName().c_str());
5202 //= MEDFileField1TSWithoutSDA
5205 * Throws if a given value is not a valid (non-extended) relative dimension.
5206 * \param [in] meshDimRelToMax - the relative dimension value.
5207 * \throw If \a meshDimRelToMax > 0.
5209 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
5211 if(meshDimRelToMax>0)
5212 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
5216 * Checks if elements of a given mesh are in the order suitable for writing
5217 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
5218 * vector describing types of elements and their number.
5219 * \param [in] mesh - the mesh to check.
5220 * \return std::vector<int> - a vector holding for each element type (1) item of
5221 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
5222 * These values are in full-interlace mode.
5223 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
5225 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
5228 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
5229 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
5230 int nbOfTypes=geoTypes.size();
5231 std::vector<int> code(3*nbOfTypes);
5232 MCAuto<DataArrayInt> arr1=DataArrayInt::New();
5233 arr1->alloc(nbOfTypes,1);
5234 int *arrPtr=arr1->getPointer();
5235 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
5236 for(int i=0;i<nbOfTypes;i++,it++)
5237 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
5238 MCAuto<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
5239 const int *arrPtr2=arr2->getConstPointer();
5241 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
5244 int nbCells=mesh->getNumberOfCellsWithType(*it);
5245 code[3*pos]=(int)(*it);
5246 code[3*pos+1]=nbCells;
5247 code[3*pos+2]=-1;//no profiles
5249 std::vector<const DataArrayInt *> idsPerType;//no profiles
5250 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
5254 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
5259 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5261 return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5265 * Returns all attributes and values of parts of \a this field lying on a given mesh.
5266 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
5267 * item of every of returned sequences refers to the _i_-th part of \a this field.
5268 * Thus all sequences returned by this method are of the same length equal to number
5269 * of different types of supporting entities.<br>
5270 * A field part can include sub-parts with several different spatial discretizations,
5271 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
5272 * for example. Hence, some of the returned sequences contains nested sequences, and an item
5273 * of a nested sequence corresponds to a type of spatial discretization.<br>
5274 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
5275 * The overhead is due to selecting values into new instances of DataArrayDouble.
5276 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
5277 * for the case with only one underlying mesh. (Actually, the number of meshes is
5278 * not checked if \a mname == \c NULL).
5279 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
5280 * a field part is returned.
5281 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
5282 * A field part can include sub-parts with several different spatial discretizations,
5283 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and
5284 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT" for example.
5285 * This sequence is of the same length as \a types.
5286 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
5287 * discretization. A profile name can be empty.
5288 * Length of this and of nested sequences is the same as that of \a typesF.
5289 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
5290 * discretization. A localization name can be empty.
5291 * Length of this and of nested sequences is the same as that of \a typesF.
5292 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
5293 * per each type of spatial discretization within one mesh entity type.
5294 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
5295 * Length of this and of nested sequences is the same as that of \a typesF.
5296 * \throw If no field is lying on \a mname.
5298 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
5302 meshId=getMeshIdFromMeshName(mname);
5304 if(_field_per_mesh.empty())
5305 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
5306 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
5307 int nbOfRet=ret0.size();
5308 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
5309 for(int i=0;i<nbOfRet;i++)
5311 const std::vector< std::pair<int,int> >& p=ret0[i];
5312 int nbOfRet1=p.size();
5313 ret[i].resize(nbOfRet1);
5314 for(int j=0;j<nbOfRet1;j++)
5316 DataArrayDouble *tmp=_arr->selectByTupleIdSafeSlice(p[j].first,p[j].second,1);
5323 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
5328 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
5330 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
5331 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5332 ret->deepCpyLeavesFrom(*this);
5333 const DataArrayDouble *arr(_arr);
5336 MCAuto<DataArrayInt> arr2(arr->convertToIntArr());
5337 ret->setArray(arr2);
5343 * Returns a pointer to the underground DataArrayDouble instance and a
5344 * sequence describing parameters of a support of each part of \a this field. The
5345 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5346 * direct access to the field values. This method is intended for the field lying on one
5348 * \param [in,out] entries - the sequence describing parameters of a support of each
5349 * part of \a this field. Each item of this sequence consists of two parts. The
5350 * first part describes a type of mesh entity and an id of discretization of a
5351 * current field part. The second part describes a range of values [begin,end)
5352 * within the returned array relating to the current field part.
5353 * \return DataArrayDouble * - the pointer to the field values array.
5354 * \throw If the number of underlying meshes is not equal to 1.
5355 * \throw If no field values are available.
5356 * \sa getUndergroundDataArray()
5358 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5360 if(_field_per_mesh.size()!=1)
5361 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5362 if(_field_per_mesh[0]==0)
5363 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5364 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5365 return getUndergroundDataArrayTemplate();
5369 * Returns a pointer to the underground DataArrayDouble instance and a
5370 * sequence describing parameters of a support of each part of \a this field. The
5371 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5372 * direct access to the field values. This method is intended for the field lying on one
5374 * \param [in,out] entries - the sequence describing parameters of a support of each
5375 * part of \a this field. Each item of this sequence consists of two parts. The
5376 * first part describes a type of mesh entity and an id of discretization of a
5377 * current field part. The second part describes a range of values [begin,end)
5378 * within the returned array relating to the current field part.
5379 * \return DataArrayDouble * - the pointer to the field values array.
5380 * \throw If the number of underlying meshes is not equal to 1.
5381 * \throw If no field values are available.
5382 * \sa getUndergroundDataArray()
5384 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5386 return getUndergroundDataArrayDoubleExt(entries);
5389 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<double>(fieldName,csit,iteration,order)
5391 DataArrayDouble *arr(getOrCreateAndGetArrayTemplate());
5392 arr->setInfoAndChangeNbOfCompo(infos);
5395 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<double>()
5399 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
5401 MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
5402 ret->deepCpyLeavesFrom(*this);
5406 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCopy() const
5408 MCAuto<MEDFileField1TSWithoutSDA> ret=static_cast<MEDFileField1TSWithoutSDA *>(shallowCpy());
5409 if((const DataArrayDouble *)_arr)
5410 ret->_arr=_arr->deepCopy();
5414 //= MEDFileIntField1TSWithoutSDA
5416 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5418 return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5421 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<int>()
5425 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order,
5426 const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<int>(fieldName,csit,iteration,order)
5428 DataArrayInt *arr(getOrCreateAndGetArrayTemplate());
5429 arr->setInfoAndChangeNbOfCompo(infos);
5432 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
5437 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const
5439 MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
5440 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5441 ret->deepCpyLeavesFrom(*this);
5442 const DataArrayInt *arr(_arr);
5445 MCAuto<DataArrayDouble> arr2(arr->convertToDblArr());
5446 ret->setArray(arr2);
5452 * Returns a pointer to the underground DataArrayInt instance and a
5453 * sequence describing parameters of a support of each part of \a this field. The
5454 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5455 * direct access to the field values. This method is intended for the field lying on one
5457 * \param [in,out] entries - the sequence describing parameters of a support of each
5458 * part of \a this field. Each item of this sequence consists of two parts. The
5459 * first part describes a type of mesh entity and an id of discretization of a
5460 * current field part. The second part describes a range of values [begin,end)
5461 * within the returned array relating to the current field part.
5462 * \return DataArrayInt * - the pointer to the field values array.
5463 * \throw If the number of underlying meshes is not equal to 1.
5464 * \throw If no field values are available.
5465 * \sa getUndergroundDataArray()
5467 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5469 return getUndergroundDataArrayIntExt(entries);
5473 * Returns a pointer to the underground DataArrayInt instance and a
5474 * sequence describing parameters of a support of each part of \a this field. The
5475 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5476 * direct access to the field values. This method is intended for the field lying on one
5478 * \param [in,out] entries - the sequence describing parameters of a support of each
5479 * part of \a this field. Each item of this sequence consists of two parts. The
5480 * first part describes a type of mesh entity and an id of discretization of a
5481 * current field part. The second part describes a range of values [begin,end)
5482 * within the returned array relating to the current field part.
5483 * \return DataArrayInt * - the pointer to the field values array.
5484 * \throw If the number of underlying meshes is not equal to 1.
5485 * \throw If no field values are available.
5486 * \sa getUndergroundDataArray()
5488 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5490 if(_field_per_mesh.size()!=1)
5491 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5492 if(_field_per_mesh[0]==0)
5493 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5494 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5495 return getUndergroundDataArrayTemplate();
5498 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5500 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5501 ret->deepCpyLeavesFrom(*this);
5505 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCopy() const
5507 MCAuto<MEDFileIntField1TSWithoutSDA> ret=static_cast<MEDFileIntField1TSWithoutSDA *>(shallowCpy());
5508 if((const DataArrayInt *)_arr)
5509 ret->_arr=_arr->deepCopy();
5513 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5517 //= MEDFileAnyTypeField1TS
5519 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
5521 med_field_type typcha;
5523 std::vector<std::string> infos;
5524 std::string dtunit,fieldName;
5525 LocateField2(fid,0,true,fieldName,typcha,infos,dtunit);
5526 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5531 ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5536 ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5541 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] !";
5542 throw INTERP_KERNEL::Exception(oss.str());
5545 ret->setDtUnit(dtunit.c_str());
5546 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5548 med_int numdt,numit;
5550 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5551 ret->setTime(numdt,numit,dt);
5554 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5556 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5560 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
5561 try:MEDFileFieldGlobsReal(fid)
5563 _content=BuildContentFrom(fid,loadAll,ms);
5566 catch(INTERP_KERNEL::Exception& e)
5571 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5573 med_field_type typcha;
5574 std::vector<std::string> infos;
5577 int nbSteps=LocateField(fid,fieldName,iii,typcha,infos,dtunit);
5578 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5583 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5588 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5593 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] !";
5594 throw INTERP_KERNEL::Exception(oss.str());
5597 ret->setDtUnit(dtunit.c_str());
5598 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5602 std::ostringstream oss; oss << "MEDFileField1TS(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5603 throw INTERP_KERNEL::Exception(oss.str());
5606 med_int numdt,numit;
5608 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5609 ret->setTime(numdt,numit,dt);
5612 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5614 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5618 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5619 try:MEDFileFieldGlobsReal(fid)
5621 _content=BuildContentFrom(fid,fieldName,loadAll,ms);
5624 catch(INTERP_KERNEL::Exception& e)
5629 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c)
5632 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5633 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5635 MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
5636 ret->_content=c; c->incrRef();
5639 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5641 MCAuto<MEDFileIntField1TS> ret(MEDFileIntField1TS::New());
5642 ret->_content=c; c->incrRef();
5645 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5648 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, med_idt fid)
5650 MEDFileAnyTypeField1TS *ret(BuildNewInstanceFromContent(c));
5651 ret->setFileName(FileNameFromFID(fid));
5655 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
5657 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5658 return New(fid,loadAll);
5661 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, bool loadAll)
5663 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
5664 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5665 ret->loadGlobals(fid);
5669 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
5671 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5672 return New(fid,fieldName,loadAll);
5675 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
5677 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0));
5678 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5679 ret->loadGlobals(fid);
5683 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
5685 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5686 return New(fid,fieldName,iteration,order,loadAll);
5689 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
5691 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0));
5692 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5693 ret->loadGlobals(fid);
5697 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5699 med_field_type typcha;
5700 std::vector<std::string> infos;
5703 int nbOfStep2(LocateField(fid,fieldName,iii,typcha,infos,dtunit));
5704 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5709 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5714 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5719 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] !";
5720 throw INTERP_KERNEL::Exception(oss.str());
5723 ret->setDtUnit(dtunit.c_str());
5724 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5727 std::vector< std::pair<int,int> > dtits(nbOfStep2);
5728 for(int i=0;i<nbOfStep2 && !found;i++)
5730 med_int numdt,numit;
5732 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt));
5733 if(numdt==iteration && numit==order)
5739 dtits[i]=std::pair<int,int>(numdt,numit);
5743 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available iterations are : ";
5744 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5745 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5746 throw INTERP_KERNEL::Exception(oss.str());
5749 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5751 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5755 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5756 try:MEDFileFieldGlobsReal(fid)
5758 _content=BuildContentFrom(fid,fieldName,iteration,order,loadAll,ms);
5761 catch(INTERP_KERNEL::Exception& e)
5767 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5768 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5770 * \warning this is a shallow copy constructor
5772 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5774 if(!shallowCopyOfContent)
5776 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5777 otherPtr->incrRef();
5778 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5782 _content=other.shallowCpy();
5786 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)
5790 int nbFields=MEDnField(fid);
5791 if(fieldIdCFormat>=nbFields)
5793 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << FileNameFromFID(fid) << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5794 throw INTERP_KERNEL::Exception(oss.str());
5797 int ncomp(MEDfieldnComponent(fid,fieldIdCFormat+1));
5798 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5799 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5800 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5801 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5802 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5805 MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep));
5806 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5807 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5808 infos.clear(); infos.resize(ncomp);
5809 for(int j=0;j<ncomp;j++)
5810 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5815 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5818 * \return in case of success the number of time steps available for the field with name \a fieldName.
5820 int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const std::string& fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
5822 int nbFields=MEDnField(fid);
5824 std::vector<std::string> fns(nbFields);
5826 for(int i=0;i<nbFields && !found;i++)
5829 nbOfStep2=LocateField2(fid,i,false,tmp,typcha,infos,dtunitOut);
5831 found=(tmp==fieldName);
5837 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available fields are : ";
5838 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5839 oss << "\"" << *it << "\" ";
5840 throw INTERP_KERNEL::Exception(oss.str());
5846 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5847 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5848 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5849 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5850 * to keep a valid instance.
5851 * 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.
5852 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5853 * 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.
5855 * \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.
5856 * \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.
5857 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5858 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5859 * \param [in] newLocName is the new localization name.
5860 * \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.
5861 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5863 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
5865 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5866 std::string oldPflName=disc->getProfile();
5867 std::vector<std::string> vv=getPflsReallyUsedMulti();
5868 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5869 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5871 disc->setProfile(newPflName);
5872 DataArrayInt *pfl=getProfile(oldPflName.c_str());
5873 pfl->setName(newPflName);
5877 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5878 throw INTERP_KERNEL::Exception(oss.str());
5883 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5884 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5885 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5886 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5887 * to keep a valid instance.
5888 * 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.
5889 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5890 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5891 * 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.
5893 * \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.
5894 * \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.
5895 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5896 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5897 * \param [in] newLocName is the new localization name.
5898 * \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.
5899 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
5901 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
5903 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5904 std::string oldLocName=disc->getLocalization();
5905 std::vector<std::string> vv=getLocsReallyUsedMulti();
5906 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
5907 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
5909 disc->setLocalization(newLocName);
5910 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
5911 loc.setName(newLocName);
5915 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
5916 throw INTERP_KERNEL::Exception(oss.str());
5920 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
5922 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5924 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
5928 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
5930 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5932 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
5937 * This method alloc the arrays and load potentially huge arrays contained in this field.
5938 * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
5939 * This method can be also called to refresh or reinit values from a file.
5941 * \throw If the fileName is not set or points to a non readable MED file.
5942 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5944 void MEDFileAnyTypeField1TS::loadArrays()
5946 if(getFileName().empty())
5947 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
5948 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
5949 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
5953 * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
5954 * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
5955 * this method does not throw if \a this does not come from file read.
5957 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
5959 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
5961 if(!getFileName().empty())
5963 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
5964 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
5969 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
5970 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
5971 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
5973 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
5975 void MEDFileAnyTypeField1TS::unloadArrays()
5977 contentNotNullBase()->unloadArrays();
5981 * 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.
5982 * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
5983 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
5985 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5987 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
5989 if(!getFileName().empty())
5990 contentNotNullBase()->unloadArrays();
5993 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
5995 int nbComp(getNumberOfComponents());
5996 INTERP_KERNEL::AutoPtr<char> comp(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
5997 INTERP_KERNEL::AutoPtr<char> unit(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
5998 for(int i=0;i<nbComp;i++)
6000 std::string info=getInfo()[i];
6002 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
6003 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
6004 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
6006 if(getName().empty())
6007 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
6008 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
6009 writeGlobals(fid,*this);
6010 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
6013 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
6015 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
6018 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
6020 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
6021 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
6026 * Returns a string describing \a this field. This string is outputted
6027 * by \c print Python command.
6029 std::string MEDFileAnyTypeField1TS::simpleRepr() const
6031 std::ostringstream oss;
6032 contentNotNullBase()->simpleRepr(0,oss,-1);
6033 simpleReprGlobs(oss);
6038 * This method returns all profiles whose name is non empty used.
6039 * \b WARNING If profile is used several times it will be reported \b only \b once.
6040 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
6042 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
6044 return contentNotNullBase()->getPflsReallyUsed2();
6048 * This method returns all localizations whose name is non empty used.
6049 * \b WARNING If localization is used several times it will be reported \b only \b once.
6051 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
6053 return contentNotNullBase()->getLocsReallyUsed2();
6057 * This method returns all profiles whose name is non empty used.
6058 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
6060 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
6062 return contentNotNullBase()->getPflsReallyUsedMulti2();
6066 * This method returns all localizations whose name is non empty used.
6067 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
6069 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
6071 return contentNotNullBase()->getLocsReallyUsedMulti2();
6074 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6076 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
6079 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6081 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
6084 int MEDFileAnyTypeField1TS::getDimension() const
6086 return contentNotNullBase()->getDimension();
6089 int MEDFileAnyTypeField1TS::getIteration() const
6091 return contentNotNullBase()->getIteration();
6094 int MEDFileAnyTypeField1TS::getOrder() const
6096 return contentNotNullBase()->getOrder();
6099 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
6101 return contentNotNullBase()->getTime(iteration,order);
6104 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
6106 contentNotNullBase()->setTime(iteration,order,val);
6109 std::string MEDFileAnyTypeField1TS::getName() const
6111 return contentNotNullBase()->getName();
6114 void MEDFileAnyTypeField1TS::setName(const std::string& name)
6116 contentNotNullBase()->setName(name);
6119 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
6121 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
6124 std::string MEDFileAnyTypeField1TS::getDtUnit() const
6126 return contentNotNullBase()->getDtUnit();
6129 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
6131 contentNotNullBase()->setDtUnit(dtUnit);
6134 std::string MEDFileAnyTypeField1TS::getMeshName() const
6136 return contentNotNullBase()->getMeshName();
6139 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
6141 contentNotNullBase()->setMeshName(newMeshName);
6144 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
6146 return contentNotNullBase()->changeMeshNames(modifTab);
6149 int MEDFileAnyTypeField1TS::getMeshIteration() const
6151 return contentNotNullBase()->getMeshIteration();
6154 int MEDFileAnyTypeField1TS::getMeshOrder() const
6156 return contentNotNullBase()->getMeshOrder();
6159 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
6161 return contentNotNullBase()->getNumberOfComponents();
6164 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
6166 return contentNotNullBase()->isDealingTS(iteration,order);
6169 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
6171 return contentNotNullBase()->getDtIt();
6174 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
6176 contentNotNullBase()->fillIteration(p);
6179 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
6181 contentNotNullBase()->fillTypesOfFieldAvailable(types);
6184 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
6186 contentNotNullBase()->setInfo(infos);
6189 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
6191 return contentNotNullBase()->getInfo();
6193 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
6195 return contentNotNullBase()->getInfo();
6198 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
6200 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
6203 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
6205 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6208 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
6210 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6213 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
6215 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
6218 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
6220 return contentNotNullBase()->getTypesOfFieldAvailable();
6223 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,
6224 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6226 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
6230 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
6231 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
6232 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
6234 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
6236 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6238 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
6239 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
6240 std::size_t sz(contentsSplit.size());
6241 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6242 for(std::size_t i=0;i<sz;i++)
6244 ret[i]=shallowCpy();
6245 ret[i]->_content=contentsSplit[i];
6251 * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
6252 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6254 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
6256 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6258 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
6259 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
6260 std::size_t sz(contentsSplit.size());
6261 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6262 for(std::size_t i=0;i<sz;i++)
6264 ret[i]=shallowCpy();
6265 ret[i]->_content=contentsSplit[i];
6271 * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this.
6272 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6274 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const
6276 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6278 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !");
6279 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
6280 std::size_t sz(contentsSplit.size());
6281 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6282 for(std::size_t i=0;i<sz;i++)
6284 ret[i]=shallowCpy();
6285 ret[i]->_content=contentsSplit[i];
6290 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCopy() const
6292 MCAuto<MEDFileAnyTypeField1TS> ret=shallowCpy();
6293 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
6294 ret->_content=_content->deepCopy();
6295 ret->deepCpyGlobs(*this);
6299 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
6301 return contentNotNullBase()->copyTinyInfoFrom(field,arr);
6307 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6308 * the first field that has been read from a specified MED file.
6309 * \param [in] fileName - the name of the MED file to read.
6310 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6311 * is to delete this field using decrRef() as it is no more needed.
6312 * \throw If reading the file fails.
6314 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll)
6316 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6317 return New(fid,loadAll);
6320 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, bool loadAll)
6322 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,loadAll,0));
6323 ret->contentNotNull();
6328 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6329 * a given field that has been read from a specified MED file.
6330 * \param [in] fileName - the name of the MED file to read.
6331 * \param [in] fieldName - the name of the field to read.
6332 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6333 * is to delete this field using decrRef() as it is no more needed.
6334 * \throw If reading the file fails.
6335 * \throw If there is no field named \a fieldName in the file.
6337 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6339 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6340 return New(fid,fieldName,loadAll);
6343 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
6345 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,fieldName,loadAll,0));
6346 ret->contentNotNull();
6351 * Returns a new instance of MEDFileField1TS holding data of a given time step of
6352 * a given field that has been read from a specified MED file.
6353 * \param [in] fileName - the name of the MED file to read.
6354 * \param [in] fieldName - the name of the field to read.
6355 * \param [in] iteration - the iteration number of a required time step.
6356 * \param [in] order - the iteration order number of required time step.
6357 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6358 * is to delete this field using decrRef() as it is no more needed.
6359 * \throw If reading the file fails.
6360 * \throw If there is no field named \a fieldName in the file.
6361 * \throw If the required time step is missing from the file.
6363 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6365 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6366 return New(fid,fieldName,iteration,order,loadAll);
6369 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
6371 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,fieldName,iteration,order,loadAll,0));
6372 ret->contentNotNull();
6377 * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6378 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6380 * Returns a new instance of MEDFileField1TS holding either a shallow copy
6381 * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
6382 * \warning this is a shallow copy constructor
6383 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
6384 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
6385 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6386 * is to delete this field using decrRef() as it is no more needed.
6388 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6390 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(other,shallowCopyOfContent));
6391 ret->contentNotNull();
6396 * Returns a new empty instance of MEDFileField1TS.
6397 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6398 * is to delete this field using decrRef() as it is no more needed.
6400 MEDFileField1TS *MEDFileField1TS::New()
6402 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS);
6403 ret->contentNotNull();
6408 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
6409 * following the given input policy.
6411 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6412 * By default (true) the globals are deeply copied.
6413 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
6415 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
6417 MCAuto<MEDFileIntField1TS> ret;
6418 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6421 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
6423 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
6424 MCAuto<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
6425 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc));
6428 ret=MEDFileIntField1TS::New();
6430 ret->deepCpyGlobs(*this);
6432 ret->shallowCpyGlobs(*this);
6436 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const
6438 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6440 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
6441 const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
6443 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 !");
6447 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull()
6449 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6451 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
6452 MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
6454 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 !");
6458 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
6461 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
6463 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
6464 DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6466 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6467 f->setArray(arrOutC);
6470 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MCAuto<DataArray>& arr)
6473 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
6474 DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6476 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6482 * Return an extraction of \a this using \a extractDef map to specify the extraction.
6483 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
6485 * \return A new object that the caller is responsible to deallocate.
6486 * \sa MEDFileUMesh::deduceNodeSubPartFromCellSubPart , MEDFileUMesh::extractPart
6488 MEDFileField1TS *MEDFileField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
6491 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : input mesh is NULL !");
6492 MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
6493 std::vector<TypeOfField> tof(getTypesOfFieldAvailable());
6494 for(std::vector<TypeOfField>::const_iterator it0=tof.begin();it0!=tof.end();it0++)
6496 if((*it0)!=ON_NODES)
6498 std::vector<int> levs;
6499 getNonEmptyLevels(mm->getName(),levs);
6500 for(std::vector<int>::const_iterator lev=levs.begin();lev!=levs.end();lev++)
6502 std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(*lev));
6503 if(it2!=extractDef.end())
6505 MCAuto<DataArrayInt> t((*it2).second);
6507 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6508 MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_CELLS,(*lev),mm));
6509 MCAuto<MEDCouplingFieldDouble> fOut(f->buildSubPart(t));
6510 ret->setFieldNoProfileSBT(fOut);
6516 std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(1));
6517 if(it2==extractDef.end())
6518 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a NODE field and no extract array available for NODE !");
6519 MCAuto<DataArrayInt> t((*it2).second);
6521 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6522 MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_NODES,0,mm));
6523 MCAuto<MEDCouplingFieldDouble> fOut(f->deepCopy());
6524 DataArrayDouble *arr(f->getArray());
6525 MCAuto<DataArrayDouble> newArr(arr->selectByTupleIdSafe(t->begin(),t->end()));
6526 fOut->setArray(newArr);
6527 ret->setFieldNoProfileSBT(fOut);
6533 MEDFileField1TS::MEDFileField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
6534 try:MEDFileAnyTypeField1TS(fid,loadAll,ms)
6537 catch(INTERP_KERNEL::Exception& e)
6540 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6541 try:MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms)
6544 catch(INTERP_KERNEL::Exception& e)
6547 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6548 try:MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms)
6551 catch(INTERP_KERNEL::Exception& e)
6555 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6556 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6558 * \warning this is a shallow copy constructor
6560 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6561 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6564 catch(INTERP_KERNEL::Exception& e)
6567 MEDFileField1TS::MEDFileField1TS()
6569 _content=new MEDFileField1TSWithoutSDA;
6573 * 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
6574 * method should be called (getFieldOnMeshAtLevel for example).
6575 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
6577 * \param [in] mesh - the mesh the field is lying on
6578 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6579 * caller is to delete this field using decrRef() as it is no more needed.
6581 MEDCouplingFieldDouble *MEDFileField1TS::field(const MEDFileMesh *mesh) const
6583 MCAuto<DataArray> arrOut;
6584 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
6585 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6590 * Returns a new MEDCouplingFieldDouble of a given type lying on
6591 * mesh entities of a given dimension of the first mesh in MED file. If \a this field
6592 * has not been constructed via file reading, an exception is thrown.
6593 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6594 * \param [in] type - a spatial discretization of interest.
6595 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6596 * \param [in] renumPol - specifies how to permute values of the result field according to
6597 * the optional numbers of cells and nodes, if any. The valid values are
6598 * - 0 - do not permute.
6599 * - 1 - permute cells.
6600 * - 2 - permute nodes.
6601 * - 3 - permute cells and nodes.
6603 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6604 * caller is to delete this field using decrRef() as it is no more needed.
6605 * \throw If \a this field has not been constructed via file reading.
6606 * \throw If the MED file is not readable.
6607 * \throw If there is no mesh in the MED file.
6608 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6609 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6610 * \sa getFieldOnMeshAtLevel()
6612 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6614 if(getFileName().empty())
6615 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6616 MCAuto<DataArray> arrOut;
6617 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
6618 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6623 * Returns a new MEDCouplingFieldDouble of a given type lying on
6624 * the top level cells of the first mesh in MED file. If \a this field
6625 * has not been constructed via file reading, an exception is thrown.
6626 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6627 * \param [in] type - a spatial discretization of interest.
6628 * \param [in] renumPol - specifies how to permute values of the result field according to
6629 * the optional numbers of cells and nodes, if any. The valid values are
6630 * - 0 - do not permute.
6631 * - 1 - permute cells.
6632 * - 2 - permute nodes.
6633 * - 3 - permute cells and nodes.
6635 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6636 * caller is to delete this field using decrRef() as it is no more needed.
6637 * \throw If \a this field has not been constructed via file reading.
6638 * \throw If the MED file is not readable.
6639 * \throw If there is no mesh in the MED file.
6640 * \throw If no field values of the given \a type.
6641 * \throw If no field values lying on the top level support.
6642 * \sa getFieldAtLevel()
6644 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
6646 if(getFileName().empty())
6647 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6648 MCAuto<DataArray> arrOut;
6649 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
6650 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6655 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6656 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6657 * \param [in] type - a spatial discretization of the new field.
6658 * \param [in] mesh - the supporting mesh.
6659 * \param [in] renumPol - specifies how to permute values of the result field according to
6660 * the optional numbers of cells and nodes, if any. The valid values are
6661 * - 0 - do not permute.
6662 * - 1 - permute cells.
6663 * - 2 - permute nodes.
6664 * - 3 - permute cells and nodes.
6666 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6667 * caller is to delete this field using decrRef() as it is no more needed.
6668 * \throw If no field of \a this is lying on \a mesh.
6669 * \throw If the mesh is empty.
6670 * \throw If no field values of the given \a type are available.
6671 * \sa getFieldAtLevel()
6672 * \sa getFieldOnMeshAtLevel()
6674 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
6676 MCAuto<DataArray> arrOut;
6677 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
6678 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6683 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6684 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6685 * \param [in] type - a spatial discretization of interest.
6686 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6687 * \param [in] mesh - the supporting mesh.
6688 * \param [in] renumPol - specifies how to permute values of the result field according to
6689 * the optional numbers of cells and nodes, if any. The valid values are
6690 * - 0 - do not permute.
6691 * - 1 - permute cells.
6692 * - 2 - permute nodes.
6693 * - 3 - permute cells and nodes.
6695 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6696 * caller is to delete this field using decrRef() as it is no more needed.
6697 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6698 * \throw If no field of \a this is lying on \a mesh.
6699 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6700 * \sa getFieldAtLevel()
6701 * \sa getFieldOnMeshAtLevel()
6703 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
6705 MCAuto<DataArray> arrOut;
6706 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
6707 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6712 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6713 * This method is called "Old" because in MED3 norm a field has only one meshName
6714 * attached, so this method is for readers of MED2 files. If \a this field
6715 * has not been constructed via file reading, an exception is thrown.
6716 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6717 * \param [in] type - a spatial discretization of interest.
6718 * \param [in] mName - a name of the supporting mesh.
6719 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6720 * \param [in] renumPol - specifies how to permute values of the result field according to
6721 * the optional numbers of cells and nodes, if any. The valid values are
6722 * - 0 - do not permute.
6723 * - 1 - permute cells.
6724 * - 2 - permute nodes.
6725 * - 3 - permute cells and nodes.
6727 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6728 * caller is to delete this field using decrRef() as it is no more needed.
6729 * \throw If the MED file is not readable.
6730 * \throw If there is no mesh named \a mName in the MED file.
6731 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6732 * \throw If \a this field has not been constructed via file reading.
6733 * \throw If no field of \a this is lying on the mesh named \a mName.
6734 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6735 * \sa getFieldAtLevel()
6737 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
6739 if(getFileName().empty())
6740 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6741 MCAuto<DataArray> arrOut;
6742 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull()));
6743 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6748 * Returns values and a profile of the field of a given type lying on a given support.
6749 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6750 * \param [in] type - a spatial discretization of the field.
6751 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6752 * \param [in] mesh - the supporting mesh.
6753 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6754 * field of interest lies on. If the field lies on all entities of the given
6755 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6756 * using decrRef() as it is no more needed.
6757 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6758 * field. The caller is to delete this array using decrRef() as it is no more needed.
6759 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6760 * \throw If no field of \a this is lying on \a mesh.
6761 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6763 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6765 MCAuto<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6766 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
6770 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6771 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6772 * "Sort By Type"), if not, an exception is thrown.
6773 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6774 * \param [in] field - the field to add to \a this.
6775 * \throw If the name of \a field is empty.
6776 * \throw If the data array of \a field is not set.
6777 * \throw If the data array is already allocated but has different number of components
6779 * \throw If the underlying mesh of \a field has no name.
6780 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6782 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
6785 contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
6789 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6790 * can be an aggregation of several MEDCouplingFieldDouble instances.
6791 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6792 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6795 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6796 * A new profile is added only if no equal profile is missing.
6797 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6798 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
6799 * \param [in] mesh - the supporting mesh of \a field.
6800 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6801 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6802 * \throw If either \a field or \a mesh or \a profile has an empty name.
6803 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6804 * \throw If the data array of \a field is not set.
6805 * \throw If the data array of \a this is already allocated but has different number of
6806 * components than \a field.
6807 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6808 * \sa setFieldNoProfileSBT()
6810 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6813 contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6816 MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const
6818 return new MEDFileField1TS(*this);
6821 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const
6823 return contentNotNull()->getUndergroundDataArrayTemplate();
6826 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
6828 return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
6831 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6832 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6834 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6837 //= MEDFileIntField1TS
6839 MEDFileIntField1TS *MEDFileIntField1TS::New()
6841 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS);
6842 ret->contentNotNull();
6846 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll)
6848 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6849 return MEDFileIntField1TS::New(fid,loadAll);
6852 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, bool loadAll)
6854 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,loadAll,0));
6855 ret->contentNotNull();
6859 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6861 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6862 return MEDFileIntField1TS::New(fid,fieldName,loadAll);
6865 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
6867 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,loadAll,0));
6868 ret->contentNotNull();
6872 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6874 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6875 return MEDFileIntField1TS::New(fid,fieldName,iteration,order,loadAll);
6878 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
6880 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,iteration,order,loadAll,0));
6881 ret->contentNotNull();
6885 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6887 MCAuto<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6888 ret->contentNotNull();
6892 MEDFileIntField1TS::MEDFileIntField1TS()
6894 _content=new MEDFileIntField1TSWithoutSDA;
6897 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
6898 try:MEDFileAnyTypeField1TS(fid,loadAll,ms)
6901 catch(INTERP_KERNEL::Exception& e)
6904 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6905 try:MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms)
6908 catch(INTERP_KERNEL::Exception& e)
6911 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6912 try:MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms)
6915 catch(INTERP_KERNEL::Exception& e)
6919 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6920 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6922 * \warning this is a shallow copy constructor
6924 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6928 MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const
6930 return new MEDFileIntField1TS(*this);
6934 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
6935 * following the given input policy.
6937 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6938 * By default (true) the globals are deeply copied.
6939 * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
6941 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const
6943 MCAuto<MEDFileField1TS> ret;
6944 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6947 const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
6949 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
6950 MCAuto<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
6951 ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc));
6954 ret=MEDFileField1TS::New();
6956 ret->deepCpyGlobs(*this);
6958 ret->shallowCpyGlobs(*this);
6963 * Adds a MEDCouplingFieldInt to \a this. The underlying mesh of the given field is
6964 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6965 * "Sort By Type"), if not, an exception is thrown.
6966 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6967 * \param [in] field - the field to add to \a this.
6968 * \throw If the name of \a field is empty.
6969 * \throw If the data array of \a field is not set.
6970 * \throw If the data array is already allocated but has different number of components
6972 * \throw If the underlying mesh of \a field has no name.
6973 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6975 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldInt *field)
6977 MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
6979 contentNotNull()->setFieldNoProfileSBT(field2,field->getArray(),*this,*contentNotNull());
6983 * Adds a MEDCouplingFieldInt to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6984 * can be an aggregation of several MEDCouplingFieldDouble instances.
6985 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6986 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6989 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6990 * A new profile is added only if no equal profile is missing.
6991 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6992 * \param [in] field - the field to add to \a this.
6993 * \param [in] mesh - the supporting mesh of \a field.
6994 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6995 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6996 * \throw If either \a field or \a mesh or \a profile has an empty name.
6997 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6998 * \throw If the data array of \a field is not set.
6999 * \throw If the data array of \a this is already allocated but has different number of
7000 * components than \a field.
7001 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
7002 * \sa setFieldNoProfileSBT()
7004 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
7006 MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
7008 contentNotNull()->setFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
7011 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const
7013 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7015 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
7016 const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
7018 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 !");
7022 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
7024 if(getFileName().empty())
7025 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7026 MCAuto<DataArray> arrOut;
7027 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
7028 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7032 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MCAuto<DataArray>& arr)
7035 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
7036 DataArrayInt *arrC(dynamic_cast<DataArrayInt *>((DataArray *)arr));
7038 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
7043 MCAuto<MEDCouplingFieldInt> MEDFileIntField1TS::SetDataArrayDoubleInIntField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
7046 double t0(f->getTime(t1,t2));
7047 MCAuto<DataArrayInt> arr2(DynamicCastSafe<DataArray,DataArrayInt>(arr));
7048 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
7049 MCAuto<MEDCouplingFieldInt> ret(MEDCouplingFieldInt::New(*ft));
7050 ret->setTime(t0,t1,t2); ret->setArray(arr2);
7054 MCAuto<MEDCouplingFieldDouble> MEDFileIntField1TS::ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f)
7057 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ConvertFieldIntToFieldDouble : null input field !");
7059 double t0(f->getTime(t1,t2));
7060 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
7061 MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(*ft));
7062 ret->setTime(t0,t1,t2);
7066 MEDFileIntField1TS *MEDFileIntField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
7068 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::extractPart : not implemented yet !");
7072 * 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
7073 * method should be called (getFieldOnMeshAtLevel for example).
7074 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
7076 * \param [in] mesh - the mesh the field is lying on
7077 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
7078 * caller is to delete this field using decrRef() as it is no more needed.
7080 MEDCouplingFieldInt *MEDFileIntField1TS::field(const MEDFileMesh *mesh) const
7082 MCAuto<DataArray> arrOut;
7083 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
7084 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7089 * Returns a new MEDCouplingFieldInt of a given type lying on
7090 * the top level cells of the first mesh in MED file. If \a this field
7091 * has not been constructed via file reading, an exception is thrown.
7092 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7093 * \param [in] type - a spatial discretization of interest.
7094 * \param [in] renumPol - specifies how to permute values of the result field according to
7095 * the optional numbers of cells and nodes, if any. The valid values are
7096 * - 0 - do not permute.
7097 * - 1 - permute cells.
7098 * - 2 - permute nodes.
7099 * - 3 - permute cells and nodes.
7101 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7102 * caller is to delete this field using decrRef() as it is no more needed.
7103 * \throw If \a this field has not been constructed via file reading.
7104 * \throw If the MED file is not readable.
7105 * \throw If there is no mesh in the MED file.
7106 * \throw If no field values of the given \a type.
7107 * \throw If no field values lying on the top level support.
7108 * \sa getFieldAtLevel()
7110 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
7112 if(getFileName().empty())
7113 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
7114 MCAuto<DataArray> arrOut;
7115 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
7116 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7121 * Returns a new MEDCouplingFieldInt of given type lying on a given mesh.
7122 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7123 * \param [in] type - a spatial discretization of the new field.
7124 * \param [in] mesh - the supporting mesh.
7125 * \param [in] renumPol - specifies how to permute values of the result field according to
7126 * the optional numbers of cells and nodes, if any. The valid values are
7127 * - 0 - do not permute.
7128 * - 1 - permute cells.
7129 * - 2 - permute nodes.
7130 * - 3 - permute cells and nodes.
7132 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7133 * caller is to delete this field using decrRef() as it is no more needed.
7134 * \throw If no field of \a this is lying on \a mesh.
7135 * \throw If the mesh is empty.
7136 * \throw If no field values of the given \a type are available.
7137 * \sa getFieldAtLevel()
7138 * \sa getFieldOnMeshAtLevel()
7140 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
7142 MCAuto<DataArray> arrOut;
7143 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
7144 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7149 * Returns a new MEDCouplingFieldInt of a given type lying on a given support.
7150 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7151 * \param [in] type - a spatial discretization of interest.
7152 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7153 * \param [in] mesh - the supporting mesh.
7154 * \param [in] renumPol - specifies how to permute values of the result field according to
7155 * the optional numbers of cells and nodes, if any. The valid values are
7156 * - 0 - do not permute.
7157 * - 1 - permute cells.
7158 * - 2 - permute nodes.
7159 * - 3 - permute cells and nodes.
7161 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7162 * caller is to delete this field using decrRef() as it is no more needed.
7163 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7164 * \throw If no field of \a this is lying on \a mesh.
7165 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7166 * \sa getFieldAtLevel()
7167 * \sa getFieldOnMeshAtLevel()
7169 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
7171 MCAuto<DataArray> arrOut;
7172 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
7173 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7178 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
7179 * This method is called "Old" because in MED3 norm a field has only one meshName
7180 * attached, so this method is for readers of MED2 files. If \a this field
7181 * has not been constructed via file reading, an exception is thrown.
7182 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7183 * \param [in] type - a spatial discretization of interest.
7184 * \param [in] mName - a name of the supporting mesh.
7185 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7186 * \param [in] renumPol - specifies how to permute values of the result field according to
7187 * the optional numbers of cells and nodes, if any. The valid values are
7188 * - 0 - do not permute.
7189 * - 1 - permute cells.
7190 * - 2 - permute nodes.
7191 * - 3 - permute cells and nodes.
7193 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7194 * caller is to delete this field using decrRef() as it is no more needed.
7195 * \throw If the MED file is not readable.
7196 * \throw If there is no mesh named \a mName in the MED file.
7197 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7198 * \throw If \a this field has not been constructed via file reading.
7199 * \throw If no field of \a this is lying on the mesh named \a mName.
7200 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7201 * \sa getFieldAtLevel()
7203 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
7205 if(getFileName().empty())
7206 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7207 MCAuto<DataArray> arrOut;
7208 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
7209 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7214 * Returns values and a profile of the field of a given type lying on a given support.
7215 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7216 * \param [in] type - a spatial discretization of the field.
7217 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7218 * \param [in] mesh - the supporting mesh.
7219 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
7220 * field of interest lies on. If the field lies on all entities of the given
7221 * dimension, all ids in \a pfl are zero. The caller is to delete this array
7222 * using decrRef() as it is no more needed.
7223 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
7224 * field. The caller is to delete this array using decrRef() as it is no more needed.
7225 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7226 * \throw If no field of \a this is lying on \a mesh.
7227 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7229 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
7231 MCAuto<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
7232 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
7235 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull()
7237 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7239 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
7240 MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
7242 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 !");
7246 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const
7248 return contentNotNull()->getUndergroundDataArrayTemplate();
7251 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
7253 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
7257 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileFieldNameScope(fieldName)
7262 * \param [in] fieldId field id in C mode
7264 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7266 med_field_type typcha;
7267 std::string dtunitOut;
7268 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fieldId,false,_name,typcha,_infos,dtunitOut));
7269 setDtUnit(dtunitOut.c_str());
7270 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities);
7273 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)
7274 try:MEDFileFieldNameScope(fieldName),_infos(infos)
7276 setDtUnit(dtunit.c_str());
7277 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities);
7279 catch(INTERP_KERNEL::Exception& e)
7284 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
7286 std::size_t ret(_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MCAuto<MEDFileField1TSWithoutSDA>));
7287 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7288 ret+=(*it).capacity();
7292 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
7294 std::vector<const BigMemoryObject *> ret;
7295 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7296 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
7301 * 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
7304 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
7306 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7307 ret->setInfo(_infos);
7308 int sz=(int)_time_steps.size();
7309 for(const int *id=startIds;id!=endIds;id++)
7311 if(*id>=0 && *id<sz)
7313 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
7314 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7318 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7320 ret->pushBackTimeStep(tse2);
7324 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
7325 oss << " ! Should be in [0," << sz << ") !";
7326 throw INTERP_KERNEL::Exception(oss.str());
7329 if(ret->getNumberOfTS()>0)
7330 ret->synchronizeNameScope();
7331 ret->copyNameScope(*this);
7336 * 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
7339 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
7341 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
7342 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7343 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7344 ret->setInfo(_infos);
7345 int sz=(int)_time_steps.size();
7347 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
7351 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
7352 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7356 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7358 ret->pushBackTimeStep(tse2);
7362 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
7363 oss << " ! Should be in [0," << sz << ") !";
7364 throw INTERP_KERNEL::Exception(oss.str());
7367 if(ret->getNumberOfTS()>0)
7368 ret->synchronizeNameScope();
7369 ret->copyNameScope(*this);
7373 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7376 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7377 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7379 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7382 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7383 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
7384 ids->pushBackSilent(id);
7386 return buildFromTimeStepIds(ids->begin(),ids->end());
7389 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7392 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7393 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7395 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7398 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7399 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
7400 ids->pushBackSilent(id);
7402 return buildFromTimeStepIds(ids->begin(),ids->end());
7405 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
7407 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7409 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7412 if(cur->presenceOfMultiDiscPerGeoType())
7418 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
7423 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
7428 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
7431 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7433 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
7434 if(pt->isDealingTS(iteration,order))
7437 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
7438 std::vector< std::pair<int,int> > vp=getIterations();
7439 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
7440 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
7441 throw INTERP_KERNEL::Exception(oss.str());
7444 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
7446 return *_time_steps[getTimeStepPos(iteration,order)];
7449 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
7451 return *_time_steps[getTimeStepPos(iteration,order)];
7454 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const
7456 if(_time_steps.empty())
7457 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
7458 return _time_steps[0]->getMeshName();
7461 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const std::string& newMeshName)
7463 std::string oldName(getMeshName());
7464 std::vector< std::pair<std::string,std::string> > v(1);
7465 v[0].first=oldName; v[0].second=newMeshName;
7469 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
7472 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7474 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7476 ret=cur->changeMeshNames(modifTab) || ret;
7482 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
7484 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
7486 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
7490 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
7492 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7494 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
7497 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
7498 MEDFileFieldGlobsReal& glob)
7501 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7503 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
7505 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
7510 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7512 std::string startLine(bkOffset,' ');
7513 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
7515 oss << " (" << fmtsId << ")";
7516 oss << " has the following name: \"" << _name << "\"." << std::endl;
7517 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
7518 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7520 oss << startLine << " - \"" << *it << "\"" << std::endl;
7523 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7525 std::string chapter(17,'0'+i);
7526 oss << startLine << chapter << std::endl;
7527 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7529 cur->simpleRepr(bkOffset+2,oss,i);
7531 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
7532 oss << startLine << chapter << std::endl;
7536 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
7538 std::size_t sz=_time_steps.size();
7539 std::vector< std::pair<int,int> > ret(sz);
7541 for(std::size_t i=0;i<sz;i++)
7543 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
7546 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
7550 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
7551 throw INTERP_KERNEL::Exception(oss.str());
7557 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MCAuto<MEDFileAnyTypeField1TSWithoutSDA>& tse)
7559 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
7561 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
7562 checkCoherencyOfType(tse2);
7563 if(_time_steps.empty())
7565 setName(tse2->getName().c_str());
7566 setInfo(tse2->getInfo());
7568 checkThatComponentsMatch(tse2->getInfo());
7569 if(getDtUnit().empty() && !tse->getDtUnit().empty())
7570 setDtUnit(tse->getDtUnit());
7571 _time_steps.push_back(tse);
7574 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
7576 std::size_t nbOfCompo=_infos.size();
7577 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7579 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7582 if((cur->getInfo()).size()!=nbOfCompo)
7584 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
7585 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
7586 throw INTERP_KERNEL::Exception(oss.str());
7588 cur->copyNameScope(*this);
7593 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7595 _time_steps.resize(nbPdt);
7596 for(int i=0;i<nbPdt;i++)
7598 std::vector< std::pair<int,int> > ts;
7599 med_int numdt=0,numo=0;
7601 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt));
7606 _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7611 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7615 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
7618 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities);
7620 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entities);
7621 synchronizeNameScope();
7625 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
7627 if(_time_steps.empty())
7628 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
7629 checkThatNbOfCompoOfTSMatchThis();
7630 std::vector<std::string> infos(getInfo());
7631 int nbComp=infos.size();
7632 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7633 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7634 for(int i=0;i<nbComp;i++)
7636 std::string info=infos[i];
7638 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7639 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7640 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7643 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7644 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
7645 int nbOfTS=_time_steps.size();
7646 for(int i=0;i<nbOfTS;i++)
7647 _time_steps[i]->writeLL(fid,opts,*this);
7650 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
7652 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7654 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7656 elt->loadBigArraysRecursively(fid,nasc);
7660 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(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->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7670 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
7672 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7674 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7676 elt->unloadArrays();
7680 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7682 return _time_steps.size();
7685 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
7687 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7688 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7690 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7692 newTS.push_back(*it);
7697 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
7699 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7700 int maxId=(int)_time_steps.size();
7702 std::set<int> idsToDel;
7703 for(const int *id=startIds;id!=endIds;id++,ii++)
7705 if(*id>=0 && *id<maxId)
7707 idsToDel.insert(*id);
7711 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7712 throw INTERP_KERNEL::Exception(oss.str());
7715 for(int iii=0;iii<maxId;iii++)
7716 if(idsToDel.find(iii)==idsToDel.end())
7717 newTS.push_back(_time_steps[iii]);
7721 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
7723 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7724 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7725 if(nbOfEntriesToKill==0)
7727 std::size_t sz=_time_steps.size();
7728 std::vector<bool> b(sz,true);
7730 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7732 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7733 for(std::size_t i=0;i<sz;i++)
7735 newTS.push_back(_time_steps[i]);
7739 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
7742 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
7743 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7745 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7749 tmp->getTime(it2,ord);
7750 if(it2==iteration && order==ord)
7753 oss << "(" << it2 << "," << ord << "), ";
7756 throw INTERP_KERNEL::Exception(oss.str());
7759 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
7762 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
7764 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7766 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7770 double ti=tmp->getTime(it2,ord);
7771 if(fabs(time-ti)<eps)
7777 throw INTERP_KERNEL::Exception(oss.str());
7780 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
7782 int lgth=_time_steps.size();
7783 std::vector< std::pair<int,int> > ret(lgth);
7784 for(int i=0;i<lgth;i++)
7785 _time_steps[i]->fillIteration(ret[i]);
7790 * 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'
7791 * This method returns two things.
7792 * - The absolute dimension of 'this' in first parameter.
7793 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7794 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
7796 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7797 * Only these 3 discretizations will be taken into account here.
7799 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7800 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7801 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7803 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7804 * 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'.
7806 * Let's consider the typical following case :
7807 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7808 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7809 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7811 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7813 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7815 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7816 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7817 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7818 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7820 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
7822 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7825 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
7827 if(pos<0 || pos>=(int)_time_steps.size())
7829 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7830 throw INTERP_KERNEL::Exception(oss.str());
7832 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7835 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7836 oss << "\nTry to use following method eraseEmptyTS !";
7837 throw INTERP_KERNEL::Exception(oss.str());
7842 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
7844 if(pos<0 || pos>=(int)_time_steps.size())
7846 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7847 throw INTERP_KERNEL::Exception(oss.str());
7849 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7852 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7853 oss << "\nTry to use following method eraseEmptyTS !";
7854 throw INTERP_KERNEL::Exception(oss.str());
7859 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
7861 std::vector<std::string> ret;
7862 std::set<std::string> ret2;
7863 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7865 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
7866 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7867 if(ret2.find(*it2)==ret2.end())
7869 ret.push_back(*it2);
7876 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
7878 std::vector<std::string> ret;
7879 std::set<std::string> ret2;
7880 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7882 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
7883 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7884 if(ret2.find(*it2)==ret2.end())
7886 ret.push_back(*it2);
7893 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
7895 std::vector<std::string> ret;
7896 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7898 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
7899 ret.insert(ret.end(),tmp.begin(),tmp.end());
7904 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
7906 std::vector<std::string> ret;
7907 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7909 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
7910 ret.insert(ret.end(),tmp.begin(),tmp.end());
7915 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7917 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7918 (*it)->changePflsRefsNamesGen2(mapOfModif);
7921 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7923 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7924 (*it)->changeLocsRefsNamesGen2(mapOfModif);
7927 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
7929 int lgth=_time_steps.size();
7930 std::vector< std::vector<TypeOfField> > ret(lgth);
7931 for(int i=0;i<lgth;i++)
7932 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
7937 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
7939 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
7941 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
7944 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCopy() const
7946 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
7948 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7950 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
7951 ret->_time_steps[i]=(*it)->deepCopy();
7956 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
7958 std::size_t sz(_infos.size()),sz2(_time_steps.size());
7959 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7960 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7961 for(std::size_t i=0;i<sz;i++)
7963 ret[i]=shallowCpy();
7964 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7966 for(std::size_t i=0;i<sz2;i++)
7968 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7971 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7972 throw INTERP_KERNEL::Exception(oss.str());
7976 for(std::size_t i=0;i<sz;i++)
7977 for(std::size_t j=0;j<sz2;j++)
7978 ret[i]->_time_steps[j]=ts[j][i];
7983 * This method splits into discretization each time steps in \a this.
7984 * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
7986 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
7988 std::size_t sz(_time_steps.size());
7989 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7990 for(std::size_t i=0;i<sz;i++)
7992 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7995 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
7996 throw INTERP_KERNEL::Exception(oss.str());
7998 items[i]=timeStep->splitDiscretizations();
8001 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
8002 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
8003 std::vector< TypeOfField > types;
8004 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
8005 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
8007 std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
8009 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
8010 std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
8011 if(it2==types.end())
8012 types.push_back(ts[0]);
8014 ret.resize(types.size()); ret2.resize(types.size());
8015 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
8016 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
8018 TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
8019 std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
8020 ret2[pos].push_back(*it1);
8022 for(std::size_t i=0;i<types.size();i++)
8024 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
8025 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
8026 elt->pushBackTimeStep(*it1);//also updates infos in elt
8028 elt->MEDFileFieldNameScope::operator=(*this);
8034 * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
8036 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
8038 std::size_t sz(_time_steps.size());
8039 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
8040 std::size_t szOut(std::numeric_limits<std::size_t>::max());
8041 for(std::size_t i=0;i<sz;i++)
8043 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
8046 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
8047 throw INTERP_KERNEL::Exception(oss.str());
8049 items[i]=timeStep->splitMultiDiscrPerGeoTypes();
8050 if(szOut==std::numeric_limits<std::size_t>::max())
8051 szOut=items[i].size();
8053 if(items[i].size()!=szOut)
8054 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
8056 if(szOut==std::numeric_limits<std::size_t>::max())
8057 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
8058 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
8059 for(std::size_t i=0;i<szOut;i++)
8061 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
8062 for(std::size_t j=0;j<sz;j++)
8063 elt->pushBackTimeStep(items[j][i]);
8065 elt->MEDFileFieldNameScope::operator=(*this);
8070 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
8072 _name=field->getName();
8074 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
8076 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
8077 _infos=arr->getInfoOnComponents();
8080 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
8082 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
8083 if(_name!=field->getName())
8085 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
8086 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
8087 throw INTERP_KERNEL::Exception(oss.str());
8090 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
8091 checkThatComponentsMatch(arr->getInfoOnComponents());
8094 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
8096 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
8097 if(getInfo().size()!=compos.size())
8099 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
8100 oss << " number of components of element to append (" << compos.size() << ") !";
8101 throw INTERP_KERNEL::Exception(oss.str());
8105 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
8106 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
8107 oss << " But compo in input fields are : ";
8108 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
8110 throw INTERP_KERNEL::Exception(oss.str());
8114 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
8116 std::size_t sz=_infos.size();
8118 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
8120 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
8122 if(elt->getInfo().size()!=sz)
8124 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
8125 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
8126 throw INTERP_KERNEL::Exception(oss.str());
8131 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
8134 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8135 if(!_time_steps.empty())
8136 checkCoherencyOfTinyInfo(field,arr);
8137 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8138 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8139 objC->setFieldNoProfileSBT(field,arr,glob,*this);
8140 copyTinyInfoFrom(field,arr);
8141 _time_steps.push_back(obj);
8144 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
8147 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8148 if(!_time_steps.empty())
8149 checkCoherencyOfTinyInfo(field,arr);
8150 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8151 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8152 objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
8153 copyTinyInfoFrom(field,arr);
8154 _time_steps.push_back(obj);
8157 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ts)
8159 int sz=(int)_time_steps.size();
8162 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
8163 throw INTERP_KERNEL::Exception(oss.str());
8165 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
8168 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
8170 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
8171 throw INTERP_KERNEL::Exception(oss.str());
8177 //= MEDFileFieldMultiTSWithoutSDA
8179 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)
8181 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8184 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
8188 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8193 * \param [in] fieldId field id in C mode
8195 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8196 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8199 catch(INTERP_KERNEL::Exception& e)
8202 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)
8203 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8206 catch(INTERP_KERNEL::Exception& e)
8209 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8211 return new MEDFileField1TSWithoutSDA;
8214 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8217 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8218 const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
8220 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8223 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const
8225 return MEDFileField1TSWithoutSDA::TYPE_STR;
8228 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const
8230 return new MEDFileFieldMultiTSWithoutSDA(*this);
8233 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const
8235 return new MEDFileFieldMultiTSWithoutSDA;
8239 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
8240 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
8242 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
8244 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
8245 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8247 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
8248 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
8251 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
8253 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
8254 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8256 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8258 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8261 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
8263 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
8264 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
8265 ret->setIteration(i,elt);
8271 //= MEDFileAnyTypeFieldMultiTS
8273 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
8277 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8278 try:MEDFileFieldGlobsReal(fid)
8280 _content=BuildContentFrom(fid,loadAll,ms);
8283 catch(INTERP_KERNEL::Exception& e)
8288 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8290 med_field_type typcha;
8291 std::vector<std::string> infos;
8294 MEDFileAnyTypeField1TS::LocateField(fid,fieldName,i,typcha,infos,dtunit);
8295 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8300 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8305 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8310 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] !";
8311 throw INTERP_KERNEL::Exception(oss.str());
8314 ret->setDtUnit(dtunit.c_str());
8318 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8320 med_field_type typcha;
8322 std::vector<std::string> infos;
8323 std::string dtunit,fieldName;
8324 MEDFileAnyTypeField1TS::LocateField2(fid,0,true,fieldName,typcha,infos,dtunit);
8325 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8330 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8335 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8340 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] !";
8341 throw INTERP_KERNEL::Exception(oss.str());
8344 ret->setDtUnit(dtunit.c_str());
8348 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c)
8351 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
8352 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
8354 MCAuto<MEDFileFieldMultiTS> ret(MEDFileFieldMultiTS::New());
8355 ret->_content=c; c->incrRef();
8358 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
8360 MCAuto<MEDFileIntFieldMultiTS> ret(MEDFileIntFieldMultiTS::New());
8361 ret->_content=c; c->incrRef();
8364 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
8367 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, med_idt fid)
8369 MEDFileAnyTypeFieldMultiTS *ret(BuildNewInstanceFromContent(c));
8370 std::string fileName(FileNameFromFID(fid));
8371 ret->setFileName(fileName);
8375 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8376 try:MEDFileFieldGlobsReal(fid)
8378 _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
8381 catch(INTERP_KERNEL::Exception& e)
8386 //= MEDFileIntFieldMultiTSWithoutSDA
8388 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)
8390 return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8393 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
8397 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8401 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)
8402 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8405 catch(INTERP_KERNEL::Exception& e)
8409 * \param [in] fieldId field id in C mode
8411 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8412 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8415 catch(INTERP_KERNEL::Exception& e)
8418 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8420 return new MEDFileIntField1TSWithoutSDA;
8423 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8426 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8427 const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
8429 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8432 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const
8434 return MEDFileIntField1TSWithoutSDA::TYPE_STR;
8437 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const
8439 return new MEDFileIntFieldMultiTSWithoutSDA(*this);
8442 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const
8444 return new MEDFileIntFieldMultiTSWithoutSDA;
8447 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const
8449 MCAuto<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
8450 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8452 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8454 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8457 const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
8459 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
8460 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
8461 ret->setIteration(i,elt);
8467 //= MEDFileAnyTypeFieldMultiTS
8470 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
8471 * that has been read from a specified MED file.
8472 * \param [in] fileName - the name of the MED file to read.
8473 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8474 * is to delete this field using decrRef() as it is no more needed.
8475 * \throw If reading the file fails.
8477 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
8479 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8480 return New(fid,loadAll);
8483 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, bool loadAll)
8485 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
8486 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8487 ret->loadGlobals(fid);
8492 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
8493 * that has been read from a specified MED file.
8494 * \param [in] fileName - the name of the MED file to read.
8495 * \param [in] fieldName - the name of the field to read.
8496 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8497 * is to delete this field using decrRef() as it is no more needed.
8498 * \throw If reading the file fails.
8499 * \throw If there is no field named \a fieldName in the file.
8501 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8503 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8504 return New(fid,fieldName,loadAll);
8507 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
8509 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
8510 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8511 ret->loadGlobals(fid);
8516 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8517 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8519 * \warning this is a shallow copy constructor
8521 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8523 if(!shallowCopyOfContent)
8525 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
8526 otherPtr->incrRef();
8527 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
8531 _content=other.shallowCpy();
8535 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
8537 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8539 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
8543 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
8545 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8547 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
8551 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
8553 return contentNotNullBase()->getPflsReallyUsed2();
8556 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
8558 return contentNotNullBase()->getLocsReallyUsed2();
8561 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
8563 return contentNotNullBase()->getPflsReallyUsedMulti2();
8566 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
8568 return contentNotNullBase()->getLocsReallyUsedMulti2();
8571 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8573 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
8576 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8578 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
8581 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
8583 return contentNotNullBase()->getNumberOfTS();
8586 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
8588 contentNotNullBase()->eraseEmptyTS();
8591 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
8593 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
8596 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
8598 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
8601 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
8603 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
8604 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8609 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
8611 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
8612 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8617 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
8619 return contentNotNullBase()->getIterations();
8622 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
8624 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
8625 pushBackTimeStep(*it);
8628 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
8631 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
8632 int nbOfTS(fmts->getNumberOfTS());
8633 for(int i=0;i<nbOfTS;i++)
8635 MCAuto<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
8636 pushBackTimeStep(elt);
8640 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
8643 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
8644 checkCoherencyOfType(f1ts);
8646 MCAuto<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
8647 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
8649 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
8650 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
8651 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
8652 _content->pushBackTimeStep(cSafe);
8653 appendGlobs(*f1ts,1e-12);
8656 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
8658 contentNotNullBase()->synchronizeNameScope();
8661 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
8663 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
8666 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
8668 return contentNotNullBase()->getPosGivenTime(time,eps);
8671 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8673 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
8676 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
8678 return contentNotNullBase()->getTypesOfFieldAvailable();
8681 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
8683 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
8686 std::string MEDFileAnyTypeFieldMultiTS::getName() const
8688 return contentNotNullBase()->getName();
8691 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
8693 contentNotNullBase()->setName(name);
8696 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
8698 return contentNotNullBase()->getDtUnit();
8701 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
8703 contentNotNullBase()->setDtUnit(dtUnit);
8706 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8708 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
8711 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
8713 return contentNotNullBase()->getTimeSteps(ret1);
8716 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
8718 return contentNotNullBase()->getMeshName();
8721 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
8723 contentNotNullBase()->setMeshName(newMeshName);
8726 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
8728 return contentNotNullBase()->changeMeshNames(modifTab);
8731 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
8733 return contentNotNullBase()->getInfo();
8736 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
8738 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
8741 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
8743 return contentNotNullBase()->setInfo(info);
8746 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
8748 const std::vector<std::string> ret=getInfo();
8749 return (int)ret.size();
8752 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
8754 writeGlobals(fid,*this);
8755 contentNotNullBase()->writeLL(fid,*this);
8759 * This method alloc the arrays and load potentially huge arrays contained in this field.
8760 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
8761 * This method can be also called to refresh or reinit values from a file.
8763 * \throw If the fileName is not set or points to a non readable MED file.
8765 void MEDFileAnyTypeFieldMultiTS::loadArrays()
8767 if(getFileName().empty())
8768 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
8769 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
8770 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
8774 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
8775 * But once data loaded once, this method does nothing.
8777 * \throw If the fileName is not set or points to a non readable MED file.
8778 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
8780 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
8782 if(!getFileName().empty())
8784 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
8785 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
8790 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
8791 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
8792 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
8794 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
8796 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
8798 contentNotNullBase()->unloadArrays();
8802 * 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.
8803 * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
8804 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
8806 * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
8808 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
8810 if(!getFileName().empty())
8811 contentNotNullBase()->unloadArrays();
8814 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
8816 std::ostringstream oss;
8817 contentNotNullBase()->simpleRepr(0,oss,-1);
8818 simpleReprGlobs(oss);
8822 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
8824 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
8827 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
8829 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
8830 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
8835 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
8836 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8837 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
8839 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
8841 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8843 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
8844 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
8845 std::size_t sz(contentsSplit.size());
8846 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8847 for(std::size_t i=0;i<sz;i++)
8849 ret[i]=shallowCpy();
8850 ret[i]->_content=contentsSplit[i];
8856 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
8857 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8859 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
8861 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8863 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
8864 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
8865 std::size_t sz(contentsSplit.size());
8866 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8867 for(std::size_t i=0;i<sz;i++)
8869 ret[i]=shallowCpy();
8870 ret[i]->_content=contentsSplit[i];
8876 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
8877 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8879 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
8881 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8883 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
8884 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
8885 std::size_t sz(contentsSplit.size());
8886 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8887 for(std::size_t i=0;i<sz;i++)
8889 ret[i]=shallowCpy();
8890 ret[i]->_content=contentsSplit[i];
8895 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCopy() const
8897 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8898 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
8899 ret->_content=_content->deepCopy();
8900 ret->deepCpyGlobs(*this);
8904 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
8910 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8911 * \param [in] iteration - the iteration number of a required time step.
8912 * \param [in] order - the iteration order number of required time step.
8913 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
8914 * delete this field using decrRef() as it is no more needed.
8915 * \throw If there is no required time step in \a this field.
8917 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
8919 int pos=getPosOfTimeStep(iteration,order);
8920 return getTimeStepAtPos(pos);
8924 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8925 * \param [in] time - the time of the time step of interest.
8926 * \param [in] eps - a precision used to compare time values.
8927 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8928 * delete this field using decrRef() as it is no more needed.
8929 * \throw If there is no required time step in \a this field.
8931 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
8933 int pos=getPosGivenTime(time,eps);
8934 return getTimeStepAtPos(pos);
8938 * 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.
8939 * The float64 value of time attached to the pair of integers are not considered here.
8940 * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
8942 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
8943 * \throw If there is a null pointer in \a vectFMTS.
8945 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
8947 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
8948 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8949 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8950 while(!lstFMTS.empty())
8952 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8953 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8955 throw INTERP_KERNEL::Exception(msg);
8956 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
8957 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8958 elt.push_back(curIt); it=lstFMTS.erase(it);
8959 while(it!=lstFMTS.end())
8963 throw INTERP_KERNEL::Exception(msg);
8964 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
8966 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8976 * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
8977 * All returned instances in a subvector can be safely loaded, rendered along time
8978 * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
8979 * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
8980 * 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).
8981 * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
8982 * 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.
8984 * \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().
8985 * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
8986 * \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.
8987 * \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.
8989 * \throw If an element in \a vectFMTS has not only one spatial discretization set.
8990 * \throw If an element in \a vectFMTS change of spatial discretization along time.
8991 * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
8992 * \thorw If some elements in \a vectFMTS do not have the same times steps.
8993 * \throw If mesh is null.
8994 * \throw If an element in \a vectFMTS is null.
8995 * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
8997 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& fsc)
8999 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
9001 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
9002 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9003 if(vectFMTS.empty())
9005 std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
9006 MEDFileAnyTypeFieldMultiTS *frstElt(*it);
9008 throw INTERP_KERNEL::Exception(msg);
9010 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
9011 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
9012 for(;it!=vectFMTS.end();it++,i++)
9015 throw INTERP_KERNEL::Exception(msg);
9016 TypeOfField tof0,tof1;
9017 if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
9020 vectFMTSNotNodes.push_back(*it);
9022 vectFMTSNodes.push_back(*it);
9025 vectFMTSNotNodes.push_back(*it);
9027 std::vector< MCAuto<MEDFileFastCellSupportComparator> > cmps;
9028 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
9030 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
9033 bool isFetched(false);
9034 for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
9037 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
9038 if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
9039 { ret[i].push_back(*it2); isFetched=true; }
9043 std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
9044 MCAuto<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
9045 ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
9053 * 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.
9054 * \param [out] cmps - same size than the returned vector.
9056 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& cmps)
9058 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9059 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
9060 while(!lstFMTS.empty())
9062 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
9063 MEDFileAnyTypeFieldMultiTS *ref(*it);
9064 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
9065 elt.push_back(ref); it=lstFMTS.erase(it);
9066 MCAuto<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
9067 MCAuto<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
9068 while(it!=lstFMTS.end())
9070 MEDFileAnyTypeFieldMultiTS *curIt(*it);
9071 if(cmp->isEqual(curIt))
9072 { elt.push_back(curIt); it=lstFMTS.erase(it); }
9076 ret.push_back(elt); cmps.push_back(cmp);
9082 * 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.
9083 * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
9085 * \throw If \a f0 or \a f1 has not only one spatial discretization set.
9086 * \throw If \a f0 or \a f1 change of spatial discretization along time.
9087 * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
9088 * \thorw If \a f0 and \a f1 do not have the same times steps.
9089 * \throw If mesh is null.
9090 * \throw If \a f0 or \a f1 is null.
9091 * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
9093 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
9096 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
9098 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
9099 if(f0->getMeshName()!=mesh->getName())
9101 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9102 throw INTERP_KERNEL::Exception(oss.str());
9104 if(f1->getMeshName()!=mesh->getName())
9106 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9107 throw INTERP_KERNEL::Exception(oss.str());
9109 int nts=f0->getNumberOfTS();
9110 if(nts!=f1->getNumberOfTS())
9111 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
9114 for(int i=0;i<nts;i++)
9116 MCAuto<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
9117 MCAuto<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
9118 std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
9119 if(tofs0.size()!=1 || tofs1.size()!=1)
9120 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
9123 if(tof0!=tofs0[0] || tof1!=tofs1[0])
9124 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
9127 { tof0=tofs0[0]; tof1=tofs1[0]; }
9128 if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
9130 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() << ") !";
9131 throw INTERP_KERNEL::Exception(oss.str());
9133 if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
9135 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() << ") !";
9136 throw INTERP_KERNEL::Exception(oss.str());
9138 if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
9140 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() << ") !";
9141 throw INTERP_KERNEL::Exception(oss.str());
9148 * Return an extraction of \a this using \a extractDef map to specify the extraction.
9149 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
9151 * \return A new object that the caller is responsible to deallocate.
9153 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
9156 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::extractPart : mesh is null !");
9157 MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(buildNewEmpty());
9158 int nbTS(getNumberOfTS());
9159 for(int i=0;i<nbTS;i++)
9161 MCAuto<MEDFileAnyTypeField1TS> f1ts(getTimeStepAtPos(i));
9162 MCAuto<MEDFileAnyTypeField1TS> f1tsOut(f1ts->extractPart(extractDef,mm));
9163 fmtsOut->pushBackTimeStep(f1tsOut);
9165 return fmtsOut.retn();
9169 MCAuto<MEDFileAnyTypeField1TS> AggregateHelperF1TS(const std::vector< typename MLFieldTraits<T>::F1TSType const *>& f1tss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9171 MCAuto< typename MLFieldTraits<T>::F1TSType > ret(MLFieldTraits<T>::F1TSType::New());
9173 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : empty vector !");
9174 std::size_t sz(f1tss.size()),i(0);
9175 std::vector< typename MLFieldTraits<T>::F1TSWSDAType const *> f1tsw(sz);
9176 for(typename std::vector< typename MLFieldTraits<T>::F1TSType const *>::const_iterator it=f1tss.begin();it!=f1tss.end();it++,i++)
9178 typename MLFieldTraits<T>::F1TSType const *elt(*it);
9180 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : presence of a null pointer !");
9181 f1tsw[i]=dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType const *>(elt->contentNotNullBase());
9183 typename MLFieldTraits<T>::F1TSWSDAType *retc(dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType *>(ret->contentNotNullBase()));
9185 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : internal error 1 !");
9186 retc->aggregate(f1tsw,dts);
9187 ret->setDtUnit(f1tss[0]->getDtUnit());
9188 return DynamicCast<typename MLFieldTraits<T>::F1TSType , MEDFileAnyTypeField1TS>(ret);
9192 MCAuto< MEDFileAnyTypeFieldMultiTS > AggregateHelperFMTS(const std::vector< typename MLFieldTraits<T>::FMTSType const *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9194 MCAuto< typename MLFieldTraits<T>::FMTSType > ret(MLFieldTraits<T>::FMTSType::New());
9196 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : empty vector !");
9197 std::size_t sz(fmtss.size());
9198 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9200 typename MLFieldTraits<T>::FMTSType const *elt(*it);
9202 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : presence of null pointer !");
9204 int nbTS(fmtss[0]->getNumberOfTS());
9205 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9206 if((*it)->getNumberOfTS()!=nbTS)
9207 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : all fields must have the same number of TS !");
9208 for(int iterTS=0;iterTS<nbTS;iterTS++)
9211 std::vector< typename MLFieldTraits<T>::F1TSType const *> f1tss(sz);
9212 std::vector< MCAuto<typename MLFieldTraits<T>::F1TSType> > f1tss2(sz);
9213 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++,i++)
9214 { f1tss2[i]=(*it)->getTimeStepAtPos(iterTS); f1tss[i]=f1tss2[i]; }
9215 MCAuto<MEDFileAnyTypeField1TS> f1ts(AggregateHelperF1TS<T>(f1tss,dts));
9216 ret->pushBackTimeStep(f1ts);
9217 ret->setDtUnit(f1ts->getDtUnit());
9219 return DynamicCast<typename MLFieldTraits<T>::FMTSType , MEDFileAnyTypeFieldMultiTS>(ret);
9223 * \a dts and \a ftmss are expected to have same size.
9225 MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileAnyTypeFieldMultiTS::Aggregate(const std::vector<const MEDFileAnyTypeFieldMultiTS *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9228 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : input vector is empty !");
9229 std::size_t sz(fmtss.size());
9230 std::vector<const MEDFileFieldMultiTS *> fmtss1;
9231 std::vector<const MEDFileIntFieldMultiTS *> fmtss2;
9232 for(std::vector<const MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9235 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : presence of null instance in input vector !");
9236 const MEDFileFieldMultiTS *elt1(dynamic_cast<const MEDFileFieldMultiTS *>(*it));
9239 fmtss1.push_back(elt1);
9242 const MEDFileIntFieldMultiTS *elt2(dynamic_cast<const MEDFileIntFieldMultiTS *>(*it));
9245 fmtss2.push_back(elt2);
9248 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not recognized type !");
9250 if(fmtss1.size()!=sz && fmtss2.size()!=sz)
9251 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : type of data is not homogeneous !");
9252 if(fmtss1.size()==sz)
9253 return AggregateHelperFMTS<double>(fmtss1,dts);
9254 if(fmtss2.size()!=sz)
9255 return AggregateHelperFMTS<int>(fmtss2,dts);
9256 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not implemented yet !");
9259 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
9261 return new MEDFileAnyTypeFieldMultiTSIterator(this);
9264 //= MEDFileFieldMultiTS
9267 * Returns a new empty instance of MEDFileFieldMultiTS.
9268 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9269 * is to delete this field using decrRef() as it is no more needed.
9271 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
9273 return new MEDFileFieldMultiTS;
9277 * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
9278 * that has been read from a specified MED file.
9279 * \param [in] fileName - the name of the MED file to read.
9280 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9281 * is to delete this field using decrRef() as it is no more needed.
9282 * \throw If reading the file fails.
9284 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll)
9286 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9287 return New(fid,loadAll);
9290 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, bool loadAll)
9292 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,loadAll,0));
9293 ret->contentNotNull();//to check that content type matches with \a this type.
9298 * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
9299 * that has been read from a specified MED file.
9300 * \param [in] fileName - the name of the MED file to read.
9301 * \param [in] fieldName - the name of the field to read.
9302 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9303 * is to delete this field using decrRef() as it is no more needed.
9304 * \throw If reading the file fails.
9305 * \throw If there is no field named \a fieldName in the file.
9307 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9309 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9310 return New(fid,fieldName,loadAll);
9313 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
9315 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0));
9316 ret->contentNotNull();//to check that content type matches with \a this type.
9321 * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9322 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9324 * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
9325 * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9326 * \warning this is a shallow copy constructor
9327 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
9328 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9329 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9330 * is to delete this field using decrRef() as it is no more needed.
9332 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9334 return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
9337 MEDFileFieldMultiTS *MEDFileFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9339 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9340 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
9341 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0,ent));
9342 ret->contentNotNull();//to check that content type matches with \a this type.
9346 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
9348 return new MEDFileFieldMultiTS(*this);
9351 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9354 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9355 const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
9357 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
9361 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
9362 * following the given input policy.
9364 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9365 * By default (true) the globals are deeply copied.
9366 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
9368 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
9370 MCAuto<MEDFileIntFieldMultiTS> ret;
9371 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9374 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
9376 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
9377 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
9378 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc));
9381 ret=MEDFileIntFieldMultiTS::New();
9383 ret->deepCpyGlobs(*this);
9385 ret->shallowCpyGlobs(*this);
9390 * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
9391 * \param [in] pos - a time step id.
9392 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9393 * delete this field using decrRef() as it is no more needed.
9394 * \throw If \a pos is not a valid time step id.
9396 MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const
9398 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9401 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9402 throw INTERP_KERNEL::Exception(oss.str());
9404 const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
9407 MCAuto<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
9408 ret->shallowCpyGlobs(*this);
9411 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
9412 throw INTERP_KERNEL::Exception(oss.str());
9416 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9417 * mesh entities of a given dimension of the first mesh in MED file.
9418 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9419 * \param [in] type - a spatial discretization of interest.
9420 * \param [in] iteration - the iteration number of a required time step.
9421 * \param [in] order - the iteration order number of required time step.
9422 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9423 * \param [in] renumPol - specifies how to permute values of the result field according to
9424 * the optional numbers of cells and nodes, if any. The valid values are
9425 * - 0 - do not permute.
9426 * - 1 - permute cells.
9427 * - 2 - permute nodes.
9428 * - 3 - permute cells and nodes.
9430 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9431 * caller is to delete this field using decrRef() as it is no more needed.
9432 * \throw If the MED file is not readable.
9433 * \throw If there is no mesh in the MED file.
9434 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9435 * \throw If no field values of the required parameters are available.
9437 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9439 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9440 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9442 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
9443 MCAuto<DataArray> arrOut;
9444 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9445 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9450 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9451 * the top level cells of the first mesh in MED file.
9452 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9453 * \param [in] type - a spatial discretization of interest.
9454 * \param [in] iteration - the iteration number of a required time step.
9455 * \param [in] order - the iteration order number of required time step.
9456 * \param [in] renumPol - specifies how to permute values of the result field according to
9457 * the optional numbers of cells and nodes, if any. The valid values are
9458 * - 0 - do not permute.
9459 * - 1 - permute cells.
9460 * - 2 - permute nodes.
9461 * - 3 - permute cells and nodes.
9463 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9464 * caller is to delete this field using decrRef() as it is no more needed.
9465 * \throw If the MED file is not readable.
9466 * \throw If there is no mesh in the MED file.
9467 * \throw If no field values of the required parameters are available.
9469 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9471 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9472 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9474 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
9475 MCAuto<DataArray> arrOut;
9476 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9477 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9482 * 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
9483 * method should be called (getFieldOnMeshAtLevel for example).
9484 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
9486 * \param [in] iteration - the iteration number of a required time step.
9487 * \param [in] order - the iteration order number of required time step.
9488 * \param [in] mesh - the mesh the field is lying on
9489 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9490 * caller is to delete this field using decrRef() as it is no more needed.
9492 MEDCouplingFieldDouble *MEDFileFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
9494 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9495 MCAuto<DataArray> arrOut;
9496 MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
9497 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9502 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9504 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9505 * \param [in] type - a spatial discretization of interest.
9506 * \param [in] iteration - the iteration number of a required time step.
9507 * \param [in] order - the iteration order number of required time step.
9508 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9509 * \param [in] mesh - the supporting mesh.
9510 * \param [in] renumPol - specifies how to permute values of the result field according to
9511 * the optional numbers of cells and nodes, if any. The valid values are
9512 * - 0 - do not permute.
9513 * - 1 - permute cells.
9514 * - 2 - permute nodes.
9515 * - 3 - permute cells and nodes.
9517 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9518 * caller is to delete this field using decrRef() as it is no more needed.
9519 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9520 * \throw If no field of \a this is lying on \a mesh.
9521 * \throw If no field values of the required parameters are available.
9523 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9525 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9526 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9528 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9529 MCAuto<DataArray> arrOut;
9530 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
9531 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9536 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9538 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9539 * \param [in] type - a spatial discretization of the new field.
9540 * \param [in] iteration - the iteration number of a required time step.
9541 * \param [in] order - the iteration order number of required time step.
9542 * \param [in] mesh - the supporting mesh.
9543 * \param [in] renumPol - specifies how to permute values of the result field according to
9544 * the optional numbers of cells and nodes, if any. The valid values are
9545 * - 0 - do not permute.
9546 * - 1 - permute cells.
9547 * - 2 - permute nodes.
9548 * - 3 - permute cells and nodes.
9550 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9551 * caller is to delete this field using decrRef() as it is no more needed.
9552 * \throw If no field of \a this is lying on \a mesh.
9553 * \throw If no field values of the required parameters are available.
9555 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
9557 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9558 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9560 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9561 MCAuto<DataArray> arrOut;
9562 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
9563 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9568 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
9569 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9570 * This method is useful for MED2 file format when field on different mesh was autorized.
9572 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
9574 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9575 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9577 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
9578 MCAuto<DataArray> arrOut;
9579 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
9580 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9585 * Returns values and a profile of the field of a given type, of a given time step,
9586 * lying on a given support.
9587 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9588 * \param [in] type - a spatial discretization of the field.
9589 * \param [in] iteration - the iteration number of a required time step.
9590 * \param [in] order - the iteration order number of required time step.
9591 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9592 * \param [in] mesh - the supporting mesh.
9593 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9594 * field of interest lies on. If the field lies on all entities of the given
9595 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9596 * using decrRef() as it is no more needed.
9597 * \param [in] glob - the global data storing profiles and localization.
9598 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
9599 * field. The caller is to delete this array using decrRef() as it is no more needed.
9600 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9601 * \throw If no field of \a this is lying on \a mesh.
9602 * \throw If no field values of the required parameters are available.
9604 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9606 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9607 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9609 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
9610 MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9611 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
9614 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const
9616 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9618 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
9619 const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
9621 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 !");
9625 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull()
9627 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9629 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
9630 MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
9632 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 !");
9637 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9638 * the given field is checked if its elements are sorted suitable for writing to MED file
9639 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9640 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9641 * \param [in] field - the field to add to \a this.
9642 * \throw If the name of \a field is empty.
9643 * \throw If the data array of \a field is not set.
9644 * \throw If existing time steps have different name or number of components than \a field.
9645 * \throw If the underlying mesh of \a field has no name.
9646 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9648 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
9650 const DataArrayDouble *arr=0;
9652 arr=field->getArray();
9653 contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
9657 * Adds a MEDCouplingFieldDouble to \a this as another time step.
9658 * The mesh support of input parameter \a field is ignored here, it can be NULL.
9659 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9662 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9663 * A new profile is added only if no equal profile is missing.
9664 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9665 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
9666 * \param [in] mesh - the supporting mesh of \a field.
9667 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9668 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
9669 * \throw If either \a field or \a mesh or \a profile has an empty name.
9670 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9671 * \throw If the data array of \a field is not set.
9672 * \throw If the data array of \a this is already allocated but has different number of
9673 * components than \a field.
9674 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9675 * \sa setFieldNoProfileSBT()
9677 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9679 const DataArrayDouble *arr=0;
9681 arr=field->getArray();
9682 contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
9685 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
9687 _content=new MEDFileFieldMultiTSWithoutSDA;
9690 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
9691 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
9694 catch(INTERP_KERNEL::Exception& e)
9697 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
9698 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
9701 catch(INTERP_KERNEL::Exception& e)
9704 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9708 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
9710 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
9713 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9715 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9718 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
9720 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
9723 MEDFileFieldMultiTS *MEDFileFieldMultiTS::buildNewEmpty() const
9725 return MEDFileFieldMultiTS::New();
9728 //= MEDFileAnyTypeFieldMultiTSIterator
9730 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
9735 _nb_iter=fmts->getNumberOfTS();
9739 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
9743 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
9745 if(_iter_id<_nb_iter)
9747 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
9749 return fmts->getTimeStepAtPos(_iter_id++);
9757 //= MEDFileIntFieldMultiTS
9760 * Returns a new empty instance of MEDFileFieldMultiTS.
9761 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9762 * is to delete this field using decrRef() as it is no more needed.
9764 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
9766 return new MEDFileIntFieldMultiTS;
9770 * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
9771 * that has been read from a specified MED file.
9772 * \param [in] fileName - the name of the MED file to read.
9773 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9774 * is to delete this field using decrRef() as it is no more needed.
9775 * \throw If reading the file fails.
9777 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll)
9779 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9780 return New(fid,loadAll);
9783 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, bool loadAll)
9785 MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,loadAll,0));
9786 ret->contentNotNull();//to check that content type matches with \a this type.
9791 * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
9792 * that has been read from a specified MED file.
9793 * \param [in] fileName - the name of the MED file to read.
9794 * \param [in] fieldName - the name of the field to read.
9795 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9796 * is to delete this field using decrRef() as it is no more needed.
9797 * \throw If reading the file fails.
9798 * \throw If there is no field named \a fieldName in the file.
9800 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9802 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9803 return New(fid,fieldName,loadAll);
9806 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
9808 MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0));
9809 ret->contentNotNull();//to check that content type matches with \a this type.
9814 * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9815 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9817 * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
9818 * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9819 * \warning this is a shallow copy constructor
9820 * \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
9821 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9822 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9823 * is to delete this field using decrRef() as it is no more needed.
9825 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9827 return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
9830 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9832 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9833 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
9834 MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0,ent));
9835 ret->contentNotNull();//to check that content type matches with \a this type.
9840 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
9841 * following the given input policy.
9843 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9844 * By default (true) the globals are deeply copied.
9845 * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
9847 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const
9849 MCAuto<MEDFileFieldMultiTS> ret;
9850 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9853 const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
9855 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
9856 MCAuto<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
9857 ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc));
9860 ret=MEDFileFieldMultiTS::New();
9862 ret->deepCpyGlobs(*this);
9864 ret->shallowCpyGlobs(*this);
9868 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const
9870 return new MEDFileIntFieldMultiTS(*this);
9873 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9876 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9877 const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
9879 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
9883 * 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
9884 * method should be called (getFieldOnMeshAtLevel for example).
9885 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
9887 * \param [in] iteration - the iteration number of a required time step.
9888 * \param [in] order - the iteration order number of required time step.
9889 * \param [in] mesh - the mesh the field is lying on
9890 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
9891 * caller is to delete this field using decrRef() as it is no more needed.
9893 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
9895 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9896 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9898 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::field : mismatch of type of field expecting INT32 !");
9899 MCAuto<DataArray> arrOut;
9900 MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
9901 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arrOut));
9906 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
9907 * mesh entities of a given dimension of the first mesh in MED file.
9908 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9909 * \param [in] type - a spatial discretization of interest.
9910 * \param [in] iteration - the iteration number of a required time step.
9911 * \param [in] order - the iteration order number of required time step.
9912 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9913 * \param [in] renumPol - specifies how to permute values of the result field according to
9914 * the optional numbers of cells and nodes, if any. The valid values are
9915 * - 0 - do not permute.
9916 * - 1 - permute cells.
9917 * - 2 - permute nodes.
9918 * - 3 - permute cells and nodes.
9920 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9921 * caller is to delete this field using decrRef() as it is no more needed.
9922 * \throw If the MED file is not readable.
9923 * \throw If there is no mesh in the MED file.
9924 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9925 * \throw If no field values of the required parameters are available.
9927 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9929 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9930 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9932 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
9933 MCAuto<DataArray> arr;
9934 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase()));
9935 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9940 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
9941 * the top level cells of the first mesh in MED file.
9942 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9943 * \param [in] type - a spatial discretization of interest.
9944 * \param [in] iteration - the iteration number of a required time step.
9945 * \param [in] order - the iteration order number of required time step.
9946 * \param [in] renumPol - specifies how to permute values of the result field according to
9947 * the optional numbers of cells and nodes, if any. The valid values are
9948 * - 0 - do not permute.
9949 * - 1 - permute cells.
9950 * - 2 - permute nodes.
9951 * - 3 - permute cells and nodes.
9953 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9954 * caller is to delete this field using decrRef() as it is no more needed.
9955 * \throw If the MED file is not readable.
9956 * \throw If there is no mesh in the MED file.
9957 * \throw If no field values of the required parameters are available.
9959 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9961 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9962 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9964 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
9965 MCAuto<DataArray> arr;
9966 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase()));
9967 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9972 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
9974 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9975 * \param [in] type - a spatial discretization of interest.
9976 * \param [in] iteration - the iteration number of a required time step.
9977 * \param [in] order - the iteration order number of required time step.
9978 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9979 * \param [in] mesh - the supporting mesh.
9980 * \param [in] renumPol - specifies how to permute values of the result field according to
9981 * the optional numbers of cells and nodes, if any. The valid values are
9982 * - 0 - do not permute.
9983 * - 1 - permute cells.
9984 * - 2 - permute nodes.
9985 * - 3 - permute cells and nodes.
9987 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9988 * caller is to delete this field using decrRef() as it is no more needed.
9989 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9990 * \throw If no field of \a this is lying on \a mesh.
9991 * \throw If no field values of the required parameters are available.
9993 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9995 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9996 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9998 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9999 MCAuto<DataArray> arr;
10000 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase()));
10001 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10002 return ret2.retn();
10006 * Returns a new MEDCouplingFieldInt of given type, of a given time step, lying on a
10008 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10009 * \param [in] type - a spatial discretization of the new field.
10010 * \param [in] iteration - the iteration number of a required time step.
10011 * \param [in] order - the iteration order number of required time step.
10012 * \param [in] mesh - the supporting mesh.
10013 * \param [out] arrOut - the DataArrayInt containing values of field.
10014 * \param [in] renumPol - specifies how to permute values of the result field according to
10015 * the optional numbers of cells and nodes, if any. The valid values are
10016 * - 0 - do not permute.
10017 * - 1 - permute cells.
10018 * - 2 - permute nodes.
10019 * - 3 - permute cells and nodes.
10021 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10022 * caller is to delete this field using decrRef() as it is no more needed.
10023 * \throw If no field of \a this is lying on \a mesh.
10024 * \throw If no field values of the required parameters are available.
10026 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
10028 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10029 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10031 throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10032 MCAuto<DataArray> arr;
10033 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase()));
10034 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10035 return ret2.retn();
10039 * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
10040 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
10041 * This method is useful for MED2 file format when field on different mesh was autorized.
10043 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol) const
10045 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10046 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10048 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10049 MCAuto<DataArray> arr;
10050 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase()));
10051 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10052 return ret2.retn();
10056 * Returns values and a profile of the field of a given type, of a given time step,
10057 * lying on a given support.
10058 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10059 * \param [in] type - a spatial discretization of the field.
10060 * \param [in] iteration - the iteration number of a required time step.
10061 * \param [in] order - the iteration order number of required time step.
10062 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10063 * \param [in] mesh - the supporting mesh.
10064 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
10065 * field of interest lies on. If the field lies on all entities of the given
10066 * dimension, all ids in \a pfl are zero. The caller is to delete this array
10067 * using decrRef() as it is no more needed.
10068 * \param [in] glob - the global data storing profiles and localization.
10069 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
10070 * field. The caller is to delete this array using decrRef() as it is no more needed.
10071 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10072 * \throw If no field of \a this is lying on \a mesh.
10073 * \throw If no field values of the required parameters are available.
10075 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
10077 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
10078 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
10080 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
10081 MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
10082 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
10086 * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
10087 * \param [in] pos - a time step id.
10088 * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
10089 * delete this field using decrRef() as it is no more needed.
10090 * \throw If \a pos is not a valid time step id.
10092 MEDFileIntField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
10094 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
10097 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
10098 throw INTERP_KERNEL::Exception(oss.str());
10100 const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
10103 MCAuto<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
10104 ret->shallowCpyGlobs(*this);
10107 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
10108 throw INTERP_KERNEL::Exception(oss.str());
10112 * Adds a MEDCouplingFieldInt to \a this as another time step. The underlying mesh of
10113 * the given field is checked if its elements are sorted suitable for writing to MED file
10114 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
10115 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10116 * \param [in] field - the field to add to \a this.
10117 * \throw If the name of \a field is empty.
10118 * \throw If the data array of \a field is not set.
10119 * \throw If existing time steps have different name or number of components than \a field.
10120 * \throw If the underlying mesh of \a field has no name.
10121 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
10123 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldInt *field)
10125 MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
10126 contentNotNull()->appendFieldNoProfileSBT(field2,field->getArray(),*this);
10130 * Adds a MEDCouplingFieldDouble to \a this as another time step.
10131 * The mesh support of input parameter \a field is ignored here, it can be NULL.
10132 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
10135 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
10136 * A new profile is added only if no equal profile is missing.
10137 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10138 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
10139 * \param [in] arrOfVals - the values of the field \a field used.
10140 * \param [in] mesh - the supporting mesh of \a field.
10141 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
10142 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
10143 * \throw If either \a field or \a mesh or \a profile has an empty name.
10144 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10145 * \throw If the data array of \a field is not set.
10146 * \throw If the data array of \a this is already allocated but has different number of
10147 * components than \a field.
10148 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
10149 * \sa setFieldNoProfileSBT()
10151 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
10153 MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
10154 contentNotNull()->appendFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this);
10157 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const
10159 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10161 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
10162 const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10164 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 !");
10168 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull()
10170 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10172 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
10173 MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10175 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 !");
10179 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
10181 _content=new MEDFileIntFieldMultiTSWithoutSDA;
10184 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
10188 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
10189 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
10192 catch(INTERP_KERNEL::Exception& e)
10195 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10196 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
10199 catch(INTERP_KERNEL::Exception& e)
10202 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
10204 return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
10207 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::buildNewEmpty() const
10209 return MEDFileIntFieldMultiTS::New();
10214 MEDFileFields *MEDFileFields::New()
10216 return new MEDFileFields;
10219 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
10221 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10222 return New(fid,loadAll);
10225 MEDFileFields *MEDFileFields::NewWithDynGT(const std::string& fileName, const MEDFileStructureElements *se, bool loadAll)
10227 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10228 return NewWithDynGT(fid,se,loadAll);
10231 MEDFileFields *MEDFileFields::NewWithDynGT(med_idt fid, const MEDFileStructureElements *se, bool loadAll)
10234 throw INTERP_KERNEL::Exception("MEDFileFields::NewWithDynGT : null struct element pointer !");
10235 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> entities(MEDFileEntities::BuildFrom(*se));
10236 return new MEDFileFields(fid,loadAll,0,entities);
10239 MEDFileFields *MEDFileFields::New(med_idt fid, bool loadAll)
10241 return new MEDFileFields(fid,loadAll,0,0);
10244 MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
10246 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10247 return new MEDFileFields(fid,loadAll,ms,0);
10250 MEDFileFields *MEDFileFields::LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
10252 MEDFileUtilities::CheckFileForRead(fileName);
10253 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
10254 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10255 return new MEDFileFields(fid,loadAll,0,ent);
10258 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
10260 std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
10261 ret+=_fields.capacity()*sizeof(MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
10265 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
10267 std::vector<const BigMemoryObject *> ret;
10268 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10269 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
10273 MEDFileFields *MEDFileFields::deepCopy() const
10275 MCAuto<MEDFileFields> ret(shallowCpy());
10277 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10279 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10280 ret->_fields[i]=(*it)->deepCopy();
10282 ret->deepCpyGlobs(*this);
10286 MEDFileFields *MEDFileFields::shallowCpy() const
10288 return new MEDFileFields(*this);
10292 * 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
10293 * 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.
10294 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
10296 * \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.
10297 * \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.
10299 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10301 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
10303 std::set< std::pair<int,int> > s;
10304 bool firstShot=true;
10305 areThereSomeForgottenTS=false;
10306 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10308 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10310 std::vector< std::pair<int,int> > v=(*it)->getIterations();
10311 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
10313 { s=s1; firstShot=false; }
10316 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
10318 areThereSomeForgottenTS=true;
10322 std::vector< std::pair<int,int> > ret;
10323 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
10327 int MEDFileFields::getNumberOfFields() const
10329 return _fields.size();
10332 std::vector<std::string> MEDFileFields::getFieldsNames() const
10334 std::vector<std::string> ret(_fields.size());
10336 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10338 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
10341 ret[i]=f->getName();
10345 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
10346 throw INTERP_KERNEL::Exception(oss.str());
10352 std::vector<std::string> MEDFileFields::getMeshesNames() const
10354 std::vector<std::string> ret;
10355 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10357 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10359 ret.push_back(cur->getMeshName());
10364 std::string MEDFileFields::simpleRepr() const
10366 std::ostringstream oss;
10367 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
10372 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
10374 int nbOfFields(getNumberOfFields());
10375 std::string startLine(bkOffset,' ');
10376 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
10378 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10380 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10383 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
10387 oss << startLine << " - not defined !" << std::endl;
10391 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10393 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10394 std::string chapter(17,'0'+i);
10395 oss << startLine << chapter << std::endl;
10398 cur->simpleRepr(bkOffset+2,oss,i);
10402 oss << startLine << " - not defined !" << std::endl;
10404 oss << startLine << chapter << std::endl;
10406 simpleReprGlobs(oss);
10409 MEDFileFields::MEDFileFields()
10413 MEDFileFields::MEDFileFields(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10414 try:MEDFileFieldGlobsReal(fid)
10416 int nbFields(MEDnField(fid));
10417 _fields.resize(nbFields);
10418 med_field_type typcha;
10419 for(int i=0;i<nbFields;i++)
10421 std::vector<std::string> infos;
10422 std::string fieldName,dtunit;
10423 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,i,false,fieldName,typcha,infos,dtunit));
10428 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10433 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10438 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] !";
10439 throw INTERP_KERNEL::Exception(oss.str());
10443 loadAllGlobals(fid);
10445 catch(INTERP_KERNEL::Exception& e)
10450 void MEDFileFields::writeLL(med_idt fid) const
10453 writeGlobals(fid,*this);
10454 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10456 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
10459 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
10460 throw INTERP_KERNEL::Exception(oss.str());
10462 elt->writeLL(fid,*this);
10467 * This method alloc the arrays and load potentially huge arrays contained in this field.
10468 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
10469 * This method can be also called to refresh or reinit values from a file.
10471 * \throw If the fileName is not set or points to a non readable MED file.
10473 void MEDFileFields::loadArrays()
10475 if(getFileName().empty())
10476 throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
10477 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
10478 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10480 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10482 elt->loadBigArraysRecursively(fid,*elt);
10487 * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
10488 * But once data loaded once, this method does nothing.
10490 * \throw If the fileName is not set or points to a non readable MED file.
10491 * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
10493 void MEDFileFields::loadArraysIfNecessary()
10495 if(!getFileName().empty())
10497 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
10498 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10500 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10502 elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
10508 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
10509 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
10510 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
10512 * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
10514 void MEDFileFields::unloadArrays()
10516 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10518 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10520 elt->unloadArrays();
10525 * 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.
10526 * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
10527 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
10529 * \sa MEDFileFields::loadArraysIfNecessary
10531 void MEDFileFields::unloadArraysWithoutDataLoss()
10533 if(!getFileName().empty())
10537 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
10539 std::vector<std::string> ret;
10540 std::set<std::string> ret2;
10541 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10543 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
10544 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10545 if(ret2.find(*it2)==ret2.end())
10547 ret.push_back(*it2);
10554 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
10556 std::vector<std::string> ret;
10557 std::set<std::string> ret2;
10558 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10560 std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
10561 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10562 if(ret2.find(*it2)==ret2.end())
10564 ret.push_back(*it2);
10571 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
10573 std::vector<std::string> ret;
10574 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10576 std::vector<std::string> tmp((*it)->getPflsReallyUsedMulti2());
10577 ret.insert(ret.end(),tmp.begin(),tmp.end());
10582 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
10584 std::vector<std::string> ret;
10585 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10587 std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
10588 ret.insert(ret.end(),tmp.begin(),tmp.end());
10593 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10595 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10596 (*it)->changePflsRefsNamesGen2(mapOfModif);
10599 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10601 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10602 (*it)->changeLocsRefsNamesGen2(mapOfModif);
10605 void MEDFileFields::resize(int newSize)
10607 _fields.resize(newSize);
10610 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
10612 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
10616 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
10619 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
10620 _fields.push_back(field->getContent());
10621 appendGlobs(*field,1e-12);
10624 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
10627 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
10628 if(i>=(int)_fields.size())
10629 _fields.resize(i+1);
10630 _fields[i]=field->getContent();
10631 appendGlobs(*field,1e-12);
10634 void MEDFileFields::destroyFieldAtPos(int i)
10636 destroyFieldsAtPos(&i,&i+1);
10639 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
10641 std::vector<bool> b(_fields.size(),true);
10642 for(const int *i=startIds;i!=endIds;i++)
10644 if(*i<0 || *i>=(int)_fields.size())
10646 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10647 throw INTERP_KERNEL::Exception(oss.str());
10651 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10653 for(std::size_t i=0;i<_fields.size();i++)
10655 fields[j++]=_fields[i];
10659 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
10661 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
10662 int nbOfEntriesToKill(DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg));
10663 std::vector<bool> b(_fields.size(),true);
10665 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
10667 if(k<0 || k>=(int)_fields.size())
10669 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
10670 throw INTERP_KERNEL::Exception(oss.str());
10674 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10676 for(std::size_t i=0;i<_fields.size();i++)
10678 fields[j++]=_fields[i];
10682 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
10685 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10687 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10689 ret=cur->changeMeshNames(modifTab) || ret;
10695 * \param [in] meshName the name of the mesh that will be renumbered.
10696 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
10697 * This code corresponds to the distribution of types in the corresponding mesh.
10698 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
10699 * \param [in] renumO2N the old to new renumber array.
10700 * \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
10701 * field in \a this.
10703 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
10706 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10708 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
10711 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
10718 * Return an extraction of \a this using \a extractDef map to specify the extraction.
10719 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
10721 * \return A new object that the caller is responsible to deallocate.
10723 MEDFileFields *MEDFileFields::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
10726 throw INTERP_KERNEL::Exception("MEDFileFields::extractPart : input mesh is NULL !");
10727 MCAuto<MEDFileFields> fsOut(MEDFileFields::New());
10728 int nbFields(getNumberOfFields());
10729 for(int i=0;i<nbFields;i++)
10731 MCAuto<MEDFileAnyTypeFieldMultiTS> fmts(getFieldAtPos(i));
10734 std::ostringstream oss; oss << "MEDFileFields::extractPart : at pos #" << i << " field is null !";
10735 throw INTERP_KERNEL::Exception(oss.str());
10737 MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(fmts->extractPart(extractDef,mm));
10738 fsOut->pushField(fmtsOut);
10740 return fsOut.retn();
10743 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
10745 if(i<0 || i>=(int)_fields.size())
10747 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
10748 throw INTERP_KERNEL::Exception(oss.str());
10750 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
10753 MCAuto<MEDFileAnyTypeFieldMultiTS> ret;
10754 const MEDFileFieldMultiTSWithoutSDA *fmtsC(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts));
10755 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts));
10757 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
10759 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
10762 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
10763 throw INTERP_KERNEL::Exception(oss.str());
10765 ret->shallowCpyGlobs(*this);
10770 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
10771 * This method is accessible in python using __getitem__ with a list in input.
10772 * \return a new object that the caller should deal with.
10774 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
10776 MCAuto<MEDFileFields> ret=shallowCpy();
10777 std::size_t sz=std::distance(startIds,endIds);
10778 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
10780 for(const int *i=startIds;i!=endIds;i++,j++)
10782 if(*i<0 || *i>=(int)_fields.size())
10784 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10785 throw INTERP_KERNEL::Exception(oss.str());
10787 fields[j]=_fields[*i];
10789 ret->_fields=fields;
10793 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
10795 return getFieldAtPos(getPosFromFieldName(fieldName));
10799 * This method removes, if any, fields in \a this having no time steps.
10800 * 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.
10802 * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
10804 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
10806 std::vector<MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
10807 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10809 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10812 if(elt->getNumberOfTS()>0)
10813 newFields.push_back(*it);
10816 if(_fields.size()==newFields.size())
10823 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
10824 * This method can be seen as a filter applied on \a this, that returns an object containing
10825 * 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
10826 * shallow copied from \a this.
10828 * \param [in] meshName - the name of the mesh on w
10829 * \return a new object that the caller should deal with.
10831 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
10833 MCAuto<MEDFileFields> ret(MEDFileFields::New());
10834 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10836 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10839 if(cur->getMeshName()==meshName)
10842 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
10843 ret->_fields.push_back(cur2);
10846 ret->shallowCpyOnlyUsedGlobs(*this);
10851 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
10852 * Input time steps are specified using a pair of integer (iteration, order).
10853 * 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,
10854 * but for each multitimestep only the time steps in \a timeSteps are kept.
10855 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
10857 * The returned object points to shallow copy of elements in \a this.
10859 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
10860 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
10861 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10863 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10865 MCAuto<MEDFileFields> ret(MEDFileFields::New());
10866 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10868 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10871 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
10872 ret->_fields.push_back(elt);
10874 ret->shallowCpyOnlyUsedGlobs(*this);
10879 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
10881 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10883 MCAuto<MEDFileFields> ret=MEDFileFields::New();
10884 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10886 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10889 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
10890 if(elt->getNumberOfTS()!=0)
10891 ret->_fields.push_back(elt);
10893 ret->shallowCpyOnlyUsedGlobs(*this);
10897 MEDFileFieldsIterator *MEDFileFields::iterator()
10899 return new MEDFileFieldsIterator(this);
10902 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
10904 std::string tmp(fieldName);
10905 std::vector<std::string> poss;
10906 for(std::size_t i=0;i<_fields.size();i++)
10908 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f(_fields[i]);
10911 std::string fname(f->getName());
10915 poss.push_back(fname);
10918 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
10919 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
10921 throw INTERP_KERNEL::Exception(oss.str());
10924 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
10929 _nb_iter=fs->getNumberOfFields();
10933 MEDFileFieldsIterator::~MEDFileFieldsIterator()
10937 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
10939 if(_iter_id<_nb_iter)
10941 MEDFileFields *fs(_fs);
10943 return fs->getFieldAtPos(_iter_id++);