1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (CEA/DEN)
21 #include "MEDFileField.txx"
22 #include "MEDFileMesh.hxx"
23 #include "MEDLoaderBase.hxx"
24 #include "MEDLoaderTraits.hxx"
25 #include "MEDFileSafeCaller.txx"
26 #include "MEDFileFieldOverView.hxx"
28 #include "MEDCouplingFieldDouble.hxx"
29 #include "MEDCouplingFieldTemplate.hxx"
30 #include "MEDCouplingFieldDiscretization.hxx"
32 #include "InterpKernelAutoPtr.hxx"
33 #include "CellModel.hxx"
38 extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
39 extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
40 extern med_geometry_type typmainoeud[1];
41 extern med_geometry_type typmai3[34];
43 using namespace MEDCoupling;
45 template class MEDFileField1TSTemplateWithoutSDA<int>;
46 template class MEDFileField1TSTemplateWithoutSDA<double>;
48 const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64";
49 const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32";
51 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const std::string& locName)
53 return new MEDFileFieldLoc(fid,locName);
56 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, int id)
58 return new MEDFileFieldLoc(fid,id);
61 MEDFileFieldLoc *MEDFileFieldLoc::New(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
63 return new MEDFileFieldLoc(locName,geoType,refCoo,gsCoo,w);
66 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, const std::string& locName):_name(locName)
68 med_geometry_type geotype;
69 med_geometry_type sectiongeotype;
71 INTERP_KERNEL::AutoPtr<char> geointerpname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
72 INTERP_KERNEL::AutoPtr<char> sectionmeshname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
73 MEDlocalizationInfoByName(fid,locName.c_str(),&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
74 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
75 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
76 _nb_node_per_cell=cm.getNumberOfNodes();
77 _ref_coo.resize(_dim*_nb_node_per_cell);
78 _gs_coo.resize(_dim*_nb_gauss_pt);
79 _w.resize(_nb_gauss_pt);
80 MEDlocalizationRd(fid,locName.c_str(),MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
83 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id)
85 med_geometry_type geotype;
86 med_geometry_type sectiongeotype;
88 INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
89 INTERP_KERNEL::AutoPtr<char> geointerpname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
90 INTERP_KERNEL::AutoPtr<char> sectionmeshname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
91 MEDlocalizationInfo(fid,id+1,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
93 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
94 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
95 _nb_node_per_cell=cm.getNumberOfNodes();
96 _ref_coo.resize(_dim*_nb_node_per_cell);
97 _gs_coo.resize(_dim*_nb_gauss_pt);
98 _w.resize(_nb_gauss_pt);
99 MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
102 MEDFileFieldLoc::MEDFileFieldLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType,
103 const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w):_name(locName),_geo_type(geoType),_ref_coo(refCoo),_gs_coo(gsCoo),
106 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
107 _dim=cm.getDimension();
108 _nb_node_per_cell=cm.getNumberOfNodes();
109 _nb_gauss_pt=_w.size();
112 MEDFileFieldLoc *MEDFileFieldLoc::deepCopy() const
114 return new MEDFileFieldLoc(*this);
117 std::size_t MEDFileFieldLoc::getHeapMemorySizeWithoutChildren() const
119 return (_ref_coo.capacity()+_gs_coo.capacity()+_w.capacity())*sizeof(double)+_name.capacity();
122 std::vector<const BigMemoryObject *> MEDFileFieldLoc::getDirectChildrenWithNull() const
124 return std::vector<const BigMemoryObject *>();
127 void MEDFileFieldLoc::simpleRepr(std::ostream& oss) const
129 static const char OFF7[]="\n ";
130 oss << "\"" << _name << "\"" << OFF7;
131 oss << "GeoType=" << INTERP_KERNEL::CellModel::GetCellModel(_geo_type).getRepr() << OFF7;
132 oss << "Dimension=" << _dim << OFF7;
133 oss << "Number of Gauss points=" << _nb_gauss_pt << OFF7;
134 oss << "Number of nodes per cell=" << _nb_node_per_cell << OFF7;
135 oss << "RefCoords="; std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
136 oss << "Weights="; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
137 oss << "GaussPtsCoords="; std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," ")); oss << std::endl;
140 void MEDFileFieldLoc::setName(const std::string& name)
145 bool MEDFileFieldLoc::isEqual(const MEDFileFieldLoc& other, double eps) const
147 if(_name!=other._name)
151 if(_nb_gauss_pt!=other._nb_gauss_pt)
153 if(_nb_node_per_cell!=other._nb_node_per_cell)
155 if(_geo_type!=other._geo_type)
157 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_ref_coo,other._ref_coo,eps))
159 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_gs_coo,other._gs_coo,eps))
161 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_w,other._w,eps))
167 void MEDFileFieldLoc::writeLL(med_idt fid) const
169 MEDlocalizationWr(fid,_name.c_str(),typmai3[(int)_geo_type],_dim,&_ref_coo[0],MED_FULL_INTERLACE,_nb_gauss_pt,&_gs_coo[0],&_w[0],MED_NO_INTERPOLATION,MED_NO_MESH_SUPPORT);
172 std::string MEDFileFieldLoc::repr() const
174 std::ostringstream oss; oss.precision(15);
175 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
176 oss << "Localization \"" << _name << "\" :\n" << " - Geometric Type : " << cm.getRepr();
177 oss << "\n - Dimension : " << _dim << "\n - Number of gauss points : ";
178 oss << _nb_gauss_pt << "\n - Number of nodes in cell : " << _nb_node_per_cell;
179 oss << "\n - Ref coords are : ";
180 int sz=_ref_coo.size();
183 int nbOfTuples=sz/_dim;
184 for(int i=0;i<nbOfTuples;i++)
187 for(int j=0;j<_dim;j++)
188 { oss << _ref_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
193 std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," "));
194 oss << "\n - Gauss coords in reference element : ";
198 int nbOfTuples=sz/_dim;
199 for(int i=0;i<nbOfTuples;i++)
202 for(int j=0;j<_dim;j++)
203 { oss << _gs_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
208 std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," "));
209 oss << "\n - Weights of Gauss coords are : "; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," "));
213 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
215 _type=field->getTypeOfField();
221 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,offset,offset+nbOfCells,1);
222 _end=_start+nbOfCells;
228 MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
229 const int *arrPtr=arr->getConstPointer();
230 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,arrPtr[offset],arrPtr[offset+nbOfCells],1);
231 _end=_start+(arrPtr[offset+nbOfCells]-arrPtr[offset]);
237 const MEDCouplingFieldDiscretization *disc(field->getDiscretization());
238 const MEDCouplingGaussLocalization& gsLoc(field->getGaussLocalization(_loc_id));
239 const MEDCouplingFieldDiscretizationGauss *disc2(dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc));
241 throw INTERP_KERNEL::Exception("assignFieldNoProfile : invalid call to this method ! Internal Error !");
242 const DataArrayInt *dai(disc2->getArrayOfDiscIds());
243 MCAuto<DataArrayInt> dai2(disc2->getOffsetArr(field->getMesh()));
244 const int *dai2Ptr(dai2->getConstPointer());
245 int nbi(gsLoc.getWeights().size());
246 MCAuto<DataArrayInt> da2(dai->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1));
247 MCAuto<DataArrayInt> da3(da2->findIdsEqual(_loc_id));
248 const int *da3Ptr(da3->getConstPointer());
249 if(da3->getNumberOfTuples()!=nbOfCells)
250 {//profile : for gauss even in NoProfile !!!
251 std::ostringstream oss; oss << "Pfl_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
253 da3->setName(_profile.c_str());
254 glob.appendProfile(da3);
256 MCAuto<DataArrayInt> da4(DataArrayInt::New());
257 _nval=da3->getNbOfElems();
258 da4->alloc(_nval*nbi,1);
259 int *da4Ptr(da4->getPointer());
260 for(int i=0;i<_nval;i++)
262 int ref=dai2Ptr[offset+da3Ptr[i]];
263 for(int j=0;j<nbi;j++)
266 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
267 _localization=oss2.str();
268 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,da4);
269 _end=_start+_nval*nbi;
270 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
274 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile : not implemented yet for such discretization type of field !");
280 * Leaf method of field with profile assignement. This method is the most general one. No optimization is done here.
281 * \param [in] pflName input containing name of profile if any. 0 if no profile (except for GAUSS_PT where a no profile can hide a profile when splitted by loc_id).
282 * \param [in] multiTypePfl is the end user profile specified in high level API
283 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
284 * \param [in] locIds is the profile needed to be created for MED file format. It can be null if all cells of current geometric type are fetched in \a multiTypePfl.
285 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
286 * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
288 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arrr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
291 _type=field->getTypeOfField();
292 std::string pflName(multiTypePfl->getName());
293 std::ostringstream oss; oss << pflName;
297 { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType()); oss << "_" << cm.getRepr(); }
304 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : existing profile with empty name !");
305 if(_type!=ON_GAUSS_PT)
307 locIds->setName(oss.str());
308 glob.appendProfile(locIds);
317 _nval=idsInPfl->getNumberOfTuples();
318 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,0,arrr->getNumberOfTuples(),1);
324 _nval=idsInPfl->getNumberOfTuples();
325 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,idsInPfl);
331 MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
332 MCAuto<DataArrayInt> arr2=arr->deltaShiftIndex();
333 MCAuto<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->begin(),multiTypePfl->end());
334 arr3->computeOffsetsFull();
335 MCAuto<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
336 int trueNval=tmp->getNumberOfTuples();
337 _nval=idsInPfl->getNumberOfTuples();
338 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
339 _end=_start+trueNval;
344 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(field->getDiscretization());
346 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
347 const DataArrayInt *da1=disc2->getArrayOfDiscIds();
348 const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
349 MCAuto<DataArrayInt> da2=da1->selectByTupleId(idsInPfl->begin(),idsInPfl->end());
350 MCAuto<DataArrayInt> da3=da2->findIdsEqual(_loc_id);
351 MCAuto<DataArrayInt> da4=idsInPfl->selectByTupleId(da3->begin(),da3->end());
353 MCAuto<MEDCouplingMesh> mesh2=mesh->buildPart(multiTypePfl->begin(),multiTypePfl->end());
354 MCAuto<DataArrayInt> arr=disc2->getOffsetArr(mesh2);
356 MCAuto<DataArrayInt> tmp=DataArrayInt::New();
358 for(const int *pt=da4->begin();pt!=da4->end();pt++)
359 trueNval+=arr->getIJ(*pt+1,0)-arr->getIJ(*pt,0);
360 tmp->alloc(trueNval,1);
361 int *tmpPtr=tmp->getPointer();
362 for(const int *pt=da4->begin();pt!=da4->end();pt++)
363 for(int j=arr->getIJ(*pt,0);j<arr->getIJ(*pt+1,0);j++)
366 _nval=da4->getNumberOfTuples();
367 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
368 _end=_start+trueNval;
369 oss << "_loc_" << _loc_id;
372 MCAuto<DataArrayInt> da5=locIds->selectByTupleId(da3->begin(),da3->end());
373 da5->setName(oss.str());
374 glob.appendProfile(da5);
379 if(!da3->isIota(nbOfEltsInWholeMesh))
381 da3->setName(oss.str());
382 glob.appendProfile(da3);
386 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
387 _localization=oss2.str();
388 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
392 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for such discretization type of field !");
397 void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob)
400 _nval=arrr->getNumberOfTuples();
401 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,0,_nval,1);
406 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int profileIt, const PartDefinition *pd)
408 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt,pd);
411 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int locId)
413 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string());
416 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(const MEDFileFieldPerMeshPerTypePerDisc& other)
418 return new MEDFileFieldPerMeshPerTypePerDisc(other);
421 std::size_t MEDFileFieldPerMeshPerTypePerDisc::getHeapMemorySizeWithoutChildren() const
423 return _profile.capacity()+_localization.capacity()+sizeof(MEDFileFieldPerMeshPerTypePerDisc);
426 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypePerDisc::getDirectChildrenWithNull() const
428 std::vector<const BigMemoryObject *> ret(1);
429 ret[0]=(const PartDefinition*)_pd;
433 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCopy(MEDFileFieldPerMeshPerTypeCommon *father) const
435 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret=new MEDFileFieldPerMeshPerTypePerDisc(*this);
440 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField atype, int profileIt, const PartDefinition *pd)
441 try:_type(atype),_father(fath),_profile_it(profileIt),_pd(const_cast<PartDefinition *>(pd))
446 catch(INTERP_KERNEL::Exception& e)
451 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
455 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(const MEDFileFieldPerMeshPerTypePerDisc& other):RefCountObject(other),_type(other._type),_father(0),_start(other._start),_end(other._end),_nval(other._nval),_profile(other._profile),_localization(other._localization),_loc_id(other._loc_id),_profile_it(other._profile_it),_pd(other._pd),_tmp_work1(other._tmp_work1)
459 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(0),_start(-std::numeric_limits<int>::max()),_end(-std::numeric_limits<int>::max()),
460 _nval(-std::numeric_limits<int>::max()),_loc_id(-std::numeric_limits<int>::max())
464 void MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile(med_idt fid, const std::string& fieldName, int nbOfCompo, int iteration, int order, med_entity_type menti, med_geometry_type mgeoti, unsigned char *startFeedingPtr)
466 const PartDefinition *pd(_pd);
469 INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
471 med_int nbValsInFile(MEDfieldnValueWithProfileByName(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile.c_str(),MED_COMPACT_PFLMODE,&tmp1,locname,&nbi));
472 if(_end-_start!=nbValsInFile*nbi)
474 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : The number of tuples to read is " << nbValsInFile << "*" << nbi << " (nb integration points) ! But in data structure it values " << _end-_start << " is expected !";
475 throw INTERP_KERNEL::Exception(oss.str());
477 MEDFILESAFECALLERRD0(MEDfieldValueWithProfileRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,_profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,startFeedingPtr));
481 if(!_profile.empty())
482 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : not implemented !");
483 INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)),locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
485 int overallNval(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
486 const SlicePartDefinition *spd(dynamic_cast<const SlicePartDefinition *>(pd));
490 spd->getSlice(start,stop,step);
491 int nbOfEltsToLoad(DataArray::GetNumberOfItemGivenBES(start,stop,step,"MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile"));
492 med_filter filter=MED_FILTER_INIT;
493 MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
494 MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
495 /*start*/start+1,/*stride*/step,/*count*/1,/*blocksize*/nbOfEltsToLoad,
496 /*lastblocksize=useless because count=1*/0,&filter);
497 MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,startFeedingPtr));
498 MEDfilterClose(&filter);
501 const DataArrayPartDefinition *dpd(dynamic_cast<const DataArrayPartDefinition *>(pd));
504 dpd->checkConsistencyLight();
505 MCAuto<DataArrayInt> myIds(dpd->toDAI());
506 int a(myIds->getMinValueInArray()),b(myIds->getMaxValueInArray());
507 myIds=myIds->deepCopy();// WARNING deep copy here because _pd is modified by applyLin !!!
508 myIds->applyLin(1,-a);
509 int nbOfEltsToLoad(b-a+1);
510 med_filter filter=MED_FILTER_INIT;
511 {//TODO : manage int32 !
512 MCAuto<DataArrayDouble> tmp(DataArrayDouble::New());
513 tmp->alloc(nbOfEltsToLoad,nbOfCompo);
514 MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
515 MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
516 /*start*/a+1,/*stride*/1,/*count*/1,/*blocksize*/nbOfEltsToLoad,
517 /*lastblocksize=useless because count=1*/0,&filter);
518 MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,reinterpret_cast<unsigned char *>(tmp->getPointer())));
519 MCAuto<DataArrayDouble> feeder(DataArrayDouble::New());
520 feeder->useExternalArrayWithRWAccess(reinterpret_cast<double *>(startFeedingPtr),_nval,nbOfCompo);
521 feeder->setContigPartOfSelectedValues(0,tmp,myIds);
523 MEDfilterClose(&filter);
526 throw INTERP_KERNEL::Exception("Not implemented yet for not slices!");
530 const MEDFileFieldPerMeshPerTypeCommon *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
535 void MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
537 INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
538 INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
539 std::string fieldName(nasc.getName()),meshName(getMeshName());
540 int iteration(getIteration()),order(getOrder()),profilesize,nbi;
541 TypeOfField type(getType());
542 med_geometry_type mgeoti;
543 med_entity_type menti;
544 _father->entriesForMEDfile(type,mgeoti,menti);
545 int zeNVal(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
546 _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
547 _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
548 const PartDefinition *pd(_pd);
555 if(!_profile.empty())
556 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively : profiles are not managed yet with part of def !");
557 _nval=pd->getNumberOfElems();
560 _end=start+_nval*nbi;
562 if(type==ON_CELLS && !_localization.empty())
564 if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
565 setType(ON_GAUSS_PT);
568 setType(ON_GAUSS_NE);
569 _localization.clear();
574 void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, const MEDFileFieldNameScope& nasc)
576 std::string fieldName(nasc.getName()),meshName(getMeshName());
577 int iteration(getIteration()),order(getOrder());
578 TypeOfField type(getType());
579 med_geometry_type mgeoti;
580 med_entity_type menti;
581 _father->entriesForMEDfile(type,mgeoti,menti);
583 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !");
586 DataArray *arr(getOrCreateAndGetArray());//arr is not null due to the spec of getOrCreateAndGetArray
587 if(_start<0 || _start>=arr->getNumberOfTuples())
589 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << ") !";
590 throw INTERP_KERNEL::Exception(oss.str());
592 if(_end<0 || _end>arr->getNumberOfTuples())
594 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !";
595 throw INTERP_KERNEL::Exception(oss.str());
597 int nbOfCompo(arr->getNumberOfComponents());
598 DataArrayDouble *arrD(dynamic_cast<DataArrayDouble *>(arr));
601 double *startFeeding(arrD->getPointer()+_start*nbOfCompo);
602 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
605 DataArrayInt *arrI(dynamic_cast<DataArrayInt *>(arr));
608 int *startFeeding(arrI->getPointer()+_start*nbOfCompo);
609 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
612 throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
616 * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
618 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart)
620 int delta=_end-_start;
621 _start=newValueOfStart;
625 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
627 return _father->getIteration();
630 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
632 return _father->getOrder();
635 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
637 return _father->getTime();
640 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
642 return _father->getMeshName();
645 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
647 const char startLine[]=" ## ";
648 std::string startLine2(bkOffset,' ');
649 startLine2+=startLine;
650 INTERP_KERNEL::AutoCppPtr<MEDCouplingFieldDiscretization> tmp(MEDCouplingFieldDiscretization::New(_type));
651 oss << startLine2 << "Localization #" << id << "." << std::endl;
652 oss << startLine2 << " Type=" << tmp->getRepr() << "." << std::endl;
653 oss << startLine2 << " This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
654 oss << startLine2 << " This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
655 oss << startLine2 << " This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
658 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
663 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
665 return _father->getGeoType();
668 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
673 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
678 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
680 return _father->getNumberOfComponents();
683 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
688 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray()
690 return _father->getOrCreateAndGetArray();
693 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const
695 const MEDFileFieldPerMeshPerTypeCommon *fath=_father;
696 return fath->getOrCreateAndGetArray();
699 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
701 return _father->getInfo();
704 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
709 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const std::string& newPflName)
714 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
716 return _localization;
719 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const std::string& newLocName)
721 _localization=newLocName;
724 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
726 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
728 if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
730 _profile=(*it2).second;
736 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
738 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
740 if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
742 _localization=(*it2).second;
748 void MEDFileFieldPerMeshPerTypePerDisc::getFieldAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
752 dads.push_back(std::pair<int,int>(_start,_end));
753 geoTypes.push_back(getGeoType());
758 pfls.push_back(glob->getProfile(_profile.c_str()));
760 if(_localization.empty())
764 locs.push_back(glob->getLocalizationId(_localization.c_str()));
768 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
770 entries[startEntryId]=std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int> ,std::pair<int,int> >(std::pair<INTERP_KERNEL::NormalizedCellType,int>(getGeoType(),discId),std::pair<int,int>(_start,_end));
774 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
776 TypeOfField type=getType();
777 INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
778 med_geometry_type mgeoti;
779 med_entity_type menti;
780 _father->entriesForMEDfile(getType(),mgeoti,menti);
781 const DataArray *arr(getOrCreateAndGetArray());
783 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
784 if(!arr->isAllocated())
785 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : the array to be written is not allocated !");
786 const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
787 const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
788 const unsigned char *locToWrite=0;
790 locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
792 locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
794 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
795 MEDFILESAFECALLERWR0(MEDfieldValueWithProfileWr,(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
796 MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
800 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const
805 dad.first=_start; dad.second=_end;
809 * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
810 * This code corresponds to the distribution of types in the corresponding mesh.
811 * \param [out] ptToFill memory zone where the output will be stored.
812 * \return the size of data pushed into output param \a ptToFill
814 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const
817 std::ostringstream oss;
818 std::size_t nbOfType=codeOfMesh.size()/3;
820 for(std::size_t i=0;i<nbOfType && found==-1;i++)
821 if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
825 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
826 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
827 throw INTERP_KERNEL::Exception(oss.str());
832 if(_nval!=codeOfMesh[3*found+1])
834 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
835 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
836 oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
837 throw INTERP_KERNEL::Exception(oss.str());
839 for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
844 const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
845 if(pfl->getNumberOfTuples()!=_nval)
847 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
848 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
850 oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
851 throw INTERP_KERNEL::Exception(oss.str());
853 int offset2=codeOfMesh[3*found+2];
854 for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
856 if(*pflId<codeOfMesh[3*found+1])
857 *work++=offset2+*pflId;
863 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const
865 for(int i=_start;i<_end;i++)
870 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId)
881 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
885 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
888 std::map<std::pair<std::string,TypeOfField>,int> m;
889 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
890 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
891 if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
892 m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
894 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
895 ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
900 * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
902 * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
903 * \param [in] entriesOnSameDisc some entries **on same localization** if not the result can be invalid. The _start and _end on them are relative to \a arr parameter.
904 * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
905 * \param [in] newCode one of the input parameter to explicit the new geo type dispatch (in classical format same than those asked by MEDFileFields::renumberEntitiesLyingOnMesh)
906 * \param [in,out] glob if necessary by the method, new profiles can be added to it
907 * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
908 * \param [out] result All new entries will be appended on it.
909 * \return false if the configuration of renumbering leads to an unnecessary resplit of input \a entriesOnSameDisc. If not true is returned (the most general case !)
911 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
912 const DataArrayInt *explicitIdsInMesh,
913 const std::vector<int>& newCode,
914 MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
915 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >& result)
917 if(entriesOnSameDisc.empty())
919 TypeOfField type=entriesOnSameDisc[0]->getType();
920 int szEntities=0,szTuples=0;
921 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
922 { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
923 int nbi=szTuples/szEntities;
924 if(szTuples%szEntities!=0)
925 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
926 MCAuto<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
927 MCAuto<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
928 std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
929 std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
930 std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
931 std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
932 MCAuto<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
934 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
936 int startOfEltIdOfChunk=(*it)->_start;
937 MCAuto<DataArrayInt> newEltIds=explicitIdsInMesh->subArray(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
938 MCAuto<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
939 MCAuto<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
941 MCAuto<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
942 newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
944 newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
945 newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
947 MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
948 MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
949 MCAuto<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
950 MCAuto<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
952 MCAuto<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
954 MCAuto<DataArrayDouble> arrPart=arr->subArray(offset,offset+szTuples);
955 arrPart->renumberInPlace(renumTupleIds->begin());
956 arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
958 const int *idIt=diffVals->begin();
959 std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
961 for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
963 MCAuto<DataArrayInt> ids=newGeoTypesEltIdsAllGather->findIdsEqual(*idIt);
964 MCAuto<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
965 int nbEntityElts=subIds->getNumberOfTuples();
967 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
968 NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIota(newCode[3*(*idIt)+1]),nbi,
972 result.push_back(eltToAdd);
973 offset2+=nbEntityElts*nbi;
975 ret=ret || li.empty();
980 * \param [in] typeF type of field of new chunk
981 * \param [in] geoType the geometric type of the chunk
982 * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
983 * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
984 * \param [in] nbi number of integration points
985 * \param [in] offset The offset in the **global array of data**.
986 * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
987 * to the new chunk to create.
988 * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
989 * \param [out] notInExisting If false the return newly allocated entry is not coming from \a entriesOnSameDisc. If true the output comes from copy of \a entriesOnSameDisc
990 * and corresponding entry erased from \a entriesOnSameDisc.
991 * \return a newly allocated chunk
993 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
994 bool isPfl, int nbi, int offset,
995 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
996 MEDFileFieldGlobsReal& glob,
999 int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
1000 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
1001 for(;it!=entriesOnSameDisc.end();it++)
1003 if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
1007 if((*it)->_profile.empty())
1010 if(!(*it)->_profile.empty())
1012 const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
1013 if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
1019 if(it==entriesOnSameDisc.end())
1022 MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
1024 ret->_loc_id=(int)geoType;
1025 ret->_nval=nbMeshEntities;
1027 ret->_end=ret->_start+ret->_nval*nbi;
1030 idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
1031 glob.appendProfile(idsOfMeshElt);
1032 ret->_profile=idsOfMeshElt->getName();
1034 //tony treatment of localization
1039 notInExisting=false;
1040 MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1041 ret->_loc_id=(int)geoType;
1042 ret->setNewStart(offset);
1043 entriesOnSameDisc.erase(it);
1049 ////////////////////////////////////
1051 MEDFileFieldPerMeshPerTypeCommon::~MEDFileFieldPerMeshPerTypeCommon()
1055 void MEDFileFieldPerMeshPerTypeCommon::setFather(MEDFileFieldPerMesh *father)
1060 void MEDFileFieldPerMeshPerTypeCommon::deepCopyElements()
1063 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1065 if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
1066 _field_pm_pt_pd[i]=(*it)->deepCopy(this);
1070 std::size_t MEDFileFieldPerMeshPerTypeCommon::getHeapMemorySizeWithoutChildren() const
1072 return _field_pm_pt_pd.capacity()*sizeof(MCAuto<MEDFileFieldPerMeshPerTypePerDisc>);
1075 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypeCommon::getDirectChildrenWithNull() const
1077 std::vector<const BigMemoryObject *> ret;
1078 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1079 ret.push_back((const MEDFileFieldPerMeshPerTypePerDisc *)*it);
1083 void MEDFileFieldPerMeshPerTypeCommon::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1085 std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
1086 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1087 _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1091 * This method is the most general one. No optimization is done here.
1092 * \param [in] multiTypePfl is the end user profile specified in high level API
1093 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1094 * \param [in] locIds is the profile needed to be created for MED file format. It can be null if all cells of current geometric type are fetched in \a multiTypePfl.
1095 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1096 * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1097 * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
1099 void MEDFileFieldPerMeshPerTypeCommon::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1101 std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1102 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1103 _field_pm_pt_pd[*it]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1106 void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1108 _field_pm_pt_pd.resize(1);
1109 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1110 _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1113 void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1115 MCAuto<DataArrayInt> pfl2=pfl->deepCopy();
1116 if(!arr || !arr->isAllocated())
1117 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile : input array is null, or not allocated !");
1118 _field_pm_pt_pd.resize(1);
1119 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1120 _field_pm_pt_pd[0]->assignFieldProfile(true,start,pfl,pfl2,pfl2,-1,field,arr,0,glob,nasc);//mesh is not requested so 0 is send.
1123 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1125 TypeOfField type=field->getTypeOfField();
1126 if(type!=ON_GAUSS_PT)
1128 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1129 int sz=_field_pm_pt_pd.size();
1131 for(int j=0;j<sz && !found;j++)
1133 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1135 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1141 _field_pm_pt_pd.resize(sz+1);
1142 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1144 std::vector<int> ret(1,(int)sz);
1149 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1150 int sz2=ret2.size();
1151 std::vector<int> ret3(sz2);
1153 for(int i=0;i<sz2;i++)
1155 int sz=_field_pm_pt_pd.size();
1156 int locIdToFind=ret2[i];
1158 for(int j=0;j<sz && !found;j++)
1160 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1162 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1169 _field_pm_pt_pd.resize(sz+1);
1170 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1178 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1180 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1181 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1183 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1184 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1186 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1187 MCAuto<DataArrayInt> da2=da->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1);
1188 MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1189 if(retTmp->presenceOfValue(-1))
1190 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1191 std::vector<int> ret(retTmp->begin(),retTmp->end());
1195 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1197 TypeOfField type=field->getTypeOfField();
1198 if(type!=ON_GAUSS_PT)
1200 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1201 int sz=_field_pm_pt_pd.size();
1203 for(int j=0;j<sz && !found;j++)
1205 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1207 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1213 _field_pm_pt_pd.resize(sz+1);
1214 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1216 std::vector<int> ret(1,0);
1221 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1222 int sz2=ret2.size();
1223 std::vector<int> ret3(sz2);
1225 for(int i=0;i<sz2;i++)
1227 int sz=_field_pm_pt_pd.size();
1228 int locIdToFind=ret2[i];
1230 for(int j=0;j<sz && !found;j++)
1232 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1234 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1241 _field_pm_pt_pd.resize(sz+1);
1242 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1250 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1252 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1253 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1255 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1256 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1258 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1259 MCAuto<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1260 MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1261 if(retTmp->presenceOfValue(-1))
1262 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1263 std::vector<int> ret(retTmp->begin(),retTmp->end());
1267 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerTypeCommon::getFather() const
1272 bool MEDFileFieldPerMeshPerTypeCommon::isUniqueLevel(int& dim) const
1274 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
1275 int curDim((int)cm.getDimension());
1276 if(dim!=std::numeric_limits<int>::max())
1286 void MEDFileFieldPerMeshPerTypeCommon::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1288 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1290 (*it)->fillTypesOfFieldAvailable(types);
1294 void MEDFileFieldPerMeshPerTypeCommon::fillFieldSplitedByType(std::vector< std::pair<int,int> >& dads, std::vector<TypeOfField>& types, std::vector<std::string>& pfls, std::vector<std::string>& locs) const
1296 int sz=_field_pm_pt_pd.size();
1297 dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1298 for(int i=0;i<sz;i++)
1300 _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1304 int MEDFileFieldPerMeshPerTypeCommon::getIteration() const
1306 return _father->getIteration();
1309 int MEDFileFieldPerMeshPerTypeCommon::getOrder() const
1311 return _father->getOrder();
1314 double MEDFileFieldPerMeshPerTypeCommon::getTime() const
1316 return _father->getTime();
1319 std::string MEDFileFieldPerMeshPerTypeCommon::getMeshName() const
1321 return _father->getMeshName();
1324 void MEDFileFieldPerMeshPerTypeCommon::getSizes(int& globalSz, int& nbOfEntries) const
1326 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1328 globalSz+=(*it)->getNumberOfTuples();
1330 nbOfEntries+=(int)_field_pm_pt_pd.size();
1333 int MEDFileFieldPerMeshPerTypeCommon::getNumberOfComponents() const
1335 return _father->getNumberOfComponents();
1338 bool MEDFileFieldPerMeshPerTypeCommon::presenceOfMultiDiscPerGeoType() const
1341 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1343 const MEDFileFieldPerMeshPerTypePerDisc *fmtd(*it);
1350 DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray()
1352 return _father->getOrCreateAndGetArray();
1355 const DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray() const
1357 const MEDFileFieldPerMesh *fath=_father;
1358 return fath->getOrCreateAndGetArray();
1361 const std::vector<std::string>& MEDFileFieldPerMeshPerTypeCommon::getInfo() const
1363 return _father->getInfo();
1366 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsed() const
1368 std::vector<std::string> ret;
1369 std::set<std::string> ret2;
1370 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1372 std::string tmp=(*it1)->getProfile();
1374 if(ret2.find(tmp)==ret2.end())
1383 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsed() const
1385 std::vector<std::string> ret;
1386 std::set<std::string> ret2;
1387 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1389 std::string tmp=(*it1)->getLocalization();
1390 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1391 if(ret2.find(tmp)==ret2.end())
1400 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsedMulti() const
1402 std::vector<std::string> ret;
1403 std::set<std::string> ret2;
1404 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1406 std::string tmp=(*it1)->getProfile();
1413 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsedMulti() const
1415 std::vector<std::string> ret;
1416 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1418 std::string tmp=(*it1)->getLocalization();
1419 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1425 void MEDFileFieldPerMeshPerTypeCommon::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1427 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1428 (*it1)->changePflsRefsNamesGen(mapOfModif);
1431 void MEDFileFieldPerMeshPerTypeCommon::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1433 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1434 (*it1)->changeLocsRefsNamesGen(mapOfModif);
1437 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId)
1439 if(_field_pm_pt_pd.empty())
1441 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << getGeoTypeRepr() << "\" !";
1442 throw INTERP_KERNEL::Exception(oss.str());
1444 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1445 return _field_pm_pt_pd[locId];
1446 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
1447 oss2 << ") for geometric type \"" << getGeoTypeRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1448 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1449 return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1452 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId) const
1454 if(_field_pm_pt_pd.empty())
1456 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << getGeoTypeRepr() << "\" !";
1457 throw INTERP_KERNEL::Exception(oss.str());
1459 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1460 return _field_pm_pt_pd[locId];
1461 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
1462 oss2 << ") for geometric type \"" << getGeoTypeRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1463 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1464 return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1467 void MEDFileFieldPerMeshPerTypeCommon::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1470 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1472 (*it)->fillValues(i,startEntryId,entries);
1476 void MEDFileFieldPerMeshPerTypeCommon::setLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
1478 _field_pm_pt_pd=leaves;
1479 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1480 (*it)->setFather(this);
1484 * \param [in,out] globalNum a global numbering counter for the renumbering.
1485 * \param [out] its - list of pair (start,stop) kept
1486 * \return bool - false if the type of field \a tof is not contained in \a this.
1488 bool MEDFileFieldPerMeshPerTypeCommon::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
1491 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1492 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1493 if((*it)->getType()==tof)
1495 newPmPtPd.push_back(*it);
1496 std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1497 (*it)->setNewStart(globalNum);
1498 globalNum=(*it)->getEnd();
1499 its.push_back(bgEnd);
1503 _field_pm_pt_pd=newPmPtPd;
1508 * \param [in,out] globalNum a global numbering counter for the renumbering.
1509 * \param [out] its - list of pair (start,stop) kept
1510 * \return bool - false if the type of field \a tof is not contained in \a this.
1512 bool MEDFileFieldPerMeshPerTypeCommon::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
1514 if(_field_pm_pt_pd.size()<=idOfDisc)
1516 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt(_field_pm_pt_pd[idOfDisc]);
1517 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd(1,elt);
1518 std::pair<int,int> bgEnd; bgEnd.first=_field_pm_pt_pd[idOfDisc]->getStart(); bgEnd.second=_field_pm_pt_pd[idOfDisc]->getEnd();
1519 elt->setNewStart(globalNum);
1520 globalNum=elt->getEnd();
1521 its.push_back(bgEnd);
1522 _field_pm_pt_pd=newPmPtPd;
1526 void MEDFileFieldPerMeshPerTypeCommon::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
1528 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1529 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1532 void MEDFileFieldPerMeshPerTypeCommon::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1534 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1535 (*it)->loadBigArray(fid,nasc);
1538 void MEDFileFieldPerMeshPerTypeCommon::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1540 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1542 (*it)->copyOptionsFrom(*this);
1543 (*it)->writeLL(fid,nasc);
1547 med_entity_type MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1552 medfGeoType=typmai3[(int)ikGeoType];
1555 medfGeoType=MED_NONE;
1558 medfGeoType=typmai3[(int)ikGeoType];
1559 return MED_NODE_ELEMENT;
1561 medfGeoType=typmai3[(int)ikGeoType];
1564 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1566 return MED_UNDEF_ENTITY_TYPE;
1569 //////////////////////////////////////////////////
1571 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd)
1573 return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc,pd);
1576 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType)
1578 return new MEDFileFieldPerMeshPerType(fath,geoType);
1581 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCopy(MEDFileFieldPerMesh *father) const
1583 MCAuto<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
1584 ret->setFather(father);
1585 ret->deepCopyElements();
1589 void MEDFileFieldPerMeshPerType::getFieldAtLevel(int meshDim, TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
1591 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1593 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1594 if(meshDim!=(int)cm.getDimension())
1597 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1598 (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1601 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1606 void MEDFileFieldPerMeshPerType::entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const
1608 ent=MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(mct,_geo_type,gt);
1611 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1613 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1614 int curDim((int)cm.getDimension());
1615 dim=std::max(dim,curDim);
1618 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1620 const char startLine[]=" ## ";
1621 std::string startLine2(bkOffset,' ');
1622 std::string startLine3(startLine2);
1623 startLine3+=startLine;
1624 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1626 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1627 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1630 oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1631 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1633 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1635 const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1637 cur->simpleRepr(bkOffset,oss,i);
1640 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1645 std::string MEDFileFieldPerMeshPerType::getGeoTypeRepr() const
1647 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1648 return std::string(cm.getRepr());
1651 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *father, INTERP_KERNEL::NormalizedCellType gt):MEDFileFieldPerMeshPerTypeCommon(father),_geo_type(gt)
1655 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):MEDFileFieldPerMeshPerTypeCommon(fath),_geo_type(geoType)
1657 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1658 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1659 med_geometry_type mgeoti;
1660 med_entity_type menti(ConvertIntoMEDFileType(type,geoType,mgeoti));
1661 int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName));
1662 _field_pm_pt_pd.resize(nbProfiles);
1663 for(int i=0;i<nbProfiles;i++)
1665 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i,pd);
1669 int nbProfiles2(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName));
1670 for(int i=0;i<nbProfiles2;i++)
1671 _field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i,pd));
1675 MCAuto<MEDFileFieldPerMeshPerType> MEDFileFieldPerMeshPerType::Aggregate(int &start, const std::vector<std::pair<int,const MEDFileFieldPerMeshPerType *> >& pms, const std::vector< std::vector< std::pair<int,int> > >& dts, INTERP_KERNEL::NormalizedCellType gt, MEDFileFieldPerMesh *father, std::vector<std::pair< int, std::pair<int,int> > >& extractInfo)
1677 MCAuto<MEDFileFieldPerMeshPerType> ret(MEDFileFieldPerMeshPerType::New(father,gt));
1678 std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > > m;
1679 for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerType *> >::const_iterator it=pms.begin();it!=pms.end();it++)
1681 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it2=(*it).second->_field_pm_pt_pd.begin();it2!=(*it).second->_field_pm_pt_pd.end();it2++)
1682 m[(*it2)->getType()].push_back(std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * >((*it).first,*it2));
1684 for(std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > >::const_iterator it=m.begin();it!=m.end();it++)
1686 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> agg(MEDFileFieldPerMeshPerTypePerDisc::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
1687 ret->_field_pm_pt_pd.push_back(agg);
1692 //////////////////////////////////////////////////
1694 MEDFileFieldPerMeshPerTypeDyn *MEDFileFieldPerMeshPerTypeDyn::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileEntities *entities, int idGT, const MEDFileFieldNameScope& nasc)
1697 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeDyn::NewOnRead : null pointer !");
1698 const MEDFileAllStaticEntitiesPlusDyn *entities2(dynamic_cast<const MEDFileAllStaticEntitiesPlusDyn *>(entities));
1700 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeDyn::NewOnRead : invalid type of entities !");
1701 const MEDFileStructureElement *se(entities2->getWithGT(idGT));
1702 return new MEDFileFieldPerMeshPerTypeDyn(fid,fath,se,nasc);
1705 MEDFileFieldPerMeshPerTypeDyn::MEDFileFieldPerMeshPerTypeDyn(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileStructureElement *se, const MEDFileFieldNameScope& nasc):MEDFileFieldPerMeshPerTypeCommon(fath)
1708 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1709 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1710 int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,_se->getDynGT(),pflName,locName));
1711 _field_pm_pt_pd.resize(nbProfiles);
1712 for(int i=0;i<nbProfiles;i++)
1714 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,_se->getEntity(),i,NULL);
1718 int MEDFileFieldPerMeshPerTypeDyn::getDynGT() const
1720 return _se->getDynGT();
1723 void MEDFileFieldPerMeshPerTypeDyn::getDimension(int& dim) const
1725 throw INTERP_KERNEL::Exception("not implemented yet !");
1728 void MEDFileFieldPerMeshPerTypeDyn::entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const
1731 ent=MED_STRUCT_ELEMENT;
1734 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypeDyn::getGeoType() const
1736 throw INTERP_KERNEL::Exception("not implemented yet !");
1739 void MEDFileFieldPerMeshPerTypeDyn::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1741 const char startLine[]=" ## ";
1742 std::string startLine2(bkOffset,' ');
1743 std::string startLine3(startLine2);
1744 startLine3+=startLine;
1745 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry STRUCTURE_ELEMENT type " << getDynGT() << "." << std::endl;
1746 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1748 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1750 if((*it).isNotNull())
1751 (*it)->simpleRepr(bkOffset,oss,i);
1754 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1759 std::string MEDFileFieldPerMeshPerTypeDyn::getGeoTypeRepr() const
1761 throw INTERP_KERNEL::Exception("not implemented yet !");
1764 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerTypeDyn::deepCopy(MEDFileFieldPerMesh *father) const
1766 throw INTERP_KERNEL::Exception("not implemented yet !");
1769 void MEDFileFieldPerMeshPerTypeDyn::getFieldAtLevel(int meshDim, TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
1771 throw INTERP_KERNEL::Exception("not implemented yet !");
1774 //////////////////////////////////////////////////
1776 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const MEDFileEntities *entities)
1778 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm,entities);
1781 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1783 return new MEDFileFieldPerMesh(fath,mesh);
1786 std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
1788 return _mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MCAuto< MEDFileFieldPerMeshPerType >);
1791 std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildrenWithNull() const
1793 std::vector<const BigMemoryObject *> ret;
1794 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1799 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCopy(MEDFileAnyTypeField1TSWithoutSDA *father) const
1801 MCAuto< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1802 ret->_father=father;
1804 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1806 if((*it).isNotNull())
1807 ret->_field_pm_pt[i]=(*it)->deepCopy((MEDFileFieldPerMesh *)(ret));
1812 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1814 std::string startLine(bkOffset,' ');
1815 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1816 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1818 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1820 if((*it).isNotNull())
1821 (*it)->simpleRepr(bkOffset,oss,i);
1824 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1829 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh)
1831 _mesh_name=mesh->getName();
1832 mesh->getTime(_mesh_iteration,_mesh_order);
1835 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1837 int nbOfTypes=code.size()/3;
1839 for(int i=0;i<nbOfTypes;i++)
1841 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1842 int nbOfCells=code[3*i+1];
1843 int pos=addNewEntryIfNecessary(type);
1844 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1850 * This method is the most general one. No optimization is done here.
1851 * \param [in] multiTypePfl is the end user profile specified in high level API
1852 * \param [in] code is the code of \a mesh[multiTypePfl] mesh. It is of size of number of different geometric types into \a mesh[multiTypePfl].
1853 * \param [in] code2 is the code of the \b WHOLE mesh on the same level. So all types in \a code are in \a code2.
1854 * \param [in] idsInPflPerType is the selection into the \a multiTypePfl whole profile that corresponds to the given geometric type. This vector is always 3 times smaller than \a code.
1855 * \param [in] idsPerType is a vector containing the profiles needed to be created for MED file format. \b WARNING these processed MED file profiles can be subdivided again in case of Gauss points.
1856 * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
1858 void MEDFileFieldPerMesh::assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const std::vector<int>& code, const std::vector<int>& code2, const std::vector<DataArrayInt *>& idsInPflPerType, const std::vector<DataArrayInt *>& idsPerType, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1860 int nbOfTypes(code.size()/3);
1861 for(int i=0;i<nbOfTypes;i++)
1863 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1864 int pos=addNewEntryIfNecessary(type);
1865 DataArrayInt *pfl=0;
1867 pfl=idsPerType[code[3*i+2]];
1868 int nbOfTupes2=code2.size()/3;
1870 for(;found<nbOfTupes2;found++)
1871 if(code[3*i]==code2[3*found])
1873 if(found==nbOfTupes2)
1874 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1875 _field_pm_pt[pos]->assignFieldProfile(nbOfTypes==1,start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1879 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1881 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1882 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1885 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1887 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1888 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1891 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
1893 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1894 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1897 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1899 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1900 (*it)->loadBigArraysRecursively(fid,nasc);
1903 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1905 int nbOfTypes=_field_pm_pt.size();
1906 for(int i=0;i<nbOfTypes;i++)
1908 _field_pm_pt[i]->copyOptionsFrom(*this);
1909 _field_pm_pt[i]->writeLL(fid,nasc);
1913 void MEDFileFieldPerMesh::getDimension(int& dim) const
1915 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1916 (*it)->getDimension(dim);
1919 bool MEDFileFieldPerMesh::isUniqueLevel(int& dim) const
1921 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1922 if(!(*it)->isUniqueLevel(dim))
1927 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1929 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1930 (*it)->fillTypesOfFieldAvailable(types);
1933 std::vector< std::vector< std::pair<int,int> > > MEDFileFieldPerMesh::getFieldSplitedByType(std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> > & locs) const
1935 int sz=_field_pm_pt.size();
1936 std::vector< std::vector<std::pair<int,int> > > ret(sz);
1937 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1938 for(int i=0;i<sz;i++)
1940 types[i]=_field_pm_pt[i]->getGeoType();
1941 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1946 double MEDFileFieldPerMesh::getTime() const
1949 return _father->getTime(tmp1,tmp2);
1952 int MEDFileFieldPerMesh::getIteration() const
1954 return _father->getIteration();
1957 int MEDFileFieldPerMesh::getOrder() const
1959 return _father->getOrder();
1962 int MEDFileFieldPerMesh::getNumberOfComponents() const
1964 return _father->getNumberOfComponents();
1967 bool MEDFileFieldPerMesh::presenceOfMultiDiscPerGeoType() const
1969 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1973 if((*it)->presenceOfMultiDiscPerGeoType())
1979 bool MEDFileFieldPerMesh::presenceOfStructureElements() const
1981 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1982 if((*it).isNotNull())
1984 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
1991 bool MEDFileFieldPerMesh::onlyStructureElements() const
1993 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1994 if((*it).isNotNull())
1996 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2003 void MEDFileFieldPerMesh::killStructureElements()
2005 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
2006 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2008 if((*it).isNotNull())
2010 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2018 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
2021 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
2022 return _father->getOrCreateAndGetArray();
2025 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
2028 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
2029 return _father->getOrCreateAndGetArray();
2032 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
2034 return _father->getInfo();
2038 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
2039 * 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.
2040 * It returns 2 output vectors :
2041 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
2042 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
2043 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
2045 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)
2047 int notNullPflsSz=0;
2048 int nbOfArrs=geoTypes.size();
2049 for(int i=0;i<nbOfArrs;i++)
2052 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
2053 int nbOfDiffGeoTypes=geoTypes3.size();
2054 code.resize(3*nbOfDiffGeoTypes);
2055 notNullPfls.resize(notNullPflsSz);
2058 for(int i=0;i<nbOfDiffGeoTypes;i++)
2061 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
2062 std::vector<const DataArrayInt *> notNullTmp;
2064 notNullTmp.push_back(pfls[j]);
2066 for(;j<nbOfArrs;j++)
2067 if(geoTypes[j]==refType)
2070 notNullTmp.push_back(pfls[j]);
2074 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
2075 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
2076 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
2077 code[3*i]=(int)refType;
2078 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
2079 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
2080 if(notNullTmp.empty())
2084 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
2085 code[3*i+2]=notNullPflsSz++;
2091 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
2093 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)
2097 for(int i=0;i<sz;i++)
2101 if(type!=ON_GAUSS_NE)
2102 ret+=dads[i].second-dads[i].first;
2105 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
2106 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
2111 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
2112 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
2118 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
2120 std::vector<std::string> ret;
2121 std::set<std::string> ret2;
2122 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2124 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
2125 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
2126 if(ret2.find(*it2)==ret2.end())
2128 ret.push_back(*it2);
2135 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
2137 std::vector<std::string> ret;
2138 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2140 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
2141 ret.insert(ret.end(),tmp.begin(),tmp.end());
2146 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
2148 std::vector<std::string> ret;
2149 std::set<std::string> ret2;
2150 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2152 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
2153 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
2154 if(ret2.find(*it2)==ret2.end())
2156 ret.push_back(*it2);
2163 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
2165 std::vector<std::string> ret;
2166 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2168 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
2169 ret.insert(ret.end(),tmp.begin(),tmp.end());
2174 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
2176 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
2178 if((*it).first==_mesh_name)
2180 _mesh_name=(*it).second;
2187 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
2188 MEDFileFieldGlobsReal& glob)
2190 if(_mesh_name!=meshName)
2192 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
2193 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
2194 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
2195 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
2196 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
2197 getUndergroundDataArrayExt(entries);
2198 DataArray *arr0(getOrCreateAndGetArray());//tony
2200 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
2201 DataArrayDouble *arr(dynamic_cast<DataArrayDouble *>(arr0));//tony
2203 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
2206 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
2207 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
2209 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
2211 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2212 sz+=(*it).second.second-(*it).second.first;
2215 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2217 MCAuto<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
2218 ////////////////////
2219 MCAuto<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
2220 int *workI2=explicitIdsOldInMesh->getPointer();
2221 int sz1=0,sz2=0,sid=1;
2222 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
2223 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
2224 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
2226 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
2227 MCAuto<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
2228 int *workI=explicitIdsOldInArr->getPointer();
2229 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
2231 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
2232 (*itL2)->setLocId(sz2);
2233 (*itL2)->_tmp_work1=(*itL2)->getStart();
2234 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
2236 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
2238 explicitIdsOldInMesh->reAlloc(sz2);
2239 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
2240 ////////////////////
2241 MCAuto<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
2242 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
2243 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
2244 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
2246 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
2247 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
2248 otherEntriesNew.back()->setLocId((*it)->getGeoType());
2250 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
2251 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
2252 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
2254 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
2255 int newStart=elt->getLocId();
2256 elt->setLocId((*it)->getGeoType());
2257 elt->setNewStart(newStart);
2258 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
2259 entriesKeptNew.push_back(elt);
2260 entriesKeptNew2.push_back(elt);
2262 MCAuto<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
2263 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
2264 MCAuto<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
2265 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
2267 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
2270 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
2272 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
2273 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
2275 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
2276 glob,arr2,otherEntriesNew) || ret;
2280 // Assign new dispatching
2281 assignNewLeaves(otherEntriesNew);
2282 arr->deepCopyFrom(*arr2);
2287 * \param [in,out] globalNum a global numbering counter for the renumbering.
2288 * \param [out] its - list of pair (start,stop) kept
2290 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
2292 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > ret;
2293 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2295 std::vector< std::pair<int,int> > its2;
2296 if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
2299 its.insert(its.end(),its2.begin(),its2.end());
2306 * \param [in,out] globalNum a global numbering counter for the renumbering.
2307 * \param [out] its - list of pair (start,stop) kept
2309 void MEDFileFieldPerMesh::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
2311 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > ret;
2312 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2314 std::vector< std::pair<int,int> > its2;
2315 if((*it)->keepOnlyGaussDiscretization(idOfDisc,globalNum,its2))
2318 its.insert(its.end(),its2.begin(),its2.end());
2324 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
2326 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > > types;
2327 for( std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
2328 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
2330 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > fieldPmPt(types.size());
2331 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
2332 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it2=fieldPmPt.begin();
2333 for(;it1!=types.end();it1++,it2++)
2335 MCAuto<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
2336 elt->setLeaves((*it1).second);
2337 MCAuto<MEDFileFieldPerMeshPerTypeCommon> elt2(DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(elt));
2340 _field_pm_pt=fieldPmPt;
2343 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2345 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2346 (*it)->changePflsRefsNamesGen(mapOfModif);
2349 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2351 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2352 (*it)->changeLocsRefsNamesGen(mapOfModif);
2356 * \param [in] mesh is the whole mesh
2358 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2360 if(_field_pm_pt.empty())
2361 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2363 std::vector< std::pair<int,int> > dads;
2364 std::vector<const DataArrayInt *> pfls;
2365 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2366 std::vector<int> locs,code;
2367 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2368 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2369 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2371 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2374 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2375 throw INTERP_KERNEL::Exception(oss.str());
2378 std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2379 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2382 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2384 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2387 MCAuto<DataArrayInt> arr2(arr);
2388 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2394 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2398 if(nb!=mesh->getNumberOfNodes())
2400 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2401 oss << " nodes in mesh !";
2402 throw INTERP_KERNEL::Exception(oss.str());
2404 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2407 return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2411 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
2413 if(_field_pm_pt.empty())
2414 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2416 std::vector<std::pair<int,int> > dads;
2417 std::vector<const DataArrayInt *> pfls;
2418 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2419 std::vector<int> locs,code;
2420 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2421 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2422 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2424 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2427 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2428 throw INTERP_KERNEL::Exception(oss.str());
2430 std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2431 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2434 MCAuto<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2435 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2440 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2444 if(nb!=mesh->getNumberOfNodes())
2446 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2447 oss << " nodes in mesh !";
2448 throw INTERP_KERNEL::Exception(oss.str());
2451 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2457 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
2461 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2463 (*it)->getSizes(globalSz,nbOfEntries);
2465 entries.resize(nbOfEntries);
2467 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2469 (*it)->fillValues(nbOfEntries,entries);
2473 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
2475 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2477 if((*it)->getGeoType()==typ)
2478 return (*it)->getLeafGivenLocId(locId);
2480 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2481 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2482 oss << "Possiblities are : ";
2483 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2485 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2486 oss << "\"" << cm2.getRepr() << "\", ";
2488 throw INTERP_KERNEL::Exception(oss.str());
2491 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
2493 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2495 if((*it)->getGeoType()==typ)
2496 return (*it)->getLeafGivenLocId(locId);
2498 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2499 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2500 oss << "Possiblities are : ";
2501 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2503 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2504 oss << "\"" << cm2.getRepr() << "\", ";
2506 throw INTERP_KERNEL::Exception(oss.str());
2510 * \param [in,out] start - Integer that gives the current position in the final aggregated array
2511 * \param [in] pms - list of elements to aggregate. integer gives the mesh id
2512 * \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.
2513 * \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.
2515 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)
2517 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret(new MEDFileFieldPerMeshPerTypePerDisc(father,tof));
2519 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : empty input vector !");
2520 for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it=pms.begin();it!=pms.end();it++)
2523 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : presence of null pointer !");
2524 if(!(*it).second->getProfile().empty())
2525 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for profiles !");
2526 if(!(*it).second->getLocalization().empty())
2527 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for gauss pts !");
2529 INTERP_KERNEL::NormalizedCellType gt(pms[0].second->getGeoType());
2531 std::vector< std::pair<int,int> > filteredDTS;
2532 for(std::vector< std::vector< std::pair<int,int> > >::const_iterator it=dts.begin();it!=dts.end();it++,i++)
2533 for(std::vector< std::pair<int,int> >::const_iterator it2=(*it).begin();it2!=(*it).end();it2++)
2534 if((*it2).first==gt)
2535 filteredDTS.push_back(std::pair<int,int>(i,(*it2).second));
2536 if(pms.size()!=filteredDTS.size())
2537 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles !");
2538 std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it1(pms.begin());
2539 std::vector< std::pair<int,int> >::const_iterator it2(filteredDTS.begin());
2540 int zeStart(start),nval(0);
2541 for(;it1!=pms.end();it1++,it2++)
2543 if((*it1).first!=(*it2).first)
2544 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles 2 !");
2545 int s1((*it1).second->getStart()),e1((*it1).second->getEnd());
2546 extractInfo.push_back(std::pair<int, std::pair<int,int> >((*it1).first,std::pair<int,int>(s1,e1)));
2548 nval+=((*it1).second)->getNumberOfVals();
2550 ret->_start=zeStart; ret->_end=start; ret->_nval=nval;
2554 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)
2556 MCAuto<MEDFileFieldPerMesh> ret(new MEDFileFieldPerMesh(father,pms[0]->getMeshName(),pms[0]->getMeshIteration(),pms[0]->getMeshOrder()));
2557 std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > > m;
2559 for(std::vector<const MEDFileFieldPerMesh *>::const_iterator it=pms.begin();it!=pms.end();it++,i++)
2561 const std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >& v((*it)->_field_pm_pt);
2562 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it2=v.begin();it2!=v.end();it2++)
2564 INTERP_KERNEL::NormalizedCellType gt((*it2)->getGeoType());
2565 const MEDFileFieldPerMeshPerType *elt(dynamic_cast<const MEDFileFieldPerMeshPerType *>((const MEDFileFieldPerMeshPerTypeCommon *)(*it2)));
2567 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::Aggregate : not managed for structelement !");
2568 m[gt].push_back(std::pair<int,const MEDFileFieldPerMeshPerType *>(i,elt));
2571 for(std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > >::const_iterator it=m.begin();it!=m.end();it++)
2573 MCAuto<MEDFileFieldPerMeshPerType> agg(MEDFileFieldPerMeshPerType::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
2574 MCAuto<MEDFileFieldPerMeshPerTypeCommon> agg2(DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(agg));
2575 ret->_field_pm_pt.push_back(agg2);
2580 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2583 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2584 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it2=_field_pm_pt.begin();
2585 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2587 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2592 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2597 int ret=std::distance(_field_pm_pt.begin(),it2);
2598 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2603 * 'dads' and 'locs' input parameters have the same number of elements
2604 * \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
2606 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2607 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2608 const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2611 MCAuto<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2612 ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2613 MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2614 const std::vector<std::string>& infos=getInfo();
2615 da->setInfoOnComponents(infos);
2617 if(type==ON_GAUSS_PT)
2620 int nbOfArrs=dads.size();
2621 for(int i=0;i<nbOfArrs;i++)
2623 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2624 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2625 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2626 MCAuto<DataArrayInt> di=DataArrayInt::New();
2627 di->alloc(nbOfElems,1);
2629 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2630 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2639 * 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.
2640 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2641 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2642 * The order of cells in the returned field is those imposed by the profile.
2643 * \param [in] mesh is the global mesh.
2645 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2646 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2647 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2648 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2650 if(da->isIota(mesh->getNumberOfCells()))
2651 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2652 MCAuto<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2653 m2->setName(mesh->getName().c_str());
2654 MCAuto<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2660 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2662 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2663 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2664 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2666 if(da->isIota(mesh->getNumberOfNodes()))
2667 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2668 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2669 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2672 if(meshu->getNodalConnectivity()==0)
2674 MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2675 int nb=da->getNbOfElems();
2676 const int *ptr=da->getConstPointer();
2677 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2678 meshuc->allocateCells(nb);
2679 for(int i=0;i<nb;i++)
2680 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2681 meshuc->finishInsertingCells();
2682 ret->setMesh(meshuc);
2683 const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2684 if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2685 disc->checkCoherencyBetween(meshuc,arrOut);
2690 MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2692 DataArrayInt *arr2=0;
2693 MCAuto<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2694 MCAuto<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2695 MCAuto<DataArrayInt> arr3(arr2);
2696 int nnodes=mesh2->getNumberOfNodes();
2697 if(nnodes==(int)da->getNbOfElems())
2699 MCAuto<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2700 arrOut->renumberInPlace(da3->getConstPointer());
2701 mesh2->setName(mesh->getName().c_str());
2702 ret->setMesh(mesh2);
2707 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 !!!";
2708 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2709 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2710 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2711 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2712 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2713 throw INTERP_KERNEL::Exception(oss.str());
2719 * This method is the most light method of field retrieving.
2721 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
2725 pflOut=DataArrayInt::New();
2726 pflOut->alloc(nbOfElems,1);
2731 pflOut=const_cast<DataArrayInt*>(pflIn);
2734 MCAuto<DataArrayInt> safePfl(pflOut);
2735 MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2736 const std::vector<std::string>& infos=getInfo();
2737 int nbOfComp=infos.size();
2738 for(int i=0;i<nbOfComp;i++)
2739 da->setInfoOnComponent(i,infos[i].c_str());
2750 static MFFPMIter *NewCell(const MEDFileEntities *entities);
2751 static bool IsPresenceOfNode(const MEDFileEntities *entities);
2752 virtual ~MFFPMIter() { }
2753 virtual void begin() = 0;
2754 virtual bool finished() const = 0;
2755 virtual void next() = 0;
2756 virtual int current() const = 0;
2759 class MFFPMIterSimple : public MFFPMIter
2762 MFFPMIterSimple():_pos(0) { }
2763 void begin() { _pos=0; }
2764 bool finished() const { return _pos>=MED_N_CELL_FIXED_GEO; }
2765 void next() { _pos++; }
2766 int current() const { return _pos; }
2771 class MFFPMIter2 : public MFFPMIter
2774 MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts);
2775 void begin() { _it=_ids.begin(); }
2776 bool finished() const { return _it==_ids.end(); }
2777 void next() { _it++; }
2778 int current() const { return *_it; }
2780 std::vector<int> _ids;
2781 std::vector<int>::const_iterator _it;
2784 MFFPMIter *MFFPMIter::NewCell(const MEDFileEntities *entities)
2787 return new MFFPMIterSimple;
2790 const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
2793 std::vector<INTERP_KERNEL::NormalizedCellType> tmp;
2794 const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
2795 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
2797 if((*it).first==ON_CELLS || (*it).first==ON_GAUSS_NE || (*it).first==ON_GAUSS_PT)
2798 tmp.push_back((*it).second);
2800 return new MFFPMIter2(tmp);
2802 return new MFFPMIterSimple;// for MEDFileAllStaticEntites and MEDFileAllStaticEntitiesPlusDyn cells are in
2806 bool MFFPMIter::IsPresenceOfNode(const MEDFileEntities *entities)
2812 const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
2815 const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
2816 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
2817 if((*it).first==ON_NODES)
2821 return true;// for MEDFileAllStaticEntites and MEDFileAllStaticEntitiesPlusDyn nodes are in
2825 MFFPMIter2::MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts)
2827 std::size_t sz(cts.size());
2829 for(std::size_t i=0;i<sz;i++)
2831 INTERP_KERNEL::NormalizedCellType *loc(std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,cts[i]));
2832 if(loc!=typmai2+MED_N_CELL_FIXED_GEO)
2833 _ids[i]=(int)std::distance(typmai2,loc);
2835 throw INTERP_KERNEL::Exception("MFFPMIter2 : The specified geo type does not exists !");
2841 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),
2844 INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2845 INTERP_KERNEL::AutoPtr<char> pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2846 INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2847 const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
2848 INTERP_KERNEL::AutoCppPtr<MFFPMIter> iter0(MFFPMIter::NewCell(entities));
2849 for(iter0->begin();!iter0->finished();iter0->next())
2851 int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL ,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2852 std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2853 int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2854 std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2855 if(nbProfile>0 || nbProfile2>0)
2857 const PartDefinition *pd(0);
2859 pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[iter0->current()]),typmai2[iter0->current()]);
2860 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nasc,pd));
2867 if(MFFPMIter::IsPresenceOfNode(entities))
2869 int nbProfile(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName));
2872 const PartDefinition *pd(0);
2874 pd=mmu->getPartDefAtLevel(1,INTERP_KERNEL::NORM_ERROR);
2875 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd));
2876 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2881 std::vector<int> dynGT(entities->getDynGTAvail());
2882 for(std::vector<int>::const_iterator it=dynGT.begin();it!=dynGT.end();it++)
2884 int nbPfl(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,*it,pflName,locName));
2887 _field_pm_pt.push_back(MEDFileFieldPerMeshPerTypeDyn::NewOnRead(fid,this,entities,*it,nasc));
2888 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2893 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2895 copyTinyInfoFrom(mesh);
2898 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
2900 if(id>=(int)_pfls.size())
2902 _pfls[id]=DataArrayInt::New();
2903 int lgth(MEDprofileSizeByName(fid,pflName.c_str()));
2904 _pfls[id]->setName(pflName);
2905 _pfls[id]->alloc(lgth,1);
2906 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName.c_str(),_pfls[id]->getPointer()));
2907 _pfls[id]->applyLin(1,-1,0);//Converting into C format
2910 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2912 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2914 MEDFILESAFECALLERRD0(MEDprofileInfo,(fid,i+1,pflName,&sz));
2915 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2916 if(i>=(int)_pfls.size())
2918 _pfls[i]=DataArrayInt::New();
2919 _pfls[i]->alloc(sz,1);
2920 _pfls[i]->setName(pflCpp.c_str());
2921 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName,_pfls[i]->getPointer()));
2922 _pfls[i]->applyLin(1,-1,0);//Converting into C format
2925 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
2927 int nbOfPfls=_pfls.size();
2928 for(int i=0;i<nbOfPfls;i++)
2930 MCAuto<DataArrayInt> cpy=_pfls[i]->deepCopy();
2931 cpy->applyLin(1,1,0);
2932 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2933 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2934 MEDFILESAFECALLERWR0(MEDprofileWr,(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer()));
2937 int nbOfLocs=_locs.size();
2938 for(int i=0;i<nbOfLocs;i++)
2939 _locs[i]->writeLL(fid);
2942 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
2944 std::vector<std::string> pfls=getPfls();
2945 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2947 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2950 _pfls.push_back(*it);
2954 int id=std::distance(pfls.begin(),it2);
2955 if(!(*it)->isEqual(*_pfls[id]))
2957 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2958 throw INTERP_KERNEL::Exception(oss.str());
2962 std::vector<std::string> locs=getLocs();
2963 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
2965 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2968 _locs.push_back(*it);
2972 int id=std::distance(locs.begin(),it2);
2973 if(!(*it)->isEqual(*_locs[id],eps))
2975 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2976 throw INTERP_KERNEL::Exception(oss.str());
2982 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
2984 for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
2985 getProfile((*it).c_str());
2988 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
2990 for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
2991 getLocalization((*it).c_str());
2994 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
2996 std::vector<std::string> profiles=real.getPflsReallyUsed();
2997 int sz=profiles.size();
2999 for(int i=0;i<sz;i++)
3000 loadProfileInFile(fid,i,profiles[i].c_str());
3002 std::vector<std::string> locs=real.getLocsReallyUsed();
3005 for(int i=0;i<sz;i++)
3006 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
3009 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid)
3011 int nProfil=MEDnProfile(fid);
3012 for(int i=0;i<nProfil;i++)
3013 loadProfileInFile(fid,i);
3014 int sz=MEDnLocalization(fid);
3016 for(int i=0;i<sz;i++)
3018 _locs[i]=MEDFileFieldLoc::New(fid,i);
3022 MEDFileFieldGlobs *MEDFileFieldGlobs::New(med_idt fid)
3024 return new MEDFileFieldGlobs(fid);
3027 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
3029 return new MEDFileFieldGlobs;
3032 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
3034 return _file_name.capacity()+_pfls.capacity()*sizeof(MCAuto<DataArrayInt>)+_locs.capacity()*sizeof(MCAuto<MEDFileFieldLoc>);
3037 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildrenWithNull() const
3039 std::vector<const BigMemoryObject *> ret;
3040 for(std::vector< MCAuto< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3041 ret.push_back((const DataArrayInt *)*it);
3042 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3043 ret.push_back((const MEDFileFieldLoc *)*it);
3047 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCopy() const
3049 MCAuto<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
3051 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3053 if((const DataArrayInt *)*it)
3054 ret->_pfls[i]=(*it)->deepCopy();
3057 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3059 if((const MEDFileFieldLoc*)*it)
3060 ret->_locs[i]=(*it)->deepCopy();
3066 * \throw if a profile in \a pfls in not in \a this.
3067 * \throw if a localization in \a locs in not in \a this.
3068 * \sa MEDFileFieldGlobs::deepCpyPart
3070 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
3072 MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
3073 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
3075 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
3077 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
3079 MCAuto<DataArrayInt> pfl2(pfl);
3080 ret->_pfls.push_back(pfl2);
3082 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
3084 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
3086 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
3088 MCAuto<MEDFileFieldLoc> loc2(loc);
3089 ret->_locs.push_back(loc2);
3091 ret->setFileName(getFileName());
3096 * \throw if a profile in \a pfls in not in \a this.
3097 * \throw if a localization in \a locs in not in \a this.
3098 * \sa MEDFileFieldGlobs::shallowCpyPart
3100 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
3102 MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
3103 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
3105 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
3107 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
3108 ret->_pfls.push_back(pfl->deepCopy());
3110 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
3112 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
3114 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
3115 ret->_locs.push_back(loc->deepCopy());
3117 ret->setFileName(getFileName());
3121 MEDFileFieldGlobs::MEDFileFieldGlobs(med_idt fid):_file_name(MEDFileWritable::FileNameFromFID(fid))
3125 MEDFileFieldGlobs::MEDFileFieldGlobs()
3129 MEDFileFieldGlobs::~MEDFileFieldGlobs()
3133 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
3135 oss << "Profiles :\n";
3136 std::size_t n=_pfls.size();
3137 for(std::size_t i=0;i<n;i++)
3139 oss << " - #" << i << " ";
3140 const DataArrayInt *pfl=_pfls[i];
3142 oss << "\"" << pfl->getName() << "\"\n";
3147 oss << "Localizations :\n";
3148 for(std::size_t i=0;i<n;i++)
3150 oss << " - #" << i << " ";
3151 const MEDFileFieldLoc *loc=_locs[i];
3153 loc->simpleRepr(oss);
3159 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3161 for(std::vector< MCAuto<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
3163 DataArrayInt *elt(*it);
3166 std::string name(elt->getName());
3167 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3169 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3171 elt->setName((*it2).second.c_str());
3179 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3181 for(std::vector< MCAuto<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
3183 MEDFileFieldLoc *elt(*it);
3186 std::string name(elt->getName());
3187 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3189 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3191 elt->setName((*it2).second.c_str());
3199 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
3201 if(locId<0 || locId>=(int)_locs.size())
3202 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
3203 return _locs[locId]->getNbOfGaussPtPerCell();
3206 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
3208 return getLocalizationFromId(getLocalizationId(locName));
3211 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
3213 if(locId<0 || locId>=(int)_locs.size())
3214 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3215 return *_locs[locId];
3219 namespace MEDCouplingImpl
3224 LocFinder(const std::string& loc):_loc(loc) { }
3225 bool operator() (const MCAuto<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
3227 const std::string &_loc;
3233 PflFinder(const std::string& pfl):_pfl(pfl) { }
3234 bool operator() (const MCAuto<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
3236 const std::string& _pfl;
3241 int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
3243 std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),MEDCouplingImpl::LocFinder(loc));
3246 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
3247 for(it=_locs.begin();it!=_locs.end();it++)
3248 oss << "\"" << (*it)->getName() << "\", ";
3249 throw INTERP_KERNEL::Exception(oss.str());
3251 return std::distance(_locs.begin(),it);
3255 * The returned value is never null.
3257 const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
3259 std::string pflNameCpp(pflName);
3260 std::vector< MCAuto<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3263 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3264 for(it=_pfls.begin();it!=_pfls.end();it++)
3265 oss << "\"" << (*it)->getName() << "\", ";
3266 throw INTERP_KERNEL::Exception(oss.str());
3271 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
3273 if(pflId<0 || pflId>=(int)_pfls.size())
3274 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3275 return _pfls[pflId];
3278 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
3280 if(locId<0 || locId>=(int)_locs.size())
3281 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3282 return *_locs[locId];
3285 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
3287 return getLocalizationFromId(getLocalizationId(locName));
3291 * The returned value is never null.
3293 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
3295 std::string pflNameCpp(pflName);
3296 std::vector< MCAuto<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3299 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3300 for(it=_pfls.begin();it!=_pfls.end();it++)
3301 oss << "\"" << (*it)->getName() << "\", ";
3302 throw INTERP_KERNEL::Exception(oss.str());
3307 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
3309 if(pflId<0 || pflId>=(int)_pfls.size())
3310 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3311 return _pfls[pflId];
3314 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
3316 std::vector< MCAuto<DataArrayInt> > newPfls;
3318 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3320 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
3321 newPfls.push_back(*it);
3326 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
3328 std::vector< MCAuto<MEDFileFieldLoc> > newLocs;
3330 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3332 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
3333 newLocs.push_back(*it);
3338 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
3340 int sz=_pfls.size();
3341 std::vector<std::string> ret(sz);
3342 for(int i=0;i<sz;i++)
3343 ret[i]=_pfls[i]->getName();
3347 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
3349 int sz=_locs.size();
3350 std::vector<std::string> ret(sz);
3351 for(int i=0;i<sz;i++)
3352 ret[i]=_locs[i]->getName();
3356 bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
3358 std::vector<std::string> v=getPfls();
3359 std::string s(pflName);
3360 return std::find(v.begin(),v.end(),s)!=v.end();
3363 bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
3365 std::vector<std::string> v=getLocs();
3366 std::string s(locName);
3367 return std::find(v.begin(),v.end(),s)!=v.end();
3370 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
3372 std::map<int,std::vector<int> > m;
3374 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3376 const DataArrayInt *tmp=(*it);
3379 m[tmp->getHashCode()].push_back(i);
3382 std::vector< std::vector<int> > ret;
3383 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
3385 if((*it2).second.size()>1)
3387 std::vector<int> ret0;
3388 bool equalityOrNot=false;
3389 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
3391 std::vector<int>::const_iterator it4=it3; it4++;
3392 for(;it4!=(*it2).second.end();it4++)
3394 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
3397 ret0.push_back(*it3);
3398 ret0.push_back(*it4);
3404 ret.push_back(ret0);
3410 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
3412 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
3415 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
3417 std::string name(pfl->getName());
3419 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
3420 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3421 if(name==(*it)->getName())
3423 if(!pfl->isEqual(*(*it)))
3425 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
3426 throw INTERP_KERNEL::Exception(oss.str());
3430 _pfls.push_back(pfl);
3433 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)
3435 std::string name(locName);
3437 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
3438 MCAuto<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
3439 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3440 if((*it)->isName(locName))
3442 if(!(*it)->isEqual(*obj,1e-12))
3444 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
3445 throw INTERP_KERNEL::Exception(oss.str());
3448 _locs.push_back(obj);
3451 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
3453 std::vector<std::string> names=getPfls();
3454 return CreateNewNameNotIn("NewPfl_",names);
3457 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
3459 std::vector<std::string> names=getLocs();
3460 return CreateNewNameNotIn("NewLoc_",names);
3463 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
3465 for(std::size_t sz=0;sz<100000;sz++)
3467 std::ostringstream tryName;
3468 tryName << prefix << sz;
3469 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
3470 return tryName.str();
3472 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
3476 * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
3477 * \param [in] fname - the file name.
3479 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(med_idt fid):_globals(MEDFileFieldGlobs::New(fid))
3484 * Creates an empty MEDFileFieldGlobsReal.
3486 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
3490 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
3495 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildrenWithNull() const
3497 std::vector<const BigMemoryObject *> ret;
3498 ret.push_back((const MEDFileFieldGlobs *)_globals);
3503 * Returns a string describing profiles and Gauss points held in \a this.
3504 * \return std::string - the description string.
3506 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
3508 const MEDFileFieldGlobs *glob=_globals;
3509 std::ostringstream oss2; oss2 << glob;
3510 std::string stars(oss2.str().length(),'*');
3511 oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n";
3513 glob->simpleRepr(oss);
3515 oss << "NO GLOBAL INFORMATION !\n";
3518 void MEDFileFieldGlobsReal::resetContent()
3520 _globals=MEDFileFieldGlobs::New();
3523 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
3528 * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
3529 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3531 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3533 _globals=other._globals;
3537 * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3538 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3540 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3542 const MEDFileFieldGlobs *otherg(other._globals);
3545 _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3549 * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3550 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3552 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3554 const MEDFileFieldGlobs *otherg(other._globals);
3557 _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3560 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3562 _globals=other._globals;
3563 if((const MEDFileFieldGlobs *)_globals)
3564 _globals=other._globals->deepCopy();
3568 * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3569 * \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3570 * \param [in] eps - a precision used to compare Gauss points with same name held by
3571 * \a this and \a other MEDFileFieldGlobsReal.
3572 * \throw If \a this and \a other hold profiles with equal names but different ids.
3573 * \throw If \a this and \a other hold different Gauss points with equal names.
3575 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
3577 const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3578 if(thisGlobals==otherGlobals)
3582 _globals=other._globals;
3585 _globals->appendGlobs(*other._globals,eps);
3588 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
3590 checkGlobsPflsPartCoherency();
3591 checkGlobsLocsPartCoherency();
3594 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
3596 contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3599 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
3601 contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3604 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3606 contentNotNull()->loadProfileInFile(fid,id,pflName);
3609 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3611 contentNotNull()->loadProfileInFile(fid,id);
3614 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
3616 contentNotNull()->loadGlobals(fid,*this);
3619 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid)
3621 contentNotNull()->loadAllGlobals(fid);
3624 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3626 contentNotNull()->writeGlobals(fid,opt);
3630 * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3631 * or getPflsReallyUsedMulti().
3632 * \return std::vector<std::string> - a sequence of names of all profiles.
3634 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3636 return contentNotNull()->getPfls();
3640 * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3641 * or getLocsReallyUsedMulti().
3642 * \return std::vector<std::string> - a sequence of names of all localizations.
3644 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3646 return contentNotNull()->getLocs();
3650 * Checks if the profile with a given name exists.
3651 * \param [in] pflName - the profile name of interest.
3652 * \return bool - \c true if the profile named \a pflName exists.
3654 bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
3656 return contentNotNull()->existsPfl(pflName);
3660 * Checks if the localization with a given name exists.
3661 * \param [in] locName - the localization name of interest.
3662 * \return bool - \c true if the localization named \a locName exists.
3664 bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
3666 return contentNotNull()->existsLoc(locName);
3669 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
3671 return contentNotNull()->createNewNameOfPfl();
3674 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
3676 return contentNotNull()->createNewNameOfLoc();
3680 * Sets the name of a MED file.
3681 * \param [inout] fileName - the file name.
3683 void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
3685 contentNotNull()->setFileName(fileName);
3689 * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3690 * in the same order.
3691 * \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3692 * Each item of this sequence is a vector containing ids of equal profiles.
3694 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3696 return contentNotNull()->whichAreEqualProfiles();
3700 * Finds equal localizations.
3701 * \param [in] eps - a precision used to compare real values of the localizations.
3702 * \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3703 * Each item of this sequence is a vector containing ids of equal localizations.
3705 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3707 return contentNotNull()->whichAreEqualLocs(eps);
3711 * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3712 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3713 * this sequence is a pair whose
3714 * - the first item is a vector of profile names to replace by the second item,
3715 * - the second item is a profile name to replace every profile name of the first item.
3717 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3719 contentNotNull()->changePflsNamesInStruct(mapOfModif);
3723 * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3724 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3725 * this sequence is a pair whose
3726 * - the first item is a vector of localization names to replace by the second item,
3727 * - the second item is a localization name to replace every localization name of the first item.
3729 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3731 contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3735 * Replaces references to some profiles (a reference is a profile name) by references
3736 * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3737 * them-selves accordingly. <br>
3738 * This method is a generalization of changePflName().
3739 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3740 * this sequence is a pair whose
3741 * - the first item is a vector of profile names to replace by the second item,
3742 * - the second item is a profile name to replace every profile of the first item.
3743 * \sa changePflsRefsNamesGen()
3744 * \sa changePflName()
3746 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3748 changePflsRefsNamesGen(mapOfModif);
3749 changePflsNamesInStruct(mapOfModif);
3753 * Replaces references to some localizations (a reference is a localization name) by references
3754 * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3755 * them-selves accordingly. <br>
3756 * This method is a generalization of changeLocName().
3757 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3758 * this sequence is a pair whose
3759 * - the first item is a vector of localization names to replace by the second item,
3760 * - the second item is a localization name to replace every localization of the first item.
3761 * \sa changeLocsRefsNamesGen()
3762 * \sa changeLocName()
3764 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3766 changeLocsRefsNamesGen(mapOfModif);
3767 changeLocsNamesInStruct(mapOfModif);
3771 * Renames the profile having a given name and updates references to this profile.
3772 * \param [in] oldName - the name of the profile to rename.
3773 * \param [in] newName - a new name of the profile.
3774 * \sa changePflsNames().
3776 void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
3778 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3779 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3781 changePflsNames(mapOfModif);
3785 * Renames the localization having a given name and updates references to this localization.
3786 * \param [in] oldName - the name of the localization to rename.
3787 * \param [in] newName - a new name of the localization.
3788 * \sa changeLocsNames().
3790 void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
3792 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3793 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3795 changeLocsNames(mapOfModif);
3799 * Removes duplicated profiles. Returns a map used to update references to removed
3800 * profiles via changePflsRefsNamesGen().
3801 * Equal profiles are found using whichAreEqualProfiles().
3802 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3803 * a sequence describing the performed replacements of profiles. Each element of
3804 * this sequence is a pair whose
3805 * - the first item is a vector of profile names replaced by the second item,
3806 * - the second item is a profile name replacing every profile of the first item.
3808 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
3810 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3811 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3813 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3815 std::vector< std::string > tmp((*it).size());
3817 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3818 tmp[j]=std::string(getProfileFromId(*it2)->getName());
3819 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3821 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3822 killProfileIds(tmp2);
3824 changePflsRefsNamesGen(ret);
3829 * Removes duplicated localizations. Returns a map used to update references to removed
3830 * localizations via changeLocsRefsNamesGen().
3831 * Equal localizations are found using whichAreEqualLocs().
3832 * \param [in] eps - a precision used to compare real values of the localizations.
3833 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3834 * a sequence describing the performed replacements of localizations. Each element of
3835 * this sequence is a pair whose
3836 * - the first item is a vector of localization names replaced by the second item,
3837 * - the second item is a localization name replacing every localization of the first item.
3839 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
3841 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3842 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3844 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3846 std::vector< std::string > tmp((*it).size());
3848 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3849 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3850 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3852 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3853 killLocalizationIds(tmp2);
3855 changeLocsRefsNamesGen(ret);
3860 * Returns number of Gauss points per cell in a given localization.
3861 * \param [in] locId - an id of the localization of interest.
3862 * \return int - the number of the Gauss points per cell.
3864 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
3866 return contentNotNull()->getNbOfGaussPtPerCell(locId);
3870 * Returns an id of a localization by its name.
3871 * \param [in] loc - the localization name of interest.
3872 * \return int - the id of the localization.
3873 * \throw If there is no a localization named \a loc.
3875 int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
3877 return contentNotNull()->getLocalizationId(loc);
3881 * Returns the name of the MED file.
3882 * \return const std::string& - the MED file name.
3884 std::string MEDFileFieldGlobsReal::getFileName() const
3886 return contentNotNull()->getFileName();
3890 * Returns a localization object by its name.
3891 * \param [in] locName - the name of the localization of interest.
3892 * \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3893 * \throw If there is no a localization named \a locName.
3895 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
3897 return contentNotNull()->getLocalization(locName);
3901 * Returns a localization object by its id.
3902 * \param [in] locId - the id of the localization of interest.
3903 * \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3904 * \throw If there is no a localization with id \a locId.
3906 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
3908 return contentNotNull()->getLocalizationFromId(locId);
3912 * Returns a profile array by its name.
3913 * \param [in] pflName - the name of the profile of interest.
3914 * \return const DataArrayInt * - the profile array having the name \a pflName.
3915 * \throw If there is no a profile named \a pflName.
3917 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
3919 return contentNotNull()->getProfile(pflName);
3923 * Returns a profile array by its id.
3924 * \param [in] pflId - the id of the profile of interest.
3925 * \return const DataArrayInt * - the profile array having the id \a pflId.
3926 * \throw If there is no a profile with id \a pflId.
3928 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
3930 return contentNotNull()->getProfileFromId(pflId);
3934 * Returns a localization object, apt for modification, by its id.
3935 * \param [in] locId - the id of the localization of interest.
3936 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3937 * having the id \a locId.
3938 * \throw If there is no a localization with id \a locId.
3940 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
3942 return contentNotNull()->getLocalizationFromId(locId);
3946 * Returns a localization object, apt for modification, by its name.
3947 * \param [in] locName - the name of the localization of interest.
3948 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3949 * having the name \a locName.
3950 * \throw If there is no a localization named \a locName.
3952 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
3954 return contentNotNull()->getLocalization(locName);
3958 * Returns a profile array, apt for modification, by its name.
3959 * \param [in] pflName - the name of the profile of interest.
3960 * \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3961 * \throw If there is no a profile named \a pflName.
3963 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
3965 return contentNotNull()->getProfile(pflName);
3969 * Returns a profile array, apt for modification, by its id.
3970 * \param [in] pflId - the id of the profile of interest.
3971 * \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3972 * \throw If there is no a profile with id \a pflId.
3974 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
3976 return contentNotNull()->getProfileFromId(pflId);
3980 * Removes profiles given by their ids. No data is updated to track this removal.
3981 * \param [in] pflIds - a sequence of ids of the profiles to remove.
3983 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
3985 contentNotNull()->killProfileIds(pflIds);
3989 * Removes localizations given by their ids. No data is updated to track this removal.
3990 * \param [in] locIds - a sequence of ids of the localizations to remove.
3992 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
3994 contentNotNull()->killLocalizationIds(locIds);
3998 * Stores a profile array.
3999 * \param [in] pfl - the profile array to store.
4000 * \throw If the name of \a pfl is empty.
4001 * \throw If a profile with the same name as that of \a pfl already exists but contains
4004 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
4006 contentNotNull()->appendProfile(pfl);
4010 * Adds a new localization of Gauss points.
4011 * \param [in] locName - the name of the new localization.
4012 * \param [in] geoType - a geometrical type of the reference cell.
4013 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
4014 * must be \c nbOfNodesPerCell * \c dimOfType.
4015 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
4016 * must be _wg_.size() * \c dimOfType.
4017 * \param [in] w - the weights of Gauss points.
4018 * \throw If \a locName is empty.
4019 * \throw If a localization with the name \a locName already exists but is
4020 * different form the new one.
4022 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)
4024 contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
4027 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
4029 MEDFileFieldGlobs *g(_globals);
4031 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
4035 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
4037 const MEDFileFieldGlobs *g(_globals);
4039 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
4043 //= MEDFileFieldNameScope
4045 MEDFileFieldNameScope::MEDFileFieldNameScope()
4049 MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName):_name(fieldName)
4054 * Returns the name of \a this field.
4055 * \return std::string - a string containing the field name.
4057 std::string MEDFileFieldNameScope::getName() const
4063 * Sets name of \a this field
4064 * \param [in] name - the new field name.
4066 void MEDFileFieldNameScope::setName(const std::string& fieldName)
4071 std::string MEDFileFieldNameScope::getDtUnit() const
4076 void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
4081 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
4084 _dt_unit=other._dt_unit;
4087 //= MEDFileAnyTypeField1TSWithoutSDA
4089 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
4091 _field_per_mesh.resize(other._field_per_mesh.size());
4093 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
4095 if((const MEDFileFieldPerMesh *)*it)
4096 _field_per_mesh[i]=(*it)->deepCopy(this);
4101 * Prints a string describing \a this field into a stream. This string is outputted
4102 * by \c print Python command.
4103 * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
4104 * \param [in,out] oss - the out stream.
4105 * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
4106 * info id printed, else, not.
4108 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
4110 std::string startOfLine(bkOffset,' ');
4111 oss << startOfLine << "Field ";
4113 oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
4114 oss << "on one time Step ";
4116 oss << "(" << f1tsId << ") ";
4117 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
4118 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
4119 const DataArray *arr=getUndergroundDataArray();
4122 const std::vector<std::string> &comps=arr->getInfoOnComponents();
4125 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
4126 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
4127 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
4129 if(arr->isAllocated())
4131 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
4134 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
4138 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
4140 oss << startOfLine << "----------------------" << std::endl;
4141 if(!_field_per_mesh.empty())
4144 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
4146 const MEDFileFieldPerMesh *cur=(*it2);
4148 cur->simpleRepr(bkOffset,oss,i);
4150 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
4155 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
4157 oss << startOfLine << "----------------------" << std::endl;
4160 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
4162 const DataArray *arr(getUndergroundDataArray());
4164 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
4165 int nbOfCompo=arr->getNumberOfComponents();
4166 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
4167 for(int i=0;i<nbOfCompo;i++)
4170 std::vector<int> v(1,i);
4171 MCAuto<DataArray> arr2=arr->keepSelectedComponents(v);
4172 ret[i]->setArray(arr2);
4177 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)
4181 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
4186 * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
4187 * empty. Returns -1 if this in on nodes.
4188 * \return int - the dimension of \a this.
4190 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
4193 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4194 (*it)->getDimension(ret);
4199 * Returns the mesh name.
4200 * \return std::string - a string holding the mesh name.
4201 * \throw If \c _field_per_mesh.empty()
4203 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const
4205 if(_field_per_mesh.empty())
4206 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
4207 return _field_per_mesh[0]->getMeshName();
4210 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const std::string& newMeshName)
4212 std::string oldName(getMeshName());
4213 std::vector< std::pair<std::string,std::string> > v(1);
4214 v[0].first=oldName; v[0].second=newMeshName;
4218 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
4221 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4223 MEDFileFieldPerMesh *cur(*it);
4225 ret=cur->changeMeshNames(modifTab) || ret;
4231 * Returns the number of iteration of the state of underlying mesh.
4232 * \return int - the iteration number.
4233 * \throw If \c _field_per_mesh.empty()
4235 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
4237 if(_field_per_mesh.empty())
4238 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
4239 return _field_per_mesh[0]->getMeshIteration();
4243 * Returns the order number of iteration of the state of underlying mesh.
4244 * \return int - the order number.
4245 * \throw If \c _field_per_mesh.empty()
4247 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
4249 if(_field_per_mesh.empty())
4250 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
4251 return _field_per_mesh[0]->getMeshOrder();
4255 * Checks if \a this field is tagged by a given iteration number and a given
4256 * iteration order number.
4257 * \param [in] iteration - the iteration number of interest.
4258 * \param [in] order - the iteration order number of interest.
4259 * \return bool - \c true if \a this->getIteration() == \a iteration &&
4260 * \a this->getOrder() == \a order.
4262 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
4264 return iteration==_iteration && order==_order;
4268 * Returns number of iteration and order number of iteration when
4269 * \a this field has been calculated.
4270 * \return std::pair<int,int> - a pair of the iteration number and the iteration
4273 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
4275 std::pair<int,int> p;
4281 * Returns number of iteration and order number of iteration when
4282 * \a this field has been calculated.
4283 * \param [in,out] p - a pair returning the iteration number and the iteration
4286 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
4293 * Returns all types of spatial discretization of \a this field.
4294 * \param [in,out] types - a sequence of types of \a this field.
4296 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
4298 std::set<TypeOfField> types2;
4299 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4301 (*it)->fillTypesOfFieldAvailable(types2);
4303 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
4304 std::copy(types2.begin(),types2.end(),bi);
4308 * Returns all types of spatial discretization of \a this field.
4309 * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
4312 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
4314 std::vector<TypeOfField> ret;
4315 fillTypesOfFieldAvailable(ret);
4319 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
4321 std::vector<std::string> ret;
4322 std::set<std::string> ret2;
4323 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4325 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
4326 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4327 if(ret2.find(*it2)==ret2.end())
4329 ret.push_back(*it2);
4336 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
4338 std::vector<std::string> ret;
4339 std::set<std::string> ret2;
4340 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4342 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
4343 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4344 if(ret2.find(*it2)==ret2.end())
4346 ret.push_back(*it2);
4353 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
4355 std::vector<std::string> ret;
4356 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4358 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
4359 ret.insert(ret.end(),tmp.begin(),tmp.end());
4364 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
4366 std::vector<std::string> ret;
4367 std::set<std::string> ret2;
4368 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4370 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
4371 ret.insert(ret.end(),tmp.begin(),tmp.end());
4376 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4378 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4379 (*it)->changePflsRefsNamesGen(mapOfModif);
4382 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4384 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4385 (*it)->changeLocsRefsNamesGen(mapOfModif);
4389 * Returns all attributes of parts of \a this field lying on a given mesh.
4390 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4391 * item of every of returned sequences refers to the _i_-th part of \a this field.
4392 * Thus all sequences returned by this method are of the same length equal to number
4393 * of different types of supporting entities.<br>
4394 * A field part can include sub-parts with several different spatial discretizations,
4395 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
4396 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4397 * of a nested sequence corresponds to a type of spatial discretization.<br>
4398 * This method allows for iteration over MEDFile DataStructure without any overhead.
4399 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4400 * for the case with only one underlying mesh. (Actually, the number of meshes is
4401 * not checked if \a mname == \c NULL).
4402 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4403 * a field part is returned.
4404 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4405 * This sequence is of the same length as \a types.
4406 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4407 * discretization. A profile name can be empty.
4408 * Length of this and of nested sequences is the same as that of \a typesF.
4409 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4410 * discretization. A localization name can be empty.
4411 * Length of this and of nested sequences is the same as that of \a typesF.
4412 * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
4413 * of ids of tuples within the data array, per each type of spatial
4414 * discretization within one mesh entity type.
4415 * Length of this and of nested sequences is the same as that of \a typesF.
4416 * \throw If no field is lying on \a mname.
4418 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
4422 meshId=getMeshIdFromMeshName(mname);
4424 if(_field_per_mesh.empty())
4425 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4426 return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4430 * Returns dimensions of mesh elements \a this field lies on. The returned value is a
4431 * maximal absolute dimension and values returned via the out parameter \a levs are
4432 * dimensions relative to the maximal absolute dimension. <br>
4433 * This method is designed for MEDFileField1TS instances that have a discretization
4434 * \ref MEDCoupling::ON_CELLS "ON_CELLS",
4435 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT",
4436 * \ref MEDCoupling::ON_GAUSS_NE "ON_GAUSS_NE".
4437 * Only these 3 discretizations will be taken into account here. If \a this is
4438 * \ref MEDCoupling::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
4439 * This method is useful to make the link between the dimension of the underlying mesh
4440 * and the levels of \a this, because it is possible that the highest dimension of \a this
4441 * field is not equal to the dimension of the underlying mesh.
4443 * Let's consider the following case:
4444 * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
4445 * TETRA4, HEXA8, TRI3 and SEG2.
4446 * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
4447 * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
4449 * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
4450 * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
4451 * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
4452 * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
4453 * parameter of getFieldAtLevel() is computed basing on the returned values as this:
4454 * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
4456 * to retrieve the highest level of
4457 * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br>
4458 * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
4459 * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
4460 * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
4461 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4462 * for the case with only one underlying mesh. (Actually, the number of meshes is
4463 * not checked if \a mname == \c NULL).
4464 * \param [in,out] levs - a sequence returning the dimensions relative to the maximal
4465 * absolute one. They are in decreasing order. This sequence is cleared before
4467 * \return int - the maximal absolute dimension of elements \a this fields lies on.
4468 * \throw If no field is lying on \a mname.
4470 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
4473 int meshId=getMeshIdFromMeshName(mname);
4474 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4475 std::vector< std::vector<TypeOfField> > typesF;
4476 std::vector< std::vector<std::string> > pfls, locs;
4477 _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4479 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
4480 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
4481 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
4483 st.erase(INTERP_KERNEL::NORM_ERROR);
4485 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
4487 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
4488 ret1.insert((int)cm.getDimension());
4490 int ret=*std::max_element(ret1.begin(),ret1.end());
4491 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
4492 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
4497 * \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.
4498 * \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.
4499 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4500 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4502 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
4504 int mid=getMeshIdFromMeshName(mName);
4505 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4509 * \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.
4510 * \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.
4511 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4512 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4514 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
4516 int mid=getMeshIdFromMeshName(mName);
4517 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4521 * \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.
4523 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
4525 if(_field_per_mesh.empty())
4526 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4529 std::string mName2(mName);
4531 std::vector<std::string> msg;
4532 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4533 if(mName2==(*it)->getMeshName())
4536 msg.push_back((*it)->getMeshName());
4537 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4538 oss << "Possible meshes are : ";
4539 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4540 oss << "\"" << (*it2) << "\" ";
4541 throw INTERP_KERNEL::Exception(oss.str());
4544 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
4547 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4548 std::string tmp(mesh->getName());
4550 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4551 std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4553 for(;it!=_field_per_mesh.end();it++,i++)
4555 if((*it)->getMeshName()==tmp)
4558 int sz=_field_per_mesh.size();
4559 _field_per_mesh.resize(sz+1);
4560 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4564 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4565 MEDFileFieldGlobsReal& glob)
4568 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4570 MEDFileFieldPerMesh *fpm(*it);
4572 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4578 * This method splits \a this into several sub-parts so that each sub parts have exactly one spatial discretization. This method implements the minimal
4579 * splitting that leads to single spatial discretization of this.
4581 * \sa splitMultiDiscrPerGeoTypes
4583 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
4585 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4586 std::vector< std::vector<TypeOfField> > typesF;
4587 std::vector< std::vector<std::string> > pfls,locs;
4588 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4589 std::set<TypeOfField> allEnt;
4590 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4591 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4592 allEnt.insert(*it2);
4593 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4594 std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4595 for(std::size_t i=0;i<allEnt.size();i++,it3++)
4597 std::vector< std::pair<int,int> > its;
4598 ret[i]=shallowCpy();
4599 int newLgth(ret[i]->keepOnlySpatialDiscretization(*it3,its));
4600 ret[i]->updateData(newLgth,its);
4606 * This method performs a sub splitting as splitDiscretizations does but finer. This is the finest spliting level that can be done.
4607 * This method implements the minimal splitting so that each returned elements are mono Gauss discretization per geometric type.
4609 * \sa splitDiscretizations
4611 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes() const
4613 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4614 std::vector< std::vector<TypeOfField> > typesF;
4615 std::vector< std::vector<std::string> > pfls,locs;
4616 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4617 std::set<TypeOfField> allEnt;
4618 std::size_t nbOfMDPGT(0),ii(0);
4619 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++,ii++)
4621 nbOfMDPGT=std::max(nbOfMDPGT,locs[ii].size());
4622 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4623 allEnt.insert(*it2);
4625 if(allEnt.size()!=1)
4626 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : this field is expected to be defined only on one spatial discretization !");
4628 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
4631 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret0(1);
4632 ret0[0]=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(this); this->incrRef();
4635 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfMDPGT);
4636 for(std::size_t i=0;i<nbOfMDPGT;i++)
4638 std::vector< std::pair<int,int> > its;
4639 ret[i]=shallowCpy();
4640 int newLgth(ret[i]->keepOnlyGaussDiscretization(i,its));
4641 ret[i]->updateData(newLgth,its);
4646 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
4648 int globalCounter(0);
4649 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4650 (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4651 return globalCounter;
4654 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlyGaussDiscretization(std::size_t idOfDisc, std::vector< std::pair<int,int> >& its)
4656 int globalCounter(0);
4657 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4658 (*it)->keepOnlyGaussDiscretization(idOfDisc,globalCounter,its);
4659 return globalCounter;
4662 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
4664 if(_nb_of_tuples_to_be_allocated>=0)
4666 _nb_of_tuples_to_be_allocated=newLgth;
4667 const DataArray *oldArr(getUndergroundDataArray());
4670 MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4671 newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
4673 _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
4677 if(_nb_of_tuples_to_be_allocated==-1)
4679 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4681 const DataArray *oldArr(getUndergroundDataArray());
4682 if(!oldArr || !oldArr->isAllocated())
4683 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4684 MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4685 newArr->alloc(newLgth,getNumberOfComponents());
4687 newArr->copyStringInfoFrom(*oldArr);
4689 for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4691 if((*it).second<(*it).first)
4692 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4693 newArr->setContigPartOfSelectedValuesSlice(pos,oldArr,(*it).first,(*it).second,1);
4694 pos+=(*it).second-(*it).first;
4699 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4702 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
4704 if(_field_per_mesh.empty())
4705 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4706 if(_field_per_mesh.size()>1)
4707 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4708 _field_per_mesh[0]->copyOptionsFrom(opts);
4709 _field_per_mesh[0]->writeLL(fid,nasc);
4713 * 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.
4714 * If false is returned the memory allocation is not required.
4716 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
4718 if(_nb_of_tuples_to_be_allocated>=0)
4720 getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4721 _nb_of_tuples_to_be_allocated=-2;
4724 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4726 if(_nb_of_tuples_to_be_allocated==-1)
4727 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4728 if(_nb_of_tuples_to_be_allocated<-3)
4729 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4730 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4733 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
4735 med_int numdt,numit;
4739 med_int meshnumdt,meshnumit;
4740 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4741 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt));
4742 MEDFILESAFECALLERRD0(MEDfield23ComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit));
4743 if(_iteration!=numdt || _order!=numit)
4744 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4745 _field_per_mesh.resize(nmesh);
4750 std::string meshNameCpp(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
4751 mm=ms->getMeshWithName(meshNameCpp);
4754 for(int i=0;i<nmesh;i++)
4755 _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i,meshnumdt,meshnumit,nasc,mm,entities);
4756 _nb_of_tuples_to_be_allocated=0;
4757 for(int i=0;i<nmesh;i++)
4758 _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4761 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
4763 allocIfNecessaryTheArrayToReceiveDataFromFile();
4764 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4765 (*it)->loadBigArraysRecursively(fid,nasc);
4768 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
4770 if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4771 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4772 (*it)->loadBigArraysRecursively(fid,nasc);
4775 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
4777 loadOnlyStructureOfDataRecursively(fid,nasc,ms,entities);
4778 loadBigArraysRecursively(fid,nasc);
4781 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
4783 DataArray *thisArr(getUndergroundDataArray());
4784 if(thisArr && thisArr->isAllocated())
4786 _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
4787 thisArr->desallocate();
4791 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
4793 return _dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MCAuto< MEDFileFieldPerMesh >);
4796 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
4798 std::vector<const BigMemoryObject *> ret;
4799 if(getUndergroundDataArray())
4800 ret.push_back(getUndergroundDataArray());
4801 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4802 ret.push_back((const MEDFileFieldPerMesh *)*it);
4807 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4808 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4809 * "Sort By Type"), if not, an exception is thrown.
4810 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
4811 * \param [in] arr - the array of values.
4812 * \param [in,out] glob - the global data where profiles and localization present in
4813 * \a field, if any, are added.
4814 * \throw If the name of \a field is empty.
4815 * \throw If the data array of \a field is not set.
4816 * \throw If \a this->_arr is already allocated but has different number of components
4818 * \throw If the underlying mesh of \a field has no name.
4819 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4821 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4823 const MEDCouplingMesh *mesh=field->getMesh();
4825 TypeOfField type=field->getTypeOfField();
4826 std::vector<DataArrayInt *> dummy;
4827 int start=copyTinyInfoFrom(field,arr);
4828 int pos=addNewEntryIfNecessary(mesh);
4831 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4832 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4835 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4839 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4840 * of a given mesh are used as the support of the given field (a real support is not used).
4841 * Elements of the given mesh must be sorted suitable for writing to MED file.
4842 * Order of underlying mesh entities of the given field specified by \a profile parameter
4843 * is not prescribed; this method permutes field values to have them sorted by element
4844 * type as required for writing to MED file. A new profile is added only if no equal
4845 * profile is missing.
4846 * \param [in] field - the field to add to \a this. The field double values are ignored.
4847 * \param [in] arrOfVals - the values of the field \a field used.
4848 * \param [in] mesh - the supporting mesh of \a field.
4849 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4850 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
4851 * \param [in,out] glob - the global data where profiles and localization present in
4852 * \a field, if any, are added.
4853 * \throw If either \a field or \a mesh or \a profile has an empty name.
4854 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4855 * \throw If the data array of \a field is not set.
4856 * \throw If \a this->_arr is already allocated but has different number of components
4858 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4859 * \sa setFieldNoProfileSBT()
4861 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4864 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
4865 if(!arrOfVals || !arrOfVals->isAllocated())
4866 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
4867 TypeOfField type=field->getTypeOfField();
4868 std::vector<DataArrayInt *> idsInPflPerType;
4869 std::vector<DataArrayInt *> idsPerType;
4870 std::vector<int> code,code2;
4871 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
4874 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4875 std::vector< MCAuto<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
4876 std::vector< MCAuto<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin());
4877 std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
4879 MCAuto<MEDCouplingFieldDouble> field2=field->clone(false);
4880 int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
4881 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4883 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4884 throw INTERP_KERNEL::Exception(oss.str());
4887 int start=copyTinyInfoFrom(field,arrOfVals);
4888 code2=m->getDistributionOfTypes();
4890 int pos=addNewEntryIfNecessary(m);
4891 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4895 if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
4896 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
4897 std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
4898 std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
4899 int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
4900 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4902 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4903 throw INTERP_KERNEL::Exception(oss.str());
4905 int start=copyTinyInfoFrom(field,arrOfVals);
4906 int pos=addNewEntryIfNecessary(m);
4907 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4912 * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
4914 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
4916 if(_nb_of_tuples_to_be_allocated>=0)
4917 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 !");
4918 DataArray *arr(getOrCreateAndGetArray());
4919 arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
4920 _nb_of_tuples_to_be_allocated=-3;
4924 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4925 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4926 * larger by the size of \a field. Returns an id of the first not filled
4927 * tuple of \a this->_arr.
4928 * \param [in] field - the field to copy the info on components and the name from.
4929 * \return int - the id of first not initialized tuple of \a this->_arr.
4930 * \throw If the name of \a field is empty.
4931 * \throw If the data array of \a field is not set.
4932 * \throw If \a this->_arr is already allocated but has different number of components
4935 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
4938 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4939 std::string name(field->getName());
4940 setName(name.c_str());
4941 setDtUnit(field->getTimeUnit());
4943 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4945 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4946 if(!arr->isAllocated())
4947 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
4948 _dt=field->getTime(_iteration,_order);
4949 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4950 if(!getOrCreateAndGetArray()->isAllocated())
4952 allocNotFromFile(arr->getNumberOfTuples());
4957 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4958 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4959 getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
4960 _nb_of_tuples_to_be_allocated=-3;
4961 return oldNbOfTuples;
4966 * Returns number of components in \a this field
4967 * \return int - the number of components.
4969 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4971 return getOrCreateAndGetArray()->getNumberOfComponents();
4975 * Change info on components in \a this.
4976 * \throw If size of \a infos is not equal to the number of components already in \a this.
4978 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
4980 DataArray *arr=getOrCreateAndGetArray();
4981 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
4985 * Returns info on components of \a this field.
4986 * \return const std::vector<std::string>& - a sequence of strings each being an
4987 * information on _i_-th component.
4989 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
4991 const DataArray *arr=getOrCreateAndGetArray();
4992 return arr->getInfoOnComponents();
4996 * Returns a mutable info on components of \a this field.
4997 * \return std::vector<std::string>& - a sequence of strings each being an
4998 * information on _i_-th component.
5000 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
5002 DataArray *arr=getOrCreateAndGetArray();
5003 return arr->getInfoOnComponents();
5006 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const
5008 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5010 const MEDFileFieldPerMesh *fpm(*it);
5013 if(fpm->presenceOfMultiDiscPerGeoType())
5019 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfStructureElements() const
5021 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5022 if((*it).isNotNull())
5023 if((*it)->presenceOfStructureElements())
5028 bool MEDFileAnyTypeField1TSWithoutSDA::onlyStructureElements() const
5030 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5031 if((*it).isNotNull())
5032 if(!(*it)->onlyStructureElements())
5037 void MEDFileAnyTypeField1TSWithoutSDA::killStructureElements()
5039 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5040 if((*it).isNotNull())
5041 (*it)->killStructureElements();
5044 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh(const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5046 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 !";
5047 if(_field_per_mesh.empty())
5048 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is empty ! Nothing to extract !");
5049 if(_field_per_mesh.size()>1)
5050 throw INTERP_KERNEL::Exception(MSG0);
5051 if(_field_per_mesh[0].isNull())
5052 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is inconsistent !");
5053 const MEDFileFieldPerMesh *pm(_field_per_mesh[0]);
5054 std::set<TypeOfField> types;
5055 pm->fillTypesOfFieldAvailable(types);
5057 throw INTERP_KERNEL::Exception(MSG0);
5058 TypeOfField type(*types.begin());
5059 int meshDimRelToMax(0);
5064 int myDim(std::numeric_limits<int>::max());
5065 bool isUnique(pm->isUniqueLevel(myDim));
5067 throw INTERP_KERNEL::Exception(MSG0);
5068 meshDimRelToMax=myDim-mesh->getMeshDimension();
5069 if(meshDimRelToMax>0)
5070 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the mesh attached to field is not compatible with the field !");
5072 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,0/*renumPol*/,glob,mesh,arrOut,nasc);
5076 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5077 * \param [in] type - a spatial discretization of the new field.
5078 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5079 * \param [in] mName - a name of the supporting mesh.
5080 * \param [in] renumPol - specifies how to permute values of the result field according to
5081 * the optional numbers of cells and nodes, if any. The valid values are
5082 * - 0 - do not permute.
5083 * - 1 - permute cells.
5084 * - 2 - permute nodes.
5085 * - 3 - permute cells and nodes.
5087 * \param [in] glob - the global data storing profiles and localization.
5088 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5089 * caller is to delete this field using decrRef() as it is no more needed.
5090 * \throw If the MED file is not readable.
5091 * \throw If there is no mesh named \a mName in the MED file.
5092 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5093 * \throw If no field of \a this is lying on the mesh \a mName.
5094 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5096 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5098 MCAuto<MEDFileMesh> mm;
5100 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
5102 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
5103 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
5107 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5108 * \param [in] type - a spatial discretization of the new field.
5109 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5110 * \param [in] renumPol - specifies how to permute values of the result field according to
5111 * the optional numbers of cells and nodes, if any. The valid values are
5112 * - 0 - do not permute.
5113 * - 1 - permute cells.
5114 * - 2 - permute nodes.
5115 * - 3 - permute cells and nodes.
5117 * \param [in] glob - the global data storing profiles and localization.
5118 * \param [in] mesh - the supporting mesh.
5119 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5120 * caller is to delete this field using decrRef() as it is no more needed.
5121 * \throw If the MED file is not readable.
5122 * \throw If no field of \a this is lying on \a mesh.
5123 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5124 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5126 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5128 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax,false));
5129 const DataArrayInt *d(mesh->getNumberFieldAtLevel(meshDimRelToMax)),*e(mesh->getNumberFieldAtLevel(1));
5130 if(meshDimRelToMax==1)
5131 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
5132 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
5136 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
5138 * \param [in] type - a spatial discretization of the new field.
5139 * \param [in] mName - a name of the supporting mesh.
5140 * \param [in] renumPol - specifies how to permute values of the result field according to
5141 * the optional numbers of cells and nodes, if any. The valid values are
5142 * - 0 - do not permute.
5143 * - 1 - permute cells.
5144 * - 2 - permute nodes.
5145 * - 3 - permute cells and nodes.
5147 * \param [in] glob - the global data storing profiles and localization.
5148 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5149 * caller is to delete this field using decrRef() as it is no more needed.
5150 * \throw If the MED file is not readable.
5151 * \throw If there is no mesh named \a mName in the MED file.
5152 * \throw If there are no mesh entities in the mesh.
5153 * \throw If no field values of the given \a type are available.
5155 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5157 MCAuto<MEDFileMesh> mm;
5159 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
5161 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
5162 int absDim=getDimension();
5163 int meshDimRelToMax=absDim-mm->getMeshDimension();
5164 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
5168 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5169 * \param [in] type - a spatial discretization of the new field.
5170 * \param [in] renumPol - specifies how to permute values of the result field according to
5171 * the optional numbers of cells and nodes, if any. The valid values are
5172 * - 0 - do not permute.
5173 * - 1 - permute cells.
5174 * - 2 - permute nodes.
5175 * - 3 - permute cells and nodes.
5177 * \param [in] glob - the global data storing profiles and localization.
5178 * \param [in] mesh - the supporting mesh.
5179 * \param [in] cellRenum - the cell numbers array used for permutation of the result
5180 * field according to \a renumPol.
5181 * \param [in] nodeRenum - the node numbers array used for permutation of the result
5182 * field according to \a renumPol.
5183 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5184 * caller is to delete this field using decrRef() as it is no more needed.
5185 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5186 * \throw If no field of \a this is lying on \a mesh.
5187 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5189 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
5191 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
5192 int meshId=getMeshIdFromMeshName(mesh->getName());
5194 MCAuto<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
5199 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5206 throw INTERP_KERNEL::Exception(msg1);
5207 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5210 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
5212 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5213 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
5214 throw INTERP_KERNEL::Exception(oss.str());
5216 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
5217 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
5218 std::vector<DataArray *> arrOut2(1,arrOut);
5219 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
5220 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
5221 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
5228 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5230 throw INTERP_KERNEL::Exception(msg1);
5233 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
5235 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5236 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
5237 throw INTERP_KERNEL::Exception(oss.str());
5239 MCAuto<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
5240 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
5241 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
5242 ret->renumberNodes(nodeRenumSafe->getConstPointer());
5247 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
5252 * Returns values and a profile of the field of a given type lying on a given support.
5253 * \param [in] type - a spatial discretization of the field.
5254 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5255 * \param [in] mesh - the supporting mesh.
5256 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
5257 * field of interest lies on. If the field lies on all entities of the given
5258 * dimension, all ids in \a pfl are zero. The caller is to delete this array
5259 * using decrRef() as it is no more needed.
5260 * \param [in] glob - the global data storing profiles and localization.
5261 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
5262 * field. The caller is to delete this array using decrRef() as it is no more needed.
5263 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
5264 * \throw If no field of \a this is lying on \a mesh.
5265 * \throw If no field values of the given \a type are available.
5267 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
5269 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
5270 int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
5271 MCAuto<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
5272 ret->setName(nasc.getName().c_str());
5276 //= MEDFileField1TSWithoutSDA
5279 * Throws if a given value is not a valid (non-extended) relative dimension.
5280 * \param [in] meshDimRelToMax - the relative dimension value.
5281 * \throw If \a meshDimRelToMax > 0.
5283 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
5285 if(meshDimRelToMax>0)
5286 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
5290 * Checks if elements of a given mesh are in the order suitable for writing
5291 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
5292 * vector describing types of elements and their number.
5293 * \param [in] mesh - the mesh to check.
5294 * \return std::vector<int> - a vector holding for each element type (1) item of
5295 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
5296 * These values are in full-interlace mode.
5297 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
5299 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
5302 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
5303 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
5304 int nbOfTypes=geoTypes.size();
5305 std::vector<int> code(3*nbOfTypes);
5306 MCAuto<DataArrayInt> arr1=DataArrayInt::New();
5307 arr1->alloc(nbOfTypes,1);
5308 int *arrPtr=arr1->getPointer();
5309 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
5310 for(int i=0;i<nbOfTypes;i++,it++)
5311 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
5312 MCAuto<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
5313 const int *arrPtr2=arr2->getConstPointer();
5315 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
5318 int nbCells=mesh->getNumberOfCellsWithType(*it);
5319 code[3*pos]=(int)(*it);
5320 code[3*pos+1]=nbCells;
5321 code[3*pos+2]=-1;//no profiles
5323 std::vector<const DataArrayInt *> idsPerType;//no profiles
5324 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
5328 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
5333 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5335 return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5339 * Returns all attributes and values of parts of \a this field lying on a given mesh.
5340 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
5341 * item of every of returned sequences refers to the _i_-th part of \a this field.
5342 * Thus all sequences returned by this method are of the same length equal to number
5343 * of different types of supporting entities.<br>
5344 * A field part can include sub-parts with several different spatial discretizations,
5345 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
5346 * for example. Hence, some of the returned sequences contains nested sequences, and an item
5347 * of a nested sequence corresponds to a type of spatial discretization.<br>
5348 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
5349 * The overhead is due to selecting values into new instances of DataArrayDouble.
5350 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
5351 * for the case with only one underlying mesh. (Actually, the number of meshes is
5352 * not checked if \a mname == \c NULL).
5353 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
5354 * a field part is returned.
5355 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
5356 * A field part can include sub-parts with several different spatial discretizations,
5357 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and
5358 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT" for example.
5359 * This sequence is of the same length as \a types.
5360 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
5361 * discretization. A profile name can be empty.
5362 * Length of this and of nested sequences is the same as that of \a typesF.
5363 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
5364 * discretization. A localization name can be empty.
5365 * Length of this and of nested sequences is the same as that of \a typesF.
5366 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
5367 * per each type of spatial discretization within one mesh entity type.
5368 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
5369 * Length of this and of nested sequences is the same as that of \a typesF.
5370 * \throw If no field is lying on \a mname.
5372 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
5376 meshId=getMeshIdFromMeshName(mname);
5378 if(_field_per_mesh.empty())
5379 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
5380 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
5381 int nbOfRet=ret0.size();
5382 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
5383 for(int i=0;i<nbOfRet;i++)
5385 const std::vector< std::pair<int,int> >& p=ret0[i];
5386 int nbOfRet1=p.size();
5387 ret[i].resize(nbOfRet1);
5388 for(int j=0;j<nbOfRet1;j++)
5390 DataArrayDouble *tmp=_arr->selectByTupleIdSafeSlice(p[j].first,p[j].second,1);
5397 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
5402 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
5404 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
5405 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5406 ret->deepCpyLeavesFrom(*this);
5407 const DataArrayDouble *arr(_arr);
5410 MCAuto<DataArrayInt> arr2(arr->convertToIntArr());
5411 ret->setArray(arr2);
5417 * Returns a pointer to the underground DataArrayDouble instance and a
5418 * sequence describing parameters of a support of each part of \a this field. The
5419 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5420 * direct access to the field values. This method is intended for the field lying on one
5422 * \param [in,out] entries - the sequence describing parameters of a support of each
5423 * part of \a this field. Each item of this sequence consists of two parts. The
5424 * first part describes a type of mesh entity and an id of discretization of a
5425 * current field part. The second part describes a range of values [begin,end)
5426 * within the returned array relating to the current field part.
5427 * \return DataArrayDouble * - the pointer to the field values array.
5428 * \throw If the number of underlying meshes is not equal to 1.
5429 * \throw If no field values are available.
5430 * \sa getUndergroundDataArray()
5432 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5434 if(_field_per_mesh.size()!=1)
5435 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5436 if(_field_per_mesh[0]==0)
5437 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5438 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5439 return getUndergroundDataArrayTemplate();
5443 * Returns a pointer to the underground DataArrayDouble instance and a
5444 * sequence describing parameters of a support of each part of \a this field. The
5445 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5446 * direct access to the field values. This method is intended for the field lying on one
5448 * \param [in,out] entries - the sequence describing parameters of a support of each
5449 * part of \a this field. Each item of this sequence consists of two parts. The
5450 * first part describes a type of mesh entity and an id of discretization of a
5451 * current field part. The second part describes a range of values [begin,end)
5452 * within the returned array relating to the current field part.
5453 * \return DataArrayDouble * - the pointer to the field values array.
5454 * \throw If the number of underlying meshes is not equal to 1.
5455 * \throw If no field values are available.
5456 * \sa getUndergroundDataArray()
5458 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5460 return getUndergroundDataArrayDoubleExt(entries);
5463 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<double>(fieldName,csit,iteration,order)
5465 DataArrayDouble *arr(getOrCreateAndGetArrayTemplate());
5466 arr->setInfoAndChangeNbOfCompo(infos);
5469 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<double>()
5473 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
5475 MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
5476 ret->deepCpyLeavesFrom(*this);
5480 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCopy() const
5482 MCAuto<MEDFileField1TSWithoutSDA> ret(shallowCpy());
5483 if(_arr.isNotNull())
5484 ret->_arr=_arr->deepCopy();
5488 //= MEDFileIntField1TSWithoutSDA
5490 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5492 return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5495 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<int>()
5499 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order,
5500 const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<int>(fieldName,csit,iteration,order)
5502 DataArrayInt *arr(getOrCreateAndGetArrayTemplate());
5503 arr->setInfoAndChangeNbOfCompo(infos);
5506 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
5511 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const
5513 MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
5514 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5515 ret->deepCpyLeavesFrom(*this);
5516 const DataArrayInt *arr(_arr);
5519 MCAuto<DataArrayDouble> arr2(arr->convertToDblArr());
5520 ret->setArray(arr2);
5526 * Returns a pointer to the underground DataArrayInt instance and a
5527 * sequence describing parameters of a support of each part of \a this field. The
5528 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5529 * direct access to the field values. This method is intended for the field lying on one
5531 * \param [in,out] entries - the sequence describing parameters of a support of each
5532 * part of \a this field. Each item of this sequence consists of two parts. The
5533 * first part describes a type of mesh entity and an id of discretization of a
5534 * current field part. The second part describes a range of values [begin,end)
5535 * within the returned array relating to the current field part.
5536 * \return DataArrayInt * - the pointer to the field values array.
5537 * \throw If the number of underlying meshes is not equal to 1.
5538 * \throw If no field values are available.
5539 * \sa getUndergroundDataArray()
5541 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5543 return getUndergroundDataArrayIntExt(entries);
5547 * Returns a pointer to the underground DataArrayInt instance and a
5548 * sequence describing parameters of a support of each part of \a this field. The
5549 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5550 * direct access to the field values. This method is intended for the field lying on one
5552 * \param [in,out] entries - the sequence describing parameters of a support of each
5553 * part of \a this field. Each item of this sequence consists of two parts. The
5554 * first part describes a type of mesh entity and an id of discretization of a
5555 * current field part. The second part describes a range of values [begin,end)
5556 * within the returned array relating to the current field part.
5557 * \return DataArrayInt * - the pointer to the field values array.
5558 * \throw If the number of underlying meshes is not equal to 1.
5559 * \throw If no field values are available.
5560 * \sa getUndergroundDataArray()
5562 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5564 if(_field_per_mesh.size()!=1)
5565 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5566 if(_field_per_mesh[0]==0)
5567 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5568 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5569 return getUndergroundDataArrayTemplate();
5572 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5574 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5575 ret->deepCpyLeavesFrom(*this);
5579 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCopy() const
5581 MCAuto<MEDFileIntField1TSWithoutSDA> ret(shallowCpy());
5582 if(_arr.isNotNull())
5583 ret->_arr=_arr->deepCopy();
5587 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5591 //= MEDFileAnyTypeField1TS
5593 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
5595 med_field_type typcha;
5597 std::vector<std::string> infos;
5598 std::string dtunit,fieldName;
5599 LocateField2(fid,0,true,fieldName,typcha,infos,dtunit);
5600 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5605 ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5610 ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5615 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] !";
5616 throw INTERP_KERNEL::Exception(oss.str());
5619 ret->setDtUnit(dtunit.c_str());
5620 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5622 med_int numdt,numit;
5624 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5625 ret->setTime(numdt,numit,dt);
5628 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5630 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5634 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
5635 try:MEDFileFieldGlobsReal(fid)
5637 _content=BuildContentFrom(fid,loadAll,ms);
5640 catch(INTERP_KERNEL::Exception& e)
5645 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5647 med_field_type typcha;
5648 std::vector<std::string> infos;
5651 int nbSteps=LocateField(fid,fieldName,iii,typcha,infos,dtunit);
5652 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5657 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5662 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5667 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] !";
5668 throw INTERP_KERNEL::Exception(oss.str());
5671 ret->setDtUnit(dtunit.c_str());
5672 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5676 std::ostringstream oss; oss << "MEDFileField1TS(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5677 throw INTERP_KERNEL::Exception(oss.str());
5680 med_int numdt,numit;
5682 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5683 ret->setTime(numdt,numit,dt);
5686 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5688 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5692 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5693 try:MEDFileFieldGlobsReal(fid)
5695 _content=BuildContentFrom(fid,fieldName,loadAll,ms);
5698 catch(INTERP_KERNEL::Exception& e)
5703 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c)
5706 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5707 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5709 MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
5710 ret->_content=c; c->incrRef();
5713 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5715 MCAuto<MEDFileIntField1TS> ret(MEDFileIntField1TS::New());
5716 ret->_content=c; c->incrRef();
5719 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5722 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, med_idt fid)
5724 MEDFileAnyTypeField1TS *ret(BuildNewInstanceFromContent(c));
5725 ret->setFileName(FileNameFromFID(fid));
5729 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
5731 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5732 return New(fid,loadAll);
5735 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, bool loadAll)
5737 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
5738 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5739 ret->loadGlobals(fid);
5743 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
5745 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5746 return New(fid,fieldName,loadAll);
5749 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
5751 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0));
5752 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5753 ret->loadGlobals(fid);
5757 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
5759 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5760 return New(fid,fieldName,iteration,order,loadAll);
5763 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
5765 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0));
5766 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5767 ret->loadGlobals(fid);
5771 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5773 med_field_type typcha;
5774 std::vector<std::string> infos;
5777 int nbOfStep2(LocateField(fid,fieldName,iii,typcha,infos,dtunit));
5778 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5783 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5788 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5793 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] !";
5794 throw INTERP_KERNEL::Exception(oss.str());
5797 ret->setDtUnit(dtunit.c_str());
5798 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5801 std::vector< std::pair<int,int> > dtits(nbOfStep2);
5802 for(int i=0;i<nbOfStep2 && !found;i++)
5804 med_int numdt,numit;
5806 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt));
5807 if(numdt==iteration && numit==order)
5813 dtits[i]=std::pair<int,int>(numdt,numit);
5817 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available iterations are : ";
5818 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5819 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5820 throw INTERP_KERNEL::Exception(oss.str());
5823 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5825 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5829 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5830 try:MEDFileFieldGlobsReal(fid)
5832 _content=BuildContentFrom(fid,fieldName,iteration,order,loadAll,ms);
5835 catch(INTERP_KERNEL::Exception& e)
5841 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5842 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5844 * \warning this is a shallow copy constructor
5846 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5848 if(!shallowCopyOfContent)
5850 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5851 otherPtr->incrRef();
5852 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5856 _content=other.shallowCpy();
5860 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)
5864 int nbFields=MEDnField(fid);
5865 if(fieldIdCFormat>=nbFields)
5867 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << FileNameFromFID(fid) << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5868 throw INTERP_KERNEL::Exception(oss.str());
5871 int ncomp(MEDfieldnComponent(fid,fieldIdCFormat+1));
5872 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5873 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5874 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5875 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5876 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5879 MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep));
5880 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5881 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5882 infos.clear(); infos.resize(ncomp);
5883 for(int j=0;j<ncomp;j++)
5884 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5889 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5892 * \return in case of success the number of time steps available for the field with name \a fieldName.
5894 int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const std::string& fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
5896 int nbFields=MEDnField(fid);
5898 std::vector<std::string> fns(nbFields);
5900 for(int i=0;i<nbFields && !found;i++)
5903 nbOfStep2=LocateField2(fid,i,false,tmp,typcha,infos,dtunitOut);
5905 found=(tmp==fieldName);
5911 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available fields are : ";
5912 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5913 oss << "\"" << *it << "\" ";
5914 throw INTERP_KERNEL::Exception(oss.str());
5920 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5921 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5922 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5923 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5924 * to keep a valid instance.
5925 * 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.
5926 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5927 * 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.
5929 * \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.
5930 * \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.
5931 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5932 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5933 * \param [in] newLocName is the new localization name.
5934 * \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.
5935 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5937 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
5939 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5940 std::string oldPflName=disc->getProfile();
5941 std::vector<std::string> vv=getPflsReallyUsedMulti();
5942 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5943 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5945 disc->setProfile(newPflName);
5946 DataArrayInt *pfl=getProfile(oldPflName.c_str());
5947 pfl->setName(newPflName);
5951 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5952 throw INTERP_KERNEL::Exception(oss.str());
5957 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5958 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5959 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5960 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5961 * to keep a valid instance.
5962 * 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.
5963 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5964 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5965 * 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.
5967 * \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.
5968 * \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.
5969 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5970 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5971 * \param [in] newLocName is the new localization name.
5972 * \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.
5973 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
5975 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
5977 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5978 std::string oldLocName=disc->getLocalization();
5979 std::vector<std::string> vv=getLocsReallyUsedMulti();
5980 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
5981 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
5983 disc->setLocalization(newLocName);
5984 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
5985 loc.setName(newLocName);
5989 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
5990 throw INTERP_KERNEL::Exception(oss.str());
5994 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
5996 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5998 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
6002 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
6004 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
6006 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
6011 * This method alloc the arrays and load potentially huge arrays contained in this field.
6012 * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
6013 * This method can be also called to refresh or reinit values from a file.
6015 * \throw If the fileName is not set or points to a non readable MED file.
6016 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
6018 void MEDFileAnyTypeField1TS::loadArrays()
6020 if(getFileName().empty())
6021 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
6022 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
6023 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
6027 * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
6028 * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
6029 * this method does not throw if \a this does not come from file read.
6031 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
6033 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
6035 if(!getFileName().empty())
6037 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
6038 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
6043 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
6044 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
6045 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
6047 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
6049 void MEDFileAnyTypeField1TS::unloadArrays()
6051 contentNotNullBase()->unloadArrays();
6055 * 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.
6056 * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
6057 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
6059 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
6061 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
6063 if(!getFileName().empty())
6064 contentNotNullBase()->unloadArrays();
6067 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
6069 int nbComp(getNumberOfComponents());
6070 INTERP_KERNEL::AutoPtr<char> comp(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
6071 INTERP_KERNEL::AutoPtr<char> unit(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
6072 for(int i=0;i<nbComp;i++)
6074 std::string info=getInfo()[i];
6076 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
6077 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
6078 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
6080 if(getName().empty())
6081 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
6082 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
6083 writeGlobals(fid,*this);
6084 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
6087 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
6089 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
6092 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
6094 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
6095 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
6100 * Returns a string describing \a this field. This string is outputted
6101 * by \c print Python command.
6103 std::string MEDFileAnyTypeField1TS::simpleRepr() const
6105 std::ostringstream oss;
6106 contentNotNullBase()->simpleRepr(0,oss,-1);
6107 simpleReprGlobs(oss);
6112 * This method returns all profiles whose name is non empty used.
6113 * \b WARNING If profile is used several times it will be reported \b only \b once.
6114 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
6116 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
6118 return contentNotNullBase()->getPflsReallyUsed2();
6122 * This method returns all localizations whose name is non empty used.
6123 * \b WARNING If localization is used several times it will be reported \b only \b once.
6125 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
6127 return contentNotNullBase()->getLocsReallyUsed2();
6131 * This method returns all profiles whose name is non empty used.
6132 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
6134 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
6136 return contentNotNullBase()->getPflsReallyUsedMulti2();
6140 * This method returns all localizations whose name is non empty used.
6141 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
6143 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
6145 return contentNotNullBase()->getLocsReallyUsedMulti2();
6148 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6150 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
6153 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6155 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
6158 int MEDFileAnyTypeField1TS::getDimension() const
6160 return contentNotNullBase()->getDimension();
6163 int MEDFileAnyTypeField1TS::getIteration() const
6165 return contentNotNullBase()->getIteration();
6168 int MEDFileAnyTypeField1TS::getOrder() const
6170 return contentNotNullBase()->getOrder();
6173 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
6175 return contentNotNullBase()->getTime(iteration,order);
6178 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
6180 contentNotNullBase()->setTime(iteration,order,val);
6183 std::string MEDFileAnyTypeField1TS::getName() const
6185 return contentNotNullBase()->getName();
6188 void MEDFileAnyTypeField1TS::setName(const std::string& name)
6190 contentNotNullBase()->setName(name);
6193 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
6195 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
6198 std::string MEDFileAnyTypeField1TS::getDtUnit() const
6200 return contentNotNullBase()->getDtUnit();
6203 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
6205 contentNotNullBase()->setDtUnit(dtUnit);
6208 std::string MEDFileAnyTypeField1TS::getMeshName() const
6210 return contentNotNullBase()->getMeshName();
6213 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
6215 contentNotNullBase()->setMeshName(newMeshName);
6218 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
6220 return contentNotNullBase()->changeMeshNames(modifTab);
6223 int MEDFileAnyTypeField1TS::getMeshIteration() const
6225 return contentNotNullBase()->getMeshIteration();
6228 int MEDFileAnyTypeField1TS::getMeshOrder() const
6230 return contentNotNullBase()->getMeshOrder();
6233 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
6235 return contentNotNullBase()->getNumberOfComponents();
6238 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
6240 return contentNotNullBase()->isDealingTS(iteration,order);
6243 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
6245 return contentNotNullBase()->getDtIt();
6248 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
6250 contentNotNullBase()->fillIteration(p);
6253 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
6255 contentNotNullBase()->fillTypesOfFieldAvailable(types);
6258 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
6260 contentNotNullBase()->setInfo(infos);
6263 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
6265 return contentNotNullBase()->getInfo();
6267 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
6269 return contentNotNullBase()->getInfo();
6272 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
6274 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
6277 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
6279 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6282 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
6284 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6287 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
6289 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
6292 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
6294 return contentNotNullBase()->getTypesOfFieldAvailable();
6297 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,
6298 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6300 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
6304 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
6305 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
6306 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
6308 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
6310 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6312 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
6313 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
6314 std::size_t sz(contentsSplit.size());
6315 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6316 for(std::size_t i=0;i<sz;i++)
6318 ret[i]=shallowCpy();
6319 ret[i]->_content=contentsSplit[i];
6325 * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
6326 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6328 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
6330 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6332 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
6333 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
6334 std::size_t sz(contentsSplit.size());
6335 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6336 for(std::size_t i=0;i<sz;i++)
6338 ret[i]=shallowCpy();
6339 ret[i]->_content=contentsSplit[i];
6345 * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this.
6346 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6348 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const
6350 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6352 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !");
6353 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
6354 std::size_t sz(contentsSplit.size());
6355 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6356 for(std::size_t i=0;i<sz;i++)
6358 ret[i]=shallowCpy();
6359 ret[i]->_content=contentsSplit[i];
6364 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCopy() const
6366 MCAuto<MEDFileAnyTypeField1TS> ret=shallowCpy();
6367 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
6368 ret->_content=_content->deepCopy();
6369 ret->deepCpyGlobs(*this);
6373 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
6375 return contentNotNullBase()->copyTinyInfoFrom(field,arr);
6381 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6382 * the first field that has been read from a specified MED file.
6383 * \param [in] fileName - the name of the MED file to read.
6384 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6385 * is to delete this field using decrRef() as it is no more needed.
6386 * \throw If reading the file fails.
6388 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll)
6390 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6391 return New(fid,loadAll);
6394 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, bool loadAll)
6396 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,loadAll,0));
6397 ret->contentNotNull();
6402 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6403 * a given field that has been read from a specified MED file.
6404 * \param [in] fileName - the name of the MED file to read.
6405 * \param [in] fieldName - the name of the field to read.
6406 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6407 * is to delete this field using decrRef() as it is no more needed.
6408 * \throw If reading the file fails.
6409 * \throw If there is no field named \a fieldName in the file.
6411 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6413 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6414 return New(fid,fieldName,loadAll);
6417 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
6419 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,fieldName,loadAll,0));
6420 ret->contentNotNull();
6425 * Returns a new instance of MEDFileField1TS holding data of a given time step of
6426 * a given field that has been read from a specified MED file.
6427 * \param [in] fileName - the name of the MED file to read.
6428 * \param [in] fieldName - the name of the field to read.
6429 * \param [in] iteration - the iteration number of a required time step.
6430 * \param [in] order - the iteration order number of required time step.
6431 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6432 * is to delete this field using decrRef() as it is no more needed.
6433 * \throw If reading the file fails.
6434 * \throw If there is no field named \a fieldName in the file.
6435 * \throw If the required time step is missing from the file.
6437 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6439 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6440 return New(fid,fieldName,iteration,order,loadAll);
6443 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
6445 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,fieldName,iteration,order,loadAll,0));
6446 ret->contentNotNull();
6451 * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6452 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6454 * Returns a new instance of MEDFileField1TS holding either a shallow copy
6455 * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
6456 * \warning this is a shallow copy constructor
6457 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
6458 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
6459 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6460 * is to delete this field using decrRef() as it is no more needed.
6462 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6464 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(other,shallowCopyOfContent));
6465 ret->contentNotNull();
6470 * Returns a new empty instance of MEDFileField1TS.
6471 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6472 * is to delete this field using decrRef() as it is no more needed.
6474 MEDFileField1TS *MEDFileField1TS::New()
6476 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS);
6477 ret->contentNotNull();
6482 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
6483 * following the given input policy.
6485 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6486 * By default (true) the globals are deeply copied.
6487 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
6489 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
6491 MCAuto<MEDFileIntField1TS> ret;
6492 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6495 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
6497 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
6498 MCAuto<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
6499 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc));
6502 ret=MEDFileIntField1TS::New();
6504 ret->deepCpyGlobs(*this);
6506 ret->shallowCpyGlobs(*this);
6510 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const
6512 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6514 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
6515 const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
6517 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 !");
6521 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull()
6523 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6525 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
6526 MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
6528 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 !");
6532 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
6535 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
6537 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
6538 DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6540 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6541 f->setArray(arrOutC);
6544 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MCAuto<DataArray>& arr)
6547 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
6548 DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6550 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6556 * Return an extraction of \a this using \a extractDef map to specify the extraction.
6557 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
6559 * \return A new object that the caller is responsible to deallocate.
6560 * \sa MEDFileUMesh::deduceNodeSubPartFromCellSubPart , MEDFileUMesh::extractPart
6562 MEDFileField1TS *MEDFileField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
6565 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : input mesh is NULL !");
6566 MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
6567 std::vector<TypeOfField> tof(getTypesOfFieldAvailable());
6568 for(std::vector<TypeOfField>::const_iterator it0=tof.begin();it0!=tof.end();it0++)
6570 if((*it0)!=ON_NODES)
6572 std::vector<int> levs;
6573 getNonEmptyLevels(mm->getName(),levs);
6574 for(std::vector<int>::const_iterator lev=levs.begin();lev!=levs.end();lev++)
6576 std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(*lev));
6577 if(it2!=extractDef.end())
6579 MCAuto<DataArrayInt> t((*it2).second);
6581 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6582 MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_CELLS,(*lev),mm));
6583 MCAuto<MEDCouplingFieldDouble> fOut(f->buildSubPart(t));
6584 ret->setFieldNoProfileSBT(fOut);
6590 std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(1));
6591 if(it2==extractDef.end())
6592 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a NODE field and no extract array available for NODE !");
6593 MCAuto<DataArrayInt> t((*it2).second);
6595 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6596 MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_NODES,0,mm));
6597 MCAuto<MEDCouplingFieldDouble> fOut(f->deepCopy());
6598 DataArrayDouble *arr(f->getArray());
6599 MCAuto<DataArrayDouble> newArr(arr->selectByTupleIdSafe(t->begin(),t->end()));
6600 fOut->setArray(newArr);
6601 ret->setFieldNoProfileSBT(fOut);
6607 MEDFileField1TS::MEDFileField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
6608 try:MEDFileAnyTypeField1TS(fid,loadAll,ms)
6611 catch(INTERP_KERNEL::Exception& e)
6614 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6615 try:MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms)
6618 catch(INTERP_KERNEL::Exception& e)
6621 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6622 try:MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms)
6625 catch(INTERP_KERNEL::Exception& e)
6629 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6630 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6632 * \warning this is a shallow copy constructor
6634 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6635 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6638 catch(INTERP_KERNEL::Exception& e)
6641 MEDFileField1TS::MEDFileField1TS()
6643 _content=new MEDFileField1TSWithoutSDA;
6647 * 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
6648 * method should be called (getFieldOnMeshAtLevel for example).
6649 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
6651 * \param [in] mesh - the mesh the field is lying on
6652 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6653 * caller is to delete this field using decrRef() as it is no more needed.
6655 MEDCouplingFieldDouble *MEDFileField1TS::field(const MEDFileMesh *mesh) const
6657 MCAuto<DataArray> arrOut;
6658 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
6659 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6664 * Returns a new MEDCouplingFieldDouble of a given type lying on
6665 * mesh entities of a given dimension of the first mesh in MED file. If \a this field
6666 * has not been constructed via file reading, an exception is thrown.
6667 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6668 * \param [in] type - a spatial discretization of interest.
6669 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6670 * \param [in] renumPol - specifies how to permute values of the result field according to
6671 * the optional numbers of cells and nodes, if any. The valid values are
6672 * - 0 - do not permute.
6673 * - 1 - permute cells.
6674 * - 2 - permute nodes.
6675 * - 3 - permute cells and nodes.
6677 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6678 * caller is to delete this field using decrRef() as it is no more needed.
6679 * \throw If \a this field has not been constructed via file reading.
6680 * \throw If the MED file is not readable.
6681 * \throw If there is no mesh in the MED file.
6682 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6683 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6684 * \sa getFieldOnMeshAtLevel()
6686 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6688 if(getFileName().empty())
6689 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6690 MCAuto<DataArray> arrOut;
6691 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
6692 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6697 * Returns a new MEDCouplingFieldDouble of a given type lying on
6698 * the top level cells of the first mesh in MED file. If \a this field
6699 * has not been constructed via file reading, an exception is thrown.
6700 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6701 * \param [in] type - a spatial discretization of interest.
6702 * \param [in] renumPol - specifies how to permute values of the result field according to
6703 * the optional numbers of cells and nodes, if any. The valid values are
6704 * - 0 - do not permute.
6705 * - 1 - permute cells.
6706 * - 2 - permute nodes.
6707 * - 3 - permute cells and nodes.
6709 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6710 * caller is to delete this field using decrRef() as it is no more needed.
6711 * \throw If \a this field has not been constructed via file reading.
6712 * \throw If the MED file is not readable.
6713 * \throw If there is no mesh in the MED file.
6714 * \throw If no field values of the given \a type.
6715 * \throw If no field values lying on the top level support.
6716 * \sa getFieldAtLevel()
6718 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
6720 if(getFileName().empty())
6721 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6722 MCAuto<DataArray> arrOut;
6723 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
6724 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6729 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6730 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6731 * \param [in] type - a spatial discretization of the new field.
6732 * \param [in] mesh - the supporting mesh.
6733 * \param [in] renumPol - specifies how to permute values of the result field according to
6734 * the optional numbers of cells and nodes, if any. The valid values are
6735 * - 0 - do not permute.
6736 * - 1 - permute cells.
6737 * - 2 - permute nodes.
6738 * - 3 - permute cells and nodes.
6740 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6741 * caller is to delete this field using decrRef() as it is no more needed.
6742 * \throw If no field of \a this is lying on \a mesh.
6743 * \throw If the mesh is empty.
6744 * \throw If no field values of the given \a type are available.
6745 * \sa getFieldAtLevel()
6746 * \sa getFieldOnMeshAtLevel()
6748 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
6750 MCAuto<DataArray> arrOut;
6751 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
6752 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6757 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6758 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6759 * \param [in] type - a spatial discretization of interest.
6760 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6761 * \param [in] mesh - the supporting mesh.
6762 * \param [in] renumPol - specifies how to permute values of the result field according to
6763 * the optional numbers of cells and nodes, if any. The valid values are
6764 * - 0 - do not permute.
6765 * - 1 - permute cells.
6766 * - 2 - permute nodes.
6767 * - 3 - permute cells and nodes.
6769 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6770 * caller is to delete this field using decrRef() as it is no more needed.
6771 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6772 * \throw If no field of \a this is lying on \a mesh.
6773 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6774 * \sa getFieldAtLevel()
6775 * \sa getFieldOnMeshAtLevel()
6777 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
6779 MCAuto<DataArray> arrOut;
6780 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
6781 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6786 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6787 * This method is called "Old" because in MED3 norm a field has only one meshName
6788 * attached, so this method is for readers of MED2 files. If \a this field
6789 * has not been constructed via file reading, an exception is thrown.
6790 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6791 * \param [in] type - a spatial discretization of interest.
6792 * \param [in] mName - a name of the supporting mesh.
6793 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6794 * \param [in] renumPol - specifies how to permute values of the result field according to
6795 * the optional numbers of cells and nodes, if any. The valid values are
6796 * - 0 - do not permute.
6797 * - 1 - permute cells.
6798 * - 2 - permute nodes.
6799 * - 3 - permute cells and nodes.
6801 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6802 * caller is to delete this field using decrRef() as it is no more needed.
6803 * \throw If the MED file is not readable.
6804 * \throw If there is no mesh named \a mName in the MED file.
6805 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6806 * \throw If \a this field has not been constructed via file reading.
6807 * \throw If no field of \a this is lying on the mesh named \a mName.
6808 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6809 * \sa getFieldAtLevel()
6811 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
6813 if(getFileName().empty())
6814 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6815 MCAuto<DataArray> arrOut;
6816 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull()));
6817 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6822 * Returns values and a profile of the field of a given type lying on a given support.
6823 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6824 * \param [in] type - a spatial discretization of the field.
6825 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6826 * \param [in] mesh - the supporting mesh.
6827 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6828 * field of interest lies on. If the field lies on all entities of the given
6829 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6830 * using decrRef() as it is no more needed.
6831 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6832 * field. The caller is to delete this array using decrRef() as it is no more needed.
6833 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6834 * \throw If no field of \a this is lying on \a mesh.
6835 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6837 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6839 MCAuto<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6840 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
6844 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6845 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6846 * "Sort By Type"), if not, an exception is thrown.
6847 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6848 * \param [in] field - the field to add to \a this.
6849 * \throw If the name of \a field is empty.
6850 * \throw If the data array of \a field is not set.
6851 * \throw If the data array is already allocated but has different number of components
6853 * \throw If the underlying mesh of \a field has no name.
6854 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6856 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
6859 contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
6863 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6864 * can be an aggregation of several MEDCouplingFieldDouble instances.
6865 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6866 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6869 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6870 * A new profile is added only if no equal profile is missing.
6871 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6872 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
6873 * \param [in] mesh - the supporting mesh of \a field.
6874 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6875 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6876 * \throw If either \a field or \a mesh or \a profile has an empty name.
6877 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6878 * \throw If the data array of \a field is not set.
6879 * \throw If the data array of \a this is already allocated but has different number of
6880 * components than \a field.
6881 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6882 * \sa setFieldNoProfileSBT()
6884 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6887 contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6890 MEDFileField1TS *MEDFileField1TS::shallowCpy() const
6892 return new MEDFileField1TS(*this);
6895 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const
6897 return contentNotNull()->getUndergroundDataArrayTemplate();
6900 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
6902 return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
6905 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6906 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6908 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6911 //= MEDFileIntField1TS
6913 MEDFileIntField1TS *MEDFileIntField1TS::New()
6915 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS);
6916 ret->contentNotNull();
6920 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll)
6922 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6923 return MEDFileIntField1TS::New(fid,loadAll);
6926 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, bool loadAll)
6928 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,loadAll,0));
6929 ret->contentNotNull();
6933 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6935 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6936 return MEDFileIntField1TS::New(fid,fieldName,loadAll);
6939 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
6941 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,loadAll,0));
6942 ret->contentNotNull();
6946 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6948 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6949 return MEDFileIntField1TS::New(fid,fieldName,iteration,order,loadAll);
6952 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
6954 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,iteration,order,loadAll,0));
6955 ret->contentNotNull();
6959 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6961 MCAuto<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6962 ret->contentNotNull();
6966 MEDFileIntField1TS::MEDFileIntField1TS()
6968 _content=new MEDFileIntField1TSWithoutSDA;
6971 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
6972 try:MEDFileAnyTypeField1TS(fid,loadAll,ms)
6975 catch(INTERP_KERNEL::Exception& e)
6978 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6979 try:MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms)
6982 catch(INTERP_KERNEL::Exception& e)
6985 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6986 try:MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms)
6989 catch(INTERP_KERNEL::Exception& e)
6993 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6994 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6996 * \warning this is a shallow copy constructor
6998 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
7002 MEDFileIntField1TS *MEDFileIntField1TS::shallowCpy() const
7004 return new MEDFileIntField1TS(*this);
7008 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
7009 * following the given input policy.
7011 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
7012 * By default (true) the globals are deeply copied.
7013 * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
7015 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const
7017 MCAuto<MEDFileField1TS> ret;
7018 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
7021 const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
7023 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
7024 MCAuto<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
7025 ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc));
7028 ret=MEDFileField1TS::New();
7030 ret->deepCpyGlobs(*this);
7032 ret->shallowCpyGlobs(*this);
7037 * Adds a MEDCouplingFieldInt to \a this. The underlying mesh of the given field is
7038 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
7039 * "Sort By Type"), if not, an exception is thrown.
7040 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7041 * \param [in] field - the field to add to \a this.
7042 * \throw If the name of \a field is empty.
7043 * \throw If the data array of \a field is not set.
7044 * \throw If the data array is already allocated but has different number of components
7046 * \throw If the underlying mesh of \a field has no name.
7047 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
7049 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldInt *field)
7051 MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
7053 contentNotNull()->setFieldNoProfileSBT(field2,field->getArray(),*this,*contentNotNull());
7057 * Adds a MEDCouplingFieldInt to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
7058 * can be an aggregation of several MEDCouplingFieldDouble instances.
7059 * The mesh support of input parameter \a field is ignored here, it can be NULL.
7060 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
7063 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
7064 * A new profile is added only if no equal profile is missing.
7065 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7066 * \param [in] field - the field to add to \a this.
7067 * \param [in] mesh - the supporting mesh of \a field.
7068 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
7069 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
7070 * \throw If either \a field or \a mesh or \a profile has an empty name.
7071 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7072 * \throw If the data array of \a field is not set.
7073 * \throw If the data array of \a this is already allocated but has different number of
7074 * components than \a field.
7075 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
7076 * \sa setFieldNoProfileSBT()
7078 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
7080 MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
7082 contentNotNull()->setFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
7085 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const
7087 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7089 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
7090 const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
7092 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 !");
7096 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
7098 if(getFileName().empty())
7099 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7100 MCAuto<DataArray> arrOut;
7101 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
7102 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7106 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MCAuto<DataArray>& arr)
7109 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
7110 DataArrayInt *arrC(dynamic_cast<DataArrayInt *>((DataArray *)arr));
7112 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
7117 MCAuto<MEDCouplingFieldInt> MEDFileIntField1TS::SetDataArrayDoubleInIntField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
7120 double t0(f->getTime(t1,t2));
7121 MCAuto<DataArrayInt> arr2(DynamicCastSafe<DataArray,DataArrayInt>(arr));
7122 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
7123 MCAuto<MEDCouplingFieldInt> ret(MEDCouplingFieldInt::New(*ft));
7124 ret->setTime(t0,t1,t2); ret->setArray(arr2);
7128 MCAuto<MEDCouplingFieldDouble> MEDFileIntField1TS::ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f)
7131 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ConvertFieldIntToFieldDouble : null input field !");
7133 double t0(f->getTime(t1,t2));
7134 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
7135 MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(*ft));
7136 ret->setTime(t0,t1,t2);
7140 MEDFileIntField1TS *MEDFileIntField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
7142 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::extractPart : not implemented yet !");
7146 * 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
7147 * method should be called (getFieldOnMeshAtLevel for example).
7148 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
7150 * \param [in] mesh - the mesh the field is lying on
7151 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
7152 * caller is to delete this field using decrRef() as it is no more needed.
7154 MEDCouplingFieldInt *MEDFileIntField1TS::field(const MEDFileMesh *mesh) const
7156 MCAuto<DataArray> arrOut;
7157 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
7158 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7163 * Returns a new MEDCouplingFieldInt of a given type lying on
7164 * the top level cells of the first mesh in MED file. If \a this field
7165 * has not been constructed via file reading, an exception is thrown.
7166 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7167 * \param [in] type - a spatial discretization of interest.
7168 * \param [in] renumPol - specifies how to permute values of the result field according to
7169 * the optional numbers of cells and nodes, if any. The valid values are
7170 * - 0 - do not permute.
7171 * - 1 - permute cells.
7172 * - 2 - permute nodes.
7173 * - 3 - permute cells and nodes.
7175 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7176 * caller is to delete this field using decrRef() as it is no more needed.
7177 * \throw If \a this field has not been constructed via file reading.
7178 * \throw If the MED file is not readable.
7179 * \throw If there is no mesh in the MED file.
7180 * \throw If no field values of the given \a type.
7181 * \throw If no field values lying on the top level support.
7182 * \sa getFieldAtLevel()
7184 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
7186 if(getFileName().empty())
7187 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
7188 MCAuto<DataArray> arrOut;
7189 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
7190 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7195 * Returns a new MEDCouplingFieldInt of given type lying on a given mesh.
7196 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7197 * \param [in] type - a spatial discretization of the new field.
7198 * \param [in] mesh - the supporting mesh.
7199 * \param [in] renumPol - specifies how to permute values of the result field according to
7200 * the optional numbers of cells and nodes, if any. The valid values are
7201 * - 0 - do not permute.
7202 * - 1 - permute cells.
7203 * - 2 - permute nodes.
7204 * - 3 - permute cells and nodes.
7206 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7207 * caller is to delete this field using decrRef() as it is no more needed.
7208 * \throw If no field of \a this is lying on \a mesh.
7209 * \throw If the mesh is empty.
7210 * \throw If no field values of the given \a type are available.
7211 * \sa getFieldAtLevel()
7212 * \sa getFieldOnMeshAtLevel()
7214 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
7216 MCAuto<DataArray> arrOut;
7217 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
7218 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7223 * Returns a new MEDCouplingFieldInt of a given type lying on a given support.
7224 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7225 * \param [in] type - a spatial discretization of interest.
7226 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7227 * \param [in] mesh - the supporting mesh.
7228 * \param [in] renumPol - specifies how to permute values of the result field according to
7229 * the optional numbers of cells and nodes, if any. The valid values are
7230 * - 0 - do not permute.
7231 * - 1 - permute cells.
7232 * - 2 - permute nodes.
7233 * - 3 - permute cells and nodes.
7235 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7236 * caller is to delete this field using decrRef() as it is no more needed.
7237 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7238 * \throw If no field of \a this is lying on \a mesh.
7239 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7240 * \sa getFieldAtLevel()
7241 * \sa getFieldOnMeshAtLevel()
7243 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
7245 MCAuto<DataArray> arrOut;
7246 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
7247 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7252 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
7253 * This method is called "Old" because in MED3 norm a field has only one meshName
7254 * attached, so this method is for readers of MED2 files. If \a this field
7255 * has not been constructed via file reading, an exception is thrown.
7256 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7257 * \param [in] type - a spatial discretization of interest.
7258 * \param [in] mName - a name of the supporting mesh.
7259 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7260 * \param [in] renumPol - specifies how to permute values of the result field according to
7261 * the optional numbers of cells and nodes, if any. The valid values are
7262 * - 0 - do not permute.
7263 * - 1 - permute cells.
7264 * - 2 - permute nodes.
7265 * - 3 - permute cells and nodes.
7267 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7268 * caller is to delete this field using decrRef() as it is no more needed.
7269 * \throw If the MED file is not readable.
7270 * \throw If there is no mesh named \a mName in the MED file.
7271 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7272 * \throw If \a this field has not been constructed via file reading.
7273 * \throw If no field of \a this is lying on the mesh named \a mName.
7274 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7275 * \sa getFieldAtLevel()
7277 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
7279 if(getFileName().empty())
7280 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7281 MCAuto<DataArray> arrOut;
7282 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
7283 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7288 * Returns values and a profile of the field of a given type lying on a given support.
7289 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7290 * \param [in] type - a spatial discretization of the field.
7291 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7292 * \param [in] mesh - the supporting mesh.
7293 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
7294 * field of interest lies on. If the field lies on all entities of the given
7295 * dimension, all ids in \a pfl are zero. The caller is to delete this array
7296 * using decrRef() as it is no more needed.
7297 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
7298 * field. The caller is to delete this array using decrRef() as it is no more needed.
7299 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7300 * \throw If no field of \a this is lying on \a mesh.
7301 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7303 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
7305 MCAuto<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
7306 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
7309 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull()
7311 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7313 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
7314 MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
7316 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 !");
7320 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const
7322 return contentNotNull()->getUndergroundDataArrayTemplate();
7325 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
7327 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
7331 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileFieldNameScope(fieldName)
7336 * \param [in] fieldId field id in C mode
7338 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7340 med_field_type typcha;
7341 std::string dtunitOut;
7342 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fieldId,false,_name,typcha,_infos,dtunitOut));
7343 setDtUnit(dtunitOut.c_str());
7344 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities);
7347 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)
7348 try:MEDFileFieldNameScope(fieldName),_infos(infos)
7350 setDtUnit(dtunit.c_str());
7351 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities);
7353 catch(INTERP_KERNEL::Exception& e)
7358 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
7360 std::size_t ret(_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MCAuto<MEDFileField1TSWithoutSDA>));
7361 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7362 ret+=(*it).capacity();
7366 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
7368 std::vector<const BigMemoryObject *> ret;
7369 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7370 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
7375 * 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
7378 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
7380 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7381 ret->setInfo(_infos);
7382 int sz=(int)_time_steps.size();
7383 for(const int *id=startIds;id!=endIds;id++)
7385 if(*id>=0 && *id<sz)
7387 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
7388 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7392 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7394 ret->pushBackTimeStep(tse2);
7398 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
7399 oss << " ! Should be in [0," << sz << ") !";
7400 throw INTERP_KERNEL::Exception(oss.str());
7403 if(ret->getNumberOfTS()>0)
7404 ret->synchronizeNameScope();
7405 ret->copyNameScope(*this);
7410 * 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
7413 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
7415 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
7416 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7417 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7418 ret->setInfo(_infos);
7419 int sz=(int)_time_steps.size();
7421 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
7425 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
7426 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7430 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7432 ret->pushBackTimeStep(tse2);
7436 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
7437 oss << " ! Should be in [0," << sz << ") !";
7438 throw INTERP_KERNEL::Exception(oss.str());
7441 if(ret->getNumberOfTS()>0)
7442 ret->synchronizeNameScope();
7443 ret->copyNameScope(*this);
7447 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7450 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7451 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7453 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7456 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7457 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
7458 ids->pushBackSilent(id);
7460 return buildFromTimeStepIds(ids->begin(),ids->end());
7463 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7466 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7467 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7469 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7472 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7473 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
7474 ids->pushBackSilent(id);
7476 return buildFromTimeStepIds(ids->begin(),ids->end());
7479 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfStructureElements() const
7481 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7482 if((*it).isNotNull())
7483 if((*it)->presenceOfStructureElements())
7488 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::onlyStructureElements() const
7490 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7491 if((*it).isNotNull())
7492 if(!(*it)->onlyStructureElements())
7497 void MEDFileAnyTypeFieldMultiTSWithoutSDA::killStructureElements()
7499 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > res;
7500 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7501 if((*it).isNotNull())
7503 if((*it)->presenceOfStructureElements())
7505 if(!(*it)->onlyStructureElements())
7507 (*it)->killStructureElements();
7519 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
7521 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7523 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7526 if(cur->presenceOfMultiDiscPerGeoType())
7532 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
7537 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
7542 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
7545 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7547 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
7548 if(pt->isDealingTS(iteration,order))
7551 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
7552 std::vector< std::pair<int,int> > vp=getIterations();
7553 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
7554 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
7555 throw INTERP_KERNEL::Exception(oss.str());
7558 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
7560 return *_time_steps[getTimeStepPos(iteration,order)];
7563 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
7565 return *_time_steps[getTimeStepPos(iteration,order)];
7568 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const
7570 if(_time_steps.empty())
7571 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
7572 return _time_steps[0]->getMeshName();
7575 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const std::string& newMeshName)
7577 std::string oldName(getMeshName());
7578 std::vector< std::pair<std::string,std::string> > v(1);
7579 v[0].first=oldName; v[0].second=newMeshName;
7583 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
7586 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7588 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7590 ret=cur->changeMeshNames(modifTab) || ret;
7596 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
7598 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
7600 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
7604 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
7606 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7608 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
7611 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
7612 MEDFileFieldGlobsReal& glob)
7615 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7617 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
7619 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
7624 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7626 std::string startLine(bkOffset,' ');
7627 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
7629 oss << " (" << fmtsId << ")";
7630 oss << " has the following name: \"" << _name << "\"." << std::endl;
7631 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
7632 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7634 oss << startLine << " - \"" << *it << "\"" << std::endl;
7637 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7639 std::string chapter(17,'0'+i);
7640 oss << startLine << chapter << std::endl;
7641 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7643 cur->simpleRepr(bkOffset+2,oss,i);
7645 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
7646 oss << startLine << chapter << std::endl;
7650 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
7652 std::size_t sz=_time_steps.size();
7653 std::vector< std::pair<int,int> > ret(sz);
7655 for(std::size_t i=0;i<sz;i++)
7657 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
7660 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
7664 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
7665 throw INTERP_KERNEL::Exception(oss.str());
7671 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MCAuto<MEDFileAnyTypeField1TSWithoutSDA>& tse)
7673 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
7675 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
7676 checkCoherencyOfType(tse2);
7677 if(_time_steps.empty())
7679 setName(tse2->getName().c_str());
7680 setInfo(tse2->getInfo());
7682 checkThatComponentsMatch(tse2->getInfo());
7683 if(getDtUnit().empty() && !tse->getDtUnit().empty())
7684 setDtUnit(tse->getDtUnit());
7685 _time_steps.push_back(tse);
7688 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
7690 std::size_t nbOfCompo=_infos.size();
7691 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7693 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7696 if((cur->getInfo()).size()!=nbOfCompo)
7698 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
7699 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
7700 throw INTERP_KERNEL::Exception(oss.str());
7702 cur->copyNameScope(*this);
7707 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7709 _time_steps.resize(nbPdt);
7710 for(int i=0;i<nbPdt;i++)
7712 std::vector< std::pair<int,int> > ts;
7713 med_int numdt=0,numo=0;
7715 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt));
7720 _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7725 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7729 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
7732 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities);
7734 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entities);
7735 synchronizeNameScope();
7739 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
7741 if(_time_steps.empty())
7742 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
7743 checkThatNbOfCompoOfTSMatchThis();
7744 std::vector<std::string> infos(getInfo());
7745 int nbComp=infos.size();
7746 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7747 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7748 for(int i=0;i<nbComp;i++)
7750 std::string info=infos[i];
7752 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7753 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7754 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7757 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7758 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
7759 int nbOfTS=_time_steps.size();
7760 for(int i=0;i<nbOfTS;i++)
7761 _time_steps[i]->writeLL(fid,opts,*this);
7764 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
7766 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7768 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7770 elt->loadBigArraysRecursively(fid,nasc);
7774 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
7776 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7778 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7780 elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7784 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
7786 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7788 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7790 elt->unloadArrays();
7794 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7796 return _time_steps.size();
7799 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
7801 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7802 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7804 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7806 newTS.push_back(*it);
7811 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
7813 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7814 int maxId=(int)_time_steps.size();
7816 std::set<int> idsToDel;
7817 for(const int *id=startIds;id!=endIds;id++,ii++)
7819 if(*id>=0 && *id<maxId)
7821 idsToDel.insert(*id);
7825 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7826 throw INTERP_KERNEL::Exception(oss.str());
7829 for(int iii=0;iii<maxId;iii++)
7830 if(idsToDel.find(iii)==idsToDel.end())
7831 newTS.push_back(_time_steps[iii]);
7835 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
7837 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7838 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7839 if(nbOfEntriesToKill==0)
7841 std::size_t sz=_time_steps.size();
7842 std::vector<bool> b(sz,true);
7844 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7846 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7847 for(std::size_t i=0;i<sz;i++)
7849 newTS.push_back(_time_steps[i]);
7853 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
7856 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
7857 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7859 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7863 tmp->getTime(it2,ord);
7864 if(it2==iteration && order==ord)
7867 oss << "(" << it2 << "," << ord << "), ";
7870 throw INTERP_KERNEL::Exception(oss.str());
7873 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
7876 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
7878 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7880 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7884 double ti=tmp->getTime(it2,ord);
7885 if(fabs(time-ti)<eps)
7891 throw INTERP_KERNEL::Exception(oss.str());
7894 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
7896 int lgth=_time_steps.size();
7897 std::vector< std::pair<int,int> > ret(lgth);
7898 for(int i=0;i<lgth;i++)
7899 _time_steps[i]->fillIteration(ret[i]);
7904 * 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'
7905 * This method returns two things.
7906 * - The absolute dimension of 'this' in first parameter.
7907 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7908 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
7910 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7911 * Only these 3 discretizations will be taken into account here.
7913 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7914 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7915 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7917 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7918 * 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'.
7920 * Let's consider the typical following case :
7921 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7922 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7923 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7925 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7927 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7929 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7930 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7931 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7932 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7934 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
7936 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7939 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
7941 if(pos<0 || pos>=(int)_time_steps.size())
7943 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7944 throw INTERP_KERNEL::Exception(oss.str());
7946 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7949 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7950 oss << "\nTry to use following method eraseEmptyTS !";
7951 throw INTERP_KERNEL::Exception(oss.str());
7956 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
7958 if(pos<0 || pos>=(int)_time_steps.size())
7960 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7961 throw INTERP_KERNEL::Exception(oss.str());
7963 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7966 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7967 oss << "\nTry to use following method eraseEmptyTS !";
7968 throw INTERP_KERNEL::Exception(oss.str());
7973 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
7975 std::vector<std::string> ret;
7976 std::set<std::string> ret2;
7977 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7979 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
7980 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7981 if(ret2.find(*it2)==ret2.end())
7983 ret.push_back(*it2);
7990 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
7992 std::vector<std::string> ret;
7993 std::set<std::string> ret2;
7994 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7996 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
7997 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7998 if(ret2.find(*it2)==ret2.end())
8000 ret.push_back(*it2);
8007 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
8009 std::vector<std::string> ret;
8010 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8012 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
8013 ret.insert(ret.end(),tmp.begin(),tmp.end());
8018 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
8020 std::vector<std::string> ret;
8021 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8023 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
8024 ret.insert(ret.end(),tmp.begin(),tmp.end());
8029 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8031 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8032 (*it)->changePflsRefsNamesGen2(mapOfModif);
8035 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8037 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8038 (*it)->changeLocsRefsNamesGen2(mapOfModif);
8041 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
8043 int lgth=_time_steps.size();
8044 std::vector< std::vector<TypeOfField> > ret(lgth);
8045 for(int i=0;i<lgth;i++)
8046 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
8051 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
8053 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
8055 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
8058 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCopy() const
8060 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
8062 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8064 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
8065 ret->_time_steps[i]=(*it)->deepCopy();
8070 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
8072 std::size_t sz(_infos.size()),sz2(_time_steps.size());
8073 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
8074 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
8075 for(std::size_t i=0;i<sz;i++)
8077 ret[i]=shallowCpy();
8078 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
8080 for(std::size_t i=0;i<sz2;i++)
8082 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
8085 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
8086 throw INTERP_KERNEL::Exception(oss.str());
8090 for(std::size_t i=0;i<sz;i++)
8091 for(std::size_t j=0;j<sz2;j++)
8092 ret[i]->_time_steps[j]=ts[j][i];
8097 * This method splits into discretization each time steps in \a this.
8098 * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
8100 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
8102 std::size_t sz(_time_steps.size());
8103 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
8104 for(std::size_t i=0;i<sz;i++)
8106 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
8109 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
8110 throw INTERP_KERNEL::Exception(oss.str());
8112 items[i]=timeStep->splitDiscretizations();
8115 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
8116 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
8117 std::vector< TypeOfField > types;
8118 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
8119 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
8121 std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
8123 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
8124 std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
8125 if(it2==types.end())
8126 types.push_back(ts[0]);
8128 ret.resize(types.size()); ret2.resize(types.size());
8129 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
8130 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
8132 TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
8133 std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
8134 ret2[pos].push_back(*it1);
8136 for(std::size_t i=0;i<types.size();i++)
8138 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
8139 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
8140 elt->pushBackTimeStep(*it1);//also updates infos in elt
8142 elt->MEDFileFieldNameScope::operator=(*this);
8148 * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
8150 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
8152 std::size_t sz(_time_steps.size());
8153 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
8154 std::size_t szOut(std::numeric_limits<std::size_t>::max());
8155 for(std::size_t i=0;i<sz;i++)
8157 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
8160 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
8161 throw INTERP_KERNEL::Exception(oss.str());
8163 items[i]=timeStep->splitMultiDiscrPerGeoTypes();
8164 if(szOut==std::numeric_limits<std::size_t>::max())
8165 szOut=items[i].size();
8167 if(items[i].size()!=szOut)
8168 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
8170 if(szOut==std::numeric_limits<std::size_t>::max())
8171 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
8172 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
8173 for(std::size_t i=0;i<szOut;i++)
8175 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
8176 for(std::size_t j=0;j<sz;j++)
8177 elt->pushBackTimeStep(items[j][i]);
8179 elt->MEDFileFieldNameScope::operator=(*this);
8184 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
8186 _name=field->getName();
8188 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
8190 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
8191 _infos=arr->getInfoOnComponents();
8194 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
8196 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
8197 if(_name!=field->getName())
8199 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
8200 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
8201 throw INTERP_KERNEL::Exception(oss.str());
8204 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
8205 checkThatComponentsMatch(arr->getInfoOnComponents());
8208 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
8210 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
8211 if(getInfo().size()!=compos.size())
8213 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
8214 oss << " number of components of element to append (" << compos.size() << ") !";
8215 throw INTERP_KERNEL::Exception(oss.str());
8219 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
8220 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
8221 oss << " But compo in input fields are : ";
8222 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
8224 throw INTERP_KERNEL::Exception(oss.str());
8228 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
8230 std::size_t sz=_infos.size();
8232 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
8234 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
8236 if(elt->getInfo().size()!=sz)
8238 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
8239 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
8240 throw INTERP_KERNEL::Exception(oss.str());
8245 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
8248 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8249 if(!_time_steps.empty())
8250 checkCoherencyOfTinyInfo(field,arr);
8251 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8252 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8253 objC->setFieldNoProfileSBT(field,arr,glob,*this);
8254 copyTinyInfoFrom(field,arr);
8255 _time_steps.push_back(obj);
8258 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
8261 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8262 if(!_time_steps.empty())
8263 checkCoherencyOfTinyInfo(field,arr);
8264 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8265 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8266 objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
8267 copyTinyInfoFrom(field,arr);
8268 _time_steps.push_back(obj);
8271 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ts)
8273 int sz=(int)_time_steps.size();
8276 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
8277 throw INTERP_KERNEL::Exception(oss.str());
8279 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
8282 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
8284 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
8285 throw INTERP_KERNEL::Exception(oss.str());
8291 //= MEDFileFieldMultiTSWithoutSDA
8293 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)
8295 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8298 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
8302 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8307 * \param [in] fieldId field id in C mode
8309 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8310 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8313 catch(INTERP_KERNEL::Exception& e)
8316 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)
8317 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8320 catch(INTERP_KERNEL::Exception& e)
8323 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8325 return new MEDFileField1TSWithoutSDA;
8328 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8331 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8332 const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
8334 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8337 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const
8339 return MEDFileField1TSWithoutSDA::TYPE_STR;
8342 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const
8344 return new MEDFileFieldMultiTSWithoutSDA(*this);
8347 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const
8349 return new MEDFileFieldMultiTSWithoutSDA;
8353 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
8354 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
8356 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
8358 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
8359 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8361 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
8362 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
8365 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
8367 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
8368 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8370 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8372 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8375 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
8377 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
8378 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
8379 ret->setIteration(i,elt);
8385 //= MEDFileAnyTypeFieldMultiTS
8387 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
8391 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8392 try:MEDFileFieldGlobsReal(fid)
8394 _content=BuildContentFrom(fid,loadAll,ms);
8397 catch(INTERP_KERNEL::Exception& e)
8402 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8404 med_field_type typcha;
8405 std::vector<std::string> infos;
8408 MEDFileAnyTypeField1TS::LocateField(fid,fieldName,i,typcha,infos,dtunit);
8409 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8414 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8419 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8424 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] !";
8425 throw INTERP_KERNEL::Exception(oss.str());
8428 ret->setDtUnit(dtunit.c_str());
8432 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8434 med_field_type typcha;
8436 std::vector<std::string> infos;
8437 std::string dtunit,fieldName;
8438 MEDFileAnyTypeField1TS::LocateField2(fid,0,true,fieldName,typcha,infos,dtunit);
8439 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8444 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8449 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8454 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] !";
8455 throw INTERP_KERNEL::Exception(oss.str());
8458 ret->setDtUnit(dtunit.c_str());
8462 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c)
8465 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
8466 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
8468 MCAuto<MEDFileFieldMultiTS> ret(MEDFileFieldMultiTS::New());
8469 ret->_content=c; c->incrRef();
8472 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
8474 MCAuto<MEDFileIntFieldMultiTS> ret(MEDFileIntFieldMultiTS::New());
8475 ret->_content=c; c->incrRef();
8478 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
8481 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, med_idt fid)
8483 MEDFileAnyTypeFieldMultiTS *ret(BuildNewInstanceFromContent(c));
8484 std::string fileName(FileNameFromFID(fid));
8485 ret->setFileName(fileName);
8489 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8490 try:MEDFileFieldGlobsReal(fid)
8492 _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
8495 catch(INTERP_KERNEL::Exception& e)
8500 //= MEDFileIntFieldMultiTSWithoutSDA
8502 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)
8504 return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8507 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
8511 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8515 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)
8516 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8519 catch(INTERP_KERNEL::Exception& e)
8523 * \param [in] fieldId field id in C mode
8525 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8526 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8529 catch(INTERP_KERNEL::Exception& e)
8532 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8534 return new MEDFileIntField1TSWithoutSDA;
8537 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8540 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8541 const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
8543 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8546 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const
8548 return MEDFileIntField1TSWithoutSDA::TYPE_STR;
8551 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const
8553 return new MEDFileIntFieldMultiTSWithoutSDA(*this);
8556 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const
8558 return new MEDFileIntFieldMultiTSWithoutSDA;
8561 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const
8563 MCAuto<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
8564 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8566 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8568 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8571 const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
8573 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
8574 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
8575 ret->setIteration(i,elt);
8581 //= MEDFileAnyTypeFieldMultiTS
8584 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
8585 * that has been read from a specified MED file.
8586 * \param [in] fileName - the name of the MED file to read.
8587 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8588 * is to delete this field using decrRef() as it is no more needed.
8589 * \throw If reading the file fails.
8591 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
8593 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8594 return New(fid,loadAll);
8597 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, bool loadAll)
8599 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
8600 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8601 ret->loadGlobals(fid);
8606 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
8607 * that has been read from a specified MED file.
8608 * \param [in] fileName - the name of the MED file to read.
8609 * \param [in] fieldName - the name of the field to read.
8610 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8611 * is to delete this field using decrRef() as it is no more needed.
8612 * \throw If reading the file fails.
8613 * \throw If there is no field named \a fieldName in the file.
8615 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8617 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8618 return New(fid,fieldName,loadAll);
8621 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
8623 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
8624 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8625 ret->loadGlobals(fid);
8630 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8631 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8633 * \warning this is a shallow copy constructor
8635 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8637 if(!shallowCopyOfContent)
8639 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
8640 otherPtr->incrRef();
8641 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
8645 _content=other.shallowCpy();
8649 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
8651 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8653 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
8657 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
8659 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8661 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
8665 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
8667 return contentNotNullBase()->getPflsReallyUsed2();
8670 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
8672 return contentNotNullBase()->getLocsReallyUsed2();
8675 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
8677 return contentNotNullBase()->getPflsReallyUsedMulti2();
8680 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
8682 return contentNotNullBase()->getLocsReallyUsedMulti2();
8685 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8687 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
8690 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8692 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
8695 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
8697 return contentNotNullBase()->getNumberOfTS();
8700 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
8702 contentNotNullBase()->eraseEmptyTS();
8705 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
8707 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
8710 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
8712 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
8715 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
8717 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
8718 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8723 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
8725 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
8726 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8731 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
8733 return contentNotNullBase()->getIterations();
8736 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
8738 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
8739 pushBackTimeStep(*it);
8742 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
8745 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
8746 int nbOfTS(fmts->getNumberOfTS());
8747 for(int i=0;i<nbOfTS;i++)
8749 MCAuto<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
8750 pushBackTimeStep(elt);
8754 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
8757 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
8758 checkCoherencyOfType(f1ts);
8760 MCAuto<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
8761 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
8763 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
8764 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
8765 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
8766 _content->pushBackTimeStep(cSafe);
8767 appendGlobs(*f1ts,1e-12);
8770 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
8772 contentNotNullBase()->synchronizeNameScope();
8775 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
8777 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
8780 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
8782 return contentNotNullBase()->getPosGivenTime(time,eps);
8785 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8787 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
8790 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
8792 return contentNotNullBase()->getTypesOfFieldAvailable();
8795 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
8797 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
8800 std::string MEDFileAnyTypeFieldMultiTS::getName() const
8802 return contentNotNullBase()->getName();
8805 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
8807 contentNotNullBase()->setName(name);
8810 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
8812 return contentNotNullBase()->getDtUnit();
8815 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
8817 contentNotNullBase()->setDtUnit(dtUnit);
8820 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8822 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
8825 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
8827 return contentNotNullBase()->getTimeSteps(ret1);
8830 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
8832 return contentNotNullBase()->getMeshName();
8835 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
8837 contentNotNullBase()->setMeshName(newMeshName);
8840 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
8842 return contentNotNullBase()->changeMeshNames(modifTab);
8845 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
8847 return contentNotNullBase()->getInfo();
8850 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
8852 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
8855 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
8857 return contentNotNullBase()->setInfo(info);
8860 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
8862 const std::vector<std::string> ret=getInfo();
8863 return (int)ret.size();
8866 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
8868 writeGlobals(fid,*this);
8869 contentNotNullBase()->writeLL(fid,*this);
8873 * This method alloc the arrays and load potentially huge arrays contained in this field.
8874 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
8875 * This method can be also called to refresh or reinit values from a file.
8877 * \throw If the fileName is not set or points to a non readable MED file.
8879 void MEDFileAnyTypeFieldMultiTS::loadArrays()
8881 if(getFileName().empty())
8882 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
8883 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
8884 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
8888 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
8889 * But once data loaded once, this method does nothing.
8891 * \throw If the fileName is not set or points to a non readable MED file.
8892 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
8894 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
8896 if(!getFileName().empty())
8898 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
8899 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
8904 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
8905 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
8906 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
8908 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
8910 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
8912 contentNotNullBase()->unloadArrays();
8916 * 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.
8917 * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
8918 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
8920 * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
8922 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
8924 if(!getFileName().empty())
8925 contentNotNullBase()->unloadArrays();
8928 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
8930 std::ostringstream oss;
8931 contentNotNullBase()->simpleRepr(0,oss,-1);
8932 simpleReprGlobs(oss);
8936 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
8938 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
8941 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
8943 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
8944 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
8949 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
8950 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8951 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
8953 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
8955 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8957 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
8958 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
8959 std::size_t sz(contentsSplit.size());
8960 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8961 for(std::size_t i=0;i<sz;i++)
8963 ret[i]=shallowCpy();
8964 ret[i]->_content=contentsSplit[i];
8970 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
8971 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8973 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
8975 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8977 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
8978 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
8979 std::size_t sz(contentsSplit.size());
8980 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8981 for(std::size_t i=0;i<sz;i++)
8983 ret[i]=shallowCpy();
8984 ret[i]->_content=contentsSplit[i];
8990 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
8991 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8993 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
8995 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8997 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
8998 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
8999 std::size_t sz(contentsSplit.size());
9000 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
9001 for(std::size_t i=0;i<sz;i++)
9003 ret[i]=shallowCpy();
9004 ret[i]->_content=contentsSplit[i];
9009 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCopy() const
9011 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
9012 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
9013 ret->_content=_content->deepCopy();
9014 ret->deepCpyGlobs(*this);
9018 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
9024 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
9025 * \param [in] iteration - the iteration number of a required time step.
9026 * \param [in] order - the iteration order number of required time step.
9027 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
9028 * delete this field using decrRef() as it is no more needed.
9029 * \throw If there is no required time step in \a this field.
9031 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
9033 int pos=getPosOfTimeStep(iteration,order);
9034 return getTimeStepAtPos(pos);
9038 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
9039 * \param [in] time - the time of the time step of interest.
9040 * \param [in] eps - a precision used to compare time values.
9041 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9042 * delete this field using decrRef() as it is no more needed.
9043 * \throw If there is no required time step in \a this field.
9045 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
9047 int pos=getPosGivenTime(time,eps);
9048 return getTimeStepAtPos(pos);
9052 * 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.
9053 * The float64 value of time attached to the pair of integers are not considered here.
9054 * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
9056 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
9057 * \throw If there is a null pointer in \a vectFMTS.
9059 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
9061 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
9062 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9063 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
9064 while(!lstFMTS.empty())
9066 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
9067 MEDFileAnyTypeFieldMultiTS *curIt(*it);
9069 throw INTERP_KERNEL::Exception(msg);
9070 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
9071 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
9072 elt.push_back(curIt); it=lstFMTS.erase(it);
9073 while(it!=lstFMTS.end())
9077 throw INTERP_KERNEL::Exception(msg);
9078 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
9080 { elt.push_back(curIt); it=lstFMTS.erase(it); }
9090 * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
9091 * All returned instances in a subvector can be safely loaded, rendered along time
9092 * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
9093 * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
9094 * 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).
9095 * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
9096 * 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.
9098 * \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().
9099 * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
9100 * \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.
9101 * \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.
9103 * \throw If an element in \a vectFMTS has not only one spatial discretization set.
9104 * \throw If an element in \a vectFMTS change of spatial discretization along time.
9105 * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
9106 * \thorw If some elements in \a vectFMTS do not have the same times steps.
9107 * \throw If mesh is null.
9108 * \throw If an element in \a vectFMTS is null.
9109 * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
9111 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& fsc)
9113 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
9115 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
9116 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9117 if(vectFMTS.empty())
9119 std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
9120 MEDFileAnyTypeFieldMultiTS *frstElt(*it);
9122 throw INTERP_KERNEL::Exception(msg);
9124 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
9125 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
9126 for(;it!=vectFMTS.end();it++,i++)
9129 throw INTERP_KERNEL::Exception(msg);
9130 TypeOfField tof0,tof1;
9131 if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
9134 vectFMTSNotNodes.push_back(*it);
9136 vectFMTSNodes.push_back(*it);
9139 vectFMTSNotNodes.push_back(*it);
9141 std::vector< MCAuto<MEDFileFastCellSupportComparator> > cmps;
9142 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
9144 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
9147 bool isFetched(false);
9148 for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
9151 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
9152 if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
9153 { ret[i].push_back(*it2); isFetched=true; }
9157 std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
9158 MCAuto<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
9159 ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
9167 * 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.
9168 * \param [out] cmps - same size than the returned vector.
9170 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& cmps)
9172 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9173 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
9174 while(!lstFMTS.empty())
9176 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
9177 MEDFileAnyTypeFieldMultiTS *ref(*it);
9178 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
9179 elt.push_back(ref); it=lstFMTS.erase(it);
9180 MCAuto<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
9181 MCAuto<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
9182 while(it!=lstFMTS.end())
9184 MEDFileAnyTypeFieldMultiTS *curIt(*it);
9185 if(cmp->isEqual(curIt))
9186 { elt.push_back(curIt); it=lstFMTS.erase(it); }
9190 ret.push_back(elt); cmps.push_back(cmp);
9196 * 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.
9197 * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
9199 * \throw If \a f0 or \a f1 has not only one spatial discretization set.
9200 * \throw If \a f0 or \a f1 change of spatial discretization along time.
9201 * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
9202 * \thorw If \a f0 and \a f1 do not have the same times steps.
9203 * \throw If mesh is null.
9204 * \throw If \a f0 or \a f1 is null.
9205 * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
9207 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
9210 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
9212 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
9213 if(f0->getMeshName()!=mesh->getName())
9215 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9216 throw INTERP_KERNEL::Exception(oss.str());
9218 if(f1->getMeshName()!=mesh->getName())
9220 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9221 throw INTERP_KERNEL::Exception(oss.str());
9223 int nts=f0->getNumberOfTS();
9224 if(nts!=f1->getNumberOfTS())
9225 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
9228 for(int i=0;i<nts;i++)
9230 MCAuto<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
9231 MCAuto<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
9232 std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
9233 if(tofs0.size()!=1 || tofs1.size()!=1)
9234 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
9237 if(tof0!=tofs0[0] || tof1!=tofs1[0])
9238 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
9241 { tof0=tofs0[0]; tof1=tofs1[0]; }
9242 if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
9244 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() << ") !";
9245 throw INTERP_KERNEL::Exception(oss.str());
9247 if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
9249 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() << ") !";
9250 throw INTERP_KERNEL::Exception(oss.str());
9252 if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
9254 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() << ") !";
9255 throw INTERP_KERNEL::Exception(oss.str());
9262 * Return an extraction of \a this using \a extractDef map to specify the extraction.
9263 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
9265 * \return A new object that the caller is responsible to deallocate.
9267 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
9270 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::extractPart : mesh is null !");
9271 MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(buildNewEmpty());
9272 int nbTS(getNumberOfTS());
9273 for(int i=0;i<nbTS;i++)
9275 MCAuto<MEDFileAnyTypeField1TS> f1ts(getTimeStepAtPos(i));
9276 MCAuto<MEDFileAnyTypeField1TS> f1tsOut(f1ts->extractPart(extractDef,mm));
9277 fmtsOut->pushBackTimeStep(f1tsOut);
9279 return fmtsOut.retn();
9283 MCAuto<MEDFileAnyTypeField1TS> AggregateHelperF1TS(const std::vector< typename MLFieldTraits<T>::F1TSType const *>& f1tss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9285 MCAuto< typename MLFieldTraits<T>::F1TSType > ret(MLFieldTraits<T>::F1TSType::New());
9287 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : empty vector !");
9288 std::size_t sz(f1tss.size()),i(0);
9289 std::vector< typename MLFieldTraits<T>::F1TSWSDAType const *> f1tsw(sz);
9290 for(typename std::vector< typename MLFieldTraits<T>::F1TSType const *>::const_iterator it=f1tss.begin();it!=f1tss.end();it++,i++)
9292 typename MLFieldTraits<T>::F1TSType const *elt(*it);
9294 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : presence of a null pointer !");
9295 f1tsw[i]=dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType const *>(elt->contentNotNullBase());
9297 typename MLFieldTraits<T>::F1TSWSDAType *retc(dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType *>(ret->contentNotNullBase()));
9299 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : internal error 1 !");
9300 retc->aggregate(f1tsw,dts);
9301 ret->setDtUnit(f1tss[0]->getDtUnit());
9302 return DynamicCast<typename MLFieldTraits<T>::F1TSType , MEDFileAnyTypeField1TS>(ret);
9306 MCAuto< MEDFileAnyTypeFieldMultiTS > AggregateHelperFMTS(const std::vector< typename MLFieldTraits<T>::FMTSType const *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9308 MCAuto< typename MLFieldTraits<T>::FMTSType > ret(MLFieldTraits<T>::FMTSType::New());
9310 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : empty vector !");
9311 std::size_t sz(fmtss.size());
9312 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9314 typename MLFieldTraits<T>::FMTSType const *elt(*it);
9316 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : presence of null pointer !");
9318 int nbTS(fmtss[0]->getNumberOfTS());
9319 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9320 if((*it)->getNumberOfTS()!=nbTS)
9321 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : all fields must have the same number of TS !");
9322 for(int iterTS=0;iterTS<nbTS;iterTS++)
9325 std::vector< typename MLFieldTraits<T>::F1TSType const *> f1tss(sz);
9326 std::vector< MCAuto<typename MLFieldTraits<T>::F1TSType> > f1tss2(sz);
9327 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++,i++)
9328 { f1tss2[i]=(*it)->getTimeStepAtPos(iterTS); f1tss[i]=f1tss2[i]; }
9329 MCAuto<MEDFileAnyTypeField1TS> f1ts(AggregateHelperF1TS<T>(f1tss,dts));
9330 ret->pushBackTimeStep(f1ts);
9331 ret->setDtUnit(f1ts->getDtUnit());
9333 return DynamicCast<typename MLFieldTraits<T>::FMTSType , MEDFileAnyTypeFieldMultiTS>(ret);
9337 * \a dts and \a ftmss are expected to have same size.
9339 MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileAnyTypeFieldMultiTS::Aggregate(const std::vector<const MEDFileAnyTypeFieldMultiTS *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9342 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : input vector is empty !");
9343 std::size_t sz(fmtss.size());
9344 std::vector<const MEDFileFieldMultiTS *> fmtss1;
9345 std::vector<const MEDFileIntFieldMultiTS *> fmtss2;
9346 for(std::vector<const MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9349 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : presence of null instance in input vector !");
9350 const MEDFileFieldMultiTS *elt1(dynamic_cast<const MEDFileFieldMultiTS *>(*it));
9353 fmtss1.push_back(elt1);
9356 const MEDFileIntFieldMultiTS *elt2(dynamic_cast<const MEDFileIntFieldMultiTS *>(*it));
9359 fmtss2.push_back(elt2);
9362 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not recognized type !");
9364 if(fmtss1.size()!=sz && fmtss2.size()!=sz)
9365 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : type of data is not homogeneous !");
9366 if(fmtss1.size()==sz)
9367 return AggregateHelperFMTS<double>(fmtss1,dts);
9368 if(fmtss2.size()!=sz)
9369 return AggregateHelperFMTS<int>(fmtss2,dts);
9370 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not implemented yet !");
9373 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
9375 return new MEDFileAnyTypeFieldMultiTSIterator(this);
9378 //= MEDFileFieldMultiTS
9381 * Returns a new empty instance of MEDFileFieldMultiTS.
9382 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9383 * is to delete this field using decrRef() as it is no more needed.
9385 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
9387 return new MEDFileFieldMultiTS;
9391 * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
9392 * that has been read from a specified MED file.
9393 * \param [in] fileName - the name of the MED file to read.
9394 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9395 * is to delete this field using decrRef() as it is no more needed.
9396 * \throw If reading the file fails.
9398 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll)
9400 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9401 return New(fid,loadAll);
9404 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, bool loadAll)
9406 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,loadAll,0));
9407 ret->contentNotNull();//to check that content type matches with \a this type.
9412 * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
9413 * that has been read from a specified MED file.
9414 * \param [in] fileName - the name of the MED file to read.
9415 * \param [in] fieldName - the name of the field to read.
9416 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9417 * is to delete this field using decrRef() as it is no more needed.
9418 * \throw If reading the file fails.
9419 * \throw If there is no field named \a fieldName in the file.
9421 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9423 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9424 return New(fid,fieldName,loadAll);
9427 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
9429 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0));
9430 ret->contentNotNull();//to check that content type matches with \a this type.
9435 * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9436 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9438 * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
9439 * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9440 * \warning this is a shallow copy constructor
9441 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
9442 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9443 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9444 * is to delete this field using decrRef() as it is no more needed.
9446 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9448 return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
9451 MEDFileFieldMultiTS *MEDFileFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9453 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9454 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
9455 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0,ent));
9456 ret->contentNotNull();//to check that content type matches with \a this type.
9460 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
9462 return new MEDFileFieldMultiTS(*this);
9465 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9468 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9469 const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
9471 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
9475 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
9476 * following the given input policy.
9478 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9479 * By default (true) the globals are deeply copied.
9480 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
9482 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
9484 MCAuto<MEDFileIntFieldMultiTS> ret;
9485 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9488 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
9490 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
9491 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
9492 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc));
9495 ret=MEDFileIntFieldMultiTS::New();
9497 ret->deepCpyGlobs(*this);
9499 ret->shallowCpyGlobs(*this);
9504 * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
9505 * \param [in] pos - a time step id.
9506 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9507 * delete this field using decrRef() as it is no more needed.
9508 * \throw If \a pos is not a valid time step id.
9510 MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const
9512 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9515 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9516 throw INTERP_KERNEL::Exception(oss.str());
9518 const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
9521 MCAuto<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
9522 ret->shallowCpyGlobs(*this);
9525 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
9526 throw INTERP_KERNEL::Exception(oss.str());
9530 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9531 * mesh entities of a given dimension of the first mesh in MED file.
9532 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9533 * \param [in] type - a spatial discretization of interest.
9534 * \param [in] iteration - the iteration number of a required time step.
9535 * \param [in] order - the iteration order number of required time step.
9536 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9537 * \param [in] renumPol - specifies how to permute values of the result field according to
9538 * the optional numbers of cells and nodes, if any. The valid values are
9539 * - 0 - do not permute.
9540 * - 1 - permute cells.
9541 * - 2 - permute nodes.
9542 * - 3 - permute cells and nodes.
9544 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9545 * caller is to delete this field using decrRef() as it is no more needed.
9546 * \throw If the MED file is not readable.
9547 * \throw If there is no mesh in the MED file.
9548 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9549 * \throw If no field values of the required parameters are available.
9551 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9553 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9554 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9556 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
9557 MCAuto<DataArray> arrOut;
9558 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9559 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9564 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9565 * the top level cells of the first mesh in MED file.
9566 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9567 * \param [in] type - a spatial discretization of interest.
9568 * \param [in] iteration - the iteration number of a required time step.
9569 * \param [in] order - the iteration order number of required time step.
9570 * \param [in] renumPol - specifies how to permute values of the result field according to
9571 * the optional numbers of cells and nodes, if any. The valid values are
9572 * - 0 - do not permute.
9573 * - 1 - permute cells.
9574 * - 2 - permute nodes.
9575 * - 3 - permute cells and nodes.
9577 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9578 * caller is to delete this field using decrRef() as it is no more needed.
9579 * \throw If the MED file is not readable.
9580 * \throw If there is no mesh in the MED file.
9581 * \throw If no field values of the required parameters are available.
9583 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9585 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9586 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9588 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
9589 MCAuto<DataArray> arrOut;
9590 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9591 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9596 * 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
9597 * method should be called (getFieldOnMeshAtLevel for example).
9598 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
9600 * \param [in] iteration - the iteration number of a required time step.
9601 * \param [in] order - the iteration order number of required time step.
9602 * \param [in] mesh - the mesh the field is lying on
9603 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9604 * caller is to delete this field using decrRef() as it is no more needed.
9606 MEDCouplingFieldDouble *MEDFileFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
9608 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9609 MCAuto<DataArray> arrOut;
9610 MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
9611 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9616 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9618 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9619 * \param [in] type - a spatial discretization of interest.
9620 * \param [in] iteration - the iteration number of a required time step.
9621 * \param [in] order - the iteration order number of required time step.
9622 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9623 * \param [in] mesh - the supporting mesh.
9624 * \param [in] renumPol - specifies how to permute values of the result field according to
9625 * the optional numbers of cells and nodes, if any. The valid values are
9626 * - 0 - do not permute.
9627 * - 1 - permute cells.
9628 * - 2 - permute nodes.
9629 * - 3 - permute cells and nodes.
9631 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9632 * caller is to delete this field using decrRef() as it is no more needed.
9633 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9634 * \throw If no field of \a this is lying on \a mesh.
9635 * \throw If no field values of the required parameters are available.
9637 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9639 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9640 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9642 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9643 MCAuto<DataArray> arrOut;
9644 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
9645 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9650 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9652 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9653 * \param [in] type - a spatial discretization of the new field.
9654 * \param [in] iteration - the iteration number of a required time step.
9655 * \param [in] order - the iteration order number of required time step.
9656 * \param [in] mesh - the supporting mesh.
9657 * \param [in] renumPol - specifies how to permute values of the result field according to
9658 * the optional numbers of cells and nodes, if any. The valid values are
9659 * - 0 - do not permute.
9660 * - 1 - permute cells.
9661 * - 2 - permute nodes.
9662 * - 3 - permute cells and nodes.
9664 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9665 * caller is to delete this field using decrRef() as it is no more needed.
9666 * \throw If no field of \a this is lying on \a mesh.
9667 * \throw If no field values of the required parameters are available.
9669 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
9671 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9672 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9674 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9675 MCAuto<DataArray> arrOut;
9676 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
9677 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9682 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
9683 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9684 * This method is useful for MED2 file format when field on different mesh was autorized.
9686 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
9688 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9689 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9691 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
9692 MCAuto<DataArray> arrOut;
9693 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
9694 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9699 * Returns values and a profile of the field of a given type, of a given time step,
9700 * lying on a given support.
9701 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9702 * \param [in] type - a spatial discretization of the field.
9703 * \param [in] iteration - the iteration number of a required time step.
9704 * \param [in] order - the iteration order number of required time step.
9705 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9706 * \param [in] mesh - the supporting mesh.
9707 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9708 * field of interest lies on. If the field lies on all entities of the given
9709 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9710 * using decrRef() as it is no more needed.
9711 * \param [in] glob - the global data storing profiles and localization.
9712 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
9713 * field. The caller is to delete this array using decrRef() as it is no more needed.
9714 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9715 * \throw If no field of \a this is lying on \a mesh.
9716 * \throw If no field values of the required parameters are available.
9718 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9720 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9721 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9723 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
9724 MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9725 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
9728 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const
9730 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9732 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
9733 const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
9735 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 !");
9739 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull()
9741 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9743 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
9744 MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
9746 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 !");
9751 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9752 * the given field is checked if its elements are sorted suitable for writing to MED file
9753 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9754 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9755 * \param [in] field - the field to add to \a this.
9756 * \throw If the name of \a field is empty.
9757 * \throw If the data array of \a field is not set.
9758 * \throw If existing time steps have different name or number of components than \a field.
9759 * \throw If the underlying mesh of \a field has no name.
9760 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9762 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
9764 const DataArrayDouble *arr=0;
9766 arr=field->getArray();
9767 contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
9771 * Adds a MEDCouplingFieldDouble to \a this as another time step.
9772 * The mesh support of input parameter \a field is ignored here, it can be NULL.
9773 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9776 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9777 * A new profile is added only if no equal profile is missing.
9778 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9779 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
9780 * \param [in] mesh - the supporting mesh of \a field.
9781 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9782 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
9783 * \throw If either \a field or \a mesh or \a profile has an empty name.
9784 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9785 * \throw If the data array of \a field is not set.
9786 * \throw If the data array of \a this is already allocated but has different number of
9787 * components than \a field.
9788 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9789 * \sa setFieldNoProfileSBT()
9791 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9793 const DataArrayDouble *arr=0;
9795 arr=field->getArray();
9796 contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
9799 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
9801 _content=new MEDFileFieldMultiTSWithoutSDA;
9804 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
9805 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
9808 catch(INTERP_KERNEL::Exception& e)
9811 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
9812 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
9815 catch(INTERP_KERNEL::Exception& e)
9818 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9822 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
9824 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
9827 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9829 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9832 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
9834 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
9837 MEDFileFieldMultiTS *MEDFileFieldMultiTS::buildNewEmpty() const
9839 return MEDFileFieldMultiTS::New();
9842 //= MEDFileAnyTypeFieldMultiTSIterator
9844 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
9849 _nb_iter=fmts->getNumberOfTS();
9853 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
9857 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
9859 if(_iter_id<_nb_iter)
9861 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
9863 return fmts->getTimeStepAtPos(_iter_id++);
9871 //= MEDFileIntFieldMultiTS
9874 * Returns a new empty instance of MEDFileFieldMultiTS.
9875 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9876 * is to delete this field using decrRef() as it is no more needed.
9878 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
9880 return new MEDFileIntFieldMultiTS;
9884 * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
9885 * that has been read from a specified MED file.
9886 * \param [in] fileName - the name of the MED file to read.
9887 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9888 * is to delete this field using decrRef() as it is no more needed.
9889 * \throw If reading the file fails.
9891 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll)
9893 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9894 return New(fid,loadAll);
9897 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, bool loadAll)
9899 MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,loadAll,0));
9900 ret->contentNotNull();//to check that content type matches with \a this type.
9905 * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
9906 * that has been read from a specified MED file.
9907 * \param [in] fileName - the name of the MED file to read.
9908 * \param [in] fieldName - the name of the field to read.
9909 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9910 * is to delete this field using decrRef() as it is no more needed.
9911 * \throw If reading the file fails.
9912 * \throw If there is no field named \a fieldName in the file.
9914 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9916 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9917 return New(fid,fieldName,loadAll);
9920 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
9922 MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0));
9923 ret->contentNotNull();//to check that content type matches with \a this type.
9928 * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9929 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9931 * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
9932 * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9933 * \warning this is a shallow copy constructor
9934 * \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
9935 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9936 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9937 * is to delete this field using decrRef() as it is no more needed.
9939 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9941 return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
9944 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9946 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9947 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
9948 MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0,ent));
9949 ret->contentNotNull();//to check that content type matches with \a this type.
9954 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
9955 * following the given input policy.
9957 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9958 * By default (true) the globals are deeply copied.
9959 * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
9961 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const
9963 MCAuto<MEDFileFieldMultiTS> ret;
9964 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9967 const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
9969 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
9970 MCAuto<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
9971 ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc));
9974 ret=MEDFileFieldMultiTS::New();
9976 ret->deepCpyGlobs(*this);
9978 ret->shallowCpyGlobs(*this);
9982 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const
9984 return new MEDFileIntFieldMultiTS(*this);
9987 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9990 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9991 const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
9993 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
9997 * 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
9998 * method should be called (getFieldOnMeshAtLevel for example).
9999 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
10001 * \param [in] iteration - the iteration number of a required time step.
10002 * \param [in] order - the iteration order number of required time step.
10003 * \param [in] mesh - the mesh the field is lying on
10004 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
10005 * caller is to delete this field using decrRef() as it is no more needed.
10007 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
10009 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10010 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10012 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::field : mismatch of type of field expecting INT32 !");
10013 MCAuto<DataArray> arrOut;
10014 MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
10015 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arrOut));
10016 return ret2.retn();
10020 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
10021 * mesh entities of a given dimension of the first mesh in MED file.
10022 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10023 * \param [in] type - a spatial discretization of interest.
10024 * \param [in] iteration - the iteration number of a required time step.
10025 * \param [in] order - the iteration order number of required time step.
10026 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10027 * \param [in] renumPol - specifies how to permute values of the result field according to
10028 * the optional numbers of cells and nodes, if any. The valid values are
10029 * - 0 - do not permute.
10030 * - 1 - permute cells.
10031 * - 2 - permute nodes.
10032 * - 3 - permute cells and nodes.
10034 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10035 * caller is to delete this field using decrRef() as it is no more needed.
10036 * \throw If the MED file is not readable.
10037 * \throw If there is no mesh in the MED file.
10038 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
10039 * \throw If no field values of the required parameters are available.
10041 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
10043 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10044 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10046 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
10047 MCAuto<DataArray> arr;
10048 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase()));
10049 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10050 return ret2.retn();
10054 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
10055 * the top level cells of the first mesh in MED file.
10056 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10057 * \param [in] type - a spatial discretization of interest.
10058 * \param [in] iteration - the iteration number of a required time step.
10059 * \param [in] order - the iteration order number of required time step.
10060 * \param [in] renumPol - specifies how to permute values of the result field according to
10061 * the optional numbers of cells and nodes, if any. The valid values are
10062 * - 0 - do not permute.
10063 * - 1 - permute cells.
10064 * - 2 - permute nodes.
10065 * - 3 - permute cells and nodes.
10067 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10068 * caller is to delete this field using decrRef() as it is no more needed.
10069 * \throw If the MED file is not readable.
10070 * \throw If there is no mesh in the MED file.
10071 * \throw If no field values of the required parameters are available.
10073 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
10075 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10076 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10078 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
10079 MCAuto<DataArray> arr;
10080 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase()));
10081 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10082 return ret2.retn();
10086 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
10088 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10089 * \param [in] type - a spatial discretization of interest.
10090 * \param [in] iteration - the iteration number of a required time step.
10091 * \param [in] order - the iteration order number of required time step.
10092 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10093 * \param [in] mesh - the supporting mesh.
10094 * \param [in] renumPol - specifies how to permute values of the result field according to
10095 * the optional numbers of cells and nodes, if any. The valid values are
10096 * - 0 - do not permute.
10097 * - 1 - permute cells.
10098 * - 2 - permute nodes.
10099 * - 3 - permute cells and nodes.
10101 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10102 * caller is to delete this field using decrRef() as it is no more needed.
10103 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
10104 * \throw If no field of \a this is lying on \a mesh.
10105 * \throw If no field values of the required parameters are available.
10107 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
10109 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10110 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10112 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10113 MCAuto<DataArray> arr;
10114 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase()));
10115 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10116 return ret2.retn();
10120 * Returns a new MEDCouplingFieldInt of given type, of a given time step, lying on a
10122 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10123 * \param [in] type - a spatial discretization of the new field.
10124 * \param [in] iteration - the iteration number of a required time step.
10125 * \param [in] order - the iteration order number of required time step.
10126 * \param [in] mesh - the supporting mesh.
10127 * \param [out] arrOut - the DataArrayInt containing values of field.
10128 * \param [in] renumPol - specifies how to permute values of the result field according to
10129 * the optional numbers of cells and nodes, if any. The valid values are
10130 * - 0 - do not permute.
10131 * - 1 - permute cells.
10132 * - 2 - permute nodes.
10133 * - 3 - permute cells and nodes.
10135 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10136 * caller is to delete this field using decrRef() as it is no more needed.
10137 * \throw If no field of \a this is lying on \a mesh.
10138 * \throw If no field values of the required parameters are available.
10140 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
10142 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10143 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10145 throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10146 MCAuto<DataArray> arr;
10147 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase()));
10148 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10149 return ret2.retn();
10153 * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
10154 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
10155 * This method is useful for MED2 file format when field on different mesh was autorized.
10157 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol) const
10159 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10160 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10162 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10163 MCAuto<DataArray> arr;
10164 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase()));
10165 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10166 return ret2.retn();
10170 * Returns values and a profile of the field of a given type, of a given time step,
10171 * lying on a given support.
10172 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10173 * \param [in] type - a spatial discretization of the field.
10174 * \param [in] iteration - the iteration number of a required time step.
10175 * \param [in] order - the iteration order number of required time step.
10176 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10177 * \param [in] mesh - the supporting mesh.
10178 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
10179 * field of interest lies on. If the field lies on all entities of the given
10180 * dimension, all ids in \a pfl are zero. The caller is to delete this array
10181 * using decrRef() as it is no more needed.
10182 * \param [in] glob - the global data storing profiles and localization.
10183 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
10184 * field. The caller is to delete this array using decrRef() as it is no more needed.
10185 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10186 * \throw If no field of \a this is lying on \a mesh.
10187 * \throw If no field values of the required parameters are available.
10189 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
10191 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
10192 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
10194 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
10195 MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
10196 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
10200 * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
10201 * \param [in] pos - a time step id.
10202 * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
10203 * delete this field using decrRef() as it is no more needed.
10204 * \throw If \a pos is not a valid time step id.
10206 MEDFileIntField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
10208 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
10211 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
10212 throw INTERP_KERNEL::Exception(oss.str());
10214 const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
10217 MCAuto<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
10218 ret->shallowCpyGlobs(*this);
10221 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
10222 throw INTERP_KERNEL::Exception(oss.str());
10226 * Adds a MEDCouplingFieldInt to \a this as another time step. The underlying mesh of
10227 * the given field is checked if its elements are sorted suitable for writing to MED file
10228 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
10229 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10230 * \param [in] field - the field to add to \a this.
10231 * \throw If the name of \a field is empty.
10232 * \throw If the data array of \a field is not set.
10233 * \throw If existing time steps have different name or number of components than \a field.
10234 * \throw If the underlying mesh of \a field has no name.
10235 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
10237 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldInt *field)
10239 MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
10240 contentNotNull()->appendFieldNoProfileSBT(field2,field->getArray(),*this);
10244 * Adds a MEDCouplingFieldDouble to \a this as another time step.
10245 * The mesh support of input parameter \a field is ignored here, it can be NULL.
10246 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
10249 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
10250 * A new profile is added only if no equal profile is missing.
10251 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10252 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
10253 * \param [in] arrOfVals - the values of the field \a field used.
10254 * \param [in] mesh - the supporting mesh of \a field.
10255 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
10256 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
10257 * \throw If either \a field or \a mesh or \a profile has an empty name.
10258 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10259 * \throw If the data array of \a field is not set.
10260 * \throw If the data array of \a this is already allocated but has different number of
10261 * components than \a field.
10262 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
10263 * \sa setFieldNoProfileSBT()
10265 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
10267 MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
10268 contentNotNull()->appendFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this);
10271 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const
10273 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10275 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
10276 const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10278 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 !");
10282 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull()
10284 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10286 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
10287 MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10289 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 !");
10293 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
10295 _content=new MEDFileIntFieldMultiTSWithoutSDA;
10298 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
10302 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
10303 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
10306 catch(INTERP_KERNEL::Exception& e)
10309 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10310 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
10313 catch(INTERP_KERNEL::Exception& e)
10316 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
10318 return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
10321 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::buildNewEmpty() const
10323 return MEDFileIntFieldMultiTS::New();
10328 MEDFileFields *MEDFileFields::New()
10330 return new MEDFileFields;
10333 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
10335 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10336 return New(fid,loadAll);
10339 MEDFileFields *MEDFileFields::NewWithDynGT(const std::string& fileName, const MEDFileStructureElements *se, bool loadAll)
10341 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10342 return NewWithDynGT(fid,se,loadAll);
10345 MEDFileFields *MEDFileFields::NewWithDynGT(med_idt fid, const MEDFileStructureElements *se, bool loadAll)
10348 throw INTERP_KERNEL::Exception("MEDFileFields::NewWithDynGT : null struct element pointer !");
10349 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> entities(MEDFileEntities::BuildFrom(*se));
10350 return new MEDFileFields(fid,loadAll,0,entities);
10353 MEDFileFields *MEDFileFields::New(med_idt fid, bool loadAll)
10355 return new MEDFileFields(fid,loadAll,0,0);
10358 MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
10360 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10361 return new MEDFileFields(fid,loadAll,ms,0);
10364 MEDFileFields *MEDFileFields::LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
10366 MEDFileUtilities::CheckFileForRead(fileName);
10367 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
10368 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10369 return new MEDFileFields(fid,loadAll,0,ent);
10372 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
10374 std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
10375 ret+=_fields.capacity()*sizeof(MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
10379 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
10381 std::vector<const BigMemoryObject *> ret;
10382 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10383 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
10387 MEDFileFields *MEDFileFields::deepCopy() const
10389 MCAuto<MEDFileFields> ret(shallowCpy());
10391 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10393 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10394 ret->_fields[i]=(*it)->deepCopy();
10396 ret->deepCpyGlobs(*this);
10400 MEDFileFields *MEDFileFields::shallowCpy() const
10402 return new MEDFileFields(*this);
10406 * 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
10407 * 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.
10408 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
10410 * \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.
10411 * \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.
10413 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10415 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
10417 std::set< std::pair<int,int> > s;
10418 bool firstShot=true;
10419 areThereSomeForgottenTS=false;
10420 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10422 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10424 std::vector< std::pair<int,int> > v=(*it)->getIterations();
10425 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
10427 { s=s1; firstShot=false; }
10430 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
10432 areThereSomeForgottenTS=true;
10436 std::vector< std::pair<int,int> > ret;
10437 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
10441 int MEDFileFields::getNumberOfFields() const
10443 return _fields.size();
10446 std::vector<std::string> MEDFileFields::getFieldsNames() const
10448 std::vector<std::string> ret(_fields.size());
10450 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10452 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
10455 ret[i]=f->getName();
10459 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
10460 throw INTERP_KERNEL::Exception(oss.str());
10466 std::vector<std::string> MEDFileFields::getMeshesNames() const
10468 std::vector<std::string> ret;
10469 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10471 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10473 ret.push_back(cur->getMeshName());
10478 std::string MEDFileFields::simpleRepr() const
10480 std::ostringstream oss;
10481 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
10486 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
10488 int nbOfFields(getNumberOfFields());
10489 std::string startLine(bkOffset,' ');
10490 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
10492 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10494 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10497 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
10501 oss << startLine << " - not defined !" << std::endl;
10505 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10507 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10508 std::string chapter(17,'0'+i);
10509 oss << startLine << chapter << std::endl;
10512 cur->simpleRepr(bkOffset+2,oss,i);
10516 oss << startLine << " - not defined !" << std::endl;
10518 oss << startLine << chapter << std::endl;
10520 simpleReprGlobs(oss);
10523 MEDFileFields::MEDFileFields()
10527 MEDFileFields::MEDFileFields(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10528 try:MEDFileFieldGlobsReal(fid)
10530 int nbFields(MEDnField(fid));
10531 _fields.resize(nbFields);
10532 med_field_type typcha;
10533 for(int i=0;i<nbFields;i++)
10535 std::vector<std::string> infos;
10536 std::string fieldName,dtunit;
10537 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,i,false,fieldName,typcha,infos,dtunit));
10542 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10547 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10552 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] !";
10553 throw INTERP_KERNEL::Exception(oss.str());
10557 loadAllGlobals(fid);
10559 catch(INTERP_KERNEL::Exception& e)
10564 void MEDFileFields::writeLL(med_idt fid) const
10567 writeGlobals(fid,*this);
10568 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10570 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
10573 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
10574 throw INTERP_KERNEL::Exception(oss.str());
10576 elt->writeLL(fid,*this);
10581 * This method alloc the arrays and load potentially huge arrays contained in this field.
10582 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
10583 * This method can be also called to refresh or reinit values from a file.
10585 * \throw If the fileName is not set or points to a non readable MED file.
10587 void MEDFileFields::loadArrays()
10589 if(getFileName().empty())
10590 throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
10591 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
10592 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10594 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10596 elt->loadBigArraysRecursively(fid,*elt);
10601 * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
10602 * But once data loaded once, this method does nothing.
10604 * \throw If the fileName is not set or points to a non readable MED file.
10605 * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
10607 void MEDFileFields::loadArraysIfNecessary()
10609 if(!getFileName().empty())
10611 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
10612 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10614 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10616 elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
10622 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
10623 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
10624 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
10626 * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
10628 void MEDFileFields::unloadArrays()
10630 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10632 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10634 elt->unloadArrays();
10639 * 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.
10640 * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
10641 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
10643 * \sa MEDFileFields::loadArraysIfNecessary
10645 void MEDFileFields::unloadArraysWithoutDataLoss()
10647 if(!getFileName().empty())
10651 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
10653 std::vector<std::string> ret;
10654 std::set<std::string> ret2;
10655 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10657 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
10658 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10659 if(ret2.find(*it2)==ret2.end())
10661 ret.push_back(*it2);
10668 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
10670 std::vector<std::string> ret;
10671 std::set<std::string> ret2;
10672 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10674 std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
10675 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10676 if(ret2.find(*it2)==ret2.end())
10678 ret.push_back(*it2);
10685 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
10687 std::vector<std::string> ret;
10688 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10690 std::vector<std::string> tmp((*it)->getPflsReallyUsedMulti2());
10691 ret.insert(ret.end(),tmp.begin(),tmp.end());
10696 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
10698 std::vector<std::string> ret;
10699 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10701 std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
10702 ret.insert(ret.end(),tmp.begin(),tmp.end());
10707 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10709 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10710 (*it)->changePflsRefsNamesGen2(mapOfModif);
10713 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10715 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10716 (*it)->changeLocsRefsNamesGen2(mapOfModif);
10719 void MEDFileFields::resize(int newSize)
10721 _fields.resize(newSize);
10724 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
10726 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
10730 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
10733 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
10734 _fields.push_back(field->getContent());
10735 appendGlobs(*field,1e-12);
10738 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
10741 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
10742 if(i>=(int)_fields.size())
10743 _fields.resize(i+1);
10744 _fields[i]=field->getContent();
10745 appendGlobs(*field,1e-12);
10748 void MEDFileFields::destroyFieldAtPos(int i)
10750 destroyFieldsAtPos(&i,&i+1);
10753 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
10755 std::vector<bool> b(_fields.size(),true);
10756 for(const int *i=startIds;i!=endIds;i++)
10758 if(*i<0 || *i>=(int)_fields.size())
10760 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10761 throw INTERP_KERNEL::Exception(oss.str());
10765 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10767 for(std::size_t i=0;i<_fields.size();i++)
10769 fields[j++]=_fields[i];
10773 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
10775 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
10776 int nbOfEntriesToKill(DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg));
10777 std::vector<bool> b(_fields.size(),true);
10779 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
10781 if(k<0 || k>=(int)_fields.size())
10783 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
10784 throw INTERP_KERNEL::Exception(oss.str());
10788 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10790 for(std::size_t i=0;i<_fields.size();i++)
10792 fields[j++]=_fields[i];
10796 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
10799 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10801 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10803 ret=cur->changeMeshNames(modifTab) || ret;
10809 * \param [in] meshName the name of the mesh that will be renumbered.
10810 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
10811 * This code corresponds to the distribution of types in the corresponding mesh.
10812 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
10813 * \param [in] renumO2N the old to new renumber array.
10814 * \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
10815 * field in \a this.
10817 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
10820 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10822 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
10825 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
10832 * Return an extraction of \a this using \a extractDef map to specify the extraction.
10833 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
10835 * \return A new object that the caller is responsible to deallocate.
10837 MEDFileFields *MEDFileFields::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
10840 throw INTERP_KERNEL::Exception("MEDFileFields::extractPart : input mesh is NULL !");
10841 MCAuto<MEDFileFields> fsOut(MEDFileFields::New());
10842 int nbFields(getNumberOfFields());
10843 for(int i=0;i<nbFields;i++)
10845 MCAuto<MEDFileAnyTypeFieldMultiTS> fmts(getFieldAtPos(i));
10848 std::ostringstream oss; oss << "MEDFileFields::extractPart : at pos #" << i << " field is null !";
10849 throw INTERP_KERNEL::Exception(oss.str());
10851 MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(fmts->extractPart(extractDef,mm));
10852 fsOut->pushField(fmtsOut);
10854 return fsOut.retn();
10857 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
10859 if(i<0 || i>=(int)_fields.size())
10861 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
10862 throw INTERP_KERNEL::Exception(oss.str());
10864 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
10867 MCAuto<MEDFileAnyTypeFieldMultiTS> ret;
10868 const MEDFileFieldMultiTSWithoutSDA *fmtsC(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts));
10869 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts));
10871 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
10873 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
10876 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
10877 throw INTERP_KERNEL::Exception(oss.str());
10879 ret->shallowCpyGlobs(*this);
10884 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
10885 * This method is accessible in python using __getitem__ with a list in input.
10886 * \return a new object that the caller should deal with.
10888 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
10890 MCAuto<MEDFileFields> ret=shallowCpy();
10891 std::size_t sz=std::distance(startIds,endIds);
10892 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
10894 for(const int *i=startIds;i!=endIds;i++,j++)
10896 if(*i<0 || *i>=(int)_fields.size())
10898 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10899 throw INTERP_KERNEL::Exception(oss.str());
10901 fields[j]=_fields[*i];
10903 ret->_fields=fields;
10907 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
10909 return getFieldAtPos(getPosFromFieldName(fieldName));
10913 * This method removes, if any, fields in \a this having no time steps.
10914 * 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.
10916 * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
10918 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
10920 std::vector<MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
10921 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10923 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10926 if(elt->getNumberOfTS()>0)
10927 newFields.push_back(*it);
10930 if(_fields.size()==newFields.size())
10937 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
10938 * This method can be seen as a filter applied on \a this, that returns an object containing
10939 * 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
10940 * shallow copied from \a this.
10942 * \param [in] meshName - the name of the mesh on w
10943 * \return a new object that the caller should deal with.
10945 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
10947 MCAuto<MEDFileFields> ret(MEDFileFields::New());
10948 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10950 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10953 if(cur->getMeshName()==meshName)
10956 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
10957 ret->_fields.push_back(cur2);
10960 ret->shallowCpyOnlyUsedGlobs(*this);
10965 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
10966 * Input time steps are specified using a pair of integer (iteration, order).
10967 * 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,
10968 * but for each multitimestep only the time steps in \a timeSteps are kept.
10969 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
10971 * The returned object points to shallow copy of elements in \a this.
10973 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
10974 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
10975 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10977 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10979 MCAuto<MEDFileFields> ret(MEDFileFields::New());
10980 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10982 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10985 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
10986 ret->_fields.push_back(elt);
10988 ret->shallowCpyOnlyUsedGlobs(*this);
10993 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
10995 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10997 MCAuto<MEDFileFields> ret=MEDFileFields::New();
10998 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11000 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
11003 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
11004 if(elt->getNumberOfTS()!=0)
11005 ret->_fields.push_back(elt);
11007 ret->shallowCpyOnlyUsedGlobs(*this);
11011 bool MEDFileFields::presenceOfStructureElements() const
11013 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11014 if((*it).isNotNull())
11015 if((*it)->presenceOfStructureElements())
11020 void MEDFileFields::killStructureElements()
11022 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
11023 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11024 if((*it).isNotNull())
11026 if((*it)->presenceOfStructureElements())
11028 if(!(*it)->onlyStructureElements())
11030 (*it)->killStructureElements();
11031 ret.push_back(*it);
11037 ret.push_back(*it);
11042 MCAuto<MEDFileFields> MEDFileFields::partOfThisOnStructureElements() const
11044 throw INTERP_KERNEL::Exception("partOfThisOnStructureElements : not implemented yet !");
11047 MEDFileFieldsIterator *MEDFileFields::iterator()
11049 return new MEDFileFieldsIterator(this);
11052 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
11054 std::string tmp(fieldName);
11055 std::vector<std::string> poss;
11056 for(std::size_t i=0;i<_fields.size();i++)
11058 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f(_fields[i]);
11061 std::string fname(f->getName());
11065 poss.push_back(fname);
11068 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
11069 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
11071 throw INTERP_KERNEL::Exception(oss.str());
11074 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
11079 _nb_iter=fs->getNumberOfFields();
11083 MEDFileFieldsIterator::~MEDFileFieldsIterator()
11087 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
11089 if(_iter_id<_nb_iter)
11091 MEDFileFields *fs(_fs);
11093 return fs->getFieldAtPos(_iter_id++);