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 MEDFileFieldPerMeshPerTypeDyn *MEDFileFieldPerMeshPerTypeDyn::deepCopy(MEDFileFieldPerMesh *father) const
1766 MCAuto<MEDFileFieldPerMeshPerTypeDyn> ret(new MEDFileFieldPerMeshPerTypeDyn(*this));
1767 ret->setFather(father);
1768 ret->deepCopyElements();
1772 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
1774 throw INTERP_KERNEL::Exception("not implemented yet !");
1777 //////////////////////////////////////////////////
1779 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const MEDFileEntities *entities)
1781 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm,entities);
1784 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1786 return new MEDFileFieldPerMesh(fath,mesh);
1789 std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
1791 return _mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MCAuto< MEDFileFieldPerMeshPerType >);
1794 std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildrenWithNull() const
1796 std::vector<const BigMemoryObject *> ret;
1797 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1802 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCopy(MEDFileAnyTypeField1TSWithoutSDA *father) const
1804 MCAuto< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1805 ret->_father=father;
1807 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1809 if((*it).isNotNull())
1810 ret->_field_pm_pt[i]=(*it)->deepCopy((MEDFileFieldPerMesh *)(ret));
1815 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1817 std::string startLine(bkOffset,' ');
1818 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1819 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1821 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1823 if((*it).isNotNull())
1824 (*it)->simpleRepr(bkOffset,oss,i);
1827 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1832 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh)
1834 _mesh_name=mesh->getName();
1835 mesh->getTime(_mesh_iteration,_mesh_order);
1838 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1840 int nbOfTypes=code.size()/3;
1842 for(int i=0;i<nbOfTypes;i++)
1844 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1845 int nbOfCells=code[3*i+1];
1846 int pos=addNewEntryIfNecessary(type);
1847 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1853 * This method is the most general one. No optimization is done here.
1854 * \param [in] multiTypePfl is the end user profile specified in high level API
1855 * \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].
1856 * \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.
1857 * \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.
1858 * \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.
1859 * \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.
1861 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)
1863 int nbOfTypes(code.size()/3);
1864 for(int i=0;i<nbOfTypes;i++)
1866 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1867 int pos=addNewEntryIfNecessary(type);
1868 DataArrayInt *pfl=0;
1870 pfl=idsPerType[code[3*i+2]];
1871 int nbOfTupes2=code2.size()/3;
1873 for(;found<nbOfTupes2;found++)
1874 if(code[3*i]==code2[3*found])
1876 if(found==nbOfTupes2)
1877 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1878 _field_pm_pt[pos]->assignFieldProfile(nbOfTypes==1,start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1882 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1884 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1885 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1888 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1890 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1891 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1894 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
1896 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1897 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1900 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1902 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1903 (*it)->loadBigArraysRecursively(fid,nasc);
1906 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1908 int nbOfTypes=_field_pm_pt.size();
1909 for(int i=0;i<nbOfTypes;i++)
1911 _field_pm_pt[i]->copyOptionsFrom(*this);
1912 _field_pm_pt[i]->writeLL(fid,nasc);
1916 void MEDFileFieldPerMesh::getDimension(int& dim) const
1918 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1919 (*it)->getDimension(dim);
1922 bool MEDFileFieldPerMesh::isUniqueLevel(int& dim) const
1924 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1925 if(!(*it)->isUniqueLevel(dim))
1930 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1932 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1933 (*it)->fillTypesOfFieldAvailable(types);
1936 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
1938 int sz=_field_pm_pt.size();
1939 std::vector< std::vector<std::pair<int,int> > > ret(sz);
1940 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1941 for(int i=0;i<sz;i++)
1943 types[i]=_field_pm_pt[i]->getGeoType();
1944 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1949 double MEDFileFieldPerMesh::getTime() const
1952 return _father->getTime(tmp1,tmp2);
1955 int MEDFileFieldPerMesh::getIteration() const
1957 return _father->getIteration();
1960 int MEDFileFieldPerMesh::getOrder() const
1962 return _father->getOrder();
1965 int MEDFileFieldPerMesh::getNumberOfComponents() const
1967 return _father->getNumberOfComponents();
1970 bool MEDFileFieldPerMesh::presenceOfMultiDiscPerGeoType() const
1972 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1976 if((*it)->presenceOfMultiDiscPerGeoType())
1982 bool MEDFileFieldPerMesh::presenceOfStructureElements() const
1984 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1985 if((*it).isNotNull())
1987 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
1994 bool MEDFileFieldPerMesh::onlyStructureElements() const
1996 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1997 if((*it).isNotNull())
1999 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2006 void MEDFileFieldPerMesh::killStructureElements()
2008 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
2009 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2011 if((*it).isNotNull())
2013 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2021 void MEDFileFieldPerMesh::keepOnlyStructureElements()
2023 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
2024 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2026 if((*it).isNotNull())
2028 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2036 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
2039 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
2040 return _father->getOrCreateAndGetArray();
2043 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
2046 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
2047 return _father->getOrCreateAndGetArray();
2050 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
2052 return _father->getInfo();
2056 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
2057 * 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.
2058 * It returns 2 output vectors :
2059 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
2060 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
2061 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
2063 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)
2065 int notNullPflsSz=0;
2066 int nbOfArrs=geoTypes.size();
2067 for(int i=0;i<nbOfArrs;i++)
2070 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
2071 int nbOfDiffGeoTypes=geoTypes3.size();
2072 code.resize(3*nbOfDiffGeoTypes);
2073 notNullPfls.resize(notNullPflsSz);
2076 for(int i=0;i<nbOfDiffGeoTypes;i++)
2079 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
2080 std::vector<const DataArrayInt *> notNullTmp;
2082 notNullTmp.push_back(pfls[j]);
2084 for(;j<nbOfArrs;j++)
2085 if(geoTypes[j]==refType)
2088 notNullTmp.push_back(pfls[j]);
2092 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
2093 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
2094 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
2095 code[3*i]=(int)refType;
2096 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
2097 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
2098 if(notNullTmp.empty())
2102 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
2103 code[3*i+2]=notNullPflsSz++;
2109 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
2111 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)
2115 for(int i=0;i<sz;i++)
2119 if(type!=ON_GAUSS_NE)
2120 ret+=dads[i].second-dads[i].first;
2123 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
2124 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
2129 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
2130 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
2136 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
2138 std::vector<std::string> ret;
2139 std::set<std::string> ret2;
2140 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2142 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
2143 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
2144 if(ret2.find(*it2)==ret2.end())
2146 ret.push_back(*it2);
2153 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
2155 std::vector<std::string> ret;
2156 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2158 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
2159 ret.insert(ret.end(),tmp.begin(),tmp.end());
2164 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
2166 std::vector<std::string> ret;
2167 std::set<std::string> ret2;
2168 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2170 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
2171 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
2172 if(ret2.find(*it2)==ret2.end())
2174 ret.push_back(*it2);
2181 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
2183 std::vector<std::string> ret;
2184 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2186 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
2187 ret.insert(ret.end(),tmp.begin(),tmp.end());
2192 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
2194 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
2196 if((*it).first==_mesh_name)
2198 _mesh_name=(*it).second;
2205 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
2206 MEDFileFieldGlobsReal& glob)
2208 if(_mesh_name!=meshName)
2210 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
2211 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
2212 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
2213 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
2214 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
2215 getUndergroundDataArrayExt(entries);
2216 DataArray *arr0(getOrCreateAndGetArray());//tony
2218 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
2219 DataArrayDouble *arr(dynamic_cast<DataArrayDouble *>(arr0));//tony
2221 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
2224 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
2225 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
2227 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
2229 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2230 sz+=(*it).second.second-(*it).second.first;
2233 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2235 MCAuto<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
2236 ////////////////////
2237 MCAuto<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
2238 int *workI2=explicitIdsOldInMesh->getPointer();
2239 int sz1=0,sz2=0,sid=1;
2240 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
2241 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
2242 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
2244 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
2245 MCAuto<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
2246 int *workI=explicitIdsOldInArr->getPointer();
2247 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
2249 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
2250 (*itL2)->setLocId(sz2);
2251 (*itL2)->_tmp_work1=(*itL2)->getStart();
2252 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
2254 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
2256 explicitIdsOldInMesh->reAlloc(sz2);
2257 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
2258 ////////////////////
2259 MCAuto<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
2260 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
2261 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
2262 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
2264 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
2265 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
2266 otherEntriesNew.back()->setLocId((*it)->getGeoType());
2268 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
2269 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
2270 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
2272 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
2273 int newStart=elt->getLocId();
2274 elt->setLocId((*it)->getGeoType());
2275 elt->setNewStart(newStart);
2276 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
2277 entriesKeptNew.push_back(elt);
2278 entriesKeptNew2.push_back(elt);
2280 MCAuto<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
2281 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
2282 MCAuto<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
2283 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
2285 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
2288 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
2290 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
2291 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
2293 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
2294 glob,arr2,otherEntriesNew) || ret;
2298 // Assign new dispatching
2299 assignNewLeaves(otherEntriesNew);
2300 arr->deepCopyFrom(*arr2);
2305 * \param [in,out] globalNum a global numbering counter for the renumbering.
2306 * \param [out] its - list of pair (start,stop) kept
2308 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
2310 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > ret;
2311 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2313 std::vector< std::pair<int,int> > its2;
2314 if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
2317 its.insert(its.end(),its2.begin(),its2.end());
2324 * \param [in,out] globalNum a global numbering counter for the renumbering.
2325 * \param [out] its - list of pair (start,stop) kept
2327 void MEDFileFieldPerMesh::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
2329 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > ret;
2330 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2332 std::vector< std::pair<int,int> > its2;
2333 if((*it)->keepOnlyGaussDiscretization(idOfDisc,globalNum,its2))
2336 its.insert(its.end(),its2.begin(),its2.end());
2342 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
2344 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > > types;
2345 for( std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
2346 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
2348 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > fieldPmPt(types.size());
2349 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
2350 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it2=fieldPmPt.begin();
2351 for(;it1!=types.end();it1++,it2++)
2353 MCAuto<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
2354 elt->setLeaves((*it1).second);
2355 MCAuto<MEDFileFieldPerMeshPerTypeCommon> elt2(DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(elt));
2358 _field_pm_pt=fieldPmPt;
2361 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2363 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2364 (*it)->changePflsRefsNamesGen(mapOfModif);
2367 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2369 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2370 (*it)->changeLocsRefsNamesGen(mapOfModif);
2374 * \param [in] mesh is the whole mesh
2376 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2378 if(_field_pm_pt.empty())
2379 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2381 std::vector< std::pair<int,int> > dads;
2382 std::vector<const DataArrayInt *> pfls;
2383 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2384 std::vector<int> locs,code;
2385 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2386 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2387 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2389 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2392 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2393 throw INTERP_KERNEL::Exception(oss.str());
2396 std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2397 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2400 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2402 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2405 MCAuto<DataArrayInt> arr2(arr);
2406 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2412 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2416 if(nb!=mesh->getNumberOfNodes())
2418 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2419 oss << " nodes in mesh !";
2420 throw INTERP_KERNEL::Exception(oss.str());
2422 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2425 return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2429 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
2431 if(_field_pm_pt.empty())
2432 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2434 std::vector<std::pair<int,int> > dads;
2435 std::vector<const DataArrayInt *> pfls;
2436 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2437 std::vector<int> locs,code;
2438 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2439 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2440 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2442 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2445 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2446 throw INTERP_KERNEL::Exception(oss.str());
2448 std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2449 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2452 MCAuto<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2453 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2458 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2462 if(nb!=mesh->getNumberOfNodes())
2464 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2465 oss << " nodes in mesh !";
2466 throw INTERP_KERNEL::Exception(oss.str());
2469 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2475 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
2479 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2481 (*it)->getSizes(globalSz,nbOfEntries);
2483 entries.resize(nbOfEntries);
2485 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2487 (*it)->fillValues(nbOfEntries,entries);
2491 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
2493 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::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());
2509 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
2511 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2513 if((*it)->getGeoType()==typ)
2514 return (*it)->getLeafGivenLocId(locId);
2516 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2517 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2518 oss << "Possiblities are : ";
2519 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2521 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2522 oss << "\"" << cm2.getRepr() << "\", ";
2524 throw INTERP_KERNEL::Exception(oss.str());
2528 * \param [in,out] start - Integer that gives the current position in the final aggregated array
2529 * \param [in] pms - list of elements to aggregate. integer gives the mesh id
2530 * \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.
2531 * \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.
2533 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)
2535 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret(new MEDFileFieldPerMeshPerTypePerDisc(father,tof));
2537 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : empty input vector !");
2538 for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it=pms.begin();it!=pms.end();it++)
2541 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : presence of null pointer !");
2542 if(!(*it).second->getProfile().empty())
2543 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for profiles !");
2544 if(!(*it).second->getLocalization().empty())
2545 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for gauss pts !");
2547 INTERP_KERNEL::NormalizedCellType gt(pms[0].second->getGeoType());
2549 std::vector< std::pair<int,int> > filteredDTS;
2550 for(std::vector< std::vector< std::pair<int,int> > >::const_iterator it=dts.begin();it!=dts.end();it++,i++)
2551 for(std::vector< std::pair<int,int> >::const_iterator it2=(*it).begin();it2!=(*it).end();it2++)
2552 if((*it2).first==gt)
2553 filteredDTS.push_back(std::pair<int,int>(i,(*it2).second));
2554 if(pms.size()!=filteredDTS.size())
2555 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles !");
2556 std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it1(pms.begin());
2557 std::vector< std::pair<int,int> >::const_iterator it2(filteredDTS.begin());
2558 int zeStart(start),nval(0);
2559 for(;it1!=pms.end();it1++,it2++)
2561 if((*it1).first!=(*it2).first)
2562 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles 2 !");
2563 int s1((*it1).second->getStart()),e1((*it1).second->getEnd());
2564 extractInfo.push_back(std::pair<int, std::pair<int,int> >((*it1).first,std::pair<int,int>(s1,e1)));
2566 nval+=((*it1).second)->getNumberOfVals();
2568 ret->_start=zeStart; ret->_end=start; ret->_nval=nval;
2572 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)
2574 MCAuto<MEDFileFieldPerMesh> ret(new MEDFileFieldPerMesh(father,pms[0]->getMeshName(),pms[0]->getMeshIteration(),pms[0]->getMeshOrder()));
2575 std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > > m;
2577 for(std::vector<const MEDFileFieldPerMesh *>::const_iterator it=pms.begin();it!=pms.end();it++,i++)
2579 const std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >& v((*it)->_field_pm_pt);
2580 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it2=v.begin();it2!=v.end();it2++)
2582 INTERP_KERNEL::NormalizedCellType gt((*it2)->getGeoType());
2583 const MEDFileFieldPerMeshPerType *elt(dynamic_cast<const MEDFileFieldPerMeshPerType *>((const MEDFileFieldPerMeshPerTypeCommon *)(*it2)));
2585 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::Aggregate : not managed for structelement !");
2586 m[gt].push_back(std::pair<int,const MEDFileFieldPerMeshPerType *>(i,elt));
2589 for(std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > >::const_iterator it=m.begin();it!=m.end();it++)
2591 MCAuto<MEDFileFieldPerMeshPerType> agg(MEDFileFieldPerMeshPerType::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
2592 MCAuto<MEDFileFieldPerMeshPerTypeCommon> agg2(DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(agg));
2593 ret->_field_pm_pt.push_back(agg2);
2598 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2601 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2602 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it2=_field_pm_pt.begin();
2603 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2605 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2610 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2615 int ret=std::distance(_field_pm_pt.begin(),it2);
2616 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2621 * 'dads' and 'locs' input parameters have the same number of elements
2622 * \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
2624 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2625 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2626 const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2629 MCAuto<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2630 ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2631 MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2632 const std::vector<std::string>& infos=getInfo();
2633 da->setInfoOnComponents(infos);
2635 if(type==ON_GAUSS_PT)
2638 int nbOfArrs=dads.size();
2639 for(int i=0;i<nbOfArrs;i++)
2641 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2642 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2643 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2644 MCAuto<DataArrayInt> di=DataArrayInt::New();
2645 di->alloc(nbOfElems,1);
2647 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2648 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2657 * 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.
2658 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2659 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2660 * The order of cells in the returned field is those imposed by the profile.
2661 * \param [in] mesh is the global mesh.
2663 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2664 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2665 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2666 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2668 if(da->isIota(mesh->getNumberOfCells()))
2669 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2670 MCAuto<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2671 m2->setName(mesh->getName().c_str());
2672 MCAuto<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2678 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2680 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2681 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2682 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2684 if(da->isIota(mesh->getNumberOfNodes()))
2685 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2686 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2687 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2690 if(meshu->getNodalConnectivity()==0)
2692 MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2693 int nb=da->getNbOfElems();
2694 const int *ptr=da->getConstPointer();
2695 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2696 meshuc->allocateCells(nb);
2697 for(int i=0;i<nb;i++)
2698 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2699 meshuc->finishInsertingCells();
2700 ret->setMesh(meshuc);
2701 const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2702 if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2703 disc->checkCoherencyBetween(meshuc,arrOut);
2708 MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2710 DataArrayInt *arr2=0;
2711 MCAuto<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2712 MCAuto<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2713 MCAuto<DataArrayInt> arr3(arr2);
2714 int nnodes=mesh2->getNumberOfNodes();
2715 if(nnodes==(int)da->getNbOfElems())
2717 MCAuto<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2718 arrOut->renumberInPlace(da3->getConstPointer());
2719 mesh2->setName(mesh->getName().c_str());
2720 ret->setMesh(mesh2);
2725 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 !!!";
2726 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2727 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2728 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2729 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2730 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2731 throw INTERP_KERNEL::Exception(oss.str());
2737 * This method is the most light method of field retrieving.
2739 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
2743 pflOut=DataArrayInt::New();
2744 pflOut->alloc(nbOfElems,1);
2749 pflOut=const_cast<DataArrayInt*>(pflIn);
2752 MCAuto<DataArrayInt> safePfl(pflOut);
2753 MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2754 const std::vector<std::string>& infos=getInfo();
2755 int nbOfComp=infos.size();
2756 for(int i=0;i<nbOfComp;i++)
2757 da->setInfoOnComponent(i,infos[i].c_str());
2768 static MFFPMIter *NewCell(const MEDFileEntities *entities);
2769 static bool IsPresenceOfNode(const MEDFileEntities *entities);
2770 virtual ~MFFPMIter() { }
2771 virtual void begin() = 0;
2772 virtual bool finished() const = 0;
2773 virtual void next() = 0;
2774 virtual int current() const = 0;
2777 class MFFPMIterSimple : public MFFPMIter
2780 MFFPMIterSimple():_pos(0) { }
2781 void begin() { _pos=0; }
2782 bool finished() const { return _pos>=MED_N_CELL_FIXED_GEO; }
2783 void next() { _pos++; }
2784 int current() const { return _pos; }
2789 class MFFPMIter2 : public MFFPMIter
2792 MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts);
2793 void begin() { _it=_ids.begin(); }
2794 bool finished() const { return _it==_ids.end(); }
2795 void next() { _it++; }
2796 int current() const { return *_it; }
2798 std::vector<int> _ids;
2799 std::vector<int>::const_iterator _it;
2802 MFFPMIter *MFFPMIter::NewCell(const MEDFileEntities *entities)
2805 return new MFFPMIterSimple;
2808 const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
2811 std::vector<INTERP_KERNEL::NormalizedCellType> tmp;
2812 const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
2813 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
2815 if((*it).first==ON_CELLS || (*it).first==ON_GAUSS_NE || (*it).first==ON_GAUSS_PT)
2816 tmp.push_back((*it).second);
2818 return new MFFPMIter2(tmp);
2820 return new MFFPMIterSimple;// for MEDFileAllStaticEntites and MEDFileAllStaticEntitiesPlusDyn cells are in
2824 bool MFFPMIter::IsPresenceOfNode(const MEDFileEntities *entities)
2830 const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
2833 const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
2834 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
2835 if((*it).first==ON_NODES)
2839 return true;// for MEDFileAllStaticEntites and MEDFileAllStaticEntitiesPlusDyn nodes are in
2843 MFFPMIter2::MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts)
2845 std::size_t sz(cts.size());
2847 for(std::size_t i=0;i<sz;i++)
2849 INTERP_KERNEL::NormalizedCellType *loc(std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,cts[i]));
2850 if(loc!=typmai2+MED_N_CELL_FIXED_GEO)
2851 _ids[i]=(int)std::distance(typmai2,loc);
2853 throw INTERP_KERNEL::Exception("MFFPMIter2 : The specified geo type does not exists !");
2859 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),
2862 INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2863 INTERP_KERNEL::AutoPtr<char> pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2864 INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2865 const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
2866 INTERP_KERNEL::AutoCppPtr<MFFPMIter> iter0(MFFPMIter::NewCell(entities));
2867 for(iter0->begin();!iter0->finished();iter0->next())
2869 int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL ,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2870 std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2871 int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2872 std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2873 if(nbProfile>0 || nbProfile2>0)
2875 const PartDefinition *pd(0);
2877 pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[iter0->current()]),typmai2[iter0->current()]);
2878 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nasc,pd));
2885 if(MFFPMIter::IsPresenceOfNode(entities))
2887 int nbProfile(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName));
2890 const PartDefinition *pd(0);
2892 pd=mmu->getPartDefAtLevel(1,INTERP_KERNEL::NORM_ERROR);
2893 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd));
2894 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2899 std::vector<int> dynGT(entities->getDynGTAvail());
2900 for(std::vector<int>::const_iterator it=dynGT.begin();it!=dynGT.end();it++)
2902 int nbPfl(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,*it,pflName,locName));
2905 _field_pm_pt.push_back(MEDFileFieldPerMeshPerTypeDyn::NewOnRead(fid,this,entities,*it,nasc));
2906 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2911 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2913 copyTinyInfoFrom(mesh);
2916 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
2918 if(id>=(int)_pfls.size())
2920 _pfls[id]=DataArrayInt::New();
2921 int lgth(MEDprofileSizeByName(fid,pflName.c_str()));
2922 _pfls[id]->setName(pflName);
2923 _pfls[id]->alloc(lgth,1);
2924 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName.c_str(),_pfls[id]->getPointer()));
2925 _pfls[id]->applyLin(1,-1,0);//Converting into C format
2928 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2930 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2932 MEDFILESAFECALLERRD0(MEDprofileInfo,(fid,i+1,pflName,&sz));
2933 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2934 if(i>=(int)_pfls.size())
2936 _pfls[i]=DataArrayInt::New();
2937 _pfls[i]->alloc(sz,1);
2938 _pfls[i]->setName(pflCpp.c_str());
2939 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName,_pfls[i]->getPointer()));
2940 _pfls[i]->applyLin(1,-1,0);//Converting into C format
2943 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
2945 int nbOfPfls=_pfls.size();
2946 for(int i=0;i<nbOfPfls;i++)
2948 MCAuto<DataArrayInt> cpy=_pfls[i]->deepCopy();
2949 cpy->applyLin(1,1,0);
2950 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2951 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2952 MEDFILESAFECALLERWR0(MEDprofileWr,(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer()));
2955 int nbOfLocs=_locs.size();
2956 for(int i=0;i<nbOfLocs;i++)
2957 _locs[i]->writeLL(fid);
2960 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
2962 std::vector<std::string> pfls=getPfls();
2963 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2965 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2968 _pfls.push_back(*it);
2972 int id=std::distance(pfls.begin(),it2);
2973 if(!(*it)->isEqual(*_pfls[id]))
2975 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2976 throw INTERP_KERNEL::Exception(oss.str());
2980 std::vector<std::string> locs=getLocs();
2981 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
2983 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2986 _locs.push_back(*it);
2990 int id=std::distance(locs.begin(),it2);
2991 if(!(*it)->isEqual(*_locs[id],eps))
2993 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2994 throw INTERP_KERNEL::Exception(oss.str());
3000 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
3002 for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
3003 getProfile((*it).c_str());
3006 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
3008 for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
3009 getLocalization((*it).c_str());
3012 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
3014 std::vector<std::string> profiles=real.getPflsReallyUsed();
3015 int sz=profiles.size();
3017 for(int i=0;i<sz;i++)
3018 loadProfileInFile(fid,i,profiles[i].c_str());
3020 std::vector<std::string> locs=real.getLocsReallyUsed();
3023 for(int i=0;i<sz;i++)
3024 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
3027 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid)
3029 int nProfil=MEDnProfile(fid);
3030 for(int i=0;i<nProfil;i++)
3031 loadProfileInFile(fid,i);
3032 int sz=MEDnLocalization(fid);
3034 for(int i=0;i<sz;i++)
3036 _locs[i]=MEDFileFieldLoc::New(fid,i);
3040 MEDFileFieldGlobs *MEDFileFieldGlobs::New(med_idt fid)
3042 return new MEDFileFieldGlobs(fid);
3045 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
3047 return new MEDFileFieldGlobs;
3050 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
3052 return _file_name.capacity()+_pfls.capacity()*sizeof(MCAuto<DataArrayInt>)+_locs.capacity()*sizeof(MCAuto<MEDFileFieldLoc>);
3055 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildrenWithNull() const
3057 std::vector<const BigMemoryObject *> ret;
3058 for(std::vector< MCAuto< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3059 ret.push_back((const DataArrayInt *)*it);
3060 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3061 ret.push_back((const MEDFileFieldLoc *)*it);
3065 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCopy() const
3067 MCAuto<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
3069 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3071 if((const DataArrayInt *)*it)
3072 ret->_pfls[i]=(*it)->deepCopy();
3075 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3077 if((const MEDFileFieldLoc*)*it)
3078 ret->_locs[i]=(*it)->deepCopy();
3084 * \throw if a profile in \a pfls in not in \a this.
3085 * \throw if a localization in \a locs in not in \a this.
3086 * \sa MEDFileFieldGlobs::deepCpyPart
3088 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
3090 MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
3091 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
3093 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
3095 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
3097 MCAuto<DataArrayInt> pfl2(pfl);
3098 ret->_pfls.push_back(pfl2);
3100 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
3102 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
3104 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
3106 MCAuto<MEDFileFieldLoc> loc2(loc);
3107 ret->_locs.push_back(loc2);
3109 ret->setFileName(getFileName());
3114 * \throw if a profile in \a pfls in not in \a this.
3115 * \throw if a localization in \a locs in not in \a this.
3116 * \sa MEDFileFieldGlobs::shallowCpyPart
3118 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
3120 MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
3121 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
3123 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
3125 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
3126 ret->_pfls.push_back(pfl->deepCopy());
3128 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
3130 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
3132 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
3133 ret->_locs.push_back(loc->deepCopy());
3135 ret->setFileName(getFileName());
3139 MEDFileFieldGlobs::MEDFileFieldGlobs(med_idt fid):_file_name(MEDFileWritable::FileNameFromFID(fid))
3143 MEDFileFieldGlobs::MEDFileFieldGlobs()
3147 MEDFileFieldGlobs::~MEDFileFieldGlobs()
3151 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
3153 oss << "Profiles :\n";
3154 std::size_t n=_pfls.size();
3155 for(std::size_t i=0;i<n;i++)
3157 oss << " - #" << i << " ";
3158 const DataArrayInt *pfl=_pfls[i];
3160 oss << "\"" << pfl->getName() << "\"\n";
3165 oss << "Localizations :\n";
3166 for(std::size_t i=0;i<n;i++)
3168 oss << " - #" << i << " ";
3169 const MEDFileFieldLoc *loc=_locs[i];
3171 loc->simpleRepr(oss);
3177 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3179 for(std::vector< MCAuto<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
3181 DataArrayInt *elt(*it);
3184 std::string name(elt->getName());
3185 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3187 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3189 elt->setName((*it2).second.c_str());
3197 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3199 for(std::vector< MCAuto<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
3201 MEDFileFieldLoc *elt(*it);
3204 std::string name(elt->getName());
3205 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3207 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3209 elt->setName((*it2).second.c_str());
3217 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
3219 if(locId<0 || locId>=(int)_locs.size())
3220 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
3221 return _locs[locId]->getNbOfGaussPtPerCell();
3224 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
3226 return getLocalizationFromId(getLocalizationId(locName));
3229 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
3231 if(locId<0 || locId>=(int)_locs.size())
3232 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3233 return *_locs[locId];
3237 namespace MEDCouplingImpl
3242 LocFinder(const std::string& loc):_loc(loc) { }
3243 bool operator() (const MCAuto<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
3245 const std::string &_loc;
3251 PflFinder(const std::string& pfl):_pfl(pfl) { }
3252 bool operator() (const MCAuto<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
3254 const std::string& _pfl;
3259 int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
3261 std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),MEDCouplingImpl::LocFinder(loc));
3264 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
3265 for(it=_locs.begin();it!=_locs.end();it++)
3266 oss << "\"" << (*it)->getName() << "\", ";
3267 throw INTERP_KERNEL::Exception(oss.str());
3269 return std::distance(_locs.begin(),it);
3273 * The returned value is never null.
3275 const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
3277 std::string pflNameCpp(pflName);
3278 std::vector< MCAuto<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3281 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3282 for(it=_pfls.begin();it!=_pfls.end();it++)
3283 oss << "\"" << (*it)->getName() << "\", ";
3284 throw INTERP_KERNEL::Exception(oss.str());
3289 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
3291 if(pflId<0 || pflId>=(int)_pfls.size())
3292 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3293 return _pfls[pflId];
3296 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
3298 if(locId<0 || locId>=(int)_locs.size())
3299 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3300 return *_locs[locId];
3303 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
3305 return getLocalizationFromId(getLocalizationId(locName));
3309 * The returned value is never null.
3311 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
3313 std::string pflNameCpp(pflName);
3314 std::vector< MCAuto<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3317 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3318 for(it=_pfls.begin();it!=_pfls.end();it++)
3319 oss << "\"" << (*it)->getName() << "\", ";
3320 throw INTERP_KERNEL::Exception(oss.str());
3325 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
3327 if(pflId<0 || pflId>=(int)_pfls.size())
3328 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3329 return _pfls[pflId];
3332 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
3334 std::vector< MCAuto<DataArrayInt> > newPfls;
3336 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3338 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
3339 newPfls.push_back(*it);
3344 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
3346 std::vector< MCAuto<MEDFileFieldLoc> > newLocs;
3348 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3350 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
3351 newLocs.push_back(*it);
3356 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
3358 int sz=_pfls.size();
3359 std::vector<std::string> ret(sz);
3360 for(int i=0;i<sz;i++)
3361 ret[i]=_pfls[i]->getName();
3365 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
3367 int sz=_locs.size();
3368 std::vector<std::string> ret(sz);
3369 for(int i=0;i<sz;i++)
3370 ret[i]=_locs[i]->getName();
3374 bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
3376 std::vector<std::string> v=getPfls();
3377 std::string s(pflName);
3378 return std::find(v.begin(),v.end(),s)!=v.end();
3381 bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
3383 std::vector<std::string> v=getLocs();
3384 std::string s(locName);
3385 return std::find(v.begin(),v.end(),s)!=v.end();
3388 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
3390 std::map<int,std::vector<int> > m;
3392 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3394 const DataArrayInt *tmp=(*it);
3397 m[tmp->getHashCode()].push_back(i);
3400 std::vector< std::vector<int> > ret;
3401 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
3403 if((*it2).second.size()>1)
3405 std::vector<int> ret0;
3406 bool equalityOrNot=false;
3407 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
3409 std::vector<int>::const_iterator it4=it3; it4++;
3410 for(;it4!=(*it2).second.end();it4++)
3412 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
3415 ret0.push_back(*it3);
3416 ret0.push_back(*it4);
3422 ret.push_back(ret0);
3428 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
3430 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
3433 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
3435 std::string name(pfl->getName());
3437 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
3438 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3439 if(name==(*it)->getName())
3441 if(!pfl->isEqual(*(*it)))
3443 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
3444 throw INTERP_KERNEL::Exception(oss.str());
3448 _pfls.push_back(pfl);
3451 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)
3453 std::string name(locName);
3455 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
3456 MCAuto<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
3457 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3458 if((*it)->isName(locName))
3460 if(!(*it)->isEqual(*obj,1e-12))
3462 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
3463 throw INTERP_KERNEL::Exception(oss.str());
3466 _locs.push_back(obj);
3469 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
3471 std::vector<std::string> names=getPfls();
3472 return CreateNewNameNotIn("NewPfl_",names);
3475 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
3477 std::vector<std::string> names=getLocs();
3478 return CreateNewNameNotIn("NewLoc_",names);
3481 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
3483 for(std::size_t sz=0;sz<100000;sz++)
3485 std::ostringstream tryName;
3486 tryName << prefix << sz;
3487 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
3488 return tryName.str();
3490 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
3494 * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
3495 * \param [in] fname - the file name.
3497 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(med_idt fid):_globals(MEDFileFieldGlobs::New(fid))
3502 * Creates an empty MEDFileFieldGlobsReal.
3504 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
3508 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
3513 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildrenWithNull() const
3515 std::vector<const BigMemoryObject *> ret;
3516 ret.push_back((const MEDFileFieldGlobs *)_globals);
3521 * Returns a string describing profiles and Gauss points held in \a this.
3522 * \return std::string - the description string.
3524 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
3526 const MEDFileFieldGlobs *glob=_globals;
3527 std::ostringstream oss2; oss2 << glob;
3528 std::string stars(oss2.str().length(),'*');
3529 oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n";
3531 glob->simpleRepr(oss);
3533 oss << "NO GLOBAL INFORMATION !\n";
3536 void MEDFileFieldGlobsReal::resetContent()
3538 _globals=MEDFileFieldGlobs::New();
3541 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
3546 * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
3547 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3549 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3551 _globals=other._globals;
3555 * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3556 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3558 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3560 const MEDFileFieldGlobs *otherg(other._globals);
3563 _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3567 * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3568 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3570 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3572 const MEDFileFieldGlobs *otherg(other._globals);
3575 _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3578 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3580 _globals=other._globals;
3581 if((const MEDFileFieldGlobs *)_globals)
3582 _globals=other._globals->deepCopy();
3586 * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3587 * \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3588 * \param [in] eps - a precision used to compare Gauss points with same name held by
3589 * \a this and \a other MEDFileFieldGlobsReal.
3590 * \throw If \a this and \a other hold profiles with equal names but different ids.
3591 * \throw If \a this and \a other hold different Gauss points with equal names.
3593 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
3595 const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3596 if(thisGlobals==otherGlobals)
3600 _globals=other._globals;
3603 _globals->appendGlobs(*other._globals,eps);
3606 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
3608 checkGlobsPflsPartCoherency();
3609 checkGlobsLocsPartCoherency();
3612 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
3614 contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3617 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
3619 contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3622 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3624 contentNotNull()->loadProfileInFile(fid,id,pflName);
3627 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3629 contentNotNull()->loadProfileInFile(fid,id);
3632 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
3634 contentNotNull()->loadGlobals(fid,*this);
3637 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid)
3639 contentNotNull()->loadAllGlobals(fid);
3642 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3644 contentNotNull()->writeGlobals(fid,opt);
3648 * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3649 * or getPflsReallyUsedMulti().
3650 * \return std::vector<std::string> - a sequence of names of all profiles.
3652 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3654 return contentNotNull()->getPfls();
3658 * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3659 * or getLocsReallyUsedMulti().
3660 * \return std::vector<std::string> - a sequence of names of all localizations.
3662 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3664 return contentNotNull()->getLocs();
3668 * Checks if the profile with a given name exists.
3669 * \param [in] pflName - the profile name of interest.
3670 * \return bool - \c true if the profile named \a pflName exists.
3672 bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
3674 return contentNotNull()->existsPfl(pflName);
3678 * Checks if the localization with a given name exists.
3679 * \param [in] locName - the localization name of interest.
3680 * \return bool - \c true if the localization named \a locName exists.
3682 bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
3684 return contentNotNull()->existsLoc(locName);
3687 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
3689 return contentNotNull()->createNewNameOfPfl();
3692 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
3694 return contentNotNull()->createNewNameOfLoc();
3698 * Sets the name of a MED file.
3699 * \param [inout] fileName - the file name.
3701 void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
3703 contentNotNull()->setFileName(fileName);
3707 * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3708 * in the same order.
3709 * \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3710 * Each item of this sequence is a vector containing ids of equal profiles.
3712 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3714 return contentNotNull()->whichAreEqualProfiles();
3718 * Finds equal localizations.
3719 * \param [in] eps - a precision used to compare real values of the localizations.
3720 * \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3721 * Each item of this sequence is a vector containing ids of equal localizations.
3723 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3725 return contentNotNull()->whichAreEqualLocs(eps);
3729 * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3730 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3731 * this sequence is a pair whose
3732 * - the first item is a vector of profile names to replace by the second item,
3733 * - the second item is a profile name to replace every profile name of the first item.
3735 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3737 contentNotNull()->changePflsNamesInStruct(mapOfModif);
3741 * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3742 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3743 * this sequence is a pair whose
3744 * - the first item is a vector of localization names to replace by the second item,
3745 * - the second item is a localization name to replace every localization name of the first item.
3747 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3749 contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3753 * Replaces references to some profiles (a reference is a profile name) by references
3754 * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3755 * them-selves accordingly. <br>
3756 * This method is a generalization of changePflName().
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 profile names to replace by the second item,
3760 * - the second item is a profile name to replace every profile of the first item.
3761 * \sa changePflsRefsNamesGen()
3762 * \sa changePflName()
3764 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3766 changePflsRefsNamesGen(mapOfModif);
3767 changePflsNamesInStruct(mapOfModif);
3771 * Replaces references to some localizations (a reference is a localization name) by references
3772 * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3773 * them-selves accordingly. <br>
3774 * This method is a generalization of changeLocName().
3775 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3776 * this sequence is a pair whose
3777 * - the first item is a vector of localization names to replace by the second item,
3778 * - the second item is a localization name to replace every localization of the first item.
3779 * \sa changeLocsRefsNamesGen()
3780 * \sa changeLocName()
3782 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3784 changeLocsRefsNamesGen(mapOfModif);
3785 changeLocsNamesInStruct(mapOfModif);
3789 * Renames the profile having a given name and updates references to this profile.
3790 * \param [in] oldName - the name of the profile to rename.
3791 * \param [in] newName - a new name of the profile.
3792 * \sa changePflsNames().
3794 void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
3796 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3797 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3799 changePflsNames(mapOfModif);
3803 * Renames the localization having a given name and updates references to this localization.
3804 * \param [in] oldName - the name of the localization to rename.
3805 * \param [in] newName - a new name of the localization.
3806 * \sa changeLocsNames().
3808 void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
3810 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3811 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3813 changeLocsNames(mapOfModif);
3817 * Removes duplicated profiles. Returns a map used to update references to removed
3818 * profiles via changePflsRefsNamesGen().
3819 * Equal profiles are found using whichAreEqualProfiles().
3820 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3821 * a sequence describing the performed replacements of profiles. Each element of
3822 * this sequence is a pair whose
3823 * - the first item is a vector of profile names replaced by the second item,
3824 * - the second item is a profile name replacing every profile of the first item.
3826 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
3828 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3829 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3831 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3833 std::vector< std::string > tmp((*it).size());
3835 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3836 tmp[j]=std::string(getProfileFromId(*it2)->getName());
3837 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3839 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3840 killProfileIds(tmp2);
3842 changePflsRefsNamesGen(ret);
3847 * Removes duplicated localizations. Returns a map used to update references to removed
3848 * localizations via changeLocsRefsNamesGen().
3849 * Equal localizations are found using whichAreEqualLocs().
3850 * \param [in] eps - a precision used to compare real values of the localizations.
3851 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3852 * a sequence describing the performed replacements of localizations. Each element of
3853 * this sequence is a pair whose
3854 * - the first item is a vector of localization names replaced by the second item,
3855 * - the second item is a localization name replacing every localization of the first item.
3857 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
3859 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3860 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3862 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3864 std::vector< std::string > tmp((*it).size());
3866 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3867 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3868 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3870 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3871 killLocalizationIds(tmp2);
3873 changeLocsRefsNamesGen(ret);
3878 * Returns number of Gauss points per cell in a given localization.
3879 * \param [in] locId - an id of the localization of interest.
3880 * \return int - the number of the Gauss points per cell.
3882 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
3884 return contentNotNull()->getNbOfGaussPtPerCell(locId);
3888 * Returns an id of a localization by its name.
3889 * \param [in] loc - the localization name of interest.
3890 * \return int - the id of the localization.
3891 * \throw If there is no a localization named \a loc.
3893 int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
3895 return contentNotNull()->getLocalizationId(loc);
3899 * Returns the name of the MED file.
3900 * \return const std::string& - the MED file name.
3902 std::string MEDFileFieldGlobsReal::getFileName() const
3904 return contentNotNull()->getFileName();
3908 * Returns a localization object by its name.
3909 * \param [in] locName - the name of the localization of interest.
3910 * \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3911 * \throw If there is no a localization named \a locName.
3913 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
3915 return contentNotNull()->getLocalization(locName);
3919 * Returns a localization object by its id.
3920 * \param [in] locId - the id of the localization of interest.
3921 * \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3922 * \throw If there is no a localization with id \a locId.
3924 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
3926 return contentNotNull()->getLocalizationFromId(locId);
3930 * Returns a profile array by its name.
3931 * \param [in] pflName - the name of the profile of interest.
3932 * \return const DataArrayInt * - the profile array having the name \a pflName.
3933 * \throw If there is no a profile named \a pflName.
3935 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
3937 return contentNotNull()->getProfile(pflName);
3941 * Returns a profile array by its id.
3942 * \param [in] pflId - the id of the profile of interest.
3943 * \return const DataArrayInt * - the profile array having the id \a pflId.
3944 * \throw If there is no a profile with id \a pflId.
3946 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
3948 return contentNotNull()->getProfileFromId(pflId);
3952 * Returns a localization object, apt for modification, by its id.
3953 * \param [in] locId - the id of the localization of interest.
3954 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3955 * having the id \a locId.
3956 * \throw If there is no a localization with id \a locId.
3958 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
3960 return contentNotNull()->getLocalizationFromId(locId);
3964 * Returns a localization object, apt for modification, by its name.
3965 * \param [in] locName - the name of the localization of interest.
3966 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3967 * having the name \a locName.
3968 * \throw If there is no a localization named \a locName.
3970 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
3972 return contentNotNull()->getLocalization(locName);
3976 * Returns a profile array, apt for modification, by its name.
3977 * \param [in] pflName - the name of the profile of interest.
3978 * \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3979 * \throw If there is no a profile named \a pflName.
3981 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
3983 return contentNotNull()->getProfile(pflName);
3987 * Returns a profile array, apt for modification, by its id.
3988 * \param [in] pflId - the id of the profile of interest.
3989 * \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3990 * \throw If there is no a profile with id \a pflId.
3992 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
3994 return contentNotNull()->getProfileFromId(pflId);
3998 * Removes profiles given by their ids. No data is updated to track this removal.
3999 * \param [in] pflIds - a sequence of ids of the profiles to remove.
4001 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
4003 contentNotNull()->killProfileIds(pflIds);
4007 * Removes localizations given by their ids. No data is updated to track this removal.
4008 * \param [in] locIds - a sequence of ids of the localizations to remove.
4010 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
4012 contentNotNull()->killLocalizationIds(locIds);
4016 * Stores a profile array.
4017 * \param [in] pfl - the profile array to store.
4018 * \throw If the name of \a pfl is empty.
4019 * \throw If a profile with the same name as that of \a pfl already exists but contains
4022 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
4024 contentNotNull()->appendProfile(pfl);
4028 * Adds a new localization of Gauss points.
4029 * \param [in] locName - the name of the new localization.
4030 * \param [in] geoType - a geometrical type of the reference cell.
4031 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
4032 * must be \c nbOfNodesPerCell * \c dimOfType.
4033 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
4034 * must be _wg_.size() * \c dimOfType.
4035 * \param [in] w - the weights of Gauss points.
4036 * \throw If \a locName is empty.
4037 * \throw If a localization with the name \a locName already exists but is
4038 * different form the new one.
4040 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)
4042 contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
4045 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
4047 MEDFileFieldGlobs *g(_globals);
4049 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
4053 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
4055 const MEDFileFieldGlobs *g(_globals);
4057 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
4061 //= MEDFileFieldNameScope
4063 MEDFileFieldNameScope::MEDFileFieldNameScope()
4067 MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName):_name(fieldName)
4072 * Returns the name of \a this field.
4073 * \return std::string - a string containing the field name.
4075 std::string MEDFileFieldNameScope::getName() const
4081 * Sets name of \a this field
4082 * \param [in] name - the new field name.
4084 void MEDFileFieldNameScope::setName(const std::string& fieldName)
4089 std::string MEDFileFieldNameScope::getDtUnit() const
4094 void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
4099 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
4102 _dt_unit=other._dt_unit;
4105 //= MEDFileAnyTypeField1TSWithoutSDA
4107 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
4109 _field_per_mesh.resize(other._field_per_mesh.size());
4111 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
4113 if((const MEDFileFieldPerMesh *)*it)
4114 _field_per_mesh[i]=(*it)->deepCopy(this);
4119 * Prints a string describing \a this field into a stream. This string is outputted
4120 * by \c print Python command.
4121 * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
4122 * \param [in,out] oss - the out stream.
4123 * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
4124 * info id printed, else, not.
4126 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
4128 std::string startOfLine(bkOffset,' ');
4129 oss << startOfLine << "Field ";
4131 oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
4132 oss << "on one time Step ";
4134 oss << "(" << f1tsId << ") ";
4135 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
4136 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
4137 const DataArray *arr=getUndergroundDataArray();
4140 const std::vector<std::string> &comps=arr->getInfoOnComponents();
4143 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
4144 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
4145 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
4147 if(arr->isAllocated())
4149 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
4152 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
4156 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
4158 oss << startOfLine << "----------------------" << std::endl;
4159 if(!_field_per_mesh.empty())
4162 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
4164 const MEDFileFieldPerMesh *cur=(*it2);
4166 cur->simpleRepr(bkOffset,oss,i);
4168 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
4173 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
4175 oss << startOfLine << "----------------------" << std::endl;
4178 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
4180 const DataArray *arr(getUndergroundDataArray());
4182 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
4183 int nbOfCompo=arr->getNumberOfComponents();
4184 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
4185 for(int i=0;i<nbOfCompo;i++)
4188 std::vector<int> v(1,i);
4189 MCAuto<DataArray> arr2=arr->keepSelectedComponents(v);
4190 ret[i]->setArray(arr2);
4195 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)
4199 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
4204 * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
4205 * empty. Returns -1 if this in on nodes.
4206 * \return int - the dimension of \a this.
4208 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
4211 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4212 (*it)->getDimension(ret);
4217 * Returns the mesh name.
4218 * \return std::string - a string holding the mesh name.
4219 * \throw If \c _field_per_mesh.empty()
4221 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const
4223 if(_field_per_mesh.empty())
4224 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
4225 return _field_per_mesh[0]->getMeshName();
4228 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const std::string& newMeshName)
4230 std::string oldName(getMeshName());
4231 std::vector< std::pair<std::string,std::string> > v(1);
4232 v[0].first=oldName; v[0].second=newMeshName;
4236 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
4239 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4241 MEDFileFieldPerMesh *cur(*it);
4243 ret=cur->changeMeshNames(modifTab) || ret;
4249 * Returns the number of iteration of the state of underlying mesh.
4250 * \return int - the iteration number.
4251 * \throw If \c _field_per_mesh.empty()
4253 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
4255 if(_field_per_mesh.empty())
4256 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
4257 return _field_per_mesh[0]->getMeshIteration();
4261 * Returns the order number of iteration of the state of underlying mesh.
4262 * \return int - the order number.
4263 * \throw If \c _field_per_mesh.empty()
4265 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
4267 if(_field_per_mesh.empty())
4268 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
4269 return _field_per_mesh[0]->getMeshOrder();
4273 * Checks if \a this field is tagged by a given iteration number and a given
4274 * iteration order number.
4275 * \param [in] iteration - the iteration number of interest.
4276 * \param [in] order - the iteration order number of interest.
4277 * \return bool - \c true if \a this->getIteration() == \a iteration &&
4278 * \a this->getOrder() == \a order.
4280 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
4282 return iteration==_iteration && order==_order;
4286 * Returns number of iteration and order number of iteration when
4287 * \a this field has been calculated.
4288 * \return std::pair<int,int> - a pair of the iteration number and the iteration
4291 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
4293 std::pair<int,int> p;
4299 * Returns number of iteration and order number of iteration when
4300 * \a this field has been calculated.
4301 * \param [in,out] p - a pair returning the iteration number and the iteration
4304 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
4311 * Returns all types of spatial discretization of \a this field.
4312 * \param [in,out] types - a sequence of types of \a this field.
4314 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
4316 std::set<TypeOfField> types2;
4317 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4319 (*it)->fillTypesOfFieldAvailable(types2);
4321 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
4322 std::copy(types2.begin(),types2.end(),bi);
4326 * Returns all types of spatial discretization of \a this field.
4327 * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
4330 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
4332 std::vector<TypeOfField> ret;
4333 fillTypesOfFieldAvailable(ret);
4337 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
4339 std::vector<std::string> ret;
4340 std::set<std::string> ret2;
4341 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4343 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
4344 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4345 if(ret2.find(*it2)==ret2.end())
4347 ret.push_back(*it2);
4354 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
4356 std::vector<std::string> ret;
4357 std::set<std::string> ret2;
4358 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4360 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
4361 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4362 if(ret2.find(*it2)==ret2.end())
4364 ret.push_back(*it2);
4371 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
4373 std::vector<std::string> ret;
4374 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4376 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
4377 ret.insert(ret.end(),tmp.begin(),tmp.end());
4382 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
4384 std::vector<std::string> ret;
4385 std::set<std::string> ret2;
4386 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4388 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
4389 ret.insert(ret.end(),tmp.begin(),tmp.end());
4394 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4396 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4397 (*it)->changePflsRefsNamesGen(mapOfModif);
4400 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4402 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4403 (*it)->changeLocsRefsNamesGen(mapOfModif);
4407 * Returns all attributes of parts of \a this field lying on a given mesh.
4408 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4409 * item of every of returned sequences refers to the _i_-th part of \a this field.
4410 * Thus all sequences returned by this method are of the same length equal to number
4411 * of different types of supporting entities.<br>
4412 * A field part can include sub-parts with several different spatial discretizations,
4413 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
4414 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4415 * of a nested sequence corresponds to a type of spatial discretization.<br>
4416 * This method allows for iteration over MEDFile DataStructure without any overhead.
4417 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4418 * for the case with only one underlying mesh. (Actually, the number of meshes is
4419 * not checked if \a mname == \c NULL).
4420 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4421 * a field part is returned.
4422 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4423 * This sequence is of the same length as \a types.
4424 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4425 * discretization. A profile name can be empty.
4426 * Length of this and of nested sequences is the same as that of \a typesF.
4427 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4428 * discretization. A localization name can be empty.
4429 * Length of this and of nested sequences is the same as that of \a typesF.
4430 * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
4431 * of ids of tuples within the data array, per each type of spatial
4432 * discretization within one mesh entity type.
4433 * Length of this and of nested sequences is the same as that of \a typesF.
4434 * \throw If no field is lying on \a mname.
4436 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
4440 meshId=getMeshIdFromMeshName(mname);
4442 if(_field_per_mesh.empty())
4443 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4444 return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4448 * Returns dimensions of mesh elements \a this field lies on. The returned value is a
4449 * maximal absolute dimension and values returned via the out parameter \a levs are
4450 * dimensions relative to the maximal absolute dimension. <br>
4451 * This method is designed for MEDFileField1TS instances that have a discretization
4452 * \ref MEDCoupling::ON_CELLS "ON_CELLS",
4453 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT",
4454 * \ref MEDCoupling::ON_GAUSS_NE "ON_GAUSS_NE".
4455 * Only these 3 discretizations will be taken into account here. If \a this is
4456 * \ref MEDCoupling::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
4457 * This method is useful to make the link between the dimension of the underlying mesh
4458 * and the levels of \a this, because it is possible that the highest dimension of \a this
4459 * field is not equal to the dimension of the underlying mesh.
4461 * Let's consider the following case:
4462 * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
4463 * TETRA4, HEXA8, TRI3 and SEG2.
4464 * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
4465 * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
4467 * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
4468 * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
4469 * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
4470 * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
4471 * parameter of getFieldAtLevel() is computed basing on the returned values as this:
4472 * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
4474 * to retrieve the highest level of
4475 * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br>
4476 * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
4477 * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
4478 * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
4479 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4480 * for the case with only one underlying mesh. (Actually, the number of meshes is
4481 * not checked if \a mname == \c NULL).
4482 * \param [in,out] levs - a sequence returning the dimensions relative to the maximal
4483 * absolute one. They are in decreasing order. This sequence is cleared before
4485 * \return int - the maximal absolute dimension of elements \a this fields lies on.
4486 * \throw If no field is lying on \a mname.
4488 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
4491 int meshId=getMeshIdFromMeshName(mname);
4492 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4493 std::vector< std::vector<TypeOfField> > typesF;
4494 std::vector< std::vector<std::string> > pfls, locs;
4495 _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4497 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
4498 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
4499 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
4501 st.erase(INTERP_KERNEL::NORM_ERROR);
4503 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
4505 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
4506 ret1.insert((int)cm.getDimension());
4508 int ret=*std::max_element(ret1.begin(),ret1.end());
4509 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
4510 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
4515 * \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.
4516 * \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.
4517 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4518 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4520 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
4522 int mid=getMeshIdFromMeshName(mName);
4523 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4527 * \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.
4528 * \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.
4529 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4530 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4532 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
4534 int mid=getMeshIdFromMeshName(mName);
4535 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4539 * \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.
4541 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
4543 if(_field_per_mesh.empty())
4544 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4547 std::string mName2(mName);
4549 std::vector<std::string> msg;
4550 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4551 if(mName2==(*it)->getMeshName())
4554 msg.push_back((*it)->getMeshName());
4555 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4556 oss << "Possible meshes are : ";
4557 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4558 oss << "\"" << (*it2) << "\" ";
4559 throw INTERP_KERNEL::Exception(oss.str());
4562 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
4565 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4566 std::string tmp(mesh->getName());
4568 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4569 std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4571 for(;it!=_field_per_mesh.end();it++,i++)
4573 if((*it)->getMeshName()==tmp)
4576 int sz=_field_per_mesh.size();
4577 _field_per_mesh.resize(sz+1);
4578 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4582 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4583 MEDFileFieldGlobsReal& glob)
4586 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4588 MEDFileFieldPerMesh *fpm(*it);
4590 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4596 * This method splits \a this into several sub-parts so that each sub parts have exactly one spatial discretization. This method implements the minimal
4597 * splitting that leads to single spatial discretization of this.
4599 * \sa splitMultiDiscrPerGeoTypes
4601 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
4603 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4604 std::vector< std::vector<TypeOfField> > typesF;
4605 std::vector< std::vector<std::string> > pfls,locs;
4606 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4607 std::set<TypeOfField> allEnt;
4608 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4609 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4610 allEnt.insert(*it2);
4611 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4612 std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4613 for(std::size_t i=0;i<allEnt.size();i++,it3++)
4615 std::vector< std::pair<int,int> > its;
4616 ret[i]=shallowCpy();
4617 int newLgth(ret[i]->keepOnlySpatialDiscretization(*it3,its));
4618 ret[i]->updateData(newLgth,its);
4624 * This method performs a sub splitting as splitDiscretizations does but finer. This is the finest spliting level that can be done.
4625 * This method implements the minimal splitting so that each returned elements are mono Gauss discretization per geometric type.
4627 * \sa splitDiscretizations
4629 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes() const
4631 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4632 std::vector< std::vector<TypeOfField> > typesF;
4633 std::vector< std::vector<std::string> > pfls,locs;
4634 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4635 std::set<TypeOfField> allEnt;
4636 std::size_t nbOfMDPGT(0),ii(0);
4637 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++,ii++)
4639 nbOfMDPGT=std::max(nbOfMDPGT,locs[ii].size());
4640 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4641 allEnt.insert(*it2);
4643 if(allEnt.size()!=1)
4644 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : this field is expected to be defined only on one spatial discretization !");
4646 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
4649 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret0(1);
4650 ret0[0]=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(this); this->incrRef();
4653 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfMDPGT);
4654 for(std::size_t i=0;i<nbOfMDPGT;i++)
4656 std::vector< std::pair<int,int> > its;
4657 ret[i]=shallowCpy();
4658 int newLgth(ret[i]->keepOnlyGaussDiscretization(i,its));
4659 ret[i]->updateData(newLgth,its);
4664 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
4666 int globalCounter(0);
4667 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4668 (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4669 return globalCounter;
4672 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlyGaussDiscretization(std::size_t idOfDisc, std::vector< std::pair<int,int> >& its)
4674 int globalCounter(0);
4675 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4676 (*it)->keepOnlyGaussDiscretization(idOfDisc,globalCounter,its);
4677 return globalCounter;
4680 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
4682 if(_nb_of_tuples_to_be_allocated>=0)
4684 _nb_of_tuples_to_be_allocated=newLgth;
4685 const DataArray *oldArr(getUndergroundDataArray());
4688 MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4689 newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
4691 _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
4695 if(_nb_of_tuples_to_be_allocated==-1)
4697 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4699 const DataArray *oldArr(getUndergroundDataArray());
4700 if(!oldArr || !oldArr->isAllocated())
4701 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4702 MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4703 newArr->alloc(newLgth,getNumberOfComponents());
4705 newArr->copyStringInfoFrom(*oldArr);
4707 for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4709 if((*it).second<(*it).first)
4710 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4711 newArr->setContigPartOfSelectedValuesSlice(pos,oldArr,(*it).first,(*it).second,1);
4712 pos+=(*it).second-(*it).first;
4717 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4720 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
4722 if(_field_per_mesh.empty())
4723 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4724 if(_field_per_mesh.size()>1)
4725 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4726 _field_per_mesh[0]->copyOptionsFrom(opts);
4727 _field_per_mesh[0]->writeLL(fid,nasc);
4731 * 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.
4732 * If false is returned the memory allocation is not required.
4734 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
4736 if(_nb_of_tuples_to_be_allocated>=0)
4738 getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4739 _nb_of_tuples_to_be_allocated=-2;
4742 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4744 if(_nb_of_tuples_to_be_allocated==-1)
4745 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4746 if(_nb_of_tuples_to_be_allocated<-3)
4747 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4748 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4751 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
4753 med_int numdt,numit;
4757 med_int meshnumdt,meshnumit;
4758 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4759 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt));
4760 MEDFILESAFECALLERRD0(MEDfield23ComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit));
4761 if(_iteration!=numdt || _order!=numit)
4762 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4763 _field_per_mesh.resize(nmesh);
4768 std::string meshNameCpp(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
4769 mm=ms->getMeshWithName(meshNameCpp);
4772 for(int i=0;i<nmesh;i++)
4773 _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i,meshnumdt,meshnumit,nasc,mm,entities);
4774 _nb_of_tuples_to_be_allocated=0;
4775 for(int i=0;i<nmesh;i++)
4776 _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4779 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
4781 allocIfNecessaryTheArrayToReceiveDataFromFile();
4782 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4783 (*it)->loadBigArraysRecursively(fid,nasc);
4786 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
4788 if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4789 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4790 (*it)->loadBigArraysRecursively(fid,nasc);
4793 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
4795 loadOnlyStructureOfDataRecursively(fid,nasc,ms,entities);
4796 loadBigArraysRecursively(fid,nasc);
4799 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
4801 DataArray *thisArr(getUndergroundDataArray());
4802 if(thisArr && thisArr->isAllocated())
4804 _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
4805 thisArr->desallocate();
4809 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
4811 return _dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MCAuto< MEDFileFieldPerMesh >);
4814 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
4816 std::vector<const BigMemoryObject *> ret;
4817 if(getUndergroundDataArray())
4818 ret.push_back(getUndergroundDataArray());
4819 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4820 ret.push_back((const MEDFileFieldPerMesh *)*it);
4825 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4826 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4827 * "Sort By Type"), if not, an exception is thrown.
4828 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
4829 * \param [in] arr - the array of values.
4830 * \param [in,out] glob - the global data where profiles and localization present in
4831 * \a field, if any, are added.
4832 * \throw If the name of \a field is empty.
4833 * \throw If the data array of \a field is not set.
4834 * \throw If \a this->_arr is already allocated but has different number of components
4836 * \throw If the underlying mesh of \a field has no name.
4837 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4839 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4841 const MEDCouplingMesh *mesh=field->getMesh();
4843 TypeOfField type=field->getTypeOfField();
4844 std::vector<DataArrayInt *> dummy;
4845 int start=copyTinyInfoFrom(field,arr);
4846 int pos=addNewEntryIfNecessary(mesh);
4849 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4850 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4853 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4857 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4858 * of a given mesh are used as the support of the given field (a real support is not used).
4859 * Elements of the given mesh must be sorted suitable for writing to MED file.
4860 * Order of underlying mesh entities of the given field specified by \a profile parameter
4861 * is not prescribed; this method permutes field values to have them sorted by element
4862 * type as required for writing to MED file. A new profile is added only if no equal
4863 * profile is missing.
4864 * \param [in] field - the field to add to \a this. The field double values are ignored.
4865 * \param [in] arrOfVals - the values of the field \a field used.
4866 * \param [in] mesh - the supporting mesh of \a field.
4867 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4868 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
4869 * \param [in,out] glob - the global data where profiles and localization present in
4870 * \a field, if any, are added.
4871 * \throw If either \a field or \a mesh or \a profile has an empty name.
4872 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4873 * \throw If the data array of \a field is not set.
4874 * \throw If \a this->_arr is already allocated but has different number of components
4876 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4877 * \sa setFieldNoProfileSBT()
4879 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4882 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
4883 if(!arrOfVals || !arrOfVals->isAllocated())
4884 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
4885 TypeOfField type=field->getTypeOfField();
4886 std::vector<DataArrayInt *> idsInPflPerType;
4887 std::vector<DataArrayInt *> idsPerType;
4888 std::vector<int> code,code2;
4889 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
4892 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4893 std::vector< MCAuto<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
4894 std::vector< MCAuto<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin());
4895 std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
4897 MCAuto<MEDCouplingFieldDouble> field2=field->clone(false);
4898 int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
4899 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4901 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4902 throw INTERP_KERNEL::Exception(oss.str());
4905 int start=copyTinyInfoFrom(field,arrOfVals);
4906 code2=m->getDistributionOfTypes();
4908 int pos=addNewEntryIfNecessary(m);
4909 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4913 if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
4914 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
4915 std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
4916 std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
4917 int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
4918 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4920 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4921 throw INTERP_KERNEL::Exception(oss.str());
4923 int start=copyTinyInfoFrom(field,arrOfVals);
4924 int pos=addNewEntryIfNecessary(m);
4925 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4930 * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
4932 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
4934 if(_nb_of_tuples_to_be_allocated>=0)
4935 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 !");
4936 DataArray *arr(getOrCreateAndGetArray());
4937 arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
4938 _nb_of_tuples_to_be_allocated=-3;
4942 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4943 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4944 * larger by the size of \a field. Returns an id of the first not filled
4945 * tuple of \a this->_arr.
4946 * \param [in] field - the field to copy the info on components and the name from.
4947 * \return int - the id of first not initialized tuple of \a this->_arr.
4948 * \throw If the name of \a field is empty.
4949 * \throw If the data array of \a field is not set.
4950 * \throw If \a this->_arr is already allocated but has different number of components
4953 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
4956 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4957 std::string name(field->getName());
4958 setName(name.c_str());
4959 setDtUnit(field->getTimeUnit());
4961 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4963 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4964 if(!arr->isAllocated())
4965 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
4966 _dt=field->getTime(_iteration,_order);
4967 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4968 if(!getOrCreateAndGetArray()->isAllocated())
4970 allocNotFromFile(arr->getNumberOfTuples());
4975 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4976 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4977 getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
4978 _nb_of_tuples_to_be_allocated=-3;
4979 return oldNbOfTuples;
4984 * Returns number of components in \a this field
4985 * \return int - the number of components.
4987 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4989 return getOrCreateAndGetArray()->getNumberOfComponents();
4993 * Change info on components in \a this.
4994 * \throw If size of \a infos is not equal to the number of components already in \a this.
4996 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
4998 DataArray *arr=getOrCreateAndGetArray();
4999 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
5003 * Returns info on components of \a this field.
5004 * \return const std::vector<std::string>& - a sequence of strings each being an
5005 * information on _i_-th component.
5007 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
5009 const DataArray *arr=getOrCreateAndGetArray();
5010 return arr->getInfoOnComponents();
5014 * Returns a mutable info on components of \a this field.
5015 * \return std::vector<std::string>& - a sequence of strings each being an
5016 * information on _i_-th component.
5018 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
5020 DataArray *arr=getOrCreateAndGetArray();
5021 return arr->getInfoOnComponents();
5024 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const
5026 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5028 const MEDFileFieldPerMesh *fpm(*it);
5031 if(fpm->presenceOfMultiDiscPerGeoType())
5037 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfStructureElements() const
5039 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5040 if((*it).isNotNull())
5041 if((*it)->presenceOfStructureElements())
5046 bool MEDFileAnyTypeField1TSWithoutSDA::onlyStructureElements() const
5048 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5049 if((*it).isNotNull())
5050 if(!(*it)->onlyStructureElements())
5055 void MEDFileAnyTypeField1TSWithoutSDA::killStructureElements()
5057 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5058 if((*it).isNotNull())
5059 (*it)->killStructureElements();
5062 void MEDFileAnyTypeField1TSWithoutSDA::keepOnlyStructureElements()
5064 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5065 if((*it).isNotNull())
5066 (*it)->keepOnlyStructureElements();
5069 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh(const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5071 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 !";
5072 if(_field_per_mesh.empty())
5073 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is empty ! Nothing to extract !");
5074 if(_field_per_mesh.size()>1)
5075 throw INTERP_KERNEL::Exception(MSG0);
5076 if(_field_per_mesh[0].isNull())
5077 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is inconsistent !");
5078 const MEDFileFieldPerMesh *pm(_field_per_mesh[0]);
5079 std::set<TypeOfField> types;
5080 pm->fillTypesOfFieldAvailable(types);
5082 throw INTERP_KERNEL::Exception(MSG0);
5083 TypeOfField type(*types.begin());
5084 int meshDimRelToMax(0);
5089 int myDim(std::numeric_limits<int>::max());
5090 bool isUnique(pm->isUniqueLevel(myDim));
5092 throw INTERP_KERNEL::Exception(MSG0);
5093 meshDimRelToMax=myDim-mesh->getMeshDimension();
5094 if(meshDimRelToMax>0)
5095 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the mesh attached to field is not compatible with the field !");
5097 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,0/*renumPol*/,glob,mesh,arrOut,nasc);
5101 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5102 * \param [in] type - a spatial discretization of the new field.
5103 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5104 * \param [in] mName - a name of the supporting mesh.
5105 * \param [in] renumPol - specifies how to permute values of the result field according to
5106 * the optional numbers of cells and nodes, if any. The valid values are
5107 * - 0 - do not permute.
5108 * - 1 - permute cells.
5109 * - 2 - permute nodes.
5110 * - 3 - permute cells and nodes.
5112 * \param [in] glob - the global data storing profiles and localization.
5113 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5114 * caller is to delete this field using decrRef() as it is no more needed.
5115 * \throw If the MED file is not readable.
5116 * \throw If there is no mesh named \a mName in the MED file.
5117 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5118 * \throw If no field of \a this is lying on the mesh \a mName.
5119 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5121 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5123 MCAuto<MEDFileMesh> mm;
5125 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
5127 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
5128 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
5132 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5133 * \param [in] type - a spatial discretization of the new field.
5134 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5135 * \param [in] renumPol - specifies how to permute values of the result field according to
5136 * the optional numbers of cells and nodes, if any. The valid values are
5137 * - 0 - do not permute.
5138 * - 1 - permute cells.
5139 * - 2 - permute nodes.
5140 * - 3 - permute cells and nodes.
5142 * \param [in] glob - the global data storing profiles and localization.
5143 * \param [in] mesh - the supporting mesh.
5144 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5145 * caller is to delete this field using decrRef() as it is no more needed.
5146 * \throw If the MED file is not readable.
5147 * \throw If no field of \a this is lying on \a mesh.
5148 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5149 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5151 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5153 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax,false));
5154 const DataArrayInt *d(mesh->getNumberFieldAtLevel(meshDimRelToMax)),*e(mesh->getNumberFieldAtLevel(1));
5155 if(meshDimRelToMax==1)
5156 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
5157 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
5161 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
5163 * \param [in] type - a spatial discretization of the new field.
5164 * \param [in] mName - a name of the supporting mesh.
5165 * \param [in] renumPol - specifies how to permute values of the result field according to
5166 * the optional numbers of cells and nodes, if any. The valid values are
5167 * - 0 - do not permute.
5168 * - 1 - permute cells.
5169 * - 2 - permute nodes.
5170 * - 3 - permute cells and nodes.
5172 * \param [in] glob - the global data storing profiles and localization.
5173 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5174 * caller is to delete this field using decrRef() as it is no more needed.
5175 * \throw If the MED file is not readable.
5176 * \throw If there is no mesh named \a mName in the MED file.
5177 * \throw If there are no mesh entities in the mesh.
5178 * \throw If no field values of the given \a type are available.
5180 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5182 MCAuto<MEDFileMesh> mm;
5184 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
5186 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
5187 int absDim=getDimension();
5188 int meshDimRelToMax=absDim-mm->getMeshDimension();
5189 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
5193 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5194 * \param [in] type - a spatial discretization of the new field.
5195 * \param [in] renumPol - specifies how to permute values of the result field according to
5196 * the optional numbers of cells and nodes, if any. The valid values are
5197 * - 0 - do not permute.
5198 * - 1 - permute cells.
5199 * - 2 - permute nodes.
5200 * - 3 - permute cells and nodes.
5202 * \param [in] glob - the global data storing profiles and localization.
5203 * \param [in] mesh - the supporting mesh.
5204 * \param [in] cellRenum - the cell numbers array used for permutation of the result
5205 * field according to \a renumPol.
5206 * \param [in] nodeRenum - the node numbers array used for permutation of the result
5207 * field according to \a renumPol.
5208 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5209 * caller is to delete this field using decrRef() as it is no more needed.
5210 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5211 * \throw If no field of \a this is lying on \a mesh.
5212 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5214 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
5216 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
5217 int meshId=getMeshIdFromMeshName(mesh->getName());
5219 MCAuto<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
5224 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5231 throw INTERP_KERNEL::Exception(msg1);
5232 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5235 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
5237 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5238 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
5239 throw INTERP_KERNEL::Exception(oss.str());
5241 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
5242 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
5243 std::vector<DataArray *> arrOut2(1,arrOut);
5244 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
5245 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
5246 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
5253 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5255 throw INTERP_KERNEL::Exception(msg1);
5258 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
5260 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5261 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
5262 throw INTERP_KERNEL::Exception(oss.str());
5264 MCAuto<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
5265 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
5266 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
5267 ret->renumberNodes(nodeRenumSafe->getConstPointer());
5272 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
5277 * Returns values and a profile of the field of a given type lying on a given support.
5278 * \param [in] type - a spatial discretization of the field.
5279 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5280 * \param [in] mesh - the supporting mesh.
5281 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
5282 * field of interest lies on. If the field lies on all entities of the given
5283 * dimension, all ids in \a pfl are zero. The caller is to delete this array
5284 * using decrRef() as it is no more needed.
5285 * \param [in] glob - the global data storing profiles and localization.
5286 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
5287 * field. The caller is to delete this array using decrRef() as it is no more needed.
5288 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
5289 * \throw If no field of \a this is lying on \a mesh.
5290 * \throw If no field values of the given \a type are available.
5292 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
5294 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
5295 int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
5296 MCAuto<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
5297 ret->setName(nasc.getName().c_str());
5301 //= MEDFileField1TSWithoutSDA
5304 * Throws if a given value is not a valid (non-extended) relative dimension.
5305 * \param [in] meshDimRelToMax - the relative dimension value.
5306 * \throw If \a meshDimRelToMax > 0.
5308 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
5310 if(meshDimRelToMax>0)
5311 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
5315 * Checks if elements of a given mesh are in the order suitable for writing
5316 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
5317 * vector describing types of elements and their number.
5318 * \param [in] mesh - the mesh to check.
5319 * \return std::vector<int> - a vector holding for each element type (1) item of
5320 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
5321 * These values are in full-interlace mode.
5322 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
5324 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
5327 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
5328 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
5329 int nbOfTypes=geoTypes.size();
5330 std::vector<int> code(3*nbOfTypes);
5331 MCAuto<DataArrayInt> arr1=DataArrayInt::New();
5332 arr1->alloc(nbOfTypes,1);
5333 int *arrPtr=arr1->getPointer();
5334 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
5335 for(int i=0;i<nbOfTypes;i++,it++)
5336 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
5337 MCAuto<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
5338 const int *arrPtr2=arr2->getConstPointer();
5340 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
5343 int nbCells=mesh->getNumberOfCellsWithType(*it);
5344 code[3*pos]=(int)(*it);
5345 code[3*pos+1]=nbCells;
5346 code[3*pos+2]=-1;//no profiles
5348 std::vector<const DataArrayInt *> idsPerType;//no profiles
5349 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
5353 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
5358 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5360 return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5364 * Returns all attributes and values of parts of \a this field lying on a given mesh.
5365 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
5366 * item of every of returned sequences refers to the _i_-th part of \a this field.
5367 * Thus all sequences returned by this method are of the same length equal to number
5368 * of different types of supporting entities.<br>
5369 * A field part can include sub-parts with several different spatial discretizations,
5370 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
5371 * for example. Hence, some of the returned sequences contains nested sequences, and an item
5372 * of a nested sequence corresponds to a type of spatial discretization.<br>
5373 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
5374 * The overhead is due to selecting values into new instances of DataArrayDouble.
5375 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
5376 * for the case with only one underlying mesh. (Actually, the number of meshes is
5377 * not checked if \a mname == \c NULL).
5378 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
5379 * a field part is returned.
5380 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
5381 * A field part can include sub-parts with several different spatial discretizations,
5382 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and
5383 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT" for example.
5384 * This sequence is of the same length as \a types.
5385 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
5386 * discretization. A profile name can be empty.
5387 * Length of this and of nested sequences is the same as that of \a typesF.
5388 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
5389 * discretization. A localization name can be empty.
5390 * Length of this and of nested sequences is the same as that of \a typesF.
5391 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
5392 * per each type of spatial discretization within one mesh entity type.
5393 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
5394 * Length of this and of nested sequences is the same as that of \a typesF.
5395 * \throw If no field is lying on \a mname.
5397 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
5401 meshId=getMeshIdFromMeshName(mname);
5403 if(_field_per_mesh.empty())
5404 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
5405 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
5406 int nbOfRet=ret0.size();
5407 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
5408 for(int i=0;i<nbOfRet;i++)
5410 const std::vector< std::pair<int,int> >& p=ret0[i];
5411 int nbOfRet1=p.size();
5412 ret[i].resize(nbOfRet1);
5413 for(int j=0;j<nbOfRet1;j++)
5415 DataArrayDouble *tmp=_arr->selectByTupleIdSafeSlice(p[j].first,p[j].second,1);
5422 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
5427 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
5429 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
5430 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5431 ret->deepCpyLeavesFrom(*this);
5432 const DataArrayDouble *arr(_arr);
5435 MCAuto<DataArrayInt> arr2(arr->convertToIntArr());
5436 ret->setArray(arr2);
5442 * Returns a pointer to the underground DataArrayDouble instance and a
5443 * sequence describing parameters of a support of each part of \a this field. The
5444 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5445 * direct access to the field values. This method is intended for the field lying on one
5447 * \param [in,out] entries - the sequence describing parameters of a support of each
5448 * part of \a this field. Each item of this sequence consists of two parts. The
5449 * first part describes a type of mesh entity and an id of discretization of a
5450 * current field part. The second part describes a range of values [begin,end)
5451 * within the returned array relating to the current field part.
5452 * \return DataArrayDouble * - the pointer to the field values array.
5453 * \throw If the number of underlying meshes is not equal to 1.
5454 * \throw If no field values are available.
5455 * \sa getUndergroundDataArray()
5457 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5459 if(_field_per_mesh.size()!=1)
5460 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5461 if(_field_per_mesh[0]==0)
5462 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5463 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5464 return getUndergroundDataArrayTemplate();
5468 * Returns a pointer to the underground DataArrayDouble instance and a
5469 * sequence describing parameters of a support of each part of \a this field. The
5470 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5471 * direct access to the field values. This method is intended for the field lying on one
5473 * \param [in,out] entries - the sequence describing parameters of a support of each
5474 * part of \a this field. Each item of this sequence consists of two parts. The
5475 * first part describes a type of mesh entity and an id of discretization of a
5476 * current field part. The second part describes a range of values [begin,end)
5477 * within the returned array relating to the current field part.
5478 * \return DataArrayDouble * - the pointer to the field values array.
5479 * \throw If the number of underlying meshes is not equal to 1.
5480 * \throw If no field values are available.
5481 * \sa getUndergroundDataArray()
5483 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5485 return getUndergroundDataArrayDoubleExt(entries);
5488 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<double>(fieldName,csit,iteration,order)
5490 DataArrayDouble *arr(getOrCreateAndGetArrayTemplate());
5491 arr->setInfoAndChangeNbOfCompo(infos);
5494 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<double>()
5498 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
5500 MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
5501 ret->deepCpyLeavesFrom(*this);
5505 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCopy() const
5507 MCAuto<MEDFileField1TSWithoutSDA> ret(shallowCpy());
5508 if(_arr.isNotNull())
5509 ret->_arr=_arr->deepCopy();
5513 //= MEDFileIntField1TSWithoutSDA
5515 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5517 return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5520 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<int>()
5524 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order,
5525 const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<int>(fieldName,csit,iteration,order)
5527 DataArrayInt *arr(getOrCreateAndGetArrayTemplate());
5528 arr->setInfoAndChangeNbOfCompo(infos);
5531 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
5536 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const
5538 MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
5539 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5540 ret->deepCpyLeavesFrom(*this);
5541 const DataArrayInt *arr(_arr);
5544 MCAuto<DataArrayDouble> arr2(arr->convertToDblArr());
5545 ret->setArray(arr2);
5551 * Returns a pointer to the underground DataArrayInt instance and a
5552 * sequence describing parameters of a support of each part of \a this field. The
5553 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5554 * direct access to the field values. This method is intended for the field lying on one
5556 * \param [in,out] entries - the sequence describing parameters of a support of each
5557 * part of \a this field. Each item of this sequence consists of two parts. The
5558 * first part describes a type of mesh entity and an id of discretization of a
5559 * current field part. The second part describes a range of values [begin,end)
5560 * within the returned array relating to the current field part.
5561 * \return DataArrayInt * - the pointer to the field values array.
5562 * \throw If the number of underlying meshes is not equal to 1.
5563 * \throw If no field values are available.
5564 * \sa getUndergroundDataArray()
5566 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5568 return getUndergroundDataArrayIntExt(entries);
5572 * Returns a pointer to the underground DataArrayInt instance and a
5573 * sequence describing parameters of a support of each part of \a this field. The
5574 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5575 * direct access to the field values. This method is intended for the field lying on one
5577 * \param [in,out] entries - the sequence describing parameters of a support of each
5578 * part of \a this field. Each item of this sequence consists of two parts. The
5579 * first part describes a type of mesh entity and an id of discretization of a
5580 * current field part. The second part describes a range of values [begin,end)
5581 * within the returned array relating to the current field part.
5582 * \return DataArrayInt * - the pointer to the field values array.
5583 * \throw If the number of underlying meshes is not equal to 1.
5584 * \throw If no field values are available.
5585 * \sa getUndergroundDataArray()
5587 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5589 if(_field_per_mesh.size()!=1)
5590 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5591 if(_field_per_mesh[0]==0)
5592 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5593 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5594 return getUndergroundDataArrayTemplate();
5597 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5599 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5600 ret->deepCpyLeavesFrom(*this);
5604 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCopy() const
5606 MCAuto<MEDFileIntField1TSWithoutSDA> ret(shallowCpy());
5607 if(_arr.isNotNull())
5608 ret->_arr=_arr->deepCopy();
5612 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5616 //= MEDFileAnyTypeField1TS
5618 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
5620 med_field_type typcha;
5622 std::vector<std::string> infos;
5623 std::string dtunit,fieldName;
5624 LocateField2(fid,0,true,fieldName,typcha,infos,dtunit);
5625 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5630 ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5635 ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5640 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] !";
5641 throw INTERP_KERNEL::Exception(oss.str());
5644 ret->setDtUnit(dtunit.c_str());
5645 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5647 med_int numdt,numit;
5649 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5650 ret->setTime(numdt,numit,dt);
5653 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5655 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5659 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
5660 try:MEDFileFieldGlobsReal(fid)
5662 _content=BuildContentFrom(fid,loadAll,ms);
5665 catch(INTERP_KERNEL::Exception& e)
5670 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5672 med_field_type typcha;
5673 std::vector<std::string> infos;
5676 int nbSteps=LocateField(fid,fieldName,iii,typcha,infos,dtunit);
5677 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5682 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5687 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5692 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] !";
5693 throw INTERP_KERNEL::Exception(oss.str());
5696 ret->setDtUnit(dtunit.c_str());
5697 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5701 std::ostringstream oss; oss << "MEDFileField1TS(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5702 throw INTERP_KERNEL::Exception(oss.str());
5705 med_int numdt,numit;
5707 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5708 ret->setTime(numdt,numit,dt);
5711 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5713 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5717 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5718 try:MEDFileFieldGlobsReal(fid)
5720 _content=BuildContentFrom(fid,fieldName,loadAll,ms);
5723 catch(INTERP_KERNEL::Exception& e)
5728 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c)
5731 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5732 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5734 MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
5735 ret->_content=c; c->incrRef();
5738 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5740 MCAuto<MEDFileIntField1TS> ret(MEDFileIntField1TS::New());
5741 ret->_content=c; c->incrRef();
5744 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5747 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, med_idt fid)
5749 MEDFileAnyTypeField1TS *ret(BuildNewInstanceFromContent(c));
5750 ret->setFileName(FileNameFromFID(fid));
5754 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
5756 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5757 return New(fid,loadAll);
5760 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, bool loadAll)
5762 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
5763 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5764 ret->loadGlobals(fid);
5768 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
5770 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5771 return New(fid,fieldName,loadAll);
5774 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
5776 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0));
5777 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5778 ret->loadGlobals(fid);
5782 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
5784 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5785 return New(fid,fieldName,iteration,order,loadAll);
5788 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
5790 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0));
5791 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5792 ret->loadGlobals(fid);
5796 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5798 med_field_type typcha;
5799 std::vector<std::string> infos;
5802 int nbOfStep2(LocateField(fid,fieldName,iii,typcha,infos,dtunit));
5803 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5808 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5813 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5818 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] !";
5819 throw INTERP_KERNEL::Exception(oss.str());
5822 ret->setDtUnit(dtunit.c_str());
5823 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5826 std::vector< std::pair<int,int> > dtits(nbOfStep2);
5827 for(int i=0;i<nbOfStep2 && !found;i++)
5829 med_int numdt,numit;
5831 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt));
5832 if(numdt==iteration && numit==order)
5838 dtits[i]=std::pair<int,int>(numdt,numit);
5842 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available iterations are : ";
5843 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5844 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5845 throw INTERP_KERNEL::Exception(oss.str());
5848 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5850 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5854 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5855 try:MEDFileFieldGlobsReal(fid)
5857 _content=BuildContentFrom(fid,fieldName,iteration,order,loadAll,ms);
5860 catch(INTERP_KERNEL::Exception& e)
5866 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5867 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5869 * \warning this is a shallow copy constructor
5871 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5873 if(!shallowCopyOfContent)
5875 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5876 otherPtr->incrRef();
5877 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5881 _content=other.shallowCpy();
5885 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)
5889 int nbFields=MEDnField(fid);
5890 if(fieldIdCFormat>=nbFields)
5892 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << FileNameFromFID(fid) << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5893 throw INTERP_KERNEL::Exception(oss.str());
5896 int ncomp(MEDfieldnComponent(fid,fieldIdCFormat+1));
5897 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5898 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5899 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5900 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5901 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5904 MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep));
5905 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5906 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5907 infos.clear(); infos.resize(ncomp);
5908 for(int j=0;j<ncomp;j++)
5909 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5914 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5917 * \return in case of success the number of time steps available for the field with name \a fieldName.
5919 int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const std::string& fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
5921 int nbFields=MEDnField(fid);
5923 std::vector<std::string> fns(nbFields);
5925 for(int i=0;i<nbFields && !found;i++)
5928 nbOfStep2=LocateField2(fid,i,false,tmp,typcha,infos,dtunitOut);
5930 found=(tmp==fieldName);
5936 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available fields are : ";
5937 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5938 oss << "\"" << *it << "\" ";
5939 throw INTERP_KERNEL::Exception(oss.str());
5945 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5946 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5947 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5948 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5949 * to keep a valid instance.
5950 * 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.
5951 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5952 * 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.
5954 * \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.
5955 * \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.
5956 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5957 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5958 * \param [in] newLocName is the new localization name.
5959 * \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.
5960 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5962 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
5964 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5965 std::string oldPflName=disc->getProfile();
5966 std::vector<std::string> vv=getPflsReallyUsedMulti();
5967 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5968 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5970 disc->setProfile(newPflName);
5971 DataArrayInt *pfl=getProfile(oldPflName.c_str());
5972 pfl->setName(newPflName);
5976 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5977 throw INTERP_KERNEL::Exception(oss.str());
5982 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5983 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5984 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5985 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5986 * to keep a valid instance.
5987 * 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.
5988 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5989 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5990 * 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.
5992 * \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.
5993 * \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.
5994 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5995 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5996 * \param [in] newLocName is the new localization name.
5997 * \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.
5998 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
6000 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
6002 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6003 std::string oldLocName=disc->getLocalization();
6004 std::vector<std::string> vv=getLocsReallyUsedMulti();
6005 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
6006 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
6008 disc->setLocalization(newLocName);
6009 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
6010 loc.setName(newLocName);
6014 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
6015 throw INTERP_KERNEL::Exception(oss.str());
6019 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
6021 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
6023 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
6027 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
6029 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
6031 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
6036 * This method alloc the arrays and load potentially huge arrays contained in this field.
6037 * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
6038 * This method can be also called to refresh or reinit values from a file.
6040 * \throw If the fileName is not set or points to a non readable MED file.
6041 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
6043 void MEDFileAnyTypeField1TS::loadArrays()
6045 if(getFileName().empty())
6046 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
6047 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
6048 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
6052 * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
6053 * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
6054 * this method does not throw if \a this does not come from file read.
6056 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
6058 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
6060 if(!getFileName().empty())
6062 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
6063 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
6068 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
6069 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
6070 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
6072 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
6074 void MEDFileAnyTypeField1TS::unloadArrays()
6076 contentNotNullBase()->unloadArrays();
6080 * 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.
6081 * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
6082 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
6084 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
6086 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
6088 if(!getFileName().empty())
6089 contentNotNullBase()->unloadArrays();
6092 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
6094 int nbComp(getNumberOfComponents());
6095 INTERP_KERNEL::AutoPtr<char> comp(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
6096 INTERP_KERNEL::AutoPtr<char> unit(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
6097 for(int i=0;i<nbComp;i++)
6099 std::string info=getInfo()[i];
6101 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
6102 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
6103 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
6105 if(getName().empty())
6106 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
6107 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
6108 writeGlobals(fid,*this);
6109 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
6112 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
6114 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
6117 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
6119 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
6120 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
6125 * Returns a string describing \a this field. This string is outputted
6126 * by \c print Python command.
6128 std::string MEDFileAnyTypeField1TS::simpleRepr() const
6130 std::ostringstream oss;
6131 contentNotNullBase()->simpleRepr(0,oss,-1);
6132 simpleReprGlobs(oss);
6137 * This method returns all profiles whose name is non empty used.
6138 * \b WARNING If profile is used several times it will be reported \b only \b once.
6139 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
6141 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
6143 return contentNotNullBase()->getPflsReallyUsed2();
6147 * This method returns all localizations whose name is non empty used.
6148 * \b WARNING If localization is used several times it will be reported \b only \b once.
6150 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
6152 return contentNotNullBase()->getLocsReallyUsed2();
6156 * This method returns all profiles whose name is non empty used.
6157 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
6159 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
6161 return contentNotNullBase()->getPflsReallyUsedMulti2();
6165 * This method returns all localizations whose name is non empty used.
6166 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
6168 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
6170 return contentNotNullBase()->getLocsReallyUsedMulti2();
6173 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6175 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
6178 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6180 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
6183 int MEDFileAnyTypeField1TS::getDimension() const
6185 return contentNotNullBase()->getDimension();
6188 int MEDFileAnyTypeField1TS::getIteration() const
6190 return contentNotNullBase()->getIteration();
6193 int MEDFileAnyTypeField1TS::getOrder() const
6195 return contentNotNullBase()->getOrder();
6198 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
6200 return contentNotNullBase()->getTime(iteration,order);
6203 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
6205 contentNotNullBase()->setTime(iteration,order,val);
6208 std::string MEDFileAnyTypeField1TS::getName() const
6210 return contentNotNullBase()->getName();
6213 void MEDFileAnyTypeField1TS::setName(const std::string& name)
6215 contentNotNullBase()->setName(name);
6218 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
6220 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
6223 std::string MEDFileAnyTypeField1TS::getDtUnit() const
6225 return contentNotNullBase()->getDtUnit();
6228 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
6230 contentNotNullBase()->setDtUnit(dtUnit);
6233 std::string MEDFileAnyTypeField1TS::getMeshName() const
6235 return contentNotNullBase()->getMeshName();
6238 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
6240 contentNotNullBase()->setMeshName(newMeshName);
6243 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
6245 return contentNotNullBase()->changeMeshNames(modifTab);
6248 int MEDFileAnyTypeField1TS::getMeshIteration() const
6250 return contentNotNullBase()->getMeshIteration();
6253 int MEDFileAnyTypeField1TS::getMeshOrder() const
6255 return contentNotNullBase()->getMeshOrder();
6258 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
6260 return contentNotNullBase()->getNumberOfComponents();
6263 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
6265 return contentNotNullBase()->isDealingTS(iteration,order);
6268 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
6270 return contentNotNullBase()->getDtIt();
6273 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
6275 contentNotNullBase()->fillIteration(p);
6278 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
6280 contentNotNullBase()->fillTypesOfFieldAvailable(types);
6283 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
6285 contentNotNullBase()->setInfo(infos);
6288 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
6290 return contentNotNullBase()->getInfo();
6292 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
6294 return contentNotNullBase()->getInfo();
6297 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
6299 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
6302 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
6304 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6307 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
6309 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6312 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
6314 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
6317 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
6319 return contentNotNullBase()->getTypesOfFieldAvailable();
6322 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,
6323 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6325 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
6329 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
6330 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
6331 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
6333 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
6335 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6337 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
6338 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
6339 std::size_t sz(contentsSplit.size());
6340 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6341 for(std::size_t i=0;i<sz;i++)
6343 ret[i]=shallowCpy();
6344 ret[i]->_content=contentsSplit[i];
6350 * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
6351 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6353 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
6355 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6357 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
6358 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
6359 std::size_t sz(contentsSplit.size());
6360 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6361 for(std::size_t i=0;i<sz;i++)
6363 ret[i]=shallowCpy();
6364 ret[i]->_content=contentsSplit[i];
6370 * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this.
6371 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6373 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const
6375 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6377 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !");
6378 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
6379 std::size_t sz(contentsSplit.size());
6380 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6381 for(std::size_t i=0;i<sz;i++)
6383 ret[i]=shallowCpy();
6384 ret[i]->_content=contentsSplit[i];
6389 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCopy() const
6391 MCAuto<MEDFileAnyTypeField1TS> ret=shallowCpy();
6392 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
6393 ret->_content=_content->deepCopy();
6394 ret->deepCpyGlobs(*this);
6398 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
6400 return contentNotNullBase()->copyTinyInfoFrom(field,arr);
6406 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6407 * the first field that has been read from a specified MED file.
6408 * \param [in] fileName - the name of the MED file to read.
6409 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6410 * is to delete this field using decrRef() as it is no more needed.
6411 * \throw If reading the file fails.
6413 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll)
6415 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6416 return New(fid,loadAll);
6419 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, bool loadAll)
6421 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,loadAll,0));
6422 ret->contentNotNull();
6427 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6428 * a given field that has been read from a specified MED file.
6429 * \param [in] fileName - the name of the MED file to read.
6430 * \param [in] fieldName - the name of the field to read.
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.
6436 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6438 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6439 return New(fid,fieldName,loadAll);
6442 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
6444 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,fieldName,loadAll,0));
6445 ret->contentNotNull();
6450 * Returns a new instance of MEDFileField1TS holding data of a given time step of
6451 * a given field that has been read from a specified MED file.
6452 * \param [in] fileName - the name of the MED file to read.
6453 * \param [in] fieldName - the name of the field to read.
6454 * \param [in] iteration - the iteration number of a required time step.
6455 * \param [in] order - the iteration order number of required time step.
6456 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6457 * is to delete this field using decrRef() as it is no more needed.
6458 * \throw If reading the file fails.
6459 * \throw If there is no field named \a fieldName in the file.
6460 * \throw If the required time step is missing from the file.
6462 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6464 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6465 return New(fid,fieldName,iteration,order,loadAll);
6468 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
6470 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,fieldName,iteration,order,loadAll,0));
6471 ret->contentNotNull();
6476 * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6477 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6479 * Returns a new instance of MEDFileField1TS holding either a shallow copy
6480 * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
6481 * \warning this is a shallow copy constructor
6482 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
6483 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
6484 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6485 * is to delete this field using decrRef() as it is no more needed.
6487 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6489 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(other,shallowCopyOfContent));
6490 ret->contentNotNull();
6495 * Returns a new empty instance of MEDFileField1TS.
6496 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6497 * is to delete this field using decrRef() as it is no more needed.
6499 MEDFileField1TS *MEDFileField1TS::New()
6501 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS);
6502 ret->contentNotNull();
6507 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
6508 * following the given input policy.
6510 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6511 * By default (true) the globals are deeply copied.
6512 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
6514 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
6516 MCAuto<MEDFileIntField1TS> ret;
6517 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6520 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
6522 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
6523 MCAuto<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
6524 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc));
6527 ret=MEDFileIntField1TS::New();
6529 ret->deepCpyGlobs(*this);
6531 ret->shallowCpyGlobs(*this);
6535 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const
6537 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6539 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
6540 const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
6542 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 !");
6546 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull()
6548 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6550 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
6551 MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
6553 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 !");
6557 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
6560 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
6562 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
6563 DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6565 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6566 f->setArray(arrOutC);
6569 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MCAuto<DataArray>& arr)
6572 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
6573 DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6575 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6581 * Return an extraction of \a this using \a extractDef map to specify the extraction.
6582 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
6584 * \return A new object that the caller is responsible to deallocate.
6585 * \sa MEDFileUMesh::deduceNodeSubPartFromCellSubPart , MEDFileUMesh::extractPart
6587 MEDFileField1TS *MEDFileField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
6590 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : input mesh is NULL !");
6591 MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
6592 std::vector<TypeOfField> tof(getTypesOfFieldAvailable());
6593 for(std::vector<TypeOfField>::const_iterator it0=tof.begin();it0!=tof.end();it0++)
6595 if((*it0)!=ON_NODES)
6597 std::vector<int> levs;
6598 getNonEmptyLevels(mm->getName(),levs);
6599 for(std::vector<int>::const_iterator lev=levs.begin();lev!=levs.end();lev++)
6601 std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(*lev));
6602 if(it2!=extractDef.end())
6604 MCAuto<DataArrayInt> t((*it2).second);
6606 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6607 MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_CELLS,(*lev),mm));
6608 MCAuto<MEDCouplingFieldDouble> fOut(f->buildSubPart(t));
6609 ret->setFieldNoProfileSBT(fOut);
6615 std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(1));
6616 if(it2==extractDef.end())
6617 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a NODE field and no extract array available for NODE !");
6618 MCAuto<DataArrayInt> t((*it2).second);
6620 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6621 MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_NODES,0,mm));
6622 MCAuto<MEDCouplingFieldDouble> fOut(f->deepCopy());
6623 DataArrayDouble *arr(f->getArray());
6624 MCAuto<DataArrayDouble> newArr(arr->selectByTupleIdSafe(t->begin(),t->end()));
6625 fOut->setArray(newArr);
6626 ret->setFieldNoProfileSBT(fOut);
6632 MEDFileField1TS::MEDFileField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
6633 try:MEDFileAnyTypeField1TS(fid,loadAll,ms)
6636 catch(INTERP_KERNEL::Exception& e)
6639 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6640 try:MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms)
6643 catch(INTERP_KERNEL::Exception& e)
6646 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6647 try:MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms)
6650 catch(INTERP_KERNEL::Exception& e)
6654 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6655 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6657 * \warning this is a shallow copy constructor
6659 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6660 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6663 catch(INTERP_KERNEL::Exception& e)
6666 MEDFileField1TS::MEDFileField1TS()
6668 _content=new MEDFileField1TSWithoutSDA;
6672 * 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
6673 * method should be called (getFieldOnMeshAtLevel for example).
6674 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
6676 * \param [in] mesh - the mesh the field is lying on
6677 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6678 * caller is to delete this field using decrRef() as it is no more needed.
6680 MEDCouplingFieldDouble *MEDFileField1TS::field(const MEDFileMesh *mesh) const
6682 MCAuto<DataArray> arrOut;
6683 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
6684 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6689 * Returns a new MEDCouplingFieldDouble of a given type lying on
6690 * mesh entities of a given dimension of the first mesh in MED file. If \a this field
6691 * has not been constructed via file reading, an exception is thrown.
6692 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6693 * \param [in] type - a spatial discretization of interest.
6694 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6695 * \param [in] renumPol - specifies how to permute values of the result field according to
6696 * the optional numbers of cells and nodes, if any. The valid values are
6697 * - 0 - do not permute.
6698 * - 1 - permute cells.
6699 * - 2 - permute nodes.
6700 * - 3 - permute cells and nodes.
6702 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6703 * caller is to delete this field using decrRef() as it is no more needed.
6704 * \throw If \a this field has not been constructed via file reading.
6705 * \throw If the MED file is not readable.
6706 * \throw If there is no mesh in the MED file.
6707 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6708 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6709 * \sa getFieldOnMeshAtLevel()
6711 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6713 if(getFileName().empty())
6714 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6715 MCAuto<DataArray> arrOut;
6716 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
6717 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6722 * Returns a new MEDCouplingFieldDouble of a given type lying on
6723 * the top level cells of the first mesh in MED file. If \a this field
6724 * has not been constructed via file reading, an exception is thrown.
6725 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6726 * \param [in] type - a spatial discretization of interest.
6727 * \param [in] renumPol - specifies how to permute values of the result field according to
6728 * the optional numbers of cells and nodes, if any. The valid values are
6729 * - 0 - do not permute.
6730 * - 1 - permute cells.
6731 * - 2 - permute nodes.
6732 * - 3 - permute cells and nodes.
6734 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6735 * caller is to delete this field using decrRef() as it is no more needed.
6736 * \throw If \a this field has not been constructed via file reading.
6737 * \throw If the MED file is not readable.
6738 * \throw If there is no mesh in the MED file.
6739 * \throw If no field values of the given \a type.
6740 * \throw If no field values lying on the top level support.
6741 * \sa getFieldAtLevel()
6743 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
6745 if(getFileName().empty())
6746 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6747 MCAuto<DataArray> arrOut;
6748 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
6749 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6754 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6755 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6756 * \param [in] type - a spatial discretization of the new field.
6757 * \param [in] mesh - the supporting mesh.
6758 * \param [in] renumPol - specifies how to permute values of the result field according to
6759 * the optional numbers of cells and nodes, if any. The valid values are
6760 * - 0 - do not permute.
6761 * - 1 - permute cells.
6762 * - 2 - permute nodes.
6763 * - 3 - permute cells and nodes.
6765 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6766 * caller is to delete this field using decrRef() as it is no more needed.
6767 * \throw If no field of \a this is lying on \a mesh.
6768 * \throw If the mesh is empty.
6769 * \throw If no field values of the given \a type are available.
6770 * \sa getFieldAtLevel()
6771 * \sa getFieldOnMeshAtLevel()
6773 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
6775 MCAuto<DataArray> arrOut;
6776 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
6777 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6782 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6783 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6784 * \param [in] type - a spatial discretization of interest.
6785 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6786 * \param [in] mesh - the supporting mesh.
6787 * \param [in] renumPol - specifies how to permute values of the result field according to
6788 * the optional numbers of cells and nodes, if any. The valid values are
6789 * - 0 - do not permute.
6790 * - 1 - permute cells.
6791 * - 2 - permute nodes.
6792 * - 3 - permute cells and nodes.
6794 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6795 * caller is to delete this field using decrRef() as it is no more needed.
6796 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6797 * \throw If no field of \a this is lying on \a mesh.
6798 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6799 * \sa getFieldAtLevel()
6800 * \sa getFieldOnMeshAtLevel()
6802 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
6804 MCAuto<DataArray> arrOut;
6805 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
6806 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6811 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6812 * This method is called "Old" because in MED3 norm a field has only one meshName
6813 * attached, so this method is for readers of MED2 files. If \a this field
6814 * has not been constructed via file reading, an exception is thrown.
6815 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6816 * \param [in] type - a spatial discretization of interest.
6817 * \param [in] mName - a name of the supporting mesh.
6818 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6819 * \param [in] renumPol - specifies how to permute values of the result field according to
6820 * the optional numbers of cells and nodes, if any. The valid values are
6821 * - 0 - do not permute.
6822 * - 1 - permute cells.
6823 * - 2 - permute nodes.
6824 * - 3 - permute cells and nodes.
6826 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6827 * caller is to delete this field using decrRef() as it is no more needed.
6828 * \throw If the MED file is not readable.
6829 * \throw If there is no mesh named \a mName in the MED file.
6830 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6831 * \throw If \a this field has not been constructed via file reading.
6832 * \throw If no field of \a this is lying on the mesh named \a mName.
6833 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6834 * \sa getFieldAtLevel()
6836 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
6838 if(getFileName().empty())
6839 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6840 MCAuto<DataArray> arrOut;
6841 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull()));
6842 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6847 * Returns values and a profile of the field of a given type lying on a given support.
6848 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6849 * \param [in] type - a spatial discretization of the field.
6850 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6851 * \param [in] mesh - the supporting mesh.
6852 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6853 * field of interest lies on. If the field lies on all entities of the given
6854 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6855 * using decrRef() as it is no more needed.
6856 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6857 * field. The caller is to delete this array using decrRef() as it is no more needed.
6858 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6859 * \throw If no field of \a this is lying on \a mesh.
6860 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6862 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6864 MCAuto<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6865 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
6869 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6870 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6871 * "Sort By Type"), if not, an exception is thrown.
6872 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6873 * \param [in] field - the field to add to \a this.
6874 * \throw If the name of \a field is empty.
6875 * \throw If the data array of \a field is not set.
6876 * \throw If the data array is already allocated but has different number of components
6878 * \throw If the underlying mesh of \a field has no name.
6879 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6881 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
6884 contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
6888 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6889 * can be an aggregation of several MEDCouplingFieldDouble instances.
6890 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6891 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6894 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6895 * A new profile is added only if no equal profile is missing.
6896 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6897 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
6898 * \param [in] mesh - the supporting mesh of \a field.
6899 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6900 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6901 * \throw If either \a field or \a mesh or \a profile has an empty name.
6902 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6903 * \throw If the data array of \a field is not set.
6904 * \throw If the data array of \a this is already allocated but has different number of
6905 * components than \a field.
6906 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6907 * \sa setFieldNoProfileSBT()
6909 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6912 contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6915 MEDFileField1TS *MEDFileField1TS::shallowCpy() const
6917 return new MEDFileField1TS(*this);
6920 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const
6922 return contentNotNull()->getUndergroundDataArrayTemplate();
6925 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
6927 return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
6930 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6931 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6933 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6936 //= MEDFileIntField1TS
6938 MEDFileIntField1TS *MEDFileIntField1TS::New()
6940 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS);
6941 ret->contentNotNull();
6945 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll)
6947 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6948 return MEDFileIntField1TS::New(fid,loadAll);
6951 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, bool loadAll)
6953 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,loadAll,0));
6954 ret->contentNotNull();
6958 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6960 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6961 return MEDFileIntField1TS::New(fid,fieldName,loadAll);
6964 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
6966 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,loadAll,0));
6967 ret->contentNotNull();
6971 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6973 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6974 return MEDFileIntField1TS::New(fid,fieldName,iteration,order,loadAll);
6977 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
6979 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,iteration,order,loadAll,0));
6980 ret->contentNotNull();
6984 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6986 MCAuto<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6987 ret->contentNotNull();
6991 MEDFileIntField1TS::MEDFileIntField1TS()
6993 _content=new MEDFileIntField1TSWithoutSDA;
6996 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
6997 try:MEDFileAnyTypeField1TS(fid,loadAll,ms)
7000 catch(INTERP_KERNEL::Exception& e)
7003 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
7004 try:MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms)
7007 catch(INTERP_KERNEL::Exception& e)
7010 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
7011 try:MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms)
7014 catch(INTERP_KERNEL::Exception& e)
7018 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
7019 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
7021 * \warning this is a shallow copy constructor
7023 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
7027 MEDFileIntField1TS *MEDFileIntField1TS::shallowCpy() const
7029 return new MEDFileIntField1TS(*this);
7033 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
7034 * following the given input policy.
7036 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
7037 * By default (true) the globals are deeply copied.
7038 * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
7040 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const
7042 MCAuto<MEDFileField1TS> ret;
7043 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
7046 const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
7048 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
7049 MCAuto<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
7050 ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc));
7053 ret=MEDFileField1TS::New();
7055 ret->deepCpyGlobs(*this);
7057 ret->shallowCpyGlobs(*this);
7062 * Adds a MEDCouplingFieldInt to \a this. The underlying mesh of the given field is
7063 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
7064 * "Sort By Type"), if not, an exception is thrown.
7065 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7066 * \param [in] field - the field to add to \a this.
7067 * \throw If the name of \a field is empty.
7068 * \throw If the data array of \a field is not set.
7069 * \throw If the data array is already allocated but has different number of components
7071 * \throw If the underlying mesh of \a field has no name.
7072 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
7074 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldInt *field)
7076 MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
7078 contentNotNull()->setFieldNoProfileSBT(field2,field->getArray(),*this,*contentNotNull());
7082 * Adds a MEDCouplingFieldInt to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
7083 * can be an aggregation of several MEDCouplingFieldDouble instances.
7084 * The mesh support of input parameter \a field is ignored here, it can be NULL.
7085 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
7088 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
7089 * A new profile is added only if no equal profile is missing.
7090 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7091 * \param [in] field - the field to add to \a this.
7092 * \param [in] mesh - the supporting mesh of \a field.
7093 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
7094 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
7095 * \throw If either \a field or \a mesh or \a profile has an empty name.
7096 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7097 * \throw If the data array of \a field is not set.
7098 * \throw If the data array of \a this is already allocated but has different number of
7099 * components than \a field.
7100 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
7101 * \sa setFieldNoProfileSBT()
7103 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
7105 MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
7107 contentNotNull()->setFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
7110 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const
7112 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7114 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
7115 const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
7117 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 !");
7121 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
7123 if(getFileName().empty())
7124 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7125 MCAuto<DataArray> arrOut;
7126 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
7127 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7131 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MCAuto<DataArray>& arr)
7134 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
7135 DataArrayInt *arrC(dynamic_cast<DataArrayInt *>((DataArray *)arr));
7137 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
7142 MCAuto<MEDCouplingFieldInt> MEDFileIntField1TS::SetDataArrayDoubleInIntField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
7145 double t0(f->getTime(t1,t2));
7146 MCAuto<DataArrayInt> arr2(DynamicCastSafe<DataArray,DataArrayInt>(arr));
7147 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
7148 MCAuto<MEDCouplingFieldInt> ret(MEDCouplingFieldInt::New(*ft));
7149 ret->setTime(t0,t1,t2); ret->setArray(arr2);
7153 MCAuto<MEDCouplingFieldDouble> MEDFileIntField1TS::ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f)
7156 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ConvertFieldIntToFieldDouble : null input field !");
7158 double t0(f->getTime(t1,t2));
7159 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
7160 MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(*ft));
7161 ret->setTime(t0,t1,t2);
7165 MEDFileIntField1TS *MEDFileIntField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
7167 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::extractPart : not implemented yet !");
7171 * 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
7172 * method should be called (getFieldOnMeshAtLevel for example).
7173 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
7175 * \param [in] mesh - the mesh the field is lying on
7176 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
7177 * caller is to delete this field using decrRef() as it is no more needed.
7179 MEDCouplingFieldInt *MEDFileIntField1TS::field(const MEDFileMesh *mesh) const
7181 MCAuto<DataArray> arrOut;
7182 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
7183 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7188 * Returns a new MEDCouplingFieldInt of a given type lying on
7189 * the top level cells of the first mesh in MED file. If \a this field
7190 * has not been constructed via file reading, an exception is thrown.
7191 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7192 * \param [in] type - a spatial discretization of interest.
7193 * \param [in] renumPol - specifies how to permute values of the result field according to
7194 * the optional numbers of cells and nodes, if any. The valid values are
7195 * - 0 - do not permute.
7196 * - 1 - permute cells.
7197 * - 2 - permute nodes.
7198 * - 3 - permute cells and nodes.
7200 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7201 * caller is to delete this field using decrRef() as it is no more needed.
7202 * \throw If \a this field has not been constructed via file reading.
7203 * \throw If the MED file is not readable.
7204 * \throw If there is no mesh in the MED file.
7205 * \throw If no field values of the given \a type.
7206 * \throw If no field values lying on the top level support.
7207 * \sa getFieldAtLevel()
7209 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
7211 if(getFileName().empty())
7212 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
7213 MCAuto<DataArray> arrOut;
7214 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
7215 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7220 * Returns a new MEDCouplingFieldInt of given type lying on a given mesh.
7221 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7222 * \param [in] type - a spatial discretization of the new field.
7223 * \param [in] mesh - the supporting mesh.
7224 * \param [in] renumPol - specifies how to permute values of the result field according to
7225 * the optional numbers of cells and nodes, if any. The valid values are
7226 * - 0 - do not permute.
7227 * - 1 - permute cells.
7228 * - 2 - permute nodes.
7229 * - 3 - permute cells and nodes.
7231 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7232 * caller is to delete this field using decrRef() as it is no more needed.
7233 * \throw If no field of \a this is lying on \a mesh.
7234 * \throw If the mesh is empty.
7235 * \throw If no field values of the given \a type are available.
7236 * \sa getFieldAtLevel()
7237 * \sa getFieldOnMeshAtLevel()
7239 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
7241 MCAuto<DataArray> arrOut;
7242 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
7243 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7248 * Returns a new MEDCouplingFieldInt of a given type lying on a given support.
7249 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7250 * \param [in] type - a spatial discretization of interest.
7251 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7252 * \param [in] mesh - the supporting mesh.
7253 * \param [in] renumPol - specifies how to permute values of the result field according to
7254 * the optional numbers of cells and nodes, if any. The valid values are
7255 * - 0 - do not permute.
7256 * - 1 - permute cells.
7257 * - 2 - permute nodes.
7258 * - 3 - permute cells and nodes.
7260 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7261 * caller is to delete this field using decrRef() as it is no more needed.
7262 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7263 * \throw If no field of \a this is lying on \a mesh.
7264 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7265 * \sa getFieldAtLevel()
7266 * \sa getFieldOnMeshAtLevel()
7268 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
7270 MCAuto<DataArray> arrOut;
7271 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
7272 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7277 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
7278 * This method is called "Old" because in MED3 norm a field has only one meshName
7279 * attached, so this method is for readers of MED2 files. If \a this field
7280 * has not been constructed via file reading, an exception is thrown.
7281 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7282 * \param [in] type - a spatial discretization of interest.
7283 * \param [in] mName - a name of the supporting mesh.
7284 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7285 * \param [in] renumPol - specifies how to permute values of the result field according to
7286 * the optional numbers of cells and nodes, if any. The valid values are
7287 * - 0 - do not permute.
7288 * - 1 - permute cells.
7289 * - 2 - permute nodes.
7290 * - 3 - permute cells and nodes.
7292 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7293 * caller is to delete this field using decrRef() as it is no more needed.
7294 * \throw If the MED file is not readable.
7295 * \throw If there is no mesh named \a mName in the MED file.
7296 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7297 * \throw If \a this field has not been constructed via file reading.
7298 * \throw If no field of \a this is lying on the mesh named \a mName.
7299 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7300 * \sa getFieldAtLevel()
7302 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
7304 if(getFileName().empty())
7305 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7306 MCAuto<DataArray> arrOut;
7307 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
7308 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7313 * Returns values and a profile of the field of a given type lying on a given support.
7314 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7315 * \param [in] type - a spatial discretization of the field.
7316 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7317 * \param [in] mesh - the supporting mesh.
7318 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
7319 * field of interest lies on. If the field lies on all entities of the given
7320 * dimension, all ids in \a pfl are zero. The caller is to delete this array
7321 * using decrRef() as it is no more needed.
7322 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
7323 * field. The caller is to delete this array using decrRef() as it is no more needed.
7324 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7325 * \throw If no field of \a this is lying on \a mesh.
7326 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7328 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
7330 MCAuto<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
7331 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
7334 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull()
7336 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7338 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
7339 MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
7341 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 !");
7345 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const
7347 return contentNotNull()->getUndergroundDataArrayTemplate();
7350 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
7352 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
7356 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileFieldNameScope(fieldName)
7361 * \param [in] fieldId field id in C mode
7363 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7365 med_field_type typcha;
7366 std::string dtunitOut;
7367 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fieldId,false,_name,typcha,_infos,dtunitOut));
7368 setDtUnit(dtunitOut.c_str());
7369 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities);
7372 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)
7373 try:MEDFileFieldNameScope(fieldName),_infos(infos)
7375 setDtUnit(dtunit.c_str());
7376 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities);
7378 catch(INTERP_KERNEL::Exception& e)
7383 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
7385 std::size_t ret(_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MCAuto<MEDFileField1TSWithoutSDA>));
7386 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7387 ret+=(*it).capacity();
7391 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
7393 std::vector<const BigMemoryObject *> ret;
7394 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7395 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
7400 * 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
7403 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
7405 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7406 ret->setInfo(_infos);
7407 int sz=(int)_time_steps.size();
7408 for(const int *id=startIds;id!=endIds;id++)
7410 if(*id>=0 && *id<sz)
7412 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
7413 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7417 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7419 ret->pushBackTimeStep(tse2);
7423 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
7424 oss << " ! Should be in [0," << sz << ") !";
7425 throw INTERP_KERNEL::Exception(oss.str());
7428 if(ret->getNumberOfTS()>0)
7429 ret->synchronizeNameScope();
7430 ret->copyNameScope(*this);
7435 * 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
7438 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
7440 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
7441 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7442 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7443 ret->setInfo(_infos);
7444 int sz=(int)_time_steps.size();
7446 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
7450 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
7451 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7455 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7457 ret->pushBackTimeStep(tse2);
7461 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
7462 oss << " ! Should be in [0," << sz << ") !";
7463 throw INTERP_KERNEL::Exception(oss.str());
7466 if(ret->getNumberOfTS()>0)
7467 ret->synchronizeNameScope();
7468 ret->copyNameScope(*this);
7472 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7475 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7476 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7478 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7481 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7482 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
7483 ids->pushBackSilent(id);
7485 return buildFromTimeStepIds(ids->begin(),ids->end());
7488 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7491 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7492 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7494 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7497 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7498 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
7499 ids->pushBackSilent(id);
7501 return buildFromTimeStepIds(ids->begin(),ids->end());
7504 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfStructureElements() const
7506 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7507 if((*it).isNotNull())
7508 if((*it)->presenceOfStructureElements())
7513 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::onlyStructureElements() const
7515 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7516 if((*it).isNotNull())
7517 if(!(*it)->onlyStructureElements())
7522 void MEDFileAnyTypeFieldMultiTSWithoutSDA::killStructureElements()
7524 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
7525 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7526 if((*it).isNotNull())
7528 if((*it)->presenceOfStructureElements())
7530 if(!(*it)->onlyStructureElements())
7532 (*it)->killStructureElements();
7544 void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyStructureElements()
7546 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
7547 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7548 if((*it).isNotNull())
7550 if((*it)->presenceOfStructureElements())
7552 if(!(*it)->onlyStructureElements())
7553 (*it)->keepOnlyStructureElements();
7560 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
7562 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7564 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7567 if(cur->presenceOfMultiDiscPerGeoType())
7573 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
7578 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
7583 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
7586 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7588 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
7589 if(pt->isDealingTS(iteration,order))
7592 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
7593 std::vector< std::pair<int,int> > vp=getIterations();
7594 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
7595 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
7596 throw INTERP_KERNEL::Exception(oss.str());
7599 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
7601 return *_time_steps[getTimeStepPos(iteration,order)];
7604 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
7606 return *_time_steps[getTimeStepPos(iteration,order)];
7609 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const
7611 if(_time_steps.empty())
7612 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
7613 return _time_steps[0]->getMeshName();
7616 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const std::string& newMeshName)
7618 std::string oldName(getMeshName());
7619 std::vector< std::pair<std::string,std::string> > v(1);
7620 v[0].first=oldName; v[0].second=newMeshName;
7624 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
7627 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7629 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7631 ret=cur->changeMeshNames(modifTab) || ret;
7637 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
7639 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
7641 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
7645 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
7647 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7649 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
7652 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
7653 MEDFileFieldGlobsReal& glob)
7656 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7658 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
7660 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
7665 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7667 std::string startLine(bkOffset,' ');
7668 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
7670 oss << " (" << fmtsId << ")";
7671 oss << " has the following name: \"" << _name << "\"." << std::endl;
7672 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
7673 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7675 oss << startLine << " - \"" << *it << "\"" << std::endl;
7678 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7680 std::string chapter(17,'0'+i);
7681 oss << startLine << chapter << std::endl;
7682 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7684 cur->simpleRepr(bkOffset+2,oss,i);
7686 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
7687 oss << startLine << chapter << std::endl;
7691 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
7693 std::size_t sz=_time_steps.size();
7694 std::vector< std::pair<int,int> > ret(sz);
7696 for(std::size_t i=0;i<sz;i++)
7698 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
7701 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
7705 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
7706 throw INTERP_KERNEL::Exception(oss.str());
7712 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MCAuto<MEDFileAnyTypeField1TSWithoutSDA>& tse)
7714 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
7716 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
7717 checkCoherencyOfType(tse2);
7718 if(_time_steps.empty())
7720 setName(tse2->getName().c_str());
7721 setInfo(tse2->getInfo());
7723 checkThatComponentsMatch(tse2->getInfo());
7724 if(getDtUnit().empty() && !tse->getDtUnit().empty())
7725 setDtUnit(tse->getDtUnit());
7726 _time_steps.push_back(tse);
7729 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
7731 std::size_t nbOfCompo=_infos.size();
7732 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7734 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7737 if((cur->getInfo()).size()!=nbOfCompo)
7739 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
7740 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
7741 throw INTERP_KERNEL::Exception(oss.str());
7743 cur->copyNameScope(*this);
7748 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7750 _time_steps.resize(nbPdt);
7751 for(int i=0;i<nbPdt;i++)
7753 std::vector< std::pair<int,int> > ts;
7754 med_int numdt=0,numo=0;
7756 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt));
7761 _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7766 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7770 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
7773 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities);
7775 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entities);
7776 synchronizeNameScope();
7780 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
7782 if(_time_steps.empty())
7783 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
7784 checkThatNbOfCompoOfTSMatchThis();
7785 std::vector<std::string> infos(getInfo());
7786 int nbComp=infos.size();
7787 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7788 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7789 for(int i=0;i<nbComp;i++)
7791 std::string info=infos[i];
7793 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7794 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7795 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7798 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7799 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
7800 int nbOfTS=_time_steps.size();
7801 for(int i=0;i<nbOfTS;i++)
7802 _time_steps[i]->writeLL(fid,opts,*this);
7805 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
7807 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7809 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7811 elt->loadBigArraysRecursively(fid,nasc);
7815 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
7817 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7819 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7821 elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7825 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
7827 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7829 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7831 elt->unloadArrays();
7835 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7837 return _time_steps.size();
7840 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
7842 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7843 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7845 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7847 newTS.push_back(*it);
7852 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
7854 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7855 int maxId=(int)_time_steps.size();
7857 std::set<int> idsToDel;
7858 for(const int *id=startIds;id!=endIds;id++,ii++)
7860 if(*id>=0 && *id<maxId)
7862 idsToDel.insert(*id);
7866 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7867 throw INTERP_KERNEL::Exception(oss.str());
7870 for(int iii=0;iii<maxId;iii++)
7871 if(idsToDel.find(iii)==idsToDel.end())
7872 newTS.push_back(_time_steps[iii]);
7876 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
7878 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7879 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7880 if(nbOfEntriesToKill==0)
7882 std::size_t sz=_time_steps.size();
7883 std::vector<bool> b(sz,true);
7885 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7887 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7888 for(std::size_t i=0;i<sz;i++)
7890 newTS.push_back(_time_steps[i]);
7894 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
7897 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
7898 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7900 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7904 tmp->getTime(it2,ord);
7905 if(it2==iteration && order==ord)
7908 oss << "(" << it2 << "," << ord << "), ";
7911 throw INTERP_KERNEL::Exception(oss.str());
7914 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
7917 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
7919 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7921 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7925 double ti=tmp->getTime(it2,ord);
7926 if(fabs(time-ti)<eps)
7932 throw INTERP_KERNEL::Exception(oss.str());
7935 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
7937 int lgth=_time_steps.size();
7938 std::vector< std::pair<int,int> > ret(lgth);
7939 for(int i=0;i<lgth;i++)
7940 _time_steps[i]->fillIteration(ret[i]);
7945 * 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'
7946 * This method returns two things.
7947 * - The absolute dimension of 'this' in first parameter.
7948 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7949 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
7951 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7952 * Only these 3 discretizations will be taken into account here.
7954 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7955 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7956 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7958 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7959 * 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'.
7961 * Let's consider the typical following case :
7962 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7963 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7964 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7966 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7968 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7970 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7971 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7972 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7973 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7975 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
7977 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7980 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
7982 if(pos<0 || pos>=(int)_time_steps.size())
7984 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7985 throw INTERP_KERNEL::Exception(oss.str());
7987 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7990 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7991 oss << "\nTry to use following method eraseEmptyTS !";
7992 throw INTERP_KERNEL::Exception(oss.str());
7997 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
7999 if(pos<0 || pos>=(int)_time_steps.size())
8001 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
8002 throw INTERP_KERNEL::Exception(oss.str());
8004 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
8007 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
8008 oss << "\nTry to use following method eraseEmptyTS !";
8009 throw INTERP_KERNEL::Exception(oss.str());
8014 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
8016 std::vector<std::string> ret;
8017 std::set<std::string> ret2;
8018 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8020 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
8021 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
8022 if(ret2.find(*it2)==ret2.end())
8024 ret.push_back(*it2);
8031 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
8033 std::vector<std::string> ret;
8034 std::set<std::string> ret2;
8035 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8037 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
8038 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
8039 if(ret2.find(*it2)==ret2.end())
8041 ret.push_back(*it2);
8048 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
8050 std::vector<std::string> ret;
8051 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8053 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
8054 ret.insert(ret.end(),tmp.begin(),tmp.end());
8059 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
8061 std::vector<std::string> ret;
8062 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8064 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
8065 ret.insert(ret.end(),tmp.begin(),tmp.end());
8070 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8072 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8073 (*it)->changePflsRefsNamesGen2(mapOfModif);
8076 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8078 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8079 (*it)->changeLocsRefsNamesGen2(mapOfModif);
8082 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
8084 int lgth=_time_steps.size();
8085 std::vector< std::vector<TypeOfField> > ret(lgth);
8086 for(int i=0;i<lgth;i++)
8087 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
8092 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
8094 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
8096 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
8099 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCopy() const
8101 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
8103 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8105 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
8106 ret->_time_steps[i]=(*it)->deepCopy();
8111 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
8113 std::size_t sz(_infos.size()),sz2(_time_steps.size());
8114 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
8115 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
8116 for(std::size_t i=0;i<sz;i++)
8118 ret[i]=shallowCpy();
8119 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
8121 for(std::size_t i=0;i<sz2;i++)
8123 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
8126 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
8127 throw INTERP_KERNEL::Exception(oss.str());
8131 for(std::size_t i=0;i<sz;i++)
8132 for(std::size_t j=0;j<sz2;j++)
8133 ret[i]->_time_steps[j]=ts[j][i];
8138 * This method splits into discretization each time steps in \a this.
8139 * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
8141 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
8143 std::size_t sz(_time_steps.size());
8144 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
8145 for(std::size_t i=0;i<sz;i++)
8147 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
8150 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
8151 throw INTERP_KERNEL::Exception(oss.str());
8153 items[i]=timeStep->splitDiscretizations();
8156 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
8157 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
8158 std::vector< TypeOfField > types;
8159 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
8160 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
8162 std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
8164 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
8165 std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
8166 if(it2==types.end())
8167 types.push_back(ts[0]);
8169 ret.resize(types.size()); ret2.resize(types.size());
8170 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
8171 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
8173 TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
8174 std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
8175 ret2[pos].push_back(*it1);
8177 for(std::size_t i=0;i<types.size();i++)
8179 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
8180 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
8181 elt->pushBackTimeStep(*it1);//also updates infos in elt
8183 elt->MEDFileFieldNameScope::operator=(*this);
8189 * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
8191 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
8193 std::size_t sz(_time_steps.size());
8194 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
8195 std::size_t szOut(std::numeric_limits<std::size_t>::max());
8196 for(std::size_t i=0;i<sz;i++)
8198 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
8201 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
8202 throw INTERP_KERNEL::Exception(oss.str());
8204 items[i]=timeStep->splitMultiDiscrPerGeoTypes();
8205 if(szOut==std::numeric_limits<std::size_t>::max())
8206 szOut=items[i].size();
8208 if(items[i].size()!=szOut)
8209 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
8211 if(szOut==std::numeric_limits<std::size_t>::max())
8212 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
8213 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
8214 for(std::size_t i=0;i<szOut;i++)
8216 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
8217 for(std::size_t j=0;j<sz;j++)
8218 elt->pushBackTimeStep(items[j][i]);
8220 elt->MEDFileFieldNameScope::operator=(*this);
8225 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
8227 _name=field->getName();
8229 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
8231 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
8232 _infos=arr->getInfoOnComponents();
8235 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
8237 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
8238 if(_name!=field->getName())
8240 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
8241 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
8242 throw INTERP_KERNEL::Exception(oss.str());
8245 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
8246 checkThatComponentsMatch(arr->getInfoOnComponents());
8249 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
8251 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
8252 if(getInfo().size()!=compos.size())
8254 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
8255 oss << " number of components of element to append (" << compos.size() << ") !";
8256 throw INTERP_KERNEL::Exception(oss.str());
8260 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
8261 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
8262 oss << " But compo in input fields are : ";
8263 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
8265 throw INTERP_KERNEL::Exception(oss.str());
8269 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
8271 std::size_t sz=_infos.size();
8273 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
8275 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
8277 if(elt->getInfo().size()!=sz)
8279 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
8280 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
8281 throw INTERP_KERNEL::Exception(oss.str());
8286 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
8289 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8290 if(!_time_steps.empty())
8291 checkCoherencyOfTinyInfo(field,arr);
8292 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8293 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8294 objC->setFieldNoProfileSBT(field,arr,glob,*this);
8295 copyTinyInfoFrom(field,arr);
8296 _time_steps.push_back(obj);
8299 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
8302 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8303 if(!_time_steps.empty())
8304 checkCoherencyOfTinyInfo(field,arr);
8305 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8306 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8307 objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
8308 copyTinyInfoFrom(field,arr);
8309 _time_steps.push_back(obj);
8312 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ts)
8314 int sz=(int)_time_steps.size();
8317 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
8318 throw INTERP_KERNEL::Exception(oss.str());
8320 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
8323 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
8325 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
8326 throw INTERP_KERNEL::Exception(oss.str());
8332 //= MEDFileFieldMultiTSWithoutSDA
8334 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)
8336 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8339 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
8343 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8348 * \param [in] fieldId field id in C mode
8350 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8351 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8354 catch(INTERP_KERNEL::Exception& e)
8357 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)
8358 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8361 catch(INTERP_KERNEL::Exception& e)
8364 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8366 return new MEDFileField1TSWithoutSDA;
8369 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8372 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8373 const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
8375 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8378 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const
8380 return MEDFileField1TSWithoutSDA::TYPE_STR;
8383 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const
8385 return new MEDFileFieldMultiTSWithoutSDA(*this);
8388 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const
8390 return new MEDFileFieldMultiTSWithoutSDA;
8394 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
8395 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
8397 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
8399 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
8400 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8402 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
8403 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
8406 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
8408 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
8409 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8411 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8413 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8416 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
8418 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
8419 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
8420 ret->setIteration(i,elt);
8426 //= MEDFileAnyTypeFieldMultiTS
8428 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
8432 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8433 try:MEDFileFieldGlobsReal(fid)
8435 _content=BuildContentFrom(fid,loadAll,ms);
8438 catch(INTERP_KERNEL::Exception& e)
8443 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8445 med_field_type typcha;
8446 std::vector<std::string> infos;
8449 MEDFileAnyTypeField1TS::LocateField(fid,fieldName,i,typcha,infos,dtunit);
8450 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8455 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8460 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8465 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] !";
8466 throw INTERP_KERNEL::Exception(oss.str());
8469 ret->setDtUnit(dtunit.c_str());
8473 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8475 med_field_type typcha;
8477 std::vector<std::string> infos;
8478 std::string dtunit,fieldName;
8479 MEDFileAnyTypeField1TS::LocateField2(fid,0,true,fieldName,typcha,infos,dtunit);
8480 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8485 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8490 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8495 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] !";
8496 throw INTERP_KERNEL::Exception(oss.str());
8499 ret->setDtUnit(dtunit.c_str());
8503 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c)
8506 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
8507 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
8509 MCAuto<MEDFileFieldMultiTS> ret(MEDFileFieldMultiTS::New());
8510 ret->_content=c; c->incrRef();
8513 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
8515 MCAuto<MEDFileIntFieldMultiTS> ret(MEDFileIntFieldMultiTS::New());
8516 ret->_content=c; c->incrRef();
8519 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
8522 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, med_idt fid)
8524 MEDFileAnyTypeFieldMultiTS *ret(BuildNewInstanceFromContent(c));
8525 std::string fileName(FileNameFromFID(fid));
8526 ret->setFileName(fileName);
8530 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8531 try:MEDFileFieldGlobsReal(fid)
8533 _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
8536 catch(INTERP_KERNEL::Exception& e)
8541 //= MEDFileIntFieldMultiTSWithoutSDA
8543 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)
8545 return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8548 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
8552 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8556 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)
8557 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8560 catch(INTERP_KERNEL::Exception& e)
8564 * \param [in] fieldId field id in C mode
8566 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8567 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8570 catch(INTERP_KERNEL::Exception& e)
8573 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8575 return new MEDFileIntField1TSWithoutSDA;
8578 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8581 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8582 const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
8584 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8587 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const
8589 return MEDFileIntField1TSWithoutSDA::TYPE_STR;
8592 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const
8594 return new MEDFileIntFieldMultiTSWithoutSDA(*this);
8597 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const
8599 return new MEDFileIntFieldMultiTSWithoutSDA;
8602 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const
8604 MCAuto<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
8605 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8607 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8609 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8612 const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
8614 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
8615 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
8616 ret->setIteration(i,elt);
8622 //= MEDFileAnyTypeFieldMultiTS
8625 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
8626 * that has been read from a specified MED file.
8627 * \param [in] fileName - the name of the MED file to read.
8628 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8629 * is to delete this field using decrRef() as it is no more needed.
8630 * \throw If reading the file fails.
8632 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
8634 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8635 return New(fid,loadAll);
8638 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, bool loadAll)
8640 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
8641 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8642 ret->loadGlobals(fid);
8647 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
8648 * that has been read from a specified MED file.
8649 * \param [in] fileName - the name of the MED file to read.
8650 * \param [in] fieldName - the name of the field to read.
8651 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8652 * is to delete this field using decrRef() as it is no more needed.
8653 * \throw If reading the file fails.
8654 * \throw If there is no field named \a fieldName in the file.
8656 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8658 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8659 return New(fid,fieldName,loadAll);
8662 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
8664 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
8665 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8666 ret->loadGlobals(fid);
8671 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8672 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8674 * \warning this is a shallow copy constructor
8676 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8678 if(!shallowCopyOfContent)
8680 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
8681 otherPtr->incrRef();
8682 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
8686 _content=other.shallowCpy();
8690 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
8692 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8694 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
8698 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
8700 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8702 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
8706 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
8708 return contentNotNullBase()->getPflsReallyUsed2();
8711 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
8713 return contentNotNullBase()->getLocsReallyUsed2();
8716 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
8718 return contentNotNullBase()->getPflsReallyUsedMulti2();
8721 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
8723 return contentNotNullBase()->getLocsReallyUsedMulti2();
8726 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8728 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
8731 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8733 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
8736 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
8738 return contentNotNullBase()->getNumberOfTS();
8741 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
8743 contentNotNullBase()->eraseEmptyTS();
8746 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
8748 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
8751 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
8753 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
8756 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
8758 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
8759 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8764 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
8766 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
8767 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8772 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
8774 return contentNotNullBase()->getIterations();
8777 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
8779 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
8780 pushBackTimeStep(*it);
8783 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
8786 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
8787 int nbOfTS(fmts->getNumberOfTS());
8788 for(int i=0;i<nbOfTS;i++)
8790 MCAuto<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
8791 pushBackTimeStep(elt);
8795 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
8798 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
8799 checkCoherencyOfType(f1ts);
8801 MCAuto<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
8802 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
8804 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
8805 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
8806 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
8807 _content->pushBackTimeStep(cSafe);
8808 appendGlobs(*f1ts,1e-12);
8811 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
8813 contentNotNullBase()->synchronizeNameScope();
8816 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
8818 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
8821 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
8823 return contentNotNullBase()->getPosGivenTime(time,eps);
8826 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8828 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
8831 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
8833 return contentNotNullBase()->getTypesOfFieldAvailable();
8836 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
8838 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
8841 std::string MEDFileAnyTypeFieldMultiTS::getName() const
8843 return contentNotNullBase()->getName();
8846 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
8848 contentNotNullBase()->setName(name);
8851 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
8853 return contentNotNullBase()->getDtUnit();
8856 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
8858 contentNotNullBase()->setDtUnit(dtUnit);
8861 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8863 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
8866 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
8868 return contentNotNullBase()->getTimeSteps(ret1);
8871 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
8873 return contentNotNullBase()->getMeshName();
8876 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
8878 contentNotNullBase()->setMeshName(newMeshName);
8881 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
8883 return contentNotNullBase()->changeMeshNames(modifTab);
8886 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
8888 return contentNotNullBase()->getInfo();
8891 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
8893 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
8896 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
8898 return contentNotNullBase()->setInfo(info);
8901 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
8903 const std::vector<std::string> ret=getInfo();
8904 return (int)ret.size();
8907 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
8909 writeGlobals(fid,*this);
8910 contentNotNullBase()->writeLL(fid,*this);
8914 * This method alloc the arrays and load potentially huge arrays contained in this field.
8915 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
8916 * This method can be also called to refresh or reinit values from a file.
8918 * \throw If the fileName is not set or points to a non readable MED file.
8920 void MEDFileAnyTypeFieldMultiTS::loadArrays()
8922 if(getFileName().empty())
8923 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
8924 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
8925 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
8929 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
8930 * But once data loaded once, this method does nothing.
8932 * \throw If the fileName is not set or points to a non readable MED file.
8933 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
8935 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
8937 if(!getFileName().empty())
8939 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
8940 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
8945 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
8946 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
8947 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
8949 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
8951 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
8953 contentNotNullBase()->unloadArrays();
8957 * 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.
8958 * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
8959 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
8961 * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
8963 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
8965 if(!getFileName().empty())
8966 contentNotNullBase()->unloadArrays();
8969 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
8971 std::ostringstream oss;
8972 contentNotNullBase()->simpleRepr(0,oss,-1);
8973 simpleReprGlobs(oss);
8977 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
8979 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
8982 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
8984 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
8985 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
8990 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
8991 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8992 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
8994 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
8996 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8998 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
8999 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
9000 std::size_t sz(contentsSplit.size());
9001 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
9002 for(std::size_t i=0;i<sz;i++)
9004 ret[i]=shallowCpy();
9005 ret[i]->_content=contentsSplit[i];
9011 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
9012 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
9014 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
9016 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9018 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
9019 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
9020 std::size_t sz(contentsSplit.size());
9021 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
9022 for(std::size_t i=0;i<sz;i++)
9024 ret[i]=shallowCpy();
9025 ret[i]->_content=contentsSplit[i];
9031 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
9032 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
9034 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
9036 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9038 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
9039 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
9040 std::size_t sz(contentsSplit.size());
9041 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
9042 for(std::size_t i=0;i<sz;i++)
9044 ret[i]=shallowCpy();
9045 ret[i]->_content=contentsSplit[i];
9050 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCopy() const
9052 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
9053 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
9054 ret->_content=_content->deepCopy();
9055 ret->deepCpyGlobs(*this);
9059 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
9065 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
9066 * \param [in] iteration - the iteration number of a required time step.
9067 * \param [in] order - the iteration order number of required time step.
9068 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
9069 * delete this field using decrRef() as it is no more needed.
9070 * \throw If there is no required time step in \a this field.
9072 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
9074 int pos=getPosOfTimeStep(iteration,order);
9075 return getTimeStepAtPos(pos);
9079 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
9080 * \param [in] time - the time of the time step of interest.
9081 * \param [in] eps - a precision used to compare time values.
9082 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9083 * delete this field using decrRef() as it is no more needed.
9084 * \throw If there is no required time step in \a this field.
9086 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
9088 int pos=getPosGivenTime(time,eps);
9089 return getTimeStepAtPos(pos);
9093 * 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.
9094 * The float64 value of time attached to the pair of integers are not considered here.
9095 * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
9097 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
9098 * \throw If there is a null pointer in \a vectFMTS.
9100 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
9102 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
9103 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9104 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
9105 while(!lstFMTS.empty())
9107 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
9108 MEDFileAnyTypeFieldMultiTS *curIt(*it);
9110 throw INTERP_KERNEL::Exception(msg);
9111 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
9112 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
9113 elt.push_back(curIt); it=lstFMTS.erase(it);
9114 while(it!=lstFMTS.end())
9118 throw INTERP_KERNEL::Exception(msg);
9119 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
9121 { elt.push_back(curIt); it=lstFMTS.erase(it); }
9131 * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
9132 * All returned instances in a subvector can be safely loaded, rendered along time
9133 * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
9134 * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
9135 * 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).
9136 * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
9137 * 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.
9139 * \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().
9140 * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
9141 * \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.
9142 * \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.
9144 * \throw If an element in \a vectFMTS has not only one spatial discretization set.
9145 * \throw If an element in \a vectFMTS change of spatial discretization along time.
9146 * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
9147 * \thorw If some elements in \a vectFMTS do not have the same times steps.
9148 * \throw If mesh is null.
9149 * \throw If an element in \a vectFMTS is null.
9150 * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
9152 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& fsc)
9154 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
9156 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
9157 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9158 if(vectFMTS.empty())
9160 std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
9161 MEDFileAnyTypeFieldMultiTS *frstElt(*it);
9163 throw INTERP_KERNEL::Exception(msg);
9165 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
9166 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
9167 for(;it!=vectFMTS.end();it++,i++)
9170 throw INTERP_KERNEL::Exception(msg);
9171 TypeOfField tof0,tof1;
9172 if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
9175 vectFMTSNotNodes.push_back(*it);
9177 vectFMTSNodes.push_back(*it);
9180 vectFMTSNotNodes.push_back(*it);
9182 std::vector< MCAuto<MEDFileFastCellSupportComparator> > cmps;
9183 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
9185 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
9188 bool isFetched(false);
9189 for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
9192 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
9193 if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
9194 { ret[i].push_back(*it2); isFetched=true; }
9198 std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
9199 MCAuto<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
9200 ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
9208 * 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.
9209 * \param [out] cmps - same size than the returned vector.
9211 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& cmps)
9213 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9214 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
9215 while(!lstFMTS.empty())
9217 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
9218 MEDFileAnyTypeFieldMultiTS *ref(*it);
9219 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
9220 elt.push_back(ref); it=lstFMTS.erase(it);
9221 MCAuto<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
9222 MCAuto<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
9223 while(it!=lstFMTS.end())
9225 MEDFileAnyTypeFieldMultiTS *curIt(*it);
9226 if(cmp->isEqual(curIt))
9227 { elt.push_back(curIt); it=lstFMTS.erase(it); }
9231 ret.push_back(elt); cmps.push_back(cmp);
9237 * 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.
9238 * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
9240 * \throw If \a f0 or \a f1 has not only one spatial discretization set.
9241 * \throw If \a f0 or \a f1 change of spatial discretization along time.
9242 * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
9243 * \thorw If \a f0 and \a f1 do not have the same times steps.
9244 * \throw If mesh is null.
9245 * \throw If \a f0 or \a f1 is null.
9246 * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
9248 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
9251 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
9253 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
9254 if(f0->getMeshName()!=mesh->getName())
9256 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9257 throw INTERP_KERNEL::Exception(oss.str());
9259 if(f1->getMeshName()!=mesh->getName())
9261 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9262 throw INTERP_KERNEL::Exception(oss.str());
9264 int nts=f0->getNumberOfTS();
9265 if(nts!=f1->getNumberOfTS())
9266 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
9269 for(int i=0;i<nts;i++)
9271 MCAuto<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
9272 MCAuto<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
9273 std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
9274 if(tofs0.size()!=1 || tofs1.size()!=1)
9275 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
9278 if(tof0!=tofs0[0] || tof1!=tofs1[0])
9279 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
9282 { tof0=tofs0[0]; tof1=tofs1[0]; }
9283 if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
9285 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() << ") !";
9286 throw INTERP_KERNEL::Exception(oss.str());
9288 if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
9290 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() << ") !";
9291 throw INTERP_KERNEL::Exception(oss.str());
9293 if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
9295 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() << ") !";
9296 throw INTERP_KERNEL::Exception(oss.str());
9303 * Return an extraction of \a this using \a extractDef map to specify the extraction.
9304 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
9306 * \return A new object that the caller is responsible to deallocate.
9308 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
9311 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::extractPart : mesh is null !");
9312 MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(buildNewEmpty());
9313 int nbTS(getNumberOfTS());
9314 for(int i=0;i<nbTS;i++)
9316 MCAuto<MEDFileAnyTypeField1TS> f1ts(getTimeStepAtPos(i));
9317 MCAuto<MEDFileAnyTypeField1TS> f1tsOut(f1ts->extractPart(extractDef,mm));
9318 fmtsOut->pushBackTimeStep(f1tsOut);
9320 return fmtsOut.retn();
9324 MCAuto<MEDFileAnyTypeField1TS> AggregateHelperF1TS(const std::vector< typename MLFieldTraits<T>::F1TSType const *>& f1tss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9326 MCAuto< typename MLFieldTraits<T>::F1TSType > ret(MLFieldTraits<T>::F1TSType::New());
9328 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : empty vector !");
9329 std::size_t sz(f1tss.size()),i(0);
9330 std::vector< typename MLFieldTraits<T>::F1TSWSDAType const *> f1tsw(sz);
9331 for(typename std::vector< typename MLFieldTraits<T>::F1TSType const *>::const_iterator it=f1tss.begin();it!=f1tss.end();it++,i++)
9333 typename MLFieldTraits<T>::F1TSType const *elt(*it);
9335 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : presence of a null pointer !");
9336 f1tsw[i]=dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType const *>(elt->contentNotNullBase());
9338 typename MLFieldTraits<T>::F1TSWSDAType *retc(dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType *>(ret->contentNotNullBase()));
9340 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : internal error 1 !");
9341 retc->aggregate(f1tsw,dts);
9342 ret->setDtUnit(f1tss[0]->getDtUnit());
9343 return DynamicCast<typename MLFieldTraits<T>::F1TSType , MEDFileAnyTypeField1TS>(ret);
9347 MCAuto< MEDFileAnyTypeFieldMultiTS > AggregateHelperFMTS(const std::vector< typename MLFieldTraits<T>::FMTSType const *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9349 MCAuto< typename MLFieldTraits<T>::FMTSType > ret(MLFieldTraits<T>::FMTSType::New());
9351 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : empty vector !");
9352 std::size_t sz(fmtss.size());
9353 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9355 typename MLFieldTraits<T>::FMTSType const *elt(*it);
9357 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : presence of null pointer !");
9359 int nbTS(fmtss[0]->getNumberOfTS());
9360 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9361 if((*it)->getNumberOfTS()!=nbTS)
9362 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : all fields must have the same number of TS !");
9363 for(int iterTS=0;iterTS<nbTS;iterTS++)
9366 std::vector< typename MLFieldTraits<T>::F1TSType const *> f1tss(sz);
9367 std::vector< MCAuto<typename MLFieldTraits<T>::F1TSType> > f1tss2(sz);
9368 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++,i++)
9369 { f1tss2[i]=(*it)->getTimeStepAtPos(iterTS); f1tss[i]=f1tss2[i]; }
9370 MCAuto<MEDFileAnyTypeField1TS> f1ts(AggregateHelperF1TS<T>(f1tss,dts));
9371 ret->pushBackTimeStep(f1ts);
9372 ret->setDtUnit(f1ts->getDtUnit());
9374 return DynamicCast<typename MLFieldTraits<T>::FMTSType , MEDFileAnyTypeFieldMultiTS>(ret);
9378 * \a dts and \a ftmss are expected to have same size.
9380 MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileAnyTypeFieldMultiTS::Aggregate(const std::vector<const MEDFileAnyTypeFieldMultiTS *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9383 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : input vector is empty !");
9384 std::size_t sz(fmtss.size());
9385 std::vector<const MEDFileFieldMultiTS *> fmtss1;
9386 std::vector<const MEDFileIntFieldMultiTS *> fmtss2;
9387 for(std::vector<const MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9390 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : presence of null instance in input vector !");
9391 const MEDFileFieldMultiTS *elt1(dynamic_cast<const MEDFileFieldMultiTS *>(*it));
9394 fmtss1.push_back(elt1);
9397 const MEDFileIntFieldMultiTS *elt2(dynamic_cast<const MEDFileIntFieldMultiTS *>(*it));
9400 fmtss2.push_back(elt2);
9403 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not recognized type !");
9405 if(fmtss1.size()!=sz && fmtss2.size()!=sz)
9406 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : type of data is not homogeneous !");
9407 if(fmtss1.size()==sz)
9408 return AggregateHelperFMTS<double>(fmtss1,dts);
9409 if(fmtss2.size()!=sz)
9410 return AggregateHelperFMTS<int>(fmtss2,dts);
9411 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not implemented yet !");
9414 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
9416 return new MEDFileAnyTypeFieldMultiTSIterator(this);
9419 //= MEDFileFieldMultiTS
9422 * Returns a new empty instance of MEDFileFieldMultiTS.
9423 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9424 * is to delete this field using decrRef() as it is no more needed.
9426 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
9428 return new MEDFileFieldMultiTS;
9432 * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
9433 * that has been read from a specified MED file.
9434 * \param [in] fileName - the name of the MED file to read.
9435 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9436 * is to delete this field using decrRef() as it is no more needed.
9437 * \throw If reading the file fails.
9439 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll)
9441 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9442 return New(fid,loadAll);
9445 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, bool loadAll)
9447 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,loadAll,0));
9448 ret->contentNotNull();//to check that content type matches with \a this type.
9453 * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
9454 * that has been read from a specified MED file.
9455 * \param [in] fileName - the name of the MED file to read.
9456 * \param [in] fieldName - the name of the field to read.
9457 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9458 * is to delete this field using decrRef() as it is no more needed.
9459 * \throw If reading the file fails.
9460 * \throw If there is no field named \a fieldName in the file.
9462 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9464 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9465 return New(fid,fieldName,loadAll);
9468 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
9470 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0));
9471 ret->contentNotNull();//to check that content type matches with \a this type.
9476 * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9477 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9479 * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
9480 * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9481 * \warning this is a shallow copy constructor
9482 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
9483 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9484 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9485 * is to delete this field using decrRef() as it is no more needed.
9487 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9489 return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
9492 MEDFileFieldMultiTS *MEDFileFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9494 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9495 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
9496 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0,ent));
9497 ret->contentNotNull();//to check that content type matches with \a this type.
9501 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
9503 return new MEDFileFieldMultiTS(*this);
9506 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9509 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9510 const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
9512 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
9516 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
9517 * following the given input policy.
9519 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9520 * By default (true) the globals are deeply copied.
9521 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
9523 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
9525 MCAuto<MEDFileIntFieldMultiTS> ret;
9526 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9529 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
9531 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
9532 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
9533 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc));
9536 ret=MEDFileIntFieldMultiTS::New();
9538 ret->deepCpyGlobs(*this);
9540 ret->shallowCpyGlobs(*this);
9545 * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
9546 * \param [in] pos - a time step id.
9547 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9548 * delete this field using decrRef() as it is no more needed.
9549 * \throw If \a pos is not a valid time step id.
9551 MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const
9553 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9556 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9557 throw INTERP_KERNEL::Exception(oss.str());
9559 const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
9562 MCAuto<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
9563 ret->shallowCpyGlobs(*this);
9566 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
9567 throw INTERP_KERNEL::Exception(oss.str());
9571 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9572 * mesh entities of a given dimension of the first mesh in MED file.
9573 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9574 * \param [in] type - a spatial discretization of interest.
9575 * \param [in] iteration - the iteration number of a required time step.
9576 * \param [in] order - the iteration order number of required time step.
9577 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9578 * \param [in] renumPol - specifies how to permute values of the result field according to
9579 * the optional numbers of cells and nodes, if any. The valid values are
9580 * - 0 - do not permute.
9581 * - 1 - permute cells.
9582 * - 2 - permute nodes.
9583 * - 3 - permute cells and nodes.
9585 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9586 * caller is to delete this field using decrRef() as it is no more needed.
9587 * \throw If the MED file is not readable.
9588 * \throw If there is no mesh in the MED file.
9589 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9590 * \throw If no field values of the required parameters are available.
9592 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9594 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9595 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9597 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
9598 MCAuto<DataArray> arrOut;
9599 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9600 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9605 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9606 * the top level cells of the first mesh in MED file.
9607 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9608 * \param [in] type - a spatial discretization of interest.
9609 * \param [in] iteration - the iteration number of a required time step.
9610 * \param [in] order - the iteration order number of required time step.
9611 * \param [in] renumPol - specifies how to permute values of the result field according to
9612 * the optional numbers of cells and nodes, if any. The valid values are
9613 * - 0 - do not permute.
9614 * - 1 - permute cells.
9615 * - 2 - permute nodes.
9616 * - 3 - permute cells and nodes.
9618 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9619 * caller is to delete this field using decrRef() as it is no more needed.
9620 * \throw If the MED file is not readable.
9621 * \throw If there is no mesh in the MED file.
9622 * \throw If no field values of the required parameters are available.
9624 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9626 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9627 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9629 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
9630 MCAuto<DataArray> arrOut;
9631 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9632 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9637 * 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
9638 * method should be called (getFieldOnMeshAtLevel for example).
9639 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
9641 * \param [in] iteration - the iteration number of a required time step.
9642 * \param [in] order - the iteration order number of required time step.
9643 * \param [in] mesh - the mesh the field is lying on
9644 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9645 * caller is to delete this field using decrRef() as it is no more needed.
9647 MEDCouplingFieldDouble *MEDFileFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
9649 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9650 MCAuto<DataArray> arrOut;
9651 MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
9652 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9657 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9659 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9660 * \param [in] type - a spatial discretization of interest.
9661 * \param [in] iteration - the iteration number of a required time step.
9662 * \param [in] order - the iteration order number of required time step.
9663 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9664 * \param [in] mesh - the supporting mesh.
9665 * \param [in] renumPol - specifies how to permute values of the result field according to
9666 * the optional numbers of cells and nodes, if any. The valid values are
9667 * - 0 - do not permute.
9668 * - 1 - permute cells.
9669 * - 2 - permute nodes.
9670 * - 3 - permute cells and nodes.
9672 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9673 * caller is to delete this field using decrRef() as it is no more needed.
9674 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9675 * \throw If no field of \a this is lying on \a mesh.
9676 * \throw If no field values of the required parameters are available.
9678 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9680 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9681 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9683 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9684 MCAuto<DataArray> arrOut;
9685 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
9686 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9691 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9693 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9694 * \param [in] type - a spatial discretization of the new field.
9695 * \param [in] iteration - the iteration number of a required time step.
9696 * \param [in] order - the iteration order number of required time step.
9697 * \param [in] mesh - the supporting mesh.
9698 * \param [in] renumPol - specifies how to permute values of the result field according to
9699 * the optional numbers of cells and nodes, if any. The valid values are
9700 * - 0 - do not permute.
9701 * - 1 - permute cells.
9702 * - 2 - permute nodes.
9703 * - 3 - permute cells and nodes.
9705 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9706 * caller is to delete this field using decrRef() as it is no more needed.
9707 * \throw If no field of \a this is lying on \a mesh.
9708 * \throw If no field values of the required parameters are available.
9710 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
9712 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9713 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9715 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9716 MCAuto<DataArray> arrOut;
9717 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
9718 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9723 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
9724 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9725 * This method is useful for MED2 file format when field on different mesh was autorized.
9727 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
9729 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9730 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9732 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
9733 MCAuto<DataArray> arrOut;
9734 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
9735 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9740 * Returns values and a profile of the field of a given type, of a given time step,
9741 * lying on a given support.
9742 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9743 * \param [in] type - a spatial discretization of the field.
9744 * \param [in] iteration - the iteration number of a required time step.
9745 * \param [in] order - the iteration order number of required time step.
9746 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9747 * \param [in] mesh - the supporting mesh.
9748 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9749 * field of interest lies on. If the field lies on all entities of the given
9750 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9751 * using decrRef() as it is no more needed.
9752 * \param [in] glob - the global data storing profiles and localization.
9753 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
9754 * field. The caller is to delete this array using decrRef() as it is no more needed.
9755 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9756 * \throw If no field of \a this is lying on \a mesh.
9757 * \throw If no field values of the required parameters are available.
9759 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9761 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9762 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9764 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
9765 MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9766 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
9769 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const
9771 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9773 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
9774 const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
9776 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 !");
9780 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull()
9782 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9784 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
9785 MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
9787 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 !");
9792 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9793 * the given field is checked if its elements are sorted suitable for writing to MED file
9794 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9795 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9796 * \param [in] field - the field to add to \a this.
9797 * \throw If the name of \a field is empty.
9798 * \throw If the data array of \a field is not set.
9799 * \throw If existing time steps have different name or number of components than \a field.
9800 * \throw If the underlying mesh of \a field has no name.
9801 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9803 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
9805 const DataArrayDouble *arr=0;
9807 arr=field->getArray();
9808 contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
9812 * Adds a MEDCouplingFieldDouble to \a this as another time step.
9813 * The mesh support of input parameter \a field is ignored here, it can be NULL.
9814 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9817 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9818 * A new profile is added only if no equal profile is missing.
9819 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9820 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
9821 * \param [in] mesh - the supporting mesh of \a field.
9822 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9823 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
9824 * \throw If either \a field or \a mesh or \a profile has an empty name.
9825 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9826 * \throw If the data array of \a field is not set.
9827 * \throw If the data array of \a this is already allocated but has different number of
9828 * components than \a field.
9829 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9830 * \sa setFieldNoProfileSBT()
9832 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9834 const DataArrayDouble *arr=0;
9836 arr=field->getArray();
9837 contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
9840 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
9842 _content=new MEDFileFieldMultiTSWithoutSDA;
9845 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
9846 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
9849 catch(INTERP_KERNEL::Exception& e)
9852 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
9853 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
9856 catch(INTERP_KERNEL::Exception& e)
9859 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9863 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
9865 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
9868 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9870 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9873 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
9875 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
9878 MEDFileFieldMultiTS *MEDFileFieldMultiTS::buildNewEmpty() const
9880 return MEDFileFieldMultiTS::New();
9883 //= MEDFileAnyTypeFieldMultiTSIterator
9885 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
9890 _nb_iter=fmts->getNumberOfTS();
9894 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
9898 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
9900 if(_iter_id<_nb_iter)
9902 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
9904 return fmts->getTimeStepAtPos(_iter_id++);
9912 //= MEDFileIntFieldMultiTS
9915 * Returns a new empty instance of MEDFileFieldMultiTS.
9916 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9917 * is to delete this field using decrRef() as it is no more needed.
9919 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
9921 return new MEDFileIntFieldMultiTS;
9925 * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
9926 * that has been read from a specified MED file.
9927 * \param [in] fileName - the name of the MED file to read.
9928 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9929 * is to delete this field using decrRef() as it is no more needed.
9930 * \throw If reading the file fails.
9932 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll)
9934 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9935 return New(fid,loadAll);
9938 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, bool loadAll)
9940 MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,loadAll,0));
9941 ret->contentNotNull();//to check that content type matches with \a this type.
9946 * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
9947 * that has been read from a specified MED file.
9948 * \param [in] fileName - the name of the MED file to read.
9949 * \param [in] fieldName - the name of the field to read.
9950 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9951 * is to delete this field using decrRef() as it is no more needed.
9952 * \throw If reading the file fails.
9953 * \throw If there is no field named \a fieldName in the file.
9955 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9957 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9958 return New(fid,fieldName,loadAll);
9961 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
9963 MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0));
9964 ret->contentNotNull();//to check that content type matches with \a this type.
9969 * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9970 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9972 * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
9973 * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9974 * \warning this is a shallow copy constructor
9975 * \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
9976 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9977 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9978 * is to delete this field using decrRef() as it is no more needed.
9980 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9982 return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
9985 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9987 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9988 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
9989 MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0,ent));
9990 ret->contentNotNull();//to check that content type matches with \a this type.
9995 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
9996 * following the given input policy.
9998 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9999 * By default (true) the globals are deeply copied.
10000 * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
10002 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const
10004 MCAuto<MEDFileFieldMultiTS> ret;
10005 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
10008 const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
10010 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
10011 MCAuto<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
10012 ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc));
10015 ret=MEDFileFieldMultiTS::New();
10017 ret->deepCpyGlobs(*this);
10019 ret->shallowCpyGlobs(*this);
10023 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const
10025 return new MEDFileIntFieldMultiTS(*this);
10028 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
10031 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
10032 const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
10034 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
10038 * 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
10039 * method should be called (getFieldOnMeshAtLevel for example).
10040 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
10042 * \param [in] iteration - the iteration number of a required time step.
10043 * \param [in] order - the iteration order number of required time step.
10044 * \param [in] mesh - the mesh the field is lying on
10045 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
10046 * caller is to delete this field using decrRef() as it is no more needed.
10048 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
10050 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10051 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10053 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::field : mismatch of type of field expecting INT32 !");
10054 MCAuto<DataArray> arrOut;
10055 MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
10056 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arrOut));
10057 return ret2.retn();
10061 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
10062 * mesh entities of a given dimension of the first mesh in MED file.
10063 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10064 * \param [in] type - a spatial discretization of interest.
10065 * \param [in] iteration - the iteration number of a required time step.
10066 * \param [in] order - the iteration order number of required time step.
10067 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10068 * \param [in] renumPol - specifies how to permute values of the result field according to
10069 * the optional numbers of cells and nodes, if any. The valid values are
10070 * - 0 - do not permute.
10071 * - 1 - permute cells.
10072 * - 2 - permute nodes.
10073 * - 3 - permute cells and nodes.
10075 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10076 * caller is to delete this field using decrRef() as it is no more needed.
10077 * \throw If the MED file is not readable.
10078 * \throw If there is no mesh in the MED file.
10079 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
10080 * \throw If no field values of the required parameters are available.
10082 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
10084 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10085 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10087 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
10088 MCAuto<DataArray> arr;
10089 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase()));
10090 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10091 return ret2.retn();
10095 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
10096 * the top level cells of the first mesh in MED file.
10097 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10098 * \param [in] type - a spatial discretization of interest.
10099 * \param [in] iteration - the iteration number of a required time step.
10100 * \param [in] order - the iteration order number of required time step.
10101 * \param [in] renumPol - specifies how to permute values of the result field according to
10102 * the optional numbers of cells and nodes, if any. The valid values are
10103 * - 0 - do not permute.
10104 * - 1 - permute cells.
10105 * - 2 - permute nodes.
10106 * - 3 - permute cells and nodes.
10108 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10109 * caller is to delete this field using decrRef() as it is no more needed.
10110 * \throw If the MED file is not readable.
10111 * \throw If there is no mesh in the MED file.
10112 * \throw If no field values of the required parameters are available.
10114 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
10116 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10117 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10119 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
10120 MCAuto<DataArray> arr;
10121 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase()));
10122 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10123 return ret2.retn();
10127 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
10129 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10130 * \param [in] type - a spatial discretization of interest.
10131 * \param [in] iteration - the iteration number of a required time step.
10132 * \param [in] order - the iteration order number of required time step.
10133 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10134 * \param [in] mesh - the supporting mesh.
10135 * \param [in] renumPol - specifies how to permute values of the result field according to
10136 * the optional numbers of cells and nodes, if any. The valid values are
10137 * - 0 - do not permute.
10138 * - 1 - permute cells.
10139 * - 2 - permute nodes.
10140 * - 3 - permute cells and nodes.
10142 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10143 * caller is to delete this field using decrRef() as it is no more needed.
10144 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
10145 * \throw If no field of \a this is lying on \a mesh.
10146 * \throw If no field values of the required parameters are available.
10148 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
10150 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10151 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10153 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10154 MCAuto<DataArray> arr;
10155 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase()));
10156 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10157 return ret2.retn();
10161 * Returns a new MEDCouplingFieldInt of given type, of a given time step, lying on a
10163 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10164 * \param [in] type - a spatial discretization of the new field.
10165 * \param [in] iteration - the iteration number of a required time step.
10166 * \param [in] order - the iteration order number of required time step.
10167 * \param [in] mesh - the supporting mesh.
10168 * \param [out] arrOut - the DataArrayInt containing values of field.
10169 * \param [in] renumPol - specifies how to permute values of the result field according to
10170 * the optional numbers of cells and nodes, if any. The valid values are
10171 * - 0 - do not permute.
10172 * - 1 - permute cells.
10173 * - 2 - permute nodes.
10174 * - 3 - permute cells and nodes.
10176 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10177 * caller is to delete this field using decrRef() as it is no more needed.
10178 * \throw If no field of \a this is lying on \a mesh.
10179 * \throw If no field values of the required parameters are available.
10181 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
10183 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10184 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10186 throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10187 MCAuto<DataArray> arr;
10188 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase()));
10189 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10190 return ret2.retn();
10194 * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
10195 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
10196 * This method is useful for MED2 file format when field on different mesh was autorized.
10198 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol) const
10200 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10201 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10203 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10204 MCAuto<DataArray> arr;
10205 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase()));
10206 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10207 return ret2.retn();
10211 * Returns values and a profile of the field of a given type, of a given time step,
10212 * lying on a given support.
10213 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10214 * \param [in] type - a spatial discretization of the field.
10215 * \param [in] iteration - the iteration number of a required time step.
10216 * \param [in] order - the iteration order number of required time step.
10217 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10218 * \param [in] mesh - the supporting mesh.
10219 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
10220 * field of interest lies on. If the field lies on all entities of the given
10221 * dimension, all ids in \a pfl are zero. The caller is to delete this array
10222 * using decrRef() as it is no more needed.
10223 * \param [in] glob - the global data storing profiles and localization.
10224 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
10225 * field. The caller is to delete this array using decrRef() as it is no more needed.
10226 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10227 * \throw If no field of \a this is lying on \a mesh.
10228 * \throw If no field values of the required parameters are available.
10230 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
10232 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
10233 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
10235 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
10236 MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
10237 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
10241 * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
10242 * \param [in] pos - a time step id.
10243 * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
10244 * delete this field using decrRef() as it is no more needed.
10245 * \throw If \a pos is not a valid time step id.
10247 MEDFileIntField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
10249 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
10252 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
10253 throw INTERP_KERNEL::Exception(oss.str());
10255 const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
10258 MCAuto<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
10259 ret->shallowCpyGlobs(*this);
10262 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
10263 throw INTERP_KERNEL::Exception(oss.str());
10267 * Adds a MEDCouplingFieldInt to \a this as another time step. The underlying mesh of
10268 * the given field is checked if its elements are sorted suitable for writing to MED file
10269 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
10270 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10271 * \param [in] field - the field to add to \a this.
10272 * \throw If the name of \a field is empty.
10273 * \throw If the data array of \a field is not set.
10274 * \throw If existing time steps have different name or number of components than \a field.
10275 * \throw If the underlying mesh of \a field has no name.
10276 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
10278 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldInt *field)
10280 MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
10281 contentNotNull()->appendFieldNoProfileSBT(field2,field->getArray(),*this);
10285 * Adds a MEDCouplingFieldDouble to \a this as another time step.
10286 * The mesh support of input parameter \a field is ignored here, it can be NULL.
10287 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
10290 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
10291 * A new profile is added only if no equal profile is missing.
10292 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10293 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
10294 * \param [in] arrOfVals - the values of the field \a field used.
10295 * \param [in] mesh - the supporting mesh of \a field.
10296 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
10297 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
10298 * \throw If either \a field or \a mesh or \a profile has an empty name.
10299 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10300 * \throw If the data array of \a field is not set.
10301 * \throw If the data array of \a this is already allocated but has different number of
10302 * components than \a field.
10303 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
10304 * \sa setFieldNoProfileSBT()
10306 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
10308 MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
10309 contentNotNull()->appendFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this);
10312 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const
10314 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10316 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
10317 const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10319 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 !");
10323 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull()
10325 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10327 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
10328 MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10330 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 !");
10334 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
10336 _content=new MEDFileIntFieldMultiTSWithoutSDA;
10339 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
10343 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
10344 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
10347 catch(INTERP_KERNEL::Exception& e)
10350 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10351 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
10354 catch(INTERP_KERNEL::Exception& e)
10357 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
10359 return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
10362 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::buildNewEmpty() const
10364 return MEDFileIntFieldMultiTS::New();
10369 MEDFileFields *MEDFileFields::New()
10371 return new MEDFileFields;
10374 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
10376 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10377 return New(fid,loadAll);
10380 MEDFileFields *MEDFileFields::NewWithDynGT(const std::string& fileName, const MEDFileStructureElements *se, bool loadAll)
10382 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10383 return NewWithDynGT(fid,se,loadAll);
10386 MEDFileFields *MEDFileFields::NewWithDynGT(med_idt fid, const MEDFileStructureElements *se, bool loadAll)
10389 throw INTERP_KERNEL::Exception("MEDFileFields::NewWithDynGT : null struct element pointer !");
10390 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> entities(MEDFileEntities::BuildFrom(*se));
10391 return new MEDFileFields(fid,loadAll,0,entities);
10394 MEDFileFields *MEDFileFields::New(med_idt fid, bool loadAll)
10396 return new MEDFileFields(fid,loadAll,0,0);
10399 MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
10401 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10402 return new MEDFileFields(fid,loadAll,ms,0);
10405 MEDFileFields *MEDFileFields::LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
10407 MEDFileUtilities::CheckFileForRead(fileName);
10408 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
10409 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10410 return new MEDFileFields(fid,loadAll,0,ent);
10413 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
10415 std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
10416 ret+=_fields.capacity()*sizeof(MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
10420 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
10422 std::vector<const BigMemoryObject *> ret;
10423 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10424 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
10428 MEDFileFields *MEDFileFields::deepCopy() const
10430 MCAuto<MEDFileFields> ret(shallowCpy());
10432 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10434 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10435 ret->_fields[i]=(*it)->deepCopy();
10437 ret->deepCpyGlobs(*this);
10441 MEDFileFields *MEDFileFields::shallowCpy() const
10443 return new MEDFileFields(*this);
10447 * 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
10448 * 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.
10449 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
10451 * \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.
10452 * \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.
10454 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10456 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
10458 std::set< std::pair<int,int> > s;
10459 bool firstShot=true;
10460 areThereSomeForgottenTS=false;
10461 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10463 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10465 std::vector< std::pair<int,int> > v=(*it)->getIterations();
10466 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
10468 { s=s1; firstShot=false; }
10471 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
10473 areThereSomeForgottenTS=true;
10477 std::vector< std::pair<int,int> > ret;
10478 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
10482 int MEDFileFields::getNumberOfFields() const
10484 return _fields.size();
10487 std::vector<std::string> MEDFileFields::getFieldsNames() const
10489 std::vector<std::string> ret(_fields.size());
10491 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10493 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
10496 ret[i]=f->getName();
10500 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
10501 throw INTERP_KERNEL::Exception(oss.str());
10507 std::vector<std::string> MEDFileFields::getMeshesNames() const
10509 std::vector<std::string> ret;
10510 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10512 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10514 ret.push_back(cur->getMeshName());
10519 std::string MEDFileFields::simpleRepr() const
10521 std::ostringstream oss;
10522 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
10527 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
10529 int nbOfFields(getNumberOfFields());
10530 std::string startLine(bkOffset,' ');
10531 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
10533 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10535 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10538 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
10542 oss << startLine << " - not defined !" << std::endl;
10546 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10548 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10549 std::string chapter(17,'0'+i);
10550 oss << startLine << chapter << std::endl;
10553 cur->simpleRepr(bkOffset+2,oss,i);
10557 oss << startLine << " - not defined !" << std::endl;
10559 oss << startLine << chapter << std::endl;
10561 simpleReprGlobs(oss);
10564 MEDFileFields::MEDFileFields()
10568 MEDFileFields::MEDFileFields(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10569 try:MEDFileFieldGlobsReal(fid)
10571 int nbFields(MEDnField(fid));
10572 _fields.resize(nbFields);
10573 med_field_type typcha;
10574 for(int i=0;i<nbFields;i++)
10576 std::vector<std::string> infos;
10577 std::string fieldName,dtunit;
10578 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,i,false,fieldName,typcha,infos,dtunit));
10583 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10588 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10593 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] !";
10594 throw INTERP_KERNEL::Exception(oss.str());
10598 loadAllGlobals(fid);
10600 catch(INTERP_KERNEL::Exception& e)
10605 void MEDFileFields::writeLL(med_idt fid) const
10608 writeGlobals(fid,*this);
10609 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10611 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
10614 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
10615 throw INTERP_KERNEL::Exception(oss.str());
10617 elt->writeLL(fid,*this);
10622 * This method alloc the arrays and load potentially huge arrays contained in this field.
10623 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
10624 * This method can be also called to refresh or reinit values from a file.
10626 * \throw If the fileName is not set or points to a non readable MED file.
10628 void MEDFileFields::loadArrays()
10630 if(getFileName().empty())
10631 throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
10632 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
10633 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10635 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10637 elt->loadBigArraysRecursively(fid,*elt);
10642 * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
10643 * But once data loaded once, this method does nothing.
10645 * \throw If the fileName is not set or points to a non readable MED file.
10646 * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
10648 void MEDFileFields::loadArraysIfNecessary()
10650 if(!getFileName().empty())
10652 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
10653 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10655 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10657 elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
10663 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
10664 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
10665 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
10667 * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
10669 void MEDFileFields::unloadArrays()
10671 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10673 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10675 elt->unloadArrays();
10680 * 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.
10681 * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
10682 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
10684 * \sa MEDFileFields::loadArraysIfNecessary
10686 void MEDFileFields::unloadArraysWithoutDataLoss()
10688 if(!getFileName().empty())
10692 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
10694 std::vector<std::string> ret;
10695 std::set<std::string> ret2;
10696 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10698 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
10699 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10700 if(ret2.find(*it2)==ret2.end())
10702 ret.push_back(*it2);
10709 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
10711 std::vector<std::string> ret;
10712 std::set<std::string> ret2;
10713 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10715 std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
10716 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10717 if(ret2.find(*it2)==ret2.end())
10719 ret.push_back(*it2);
10726 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
10728 std::vector<std::string> ret;
10729 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10731 std::vector<std::string> tmp((*it)->getPflsReallyUsedMulti2());
10732 ret.insert(ret.end(),tmp.begin(),tmp.end());
10737 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
10739 std::vector<std::string> ret;
10740 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10742 std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
10743 ret.insert(ret.end(),tmp.begin(),tmp.end());
10748 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10750 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10751 (*it)->changePflsRefsNamesGen2(mapOfModif);
10754 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10756 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10757 (*it)->changeLocsRefsNamesGen2(mapOfModif);
10760 void MEDFileFields::resize(int newSize)
10762 _fields.resize(newSize);
10765 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
10767 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
10771 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
10774 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
10775 _fields.push_back(field->getContent());
10776 appendGlobs(*field,1e-12);
10779 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
10782 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
10783 if(i>=(int)_fields.size())
10784 _fields.resize(i+1);
10785 _fields[i]=field->getContent();
10786 appendGlobs(*field,1e-12);
10789 void MEDFileFields::destroyFieldAtPos(int i)
10791 destroyFieldsAtPos(&i,&i+1);
10794 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
10796 std::vector<bool> b(_fields.size(),true);
10797 for(const int *i=startIds;i!=endIds;i++)
10799 if(*i<0 || *i>=(int)_fields.size())
10801 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10802 throw INTERP_KERNEL::Exception(oss.str());
10806 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10808 for(std::size_t i=0;i<_fields.size();i++)
10810 fields[j++]=_fields[i];
10814 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
10816 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
10817 int nbOfEntriesToKill(DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg));
10818 std::vector<bool> b(_fields.size(),true);
10820 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
10822 if(k<0 || k>=(int)_fields.size())
10824 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
10825 throw INTERP_KERNEL::Exception(oss.str());
10829 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10831 for(std::size_t i=0;i<_fields.size();i++)
10833 fields[j++]=_fields[i];
10837 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
10840 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10842 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10844 ret=cur->changeMeshNames(modifTab) || ret;
10850 * \param [in] meshName the name of the mesh that will be renumbered.
10851 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
10852 * This code corresponds to the distribution of types in the corresponding mesh.
10853 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
10854 * \param [in] renumO2N the old to new renumber array.
10855 * \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
10856 * field in \a this.
10858 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
10861 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10863 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
10866 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
10873 * Return an extraction of \a this using \a extractDef map to specify the extraction.
10874 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
10876 * \return A new object that the caller is responsible to deallocate.
10878 MEDFileFields *MEDFileFields::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
10881 throw INTERP_KERNEL::Exception("MEDFileFields::extractPart : input mesh is NULL !");
10882 MCAuto<MEDFileFields> fsOut(MEDFileFields::New());
10883 int nbFields(getNumberOfFields());
10884 for(int i=0;i<nbFields;i++)
10886 MCAuto<MEDFileAnyTypeFieldMultiTS> fmts(getFieldAtPos(i));
10889 std::ostringstream oss; oss << "MEDFileFields::extractPart : at pos #" << i << " field is null !";
10890 throw INTERP_KERNEL::Exception(oss.str());
10892 MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(fmts->extractPart(extractDef,mm));
10893 fsOut->pushField(fmtsOut);
10895 return fsOut.retn();
10898 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
10900 if(i<0 || i>=(int)_fields.size())
10902 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
10903 throw INTERP_KERNEL::Exception(oss.str());
10905 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
10908 MCAuto<MEDFileAnyTypeFieldMultiTS> ret;
10909 const MEDFileFieldMultiTSWithoutSDA *fmtsC(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts));
10910 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts));
10912 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
10914 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
10917 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
10918 throw INTERP_KERNEL::Exception(oss.str());
10920 ret->shallowCpyGlobs(*this);
10925 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
10926 * This method is accessible in python using __getitem__ with a list in input.
10927 * \return a new object that the caller should deal with.
10929 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
10931 MCAuto<MEDFileFields> ret=shallowCpy();
10932 std::size_t sz=std::distance(startIds,endIds);
10933 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
10935 for(const int *i=startIds;i!=endIds;i++,j++)
10937 if(*i<0 || *i>=(int)_fields.size())
10939 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10940 throw INTERP_KERNEL::Exception(oss.str());
10942 fields[j]=_fields[*i];
10944 ret->_fields=fields;
10948 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
10950 return getFieldAtPos(getPosFromFieldName(fieldName));
10954 * This method removes, if any, fields in \a this having no time steps.
10955 * 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.
10957 * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
10959 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
10961 std::vector<MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
10962 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10964 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10967 if(elt->getNumberOfTS()>0)
10968 newFields.push_back(*it);
10971 if(_fields.size()==newFields.size())
10978 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
10979 * This method can be seen as a filter applied on \a this, that returns an object containing
10980 * 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
10981 * shallow copied from \a this.
10983 * \param [in] meshName - the name of the mesh on w
10984 * \return a new object that the caller should deal with.
10986 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
10988 MCAuto<MEDFileFields> ret(MEDFileFields::New());
10989 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10991 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10994 if(cur->getMeshName()==meshName)
10997 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
10998 ret->_fields.push_back(cur2);
11001 ret->shallowCpyOnlyUsedGlobs(*this);
11006 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
11007 * Input time steps are specified using a pair of integer (iteration, order).
11008 * 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,
11009 * but for each multitimestep only the time steps in \a timeSteps are kept.
11010 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
11012 * The returned object points to shallow copy of elements in \a this.
11014 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
11015 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
11016 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
11018 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
11020 MCAuto<MEDFileFields> ret(MEDFileFields::New());
11021 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11023 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
11026 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
11027 ret->_fields.push_back(elt);
11029 ret->shallowCpyOnlyUsedGlobs(*this);
11034 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
11036 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
11038 MCAuto<MEDFileFields> ret=MEDFileFields::New();
11039 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11041 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
11044 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
11045 if(elt->getNumberOfTS()!=0)
11046 ret->_fields.push_back(elt);
11048 ret->shallowCpyOnlyUsedGlobs(*this);
11052 bool MEDFileFields::presenceOfStructureElements() const
11054 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11055 if((*it).isNotNull())
11056 if((*it)->presenceOfStructureElements())
11061 void MEDFileFields::killStructureElements()
11063 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
11064 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11065 if((*it).isNotNull())
11067 if((*it)->presenceOfStructureElements())
11069 if(!(*it)->onlyStructureElements())
11071 (*it)->killStructureElements();
11072 ret.push_back(*it);
11077 ret.push_back(*it);
11083 void MEDFileFields::keepOnlyStructureElements()
11085 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
11086 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11087 if((*it).isNotNull())
11089 if((*it)->presenceOfStructureElements())
11091 if(!(*it)->onlyStructureElements())
11092 (*it)->keepOnlyStructureElements();
11093 ret.push_back(*it);
11099 MCAuto<MEDFileFields> MEDFileFields::partOfThisOnStructureElements() const
11101 MCAuto<MEDFileFields> ret(deepCopy());
11102 ret->keepOnlyStructureElements();
11106 MEDFileFieldsIterator *MEDFileFields::iterator()
11108 return new MEDFileFieldsIterator(this);
11111 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
11113 std::string tmp(fieldName);
11114 std::vector<std::string> poss;
11115 for(std::size_t i=0;i<_fields.size();i++)
11117 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f(_fields[i]);
11120 std::string fname(f->getName());
11124 poss.push_back(fname);
11127 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
11128 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
11130 throw INTERP_KERNEL::Exception(oss.str());
11133 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
11138 _nb_iter=fs->getNumberOfFields();
11142 MEDFileFieldsIterator::~MEDFileFieldsIterator()
11146 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
11148 if(_iter_id<_nb_iter)
11150 MEDFileFields *fs(_fs);
11152 return fs->getFieldAtPos(_iter_id++);