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 std::string MEDFileFieldPerMeshPerTypeDyn::getModelName() const
1725 return _se->getName();
1728 void MEDFileFieldPerMeshPerTypeDyn::getDimension(int& dim) const
1730 throw INTERP_KERNEL::Exception("not implemented yet !");
1733 void MEDFileFieldPerMeshPerTypeDyn::entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const
1736 ent=MED_STRUCT_ELEMENT;
1739 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypeDyn::getGeoType() const
1741 throw INTERP_KERNEL::Exception("not implemented yet !");
1744 void MEDFileFieldPerMeshPerTypeDyn::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1746 const char startLine[]=" ## ";
1747 std::string startLine2(bkOffset,' ');
1748 std::string startLine3(startLine2);
1749 startLine3+=startLine;
1750 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry STRUCTURE_ELEMENT type " << getDynGT() << "." << std::endl;
1751 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1753 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1755 if((*it).isNotNull())
1756 (*it)->simpleRepr(bkOffset,oss,i);
1759 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1764 std::string MEDFileFieldPerMeshPerTypeDyn::getGeoTypeRepr() const
1766 throw INTERP_KERNEL::Exception("not implemented yet !");
1769 MEDFileFieldPerMeshPerTypeDyn *MEDFileFieldPerMeshPerTypeDyn::deepCopy(MEDFileFieldPerMesh *father) const
1771 MCAuto<MEDFileFieldPerMeshPerTypeDyn> ret(new MEDFileFieldPerMeshPerTypeDyn(*this));
1772 ret->setFather(father);
1773 ret->deepCopyElements();
1777 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
1779 throw INTERP_KERNEL::Exception("not implemented yet !");
1782 //////////////////////////////////////////////////
1784 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const MEDFileEntities *entities)
1786 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm,entities);
1789 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1791 return new MEDFileFieldPerMesh(fath,mesh);
1794 std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
1796 return _mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MCAuto< MEDFileFieldPerMeshPerType >);
1799 std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildrenWithNull() const
1801 std::vector<const BigMemoryObject *> ret;
1802 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1807 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCopy(MEDFileAnyTypeField1TSWithoutSDA *father) const
1809 MCAuto< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1810 ret->_father=father;
1812 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1814 if((*it).isNotNull())
1815 ret->_field_pm_pt[i]=(*it)->deepCopy((MEDFileFieldPerMesh *)(ret));
1820 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1822 std::string startLine(bkOffset,' ');
1823 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1824 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1826 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1828 if((*it).isNotNull())
1829 (*it)->simpleRepr(bkOffset,oss,i);
1832 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1837 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh)
1839 _mesh_name=mesh->getName();
1840 mesh->getTime(_mesh_iteration,_mesh_order);
1843 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1845 int nbOfTypes=code.size()/3;
1847 for(int i=0;i<nbOfTypes;i++)
1849 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1850 int nbOfCells=code[3*i+1];
1851 int pos=addNewEntryIfNecessary(type);
1852 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1858 * This method is the most general one. No optimization is done here.
1859 * \param [in] multiTypePfl is the end user profile specified in high level API
1860 * \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].
1861 * \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.
1862 * \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.
1863 * \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.
1864 * \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.
1866 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)
1868 int nbOfTypes(code.size()/3);
1869 for(int i=0;i<nbOfTypes;i++)
1871 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1872 int pos=addNewEntryIfNecessary(type);
1873 DataArrayInt *pfl=0;
1875 pfl=idsPerType[code[3*i+2]];
1876 int nbOfTupes2=code2.size()/3;
1878 for(;found<nbOfTupes2;found++)
1879 if(code[3*i]==code2[3*found])
1881 if(found==nbOfTupes2)
1882 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1883 _field_pm_pt[pos]->assignFieldProfile(nbOfTypes==1,start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1887 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1889 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1890 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1893 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1895 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1896 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1899 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
1901 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1902 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1905 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1907 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1908 (*it)->loadBigArraysRecursively(fid,nasc);
1911 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1913 int nbOfTypes=_field_pm_pt.size();
1914 for(int i=0;i<nbOfTypes;i++)
1916 _field_pm_pt[i]->copyOptionsFrom(*this);
1917 _field_pm_pt[i]->writeLL(fid,nasc);
1921 void MEDFileFieldPerMesh::getDimension(int& dim) const
1923 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1924 (*it)->getDimension(dim);
1927 bool MEDFileFieldPerMesh::isUniqueLevel(int& dim) const
1929 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1930 if(!(*it)->isUniqueLevel(dim))
1935 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1937 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1938 (*it)->fillTypesOfFieldAvailable(types);
1941 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
1943 int sz=_field_pm_pt.size();
1944 std::vector< std::vector<std::pair<int,int> > > ret(sz);
1945 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1946 for(int i=0;i<sz;i++)
1948 types[i]=_field_pm_pt[i]->getGeoType();
1949 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1954 double MEDFileFieldPerMesh::getTime() const
1957 return _father->getTime(tmp1,tmp2);
1960 int MEDFileFieldPerMesh::getIteration() const
1962 return _father->getIteration();
1965 int MEDFileFieldPerMesh::getOrder() const
1967 return _father->getOrder();
1970 int MEDFileFieldPerMesh::getNumberOfComponents() const
1972 return _father->getNumberOfComponents();
1975 bool MEDFileFieldPerMesh::presenceOfMultiDiscPerGeoType() const
1977 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1981 if((*it)->presenceOfMultiDiscPerGeoType())
1987 bool MEDFileFieldPerMesh::presenceOfStructureElements() const
1989 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1990 if((*it).isNotNull())
1992 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
1999 bool MEDFileFieldPerMesh::onlyStructureElements() const
2001 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2002 if((*it).isNotNull())
2004 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2011 void MEDFileFieldPerMesh::killStructureElements()
2013 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
2014 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2016 if((*it).isNotNull())
2018 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2026 void MEDFileFieldPerMesh::keepOnlyStructureElements()
2028 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
2029 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2031 if((*it).isNotNull())
2033 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2041 void MEDFileFieldPerMesh::keepOnlyOnSE(const std::string& seName)
2043 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
2044 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2046 if((*it).isNotNull())
2048 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2050 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::keepOnlyOnSE : presence of non SE !");
2051 if(pt->getModelName()==seName)
2058 void MEDFileFieldPerMesh::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
2060 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2062 if((*it).isNotNull())
2064 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2067 ps.push_back(std::pair<std::string,std::string>(getMeshName(),pt->getModelName()));
2070 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getMeshSENames : presence of a non structure element part !");
2075 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
2078 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
2079 return _father->getOrCreateAndGetArray();
2082 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
2085 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
2086 return _father->getOrCreateAndGetArray();
2089 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
2091 return _father->getInfo();
2095 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
2096 * 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.
2097 * It returns 2 output vectors :
2098 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
2099 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
2100 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
2102 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)
2104 int notNullPflsSz=0;
2105 int nbOfArrs=geoTypes.size();
2106 for(int i=0;i<nbOfArrs;i++)
2109 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
2110 int nbOfDiffGeoTypes=geoTypes3.size();
2111 code.resize(3*nbOfDiffGeoTypes);
2112 notNullPfls.resize(notNullPflsSz);
2115 for(int i=0;i<nbOfDiffGeoTypes;i++)
2118 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
2119 std::vector<const DataArrayInt *> notNullTmp;
2121 notNullTmp.push_back(pfls[j]);
2123 for(;j<nbOfArrs;j++)
2124 if(geoTypes[j]==refType)
2127 notNullTmp.push_back(pfls[j]);
2131 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
2132 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
2133 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
2134 code[3*i]=(int)refType;
2135 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
2136 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
2137 if(notNullTmp.empty())
2141 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
2142 code[3*i+2]=notNullPflsSz++;
2148 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
2150 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)
2154 for(int i=0;i<sz;i++)
2158 if(type!=ON_GAUSS_NE)
2159 ret+=dads[i].second-dads[i].first;
2162 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
2163 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
2168 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
2169 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
2175 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
2177 std::vector<std::string> ret;
2178 std::set<std::string> ret2;
2179 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2181 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
2182 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
2183 if(ret2.find(*it2)==ret2.end())
2185 ret.push_back(*it2);
2192 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
2194 std::vector<std::string> ret;
2195 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2197 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
2198 ret.insert(ret.end(),tmp.begin(),tmp.end());
2203 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
2205 std::vector<std::string> ret;
2206 std::set<std::string> ret2;
2207 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2209 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
2210 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
2211 if(ret2.find(*it2)==ret2.end())
2213 ret.push_back(*it2);
2220 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
2222 std::vector<std::string> ret;
2223 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2225 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
2226 ret.insert(ret.end(),tmp.begin(),tmp.end());
2231 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
2233 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
2235 if((*it).first==_mesh_name)
2237 _mesh_name=(*it).second;
2244 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
2245 MEDFileFieldGlobsReal& glob)
2247 if(_mesh_name!=meshName)
2249 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
2250 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
2251 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
2252 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
2253 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
2254 getUndergroundDataArrayExt(entries);
2255 DataArray *arr0(getOrCreateAndGetArray());//tony
2257 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
2258 DataArrayDouble *arr(dynamic_cast<DataArrayDouble *>(arr0));//tony
2260 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
2263 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
2264 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
2266 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
2268 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2269 sz+=(*it).second.second-(*it).second.first;
2272 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2274 MCAuto<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
2275 ////////////////////
2276 MCAuto<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
2277 int *workI2=explicitIdsOldInMesh->getPointer();
2278 int sz1=0,sz2=0,sid=1;
2279 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
2280 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
2281 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
2283 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
2284 MCAuto<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
2285 int *workI=explicitIdsOldInArr->getPointer();
2286 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
2288 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
2289 (*itL2)->setLocId(sz2);
2290 (*itL2)->_tmp_work1=(*itL2)->getStart();
2291 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
2293 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
2295 explicitIdsOldInMesh->reAlloc(sz2);
2296 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
2297 ////////////////////
2298 MCAuto<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
2299 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
2300 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
2301 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
2303 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
2304 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
2305 otherEntriesNew.back()->setLocId((*it)->getGeoType());
2307 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
2308 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
2309 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
2311 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
2312 int newStart=elt->getLocId();
2313 elt->setLocId((*it)->getGeoType());
2314 elt->setNewStart(newStart);
2315 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
2316 entriesKeptNew.push_back(elt);
2317 entriesKeptNew2.push_back(elt);
2319 MCAuto<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
2320 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
2321 MCAuto<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
2322 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
2324 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
2327 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
2329 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
2330 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
2332 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
2333 glob,arr2,otherEntriesNew) || ret;
2337 // Assign new dispatching
2338 assignNewLeaves(otherEntriesNew);
2339 arr->deepCopyFrom(*arr2);
2344 * \param [in,out] globalNum a global numbering counter for the renumbering.
2345 * \param [out] its - list of pair (start,stop) kept
2347 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
2349 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > ret;
2350 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2352 std::vector< std::pair<int,int> > its2;
2353 if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
2356 its.insert(its.end(),its2.begin(),its2.end());
2363 * \param [in,out] globalNum a global numbering counter for the renumbering.
2364 * \param [out] its - list of pair (start,stop) kept
2366 void MEDFileFieldPerMesh::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
2368 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > ret;
2369 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2371 std::vector< std::pair<int,int> > its2;
2372 if((*it)->keepOnlyGaussDiscretization(idOfDisc,globalNum,its2))
2375 its.insert(its.end(),its2.begin(),its2.end());
2381 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
2383 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > > types;
2384 for( std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
2385 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
2387 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > fieldPmPt(types.size());
2388 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
2389 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it2=fieldPmPt.begin();
2390 for(;it1!=types.end();it1++,it2++)
2392 MCAuto<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
2393 elt->setLeaves((*it1).second);
2394 MCAuto<MEDFileFieldPerMeshPerTypeCommon> elt2(DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(elt));
2397 _field_pm_pt=fieldPmPt;
2400 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2402 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2403 (*it)->changePflsRefsNamesGen(mapOfModif);
2406 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2408 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2409 (*it)->changeLocsRefsNamesGen(mapOfModif);
2413 * \param [in] mesh is the whole mesh
2415 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2417 if(_field_pm_pt.empty())
2418 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2420 std::vector< std::pair<int,int> > dads;
2421 std::vector<const DataArrayInt *> pfls;
2422 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2423 std::vector<int> locs,code;
2424 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2425 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2426 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2428 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2431 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2432 throw INTERP_KERNEL::Exception(oss.str());
2435 std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2436 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2439 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2441 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2444 MCAuto<DataArrayInt> arr2(arr);
2445 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2451 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2455 if(nb!=mesh->getNumberOfNodes())
2457 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2458 oss << " nodes in mesh !";
2459 throw INTERP_KERNEL::Exception(oss.str());
2461 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2464 return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2468 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
2470 if(_field_pm_pt.empty())
2471 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2473 std::vector<std::pair<int,int> > dads;
2474 std::vector<const DataArrayInt *> pfls;
2475 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2476 std::vector<int> locs,code;
2477 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2478 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2479 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2481 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2484 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2485 throw INTERP_KERNEL::Exception(oss.str());
2487 std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2488 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2491 MCAuto<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2492 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2497 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2501 if(nb!=mesh->getNumberOfNodes())
2503 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2504 oss << " nodes in mesh !";
2505 throw INTERP_KERNEL::Exception(oss.str());
2508 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2514 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
2518 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2520 (*it)->getSizes(globalSz,nbOfEntries);
2522 entries.resize(nbOfEntries);
2524 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2526 (*it)->fillValues(nbOfEntries,entries);
2530 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
2532 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2534 if((*it)->getGeoType()==typ)
2535 return (*it)->getLeafGivenLocId(locId);
2537 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2538 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2539 oss << "Possiblities are : ";
2540 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2542 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2543 oss << "\"" << cm2.getRepr() << "\", ";
2545 throw INTERP_KERNEL::Exception(oss.str());
2548 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
2550 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2552 if((*it)->getGeoType()==typ)
2553 return (*it)->getLeafGivenLocId(locId);
2555 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2556 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2557 oss << "Possiblities are : ";
2558 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2560 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2561 oss << "\"" << cm2.getRepr() << "\", ";
2563 throw INTERP_KERNEL::Exception(oss.str());
2567 * \param [in,out] start - Integer that gives the current position in the final aggregated array
2568 * \param [in] pms - list of elements to aggregate. integer gives the mesh id
2569 * \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.
2570 * \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.
2572 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)
2574 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret(new MEDFileFieldPerMeshPerTypePerDisc(father,tof));
2576 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : empty input vector !");
2577 for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it=pms.begin();it!=pms.end();it++)
2580 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : presence of null pointer !");
2581 if(!(*it).second->getProfile().empty())
2582 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for profiles !");
2583 if(!(*it).second->getLocalization().empty())
2584 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for gauss pts !");
2586 INTERP_KERNEL::NormalizedCellType gt(pms[0].second->getGeoType());
2588 std::vector< std::pair<int,int> > filteredDTS;
2589 for(std::vector< std::vector< std::pair<int,int> > >::const_iterator it=dts.begin();it!=dts.end();it++,i++)
2590 for(std::vector< std::pair<int,int> >::const_iterator it2=(*it).begin();it2!=(*it).end();it2++)
2591 if((*it2).first==gt)
2592 filteredDTS.push_back(std::pair<int,int>(i,(*it2).second));
2593 if(pms.size()!=filteredDTS.size())
2594 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles !");
2595 std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it1(pms.begin());
2596 std::vector< std::pair<int,int> >::const_iterator it2(filteredDTS.begin());
2597 int zeStart(start),nval(0);
2598 for(;it1!=pms.end();it1++,it2++)
2600 if((*it1).first!=(*it2).first)
2601 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles 2 !");
2602 int s1((*it1).second->getStart()),e1((*it1).second->getEnd());
2603 extractInfo.push_back(std::pair<int, std::pair<int,int> >((*it1).first,std::pair<int,int>(s1,e1)));
2605 nval+=((*it1).second)->getNumberOfVals();
2607 ret->_start=zeStart; ret->_end=start; ret->_nval=nval;
2611 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)
2613 MCAuto<MEDFileFieldPerMesh> ret(new MEDFileFieldPerMesh(father,pms[0]->getMeshName(),pms[0]->getMeshIteration(),pms[0]->getMeshOrder()));
2614 std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > > m;
2616 for(std::vector<const MEDFileFieldPerMesh *>::const_iterator it=pms.begin();it!=pms.end();it++,i++)
2618 const std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >& v((*it)->_field_pm_pt);
2619 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it2=v.begin();it2!=v.end();it2++)
2621 INTERP_KERNEL::NormalizedCellType gt((*it2)->getGeoType());
2622 const MEDFileFieldPerMeshPerType *elt(dynamic_cast<const MEDFileFieldPerMeshPerType *>((const MEDFileFieldPerMeshPerTypeCommon *)(*it2)));
2624 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::Aggregate : not managed for structelement !");
2625 m[gt].push_back(std::pair<int,const MEDFileFieldPerMeshPerType *>(i,elt));
2628 for(std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > >::const_iterator it=m.begin();it!=m.end();it++)
2630 MCAuto<MEDFileFieldPerMeshPerType> agg(MEDFileFieldPerMeshPerType::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
2631 MCAuto<MEDFileFieldPerMeshPerTypeCommon> agg2(DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(agg));
2632 ret->_field_pm_pt.push_back(agg2);
2637 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2640 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2641 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it2=_field_pm_pt.begin();
2642 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2644 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2649 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2654 int ret=std::distance(_field_pm_pt.begin(),it2);
2655 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2660 * 'dads' and 'locs' input parameters have the same number of elements
2661 * \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
2663 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2664 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2665 const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2668 MCAuto<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2669 ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2670 MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2671 const std::vector<std::string>& infos=getInfo();
2672 da->setInfoOnComponents(infos);
2674 if(type==ON_GAUSS_PT)
2677 int nbOfArrs=dads.size();
2678 for(int i=0;i<nbOfArrs;i++)
2680 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2681 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2682 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2683 MCAuto<DataArrayInt> di=DataArrayInt::New();
2684 di->alloc(nbOfElems,1);
2686 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2687 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2696 * 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.
2697 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2698 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2699 * The order of cells in the returned field is those imposed by the profile.
2700 * \param [in] mesh is the global mesh.
2702 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2703 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2704 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2705 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2707 if(da->isIota(mesh->getNumberOfCells()))
2708 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2709 MCAuto<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2710 m2->setName(mesh->getName().c_str());
2711 MCAuto<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2717 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2719 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2720 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2721 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2723 if(da->isIota(mesh->getNumberOfNodes()))
2724 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2725 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2726 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2729 if(meshu->getNodalConnectivity()==0)
2731 MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2732 int nb=da->getNbOfElems();
2733 const int *ptr=da->getConstPointer();
2734 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2735 meshuc->allocateCells(nb);
2736 for(int i=0;i<nb;i++)
2737 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2738 meshuc->finishInsertingCells();
2739 ret->setMesh(meshuc);
2740 const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2741 if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2742 disc->checkCoherencyBetween(meshuc,arrOut);
2747 MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2749 DataArrayInt *arr2=0;
2750 MCAuto<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2751 MCAuto<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2752 MCAuto<DataArrayInt> arr3(arr2);
2753 int nnodes=mesh2->getNumberOfNodes();
2754 if(nnodes==(int)da->getNbOfElems())
2756 MCAuto<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2757 arrOut->renumberInPlace(da3->getConstPointer());
2758 mesh2->setName(mesh->getName().c_str());
2759 ret->setMesh(mesh2);
2764 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 !!!";
2765 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2766 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2767 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2768 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2769 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2770 throw INTERP_KERNEL::Exception(oss.str());
2776 * This method is the most light method of field retrieving.
2778 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
2782 pflOut=DataArrayInt::New();
2783 pflOut->alloc(nbOfElems,1);
2788 pflOut=const_cast<DataArrayInt*>(pflIn);
2791 MCAuto<DataArrayInt> safePfl(pflOut);
2792 MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2793 const std::vector<std::string>& infos=getInfo();
2794 int nbOfComp=infos.size();
2795 for(int i=0;i<nbOfComp;i++)
2796 da->setInfoOnComponent(i,infos[i].c_str());
2807 static MFFPMIter *NewCell(const MEDFileEntities *entities);
2808 static bool IsPresenceOfNode(const MEDFileEntities *entities);
2809 virtual ~MFFPMIter() { }
2810 virtual void begin() = 0;
2811 virtual bool finished() const = 0;
2812 virtual void next() = 0;
2813 virtual int current() const = 0;
2816 class MFFPMIterSimple : public MFFPMIter
2819 MFFPMIterSimple():_pos(0) { }
2820 void begin() { _pos=0; }
2821 bool finished() const { return _pos>=MED_N_CELL_FIXED_GEO; }
2822 void next() { _pos++; }
2823 int current() const { return _pos; }
2828 class MFFPMIter2 : public MFFPMIter
2831 MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts);
2832 void begin() { _it=_ids.begin(); }
2833 bool finished() const { return _it==_ids.end(); }
2834 void next() { _it++; }
2835 int current() const { return *_it; }
2837 std::vector<int> _ids;
2838 std::vector<int>::const_iterator _it;
2841 MFFPMIter *MFFPMIter::NewCell(const MEDFileEntities *entities)
2844 return new MFFPMIterSimple;
2847 const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
2850 std::vector<INTERP_KERNEL::NormalizedCellType> tmp;
2851 const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
2852 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
2854 if((*it).first==ON_CELLS || (*it).first==ON_GAUSS_NE || (*it).first==ON_GAUSS_PT)
2855 tmp.push_back((*it).second);
2857 return new MFFPMIter2(tmp);
2859 return new MFFPMIterSimple;// for MEDFileAllStaticEntites and MEDFileAllStaticEntitiesPlusDyn cells are in
2863 bool MFFPMIter::IsPresenceOfNode(const MEDFileEntities *entities)
2869 const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
2872 const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
2873 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
2874 if((*it).first==ON_NODES)
2878 return true;// for MEDFileAllStaticEntites and MEDFileAllStaticEntitiesPlusDyn nodes are in
2882 MFFPMIter2::MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts)
2884 std::size_t sz(cts.size());
2886 for(std::size_t i=0;i<sz;i++)
2888 INTERP_KERNEL::NormalizedCellType *loc(std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,cts[i]));
2889 if(loc!=typmai2+MED_N_CELL_FIXED_GEO)
2890 _ids[i]=(int)std::distance(typmai2,loc);
2892 throw INTERP_KERNEL::Exception("MFFPMIter2 : The specified geo type does not exists !");
2898 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),
2901 INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2902 INTERP_KERNEL::AutoPtr<char> pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2903 INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2904 const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
2905 INTERP_KERNEL::AutoCppPtr<MFFPMIter> iter0(MFFPMIter::NewCell(entities));
2906 for(iter0->begin();!iter0->finished();iter0->next())
2908 int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL ,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2909 std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2910 int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2911 std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2912 if(nbProfile>0 || nbProfile2>0)
2914 const PartDefinition *pd(0);
2916 pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[iter0->current()]),typmai2[iter0->current()]);
2917 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nasc,pd));
2924 if(MFFPMIter::IsPresenceOfNode(entities))
2926 int nbProfile(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName));
2929 const PartDefinition *pd(0);
2931 pd=mmu->getPartDefAtLevel(1,INTERP_KERNEL::NORM_ERROR);
2932 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd));
2933 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2938 std::vector<int> dynGT(entities->getDynGTAvail());
2939 for(std::vector<int>::const_iterator it=dynGT.begin();it!=dynGT.end();it++)
2941 int nbPfl(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,*it,pflName,locName));
2944 _field_pm_pt.push_back(MEDFileFieldPerMeshPerTypeDyn::NewOnRead(fid,this,entities,*it,nasc));
2945 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2950 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2952 copyTinyInfoFrom(mesh);
2955 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
2957 if(id>=(int)_pfls.size())
2959 _pfls[id]=DataArrayInt::New();
2960 int lgth(MEDprofileSizeByName(fid,pflName.c_str()));
2961 _pfls[id]->setName(pflName);
2962 _pfls[id]->alloc(lgth,1);
2963 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName.c_str(),_pfls[id]->getPointer()));
2964 _pfls[id]->applyLin(1,-1,0);//Converting into C format
2967 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2969 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2971 MEDFILESAFECALLERRD0(MEDprofileInfo,(fid,i+1,pflName,&sz));
2972 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2973 if(i>=(int)_pfls.size())
2975 _pfls[i]=DataArrayInt::New();
2976 _pfls[i]->alloc(sz,1);
2977 _pfls[i]->setName(pflCpp.c_str());
2978 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName,_pfls[i]->getPointer()));
2979 _pfls[i]->applyLin(1,-1,0);//Converting into C format
2982 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
2984 int nbOfPfls=_pfls.size();
2985 for(int i=0;i<nbOfPfls;i++)
2987 MCAuto<DataArrayInt> cpy=_pfls[i]->deepCopy();
2988 cpy->applyLin(1,1,0);
2989 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2990 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2991 MEDFILESAFECALLERWR0(MEDprofileWr,(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer()));
2994 int nbOfLocs=_locs.size();
2995 for(int i=0;i<nbOfLocs;i++)
2996 _locs[i]->writeLL(fid);
2999 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
3001 std::vector<std::string> pfls=getPfls();
3002 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
3004 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
3007 _pfls.push_back(*it);
3011 int id=std::distance(pfls.begin(),it2);
3012 if(!(*it)->isEqual(*_pfls[id]))
3014 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
3015 throw INTERP_KERNEL::Exception(oss.str());
3019 std::vector<std::string> locs=getLocs();
3020 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
3022 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
3025 _locs.push_back(*it);
3029 int id=std::distance(locs.begin(),it2);
3030 if(!(*it)->isEqual(*_locs[id],eps))
3032 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
3033 throw INTERP_KERNEL::Exception(oss.str());
3039 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
3041 for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
3042 getProfile((*it).c_str());
3045 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
3047 for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
3048 getLocalization((*it).c_str());
3051 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
3053 std::vector<std::string> profiles=real.getPflsReallyUsed();
3054 int sz=profiles.size();
3056 for(int i=0;i<sz;i++)
3057 loadProfileInFile(fid,i,profiles[i].c_str());
3059 std::vector<std::string> locs=real.getLocsReallyUsed();
3062 for(int i=0;i<sz;i++)
3063 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
3066 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid)
3068 int nProfil=MEDnProfile(fid);
3069 for(int i=0;i<nProfil;i++)
3070 loadProfileInFile(fid,i);
3071 int sz=MEDnLocalization(fid);
3073 for(int i=0;i<sz;i++)
3075 _locs[i]=MEDFileFieldLoc::New(fid,i);
3079 MEDFileFieldGlobs *MEDFileFieldGlobs::New(med_idt fid)
3081 return new MEDFileFieldGlobs(fid);
3084 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
3086 return new MEDFileFieldGlobs;
3089 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
3091 return _file_name.capacity()+_pfls.capacity()*sizeof(MCAuto<DataArrayInt>)+_locs.capacity()*sizeof(MCAuto<MEDFileFieldLoc>);
3094 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildrenWithNull() const
3096 std::vector<const BigMemoryObject *> ret;
3097 for(std::vector< MCAuto< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3098 ret.push_back((const DataArrayInt *)*it);
3099 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3100 ret.push_back((const MEDFileFieldLoc *)*it);
3104 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCopy() const
3106 MCAuto<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
3108 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3110 if((const DataArrayInt *)*it)
3111 ret->_pfls[i]=(*it)->deepCopy();
3114 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3116 if((const MEDFileFieldLoc*)*it)
3117 ret->_locs[i]=(*it)->deepCopy();
3123 * \throw if a profile in \a pfls in not in \a this.
3124 * \throw if a localization in \a locs in not in \a this.
3125 * \sa MEDFileFieldGlobs::deepCpyPart
3127 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
3129 MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
3130 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
3132 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
3134 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
3136 MCAuto<DataArrayInt> pfl2(pfl);
3137 ret->_pfls.push_back(pfl2);
3139 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
3141 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
3143 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
3145 MCAuto<MEDFileFieldLoc> loc2(loc);
3146 ret->_locs.push_back(loc2);
3148 ret->setFileName(getFileName());
3153 * \throw if a profile in \a pfls in not in \a this.
3154 * \throw if a localization in \a locs in not in \a this.
3155 * \sa MEDFileFieldGlobs::shallowCpyPart
3157 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
3159 MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
3160 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
3162 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
3164 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
3165 ret->_pfls.push_back(pfl->deepCopy());
3167 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
3169 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
3171 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
3172 ret->_locs.push_back(loc->deepCopy());
3174 ret->setFileName(getFileName());
3178 MEDFileFieldGlobs::MEDFileFieldGlobs(med_idt fid):_file_name(MEDFileWritable::FileNameFromFID(fid))
3182 MEDFileFieldGlobs::MEDFileFieldGlobs()
3186 MEDFileFieldGlobs::~MEDFileFieldGlobs()
3190 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
3192 oss << "Profiles :\n";
3193 std::size_t n=_pfls.size();
3194 for(std::size_t i=0;i<n;i++)
3196 oss << " - #" << i << " ";
3197 const DataArrayInt *pfl=_pfls[i];
3199 oss << "\"" << pfl->getName() << "\"\n";
3204 oss << "Localizations :\n";
3205 for(std::size_t i=0;i<n;i++)
3207 oss << " - #" << i << " ";
3208 const MEDFileFieldLoc *loc=_locs[i];
3210 loc->simpleRepr(oss);
3216 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3218 for(std::vector< MCAuto<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
3220 DataArrayInt *elt(*it);
3223 std::string name(elt->getName());
3224 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3226 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3228 elt->setName((*it2).second.c_str());
3236 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3238 for(std::vector< MCAuto<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
3240 MEDFileFieldLoc *elt(*it);
3243 std::string name(elt->getName());
3244 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3246 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3248 elt->setName((*it2).second.c_str());
3256 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
3258 if(locId<0 || locId>=(int)_locs.size())
3259 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
3260 return _locs[locId]->getNbOfGaussPtPerCell();
3263 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
3265 return getLocalizationFromId(getLocalizationId(locName));
3268 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
3270 if(locId<0 || locId>=(int)_locs.size())
3271 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3272 return *_locs[locId];
3276 namespace MEDCouplingImpl
3281 LocFinder(const std::string& loc):_loc(loc) { }
3282 bool operator() (const MCAuto<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
3284 const std::string &_loc;
3290 PflFinder(const std::string& pfl):_pfl(pfl) { }
3291 bool operator() (const MCAuto<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
3293 const std::string& _pfl;
3298 int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
3300 std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),MEDCouplingImpl::LocFinder(loc));
3303 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
3304 for(it=_locs.begin();it!=_locs.end();it++)
3305 oss << "\"" << (*it)->getName() << "\", ";
3306 throw INTERP_KERNEL::Exception(oss.str());
3308 return std::distance(_locs.begin(),it);
3312 * The returned value is never null.
3314 const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
3316 std::string pflNameCpp(pflName);
3317 std::vector< MCAuto<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3320 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3321 for(it=_pfls.begin();it!=_pfls.end();it++)
3322 oss << "\"" << (*it)->getName() << "\", ";
3323 throw INTERP_KERNEL::Exception(oss.str());
3328 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
3330 if(pflId<0 || pflId>=(int)_pfls.size())
3331 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3332 return _pfls[pflId];
3335 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
3337 if(locId<0 || locId>=(int)_locs.size())
3338 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3339 return *_locs[locId];
3342 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
3344 return getLocalizationFromId(getLocalizationId(locName));
3348 * The returned value is never null.
3350 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
3352 std::string pflNameCpp(pflName);
3353 std::vector< MCAuto<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3356 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3357 for(it=_pfls.begin();it!=_pfls.end();it++)
3358 oss << "\"" << (*it)->getName() << "\", ";
3359 throw INTERP_KERNEL::Exception(oss.str());
3364 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
3366 if(pflId<0 || pflId>=(int)_pfls.size())
3367 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3368 return _pfls[pflId];
3371 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
3373 std::vector< MCAuto<DataArrayInt> > newPfls;
3375 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3377 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
3378 newPfls.push_back(*it);
3383 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
3385 std::vector< MCAuto<MEDFileFieldLoc> > newLocs;
3387 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3389 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
3390 newLocs.push_back(*it);
3395 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
3397 int sz=_pfls.size();
3398 std::vector<std::string> ret(sz);
3399 for(int i=0;i<sz;i++)
3400 ret[i]=_pfls[i]->getName();
3404 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
3406 int sz=_locs.size();
3407 std::vector<std::string> ret(sz);
3408 for(int i=0;i<sz;i++)
3409 ret[i]=_locs[i]->getName();
3413 bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
3415 std::vector<std::string> v=getPfls();
3416 std::string s(pflName);
3417 return std::find(v.begin(),v.end(),s)!=v.end();
3420 bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
3422 std::vector<std::string> v=getLocs();
3423 std::string s(locName);
3424 return std::find(v.begin(),v.end(),s)!=v.end();
3427 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
3429 std::map<int,std::vector<int> > m;
3431 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3433 const DataArrayInt *tmp=(*it);
3436 m[tmp->getHashCode()].push_back(i);
3439 std::vector< std::vector<int> > ret;
3440 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
3442 if((*it2).second.size()>1)
3444 std::vector<int> ret0;
3445 bool equalityOrNot=false;
3446 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
3448 std::vector<int>::const_iterator it4=it3; it4++;
3449 for(;it4!=(*it2).second.end();it4++)
3451 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
3454 ret0.push_back(*it3);
3455 ret0.push_back(*it4);
3461 ret.push_back(ret0);
3467 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
3469 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
3472 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
3474 std::string name(pfl->getName());
3476 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
3477 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3478 if(name==(*it)->getName())
3480 if(!pfl->isEqual(*(*it)))
3482 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
3483 throw INTERP_KERNEL::Exception(oss.str());
3487 _pfls.push_back(pfl);
3490 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)
3492 std::string name(locName);
3494 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
3495 MCAuto<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
3496 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3497 if((*it)->isName(locName))
3499 if(!(*it)->isEqual(*obj,1e-12))
3501 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
3502 throw INTERP_KERNEL::Exception(oss.str());
3505 _locs.push_back(obj);
3508 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
3510 std::vector<std::string> names=getPfls();
3511 return CreateNewNameNotIn("NewPfl_",names);
3514 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
3516 std::vector<std::string> names=getLocs();
3517 return CreateNewNameNotIn("NewLoc_",names);
3520 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
3522 for(std::size_t sz=0;sz<100000;sz++)
3524 std::ostringstream tryName;
3525 tryName << prefix << sz;
3526 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
3527 return tryName.str();
3529 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
3533 * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
3534 * \param [in] fname - the file name.
3536 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(med_idt fid):_globals(MEDFileFieldGlobs::New(fid))
3541 * Creates an empty MEDFileFieldGlobsReal.
3543 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
3547 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
3552 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildrenWithNull() const
3554 std::vector<const BigMemoryObject *> ret;
3555 ret.push_back((const MEDFileFieldGlobs *)_globals);
3560 * Returns a string describing profiles and Gauss points held in \a this.
3561 * \return std::string - the description string.
3563 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
3565 const MEDFileFieldGlobs *glob=_globals;
3566 std::ostringstream oss2; oss2 << glob;
3567 std::string stars(oss2.str().length(),'*');
3568 oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n";
3570 glob->simpleRepr(oss);
3572 oss << "NO GLOBAL INFORMATION !\n";
3575 void MEDFileFieldGlobsReal::resetContent()
3577 _globals=MEDFileFieldGlobs::New();
3580 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
3585 * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
3586 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3588 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3590 _globals=other._globals;
3594 * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3595 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3597 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3599 const MEDFileFieldGlobs *otherg(other._globals);
3602 _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3606 * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3607 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3609 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3611 const MEDFileFieldGlobs *otherg(other._globals);
3614 _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3617 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3619 _globals=other._globals;
3620 if((const MEDFileFieldGlobs *)_globals)
3621 _globals=other._globals->deepCopy();
3625 * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3626 * \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3627 * \param [in] eps - a precision used to compare Gauss points with same name held by
3628 * \a this and \a other MEDFileFieldGlobsReal.
3629 * \throw If \a this and \a other hold profiles with equal names but different ids.
3630 * \throw If \a this and \a other hold different Gauss points with equal names.
3632 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
3634 const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3635 if(thisGlobals==otherGlobals)
3639 _globals=other._globals;
3642 _globals->appendGlobs(*other._globals,eps);
3645 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
3647 checkGlobsPflsPartCoherency();
3648 checkGlobsLocsPartCoherency();
3651 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
3653 contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3656 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
3658 contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3661 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3663 contentNotNull()->loadProfileInFile(fid,id,pflName);
3666 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3668 contentNotNull()->loadProfileInFile(fid,id);
3671 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
3673 contentNotNull()->loadGlobals(fid,*this);
3676 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid)
3678 contentNotNull()->loadAllGlobals(fid);
3681 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3683 contentNotNull()->writeGlobals(fid,opt);
3687 * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3688 * or getPflsReallyUsedMulti().
3689 * \return std::vector<std::string> - a sequence of names of all profiles.
3691 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3693 return contentNotNull()->getPfls();
3697 * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3698 * or getLocsReallyUsedMulti().
3699 * \return std::vector<std::string> - a sequence of names of all localizations.
3701 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3703 return contentNotNull()->getLocs();
3707 * Checks if the profile with a given name exists.
3708 * \param [in] pflName - the profile name of interest.
3709 * \return bool - \c true if the profile named \a pflName exists.
3711 bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
3713 return contentNotNull()->existsPfl(pflName);
3717 * Checks if the localization with a given name exists.
3718 * \param [in] locName - the localization name of interest.
3719 * \return bool - \c true if the localization named \a locName exists.
3721 bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
3723 return contentNotNull()->existsLoc(locName);
3726 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
3728 return contentNotNull()->createNewNameOfPfl();
3731 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
3733 return contentNotNull()->createNewNameOfLoc();
3737 * Sets the name of a MED file.
3738 * \param [inout] fileName - the file name.
3740 void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
3742 contentNotNull()->setFileName(fileName);
3746 * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3747 * in the same order.
3748 * \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3749 * Each item of this sequence is a vector containing ids of equal profiles.
3751 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3753 return contentNotNull()->whichAreEqualProfiles();
3757 * Finds equal localizations.
3758 * \param [in] eps - a precision used to compare real values of the localizations.
3759 * \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3760 * Each item of this sequence is a vector containing ids of equal localizations.
3762 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3764 return contentNotNull()->whichAreEqualLocs(eps);
3768 * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3769 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3770 * this sequence is a pair whose
3771 * - the first item is a vector of profile names to replace by the second item,
3772 * - the second item is a profile name to replace every profile name of the first item.
3774 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3776 contentNotNull()->changePflsNamesInStruct(mapOfModif);
3780 * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3781 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3782 * this sequence is a pair whose
3783 * - the first item is a vector of localization names to replace by the second item,
3784 * - the second item is a localization name to replace every localization name of the first item.
3786 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3788 contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3792 * Replaces references to some profiles (a reference is a profile name) by references
3793 * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3794 * them-selves accordingly. <br>
3795 * This method is a generalization of changePflName().
3796 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3797 * this sequence is a pair whose
3798 * - the first item is a vector of profile names to replace by the second item,
3799 * - the second item is a profile name to replace every profile of the first item.
3800 * \sa changePflsRefsNamesGen()
3801 * \sa changePflName()
3803 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3805 changePflsRefsNamesGen(mapOfModif);
3806 changePflsNamesInStruct(mapOfModif);
3810 * Replaces references to some localizations (a reference is a localization name) by references
3811 * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3812 * them-selves accordingly. <br>
3813 * This method is a generalization of changeLocName().
3814 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3815 * this sequence is a pair whose
3816 * - the first item is a vector of localization names to replace by the second item,
3817 * - the second item is a localization name to replace every localization of the first item.
3818 * \sa changeLocsRefsNamesGen()
3819 * \sa changeLocName()
3821 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3823 changeLocsRefsNamesGen(mapOfModif);
3824 changeLocsNamesInStruct(mapOfModif);
3828 * Renames the profile having a given name and updates references to this profile.
3829 * \param [in] oldName - the name of the profile to rename.
3830 * \param [in] newName - a new name of the profile.
3831 * \sa changePflsNames().
3833 void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
3835 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3836 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3838 changePflsNames(mapOfModif);
3842 * Renames the localization having a given name and updates references to this localization.
3843 * \param [in] oldName - the name of the localization to rename.
3844 * \param [in] newName - a new name of the localization.
3845 * \sa changeLocsNames().
3847 void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
3849 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3850 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3852 changeLocsNames(mapOfModif);
3856 * Removes duplicated profiles. Returns a map used to update references to removed
3857 * profiles via changePflsRefsNamesGen().
3858 * Equal profiles are found using whichAreEqualProfiles().
3859 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3860 * a sequence describing the performed replacements of profiles. Each element of
3861 * this sequence is a pair whose
3862 * - the first item is a vector of profile names replaced by the second item,
3863 * - the second item is a profile name replacing every profile of the first item.
3865 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
3867 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3868 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3870 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3872 std::vector< std::string > tmp((*it).size());
3874 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3875 tmp[j]=std::string(getProfileFromId(*it2)->getName());
3876 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3878 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3879 killProfileIds(tmp2);
3881 changePflsRefsNamesGen(ret);
3886 * Removes duplicated localizations. Returns a map used to update references to removed
3887 * localizations via changeLocsRefsNamesGen().
3888 * Equal localizations are found using whichAreEqualLocs().
3889 * \param [in] eps - a precision used to compare real values of the localizations.
3890 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3891 * a sequence describing the performed replacements of localizations. Each element of
3892 * this sequence is a pair whose
3893 * - the first item is a vector of localization names replaced by the second item,
3894 * - the second item is a localization name replacing every localization of the first item.
3896 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
3898 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3899 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3901 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3903 std::vector< std::string > tmp((*it).size());
3905 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3906 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3907 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3909 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3910 killLocalizationIds(tmp2);
3912 changeLocsRefsNamesGen(ret);
3917 * Returns number of Gauss points per cell in a given localization.
3918 * \param [in] locId - an id of the localization of interest.
3919 * \return int - the number of the Gauss points per cell.
3921 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
3923 return contentNotNull()->getNbOfGaussPtPerCell(locId);
3927 * Returns an id of a localization by its name.
3928 * \param [in] loc - the localization name of interest.
3929 * \return int - the id of the localization.
3930 * \throw If there is no a localization named \a loc.
3932 int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
3934 return contentNotNull()->getLocalizationId(loc);
3938 * Returns the name of the MED file.
3939 * \return const std::string& - the MED file name.
3941 std::string MEDFileFieldGlobsReal::getFileName() const
3943 return contentNotNull()->getFileName();
3947 * Returns a localization object by its name.
3948 * \param [in] locName - the name of the localization of interest.
3949 * \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3950 * \throw If there is no a localization named \a locName.
3952 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
3954 return contentNotNull()->getLocalization(locName);
3958 * Returns a localization object by its id.
3959 * \param [in] locId - the id of the localization of interest.
3960 * \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3961 * \throw If there is no a localization with id \a locId.
3963 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
3965 return contentNotNull()->getLocalizationFromId(locId);
3969 * Returns a profile array by its name.
3970 * \param [in] pflName - the name of the profile of interest.
3971 * \return const DataArrayInt * - the profile array having the name \a pflName.
3972 * \throw If there is no a profile named \a pflName.
3974 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
3976 return contentNotNull()->getProfile(pflName);
3980 * Returns a profile array by its id.
3981 * \param [in] pflId - the id of the profile of interest.
3982 * \return const DataArrayInt * - the profile array having the id \a pflId.
3983 * \throw If there is no a profile with id \a pflId.
3985 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
3987 return contentNotNull()->getProfileFromId(pflId);
3991 * Returns a localization object, apt for modification, by its id.
3992 * \param [in] locId - the id of the localization of interest.
3993 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3994 * having the id \a locId.
3995 * \throw If there is no a localization with id \a locId.
3997 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
3999 return contentNotNull()->getLocalizationFromId(locId);
4003 * Returns a localization object, apt for modification, by its name.
4004 * \param [in] locName - the name of the localization of interest.
4005 * \return MEDFileFieldLoc& - a non-const reference to the localization object
4006 * having the name \a locName.
4007 * \throw If there is no a localization named \a locName.
4009 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
4011 return contentNotNull()->getLocalization(locName);
4015 * Returns a profile array, apt for modification, by its name.
4016 * \param [in] pflName - the name of the profile of interest.
4017 * \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
4018 * \throw If there is no a profile named \a pflName.
4020 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
4022 return contentNotNull()->getProfile(pflName);
4026 * Returns a profile array, apt for modification, by its id.
4027 * \param [in] pflId - the id of the profile of interest.
4028 * \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
4029 * \throw If there is no a profile with id \a pflId.
4031 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
4033 return contentNotNull()->getProfileFromId(pflId);
4037 * Removes profiles given by their ids. No data is updated to track this removal.
4038 * \param [in] pflIds - a sequence of ids of the profiles to remove.
4040 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
4042 contentNotNull()->killProfileIds(pflIds);
4046 * Removes localizations given by their ids. No data is updated to track this removal.
4047 * \param [in] locIds - a sequence of ids of the localizations to remove.
4049 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
4051 contentNotNull()->killLocalizationIds(locIds);
4055 * Stores a profile array.
4056 * \param [in] pfl - the profile array to store.
4057 * \throw If the name of \a pfl is empty.
4058 * \throw If a profile with the same name as that of \a pfl already exists but contains
4061 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
4063 contentNotNull()->appendProfile(pfl);
4067 * Adds a new localization of Gauss points.
4068 * \param [in] locName - the name of the new localization.
4069 * \param [in] geoType - a geometrical type of the reference cell.
4070 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
4071 * must be \c nbOfNodesPerCell * \c dimOfType.
4072 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
4073 * must be _wg_.size() * \c dimOfType.
4074 * \param [in] w - the weights of Gauss points.
4075 * \throw If \a locName is empty.
4076 * \throw If a localization with the name \a locName already exists but is
4077 * different form the new one.
4079 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)
4081 contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
4084 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
4086 MEDFileFieldGlobs *g(_globals);
4088 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
4092 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
4094 const MEDFileFieldGlobs *g(_globals);
4096 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
4100 //= MEDFileFieldNameScope
4102 MEDFileFieldNameScope::MEDFileFieldNameScope()
4106 MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName):_name(fieldName)
4111 * Returns the name of \a this field.
4112 * \return std::string - a string containing the field name.
4114 std::string MEDFileFieldNameScope::getName() const
4120 * Sets name of \a this field
4121 * \param [in] name - the new field name.
4123 void MEDFileFieldNameScope::setName(const std::string& fieldName)
4128 std::string MEDFileFieldNameScope::getDtUnit() const
4133 void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
4138 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
4141 _dt_unit=other._dt_unit;
4144 //= MEDFileAnyTypeField1TSWithoutSDA
4146 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
4148 _field_per_mesh.resize(other._field_per_mesh.size());
4150 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
4152 if((const MEDFileFieldPerMesh *)*it)
4153 _field_per_mesh[i]=(*it)->deepCopy(this);
4158 * Prints a string describing \a this field into a stream. This string is outputted
4159 * by \c print Python command.
4160 * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
4161 * \param [in,out] oss - the out stream.
4162 * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
4163 * info id printed, else, not.
4165 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
4167 std::string startOfLine(bkOffset,' ');
4168 oss << startOfLine << "Field ";
4170 oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
4171 oss << "on one time Step ";
4173 oss << "(" << f1tsId << ") ";
4174 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
4175 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
4176 const DataArray *arr=getUndergroundDataArray();
4179 const std::vector<std::string> &comps=arr->getInfoOnComponents();
4182 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
4183 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
4184 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
4186 if(arr->isAllocated())
4188 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
4191 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
4195 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
4197 oss << startOfLine << "----------------------" << std::endl;
4198 if(!_field_per_mesh.empty())
4201 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
4203 const MEDFileFieldPerMesh *cur=(*it2);
4205 cur->simpleRepr(bkOffset,oss,i);
4207 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
4212 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
4214 oss << startOfLine << "----------------------" << std::endl;
4217 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
4219 const DataArray *arr(getUndergroundDataArray());
4221 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
4222 int nbOfCompo=arr->getNumberOfComponents();
4223 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
4224 for(int i=0;i<nbOfCompo;i++)
4227 std::vector<int> v(1,i);
4228 MCAuto<DataArray> arr2=arr->keepSelectedComponents(v);
4229 ret[i]->setArray(arr2);
4234 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)
4238 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
4243 * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
4244 * empty. Returns -1 if this in on nodes.
4245 * \return int - the dimension of \a this.
4247 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
4250 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4251 (*it)->getDimension(ret);
4256 * Returns the mesh name.
4257 * \return std::string - a string holding the mesh name.
4258 * \throw If \c _field_per_mesh.empty()
4260 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const
4262 if(_field_per_mesh.empty())
4263 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
4264 return _field_per_mesh[0]->getMeshName();
4267 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const std::string& newMeshName)
4269 std::string oldName(getMeshName());
4270 std::vector< std::pair<std::string,std::string> > v(1);
4271 v[0].first=oldName; v[0].second=newMeshName;
4275 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
4278 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4280 MEDFileFieldPerMesh *cur(*it);
4282 ret=cur->changeMeshNames(modifTab) || ret;
4288 * Returns the number of iteration of the state of underlying mesh.
4289 * \return int - the iteration number.
4290 * \throw If \c _field_per_mesh.empty()
4292 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
4294 if(_field_per_mesh.empty())
4295 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
4296 return _field_per_mesh[0]->getMeshIteration();
4300 * Returns the order number of iteration of the state of underlying mesh.
4301 * \return int - the order number.
4302 * \throw If \c _field_per_mesh.empty()
4304 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
4306 if(_field_per_mesh.empty())
4307 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
4308 return _field_per_mesh[0]->getMeshOrder();
4312 * Checks if \a this field is tagged by a given iteration number and a given
4313 * iteration order number.
4314 * \param [in] iteration - the iteration number of interest.
4315 * \param [in] order - the iteration order number of interest.
4316 * \return bool - \c true if \a this->getIteration() == \a iteration &&
4317 * \a this->getOrder() == \a order.
4319 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
4321 return iteration==_iteration && order==_order;
4325 * Returns number of iteration and order number of iteration when
4326 * \a this field has been calculated.
4327 * \return std::pair<int,int> - a pair of the iteration number and the iteration
4330 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
4332 std::pair<int,int> p;
4338 * Returns number of iteration and order number of iteration when
4339 * \a this field has been calculated.
4340 * \param [in,out] p - a pair returning the iteration number and the iteration
4343 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
4350 * Returns all types of spatial discretization of \a this field.
4351 * \param [in,out] types - a sequence of types of \a this field.
4353 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
4355 std::set<TypeOfField> types2;
4356 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4358 (*it)->fillTypesOfFieldAvailable(types2);
4360 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
4361 std::copy(types2.begin(),types2.end(),bi);
4365 * Returns all types of spatial discretization of \a this field.
4366 * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
4369 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
4371 std::vector<TypeOfField> ret;
4372 fillTypesOfFieldAvailable(ret);
4376 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
4378 std::vector<std::string> ret;
4379 std::set<std::string> ret2;
4380 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4382 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
4383 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4384 if(ret2.find(*it2)==ret2.end())
4386 ret.push_back(*it2);
4393 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
4395 std::vector<std::string> ret;
4396 std::set<std::string> ret2;
4397 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4399 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
4400 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4401 if(ret2.find(*it2)==ret2.end())
4403 ret.push_back(*it2);
4410 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
4412 std::vector<std::string> ret;
4413 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4415 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
4416 ret.insert(ret.end(),tmp.begin(),tmp.end());
4421 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
4423 std::vector<std::string> ret;
4424 std::set<std::string> ret2;
4425 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4427 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
4428 ret.insert(ret.end(),tmp.begin(),tmp.end());
4433 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4435 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4436 (*it)->changePflsRefsNamesGen(mapOfModif);
4439 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4441 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4442 (*it)->changeLocsRefsNamesGen(mapOfModif);
4446 * Returns all attributes of parts of \a this field lying on a given mesh.
4447 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4448 * item of every of returned sequences refers to the _i_-th part of \a this field.
4449 * Thus all sequences returned by this method are of the same length equal to number
4450 * of different types of supporting entities.<br>
4451 * A field part can include sub-parts with several different spatial discretizations,
4452 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
4453 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4454 * of a nested sequence corresponds to a type of spatial discretization.<br>
4455 * This method allows for iteration over MEDFile DataStructure without any overhead.
4456 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4457 * for the case with only one underlying mesh. (Actually, the number of meshes is
4458 * not checked if \a mname == \c NULL).
4459 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4460 * a field part is returned.
4461 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4462 * This sequence is of the same length as \a types.
4463 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4464 * discretization. A profile name can be empty.
4465 * Length of this and of nested sequences is the same as that of \a typesF.
4466 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4467 * discretization. A localization name can be empty.
4468 * Length of this and of nested sequences is the same as that of \a typesF.
4469 * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
4470 * of ids of tuples within the data array, per each type of spatial
4471 * discretization within one mesh entity type.
4472 * Length of this and of nested sequences is the same as that of \a typesF.
4473 * \throw If no field is lying on \a mname.
4475 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
4479 meshId=getMeshIdFromMeshName(mname);
4481 if(_field_per_mesh.empty())
4482 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4483 return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4487 * Returns dimensions of mesh elements \a this field lies on. The returned value is a
4488 * maximal absolute dimension and values returned via the out parameter \a levs are
4489 * dimensions relative to the maximal absolute dimension. <br>
4490 * This method is designed for MEDFileField1TS instances that have a discretization
4491 * \ref MEDCoupling::ON_CELLS "ON_CELLS",
4492 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT",
4493 * \ref MEDCoupling::ON_GAUSS_NE "ON_GAUSS_NE".
4494 * Only these 3 discretizations will be taken into account here. If \a this is
4495 * \ref MEDCoupling::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
4496 * This method is useful to make the link between the dimension of the underlying mesh
4497 * and the levels of \a this, because it is possible that the highest dimension of \a this
4498 * field is not equal to the dimension of the underlying mesh.
4500 * Let's consider the following case:
4501 * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
4502 * TETRA4, HEXA8, TRI3 and SEG2.
4503 * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
4504 * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
4506 * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
4507 * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
4508 * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
4509 * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
4510 * parameter of getFieldAtLevel() is computed basing on the returned values as this:
4511 * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
4513 * to retrieve the highest level of
4514 * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br>
4515 * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
4516 * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
4517 * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
4518 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4519 * for the case with only one underlying mesh. (Actually, the number of meshes is
4520 * not checked if \a mname == \c NULL).
4521 * \param [in,out] levs - a sequence returning the dimensions relative to the maximal
4522 * absolute one. They are in decreasing order. This sequence is cleared before
4524 * \return int - the maximal absolute dimension of elements \a this fields lies on.
4525 * \throw If no field is lying on \a mname.
4527 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
4530 int meshId=getMeshIdFromMeshName(mname);
4531 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4532 std::vector< std::vector<TypeOfField> > typesF;
4533 std::vector< std::vector<std::string> > pfls, locs;
4534 _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4536 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
4537 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
4538 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
4540 st.erase(INTERP_KERNEL::NORM_ERROR);
4542 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
4544 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
4545 ret1.insert((int)cm.getDimension());
4547 int ret=*std::max_element(ret1.begin(),ret1.end());
4548 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
4549 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
4554 * \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.
4555 * \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.
4556 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4557 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4559 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
4561 int mid=getMeshIdFromMeshName(mName);
4562 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4566 * \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.
4567 * \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.
4568 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4569 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4571 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
4573 int mid=getMeshIdFromMeshName(mName);
4574 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4578 * \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.
4580 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
4582 if(_field_per_mesh.empty())
4583 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4586 std::string mName2(mName);
4588 std::vector<std::string> msg;
4589 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4590 if(mName2==(*it)->getMeshName())
4593 msg.push_back((*it)->getMeshName());
4594 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4595 oss << "Possible meshes are : ";
4596 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4597 oss << "\"" << (*it2) << "\" ";
4598 throw INTERP_KERNEL::Exception(oss.str());
4601 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
4604 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4605 std::string tmp(mesh->getName());
4607 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4608 std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4610 for(;it!=_field_per_mesh.end();it++,i++)
4612 if((*it)->getMeshName()==tmp)
4615 int sz=_field_per_mesh.size();
4616 _field_per_mesh.resize(sz+1);
4617 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4621 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4622 MEDFileFieldGlobsReal& glob)
4625 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4627 MEDFileFieldPerMesh *fpm(*it);
4629 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4635 * This method splits \a this into several sub-parts so that each sub parts have exactly one spatial discretization. This method implements the minimal
4636 * splitting that leads to single spatial discretization of this.
4638 * \sa splitMultiDiscrPerGeoTypes
4640 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
4642 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4643 std::vector< std::vector<TypeOfField> > typesF;
4644 std::vector< std::vector<std::string> > pfls,locs;
4645 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4646 std::set<TypeOfField> allEnt;
4647 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4648 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4649 allEnt.insert(*it2);
4650 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4651 std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4652 for(std::size_t i=0;i<allEnt.size();i++,it3++)
4654 std::vector< std::pair<int,int> > its;
4655 ret[i]=shallowCpy();
4656 int newLgth(ret[i]->keepOnlySpatialDiscretization(*it3,its));
4657 ret[i]->updateData(newLgth,its);
4663 * This method performs a sub splitting as splitDiscretizations does but finer. This is the finest spliting level that can be done.
4664 * This method implements the minimal splitting so that each returned elements are mono Gauss discretization per geometric type.
4666 * \sa splitDiscretizations
4668 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes() const
4670 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4671 std::vector< std::vector<TypeOfField> > typesF;
4672 std::vector< std::vector<std::string> > pfls,locs;
4673 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4674 std::set<TypeOfField> allEnt;
4675 std::size_t nbOfMDPGT(0),ii(0);
4676 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++,ii++)
4678 nbOfMDPGT=std::max(nbOfMDPGT,locs[ii].size());
4679 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4680 allEnt.insert(*it2);
4682 if(allEnt.size()!=1)
4683 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : this field is expected to be defined only on one spatial discretization !");
4685 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
4688 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret0(1);
4689 ret0[0]=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(this); this->incrRef();
4692 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfMDPGT);
4693 for(std::size_t i=0;i<nbOfMDPGT;i++)
4695 std::vector< std::pair<int,int> > its;
4696 ret[i]=shallowCpy();
4697 int newLgth(ret[i]->keepOnlyGaussDiscretization(i,its));
4698 ret[i]->updateData(newLgth,its);
4703 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
4705 int globalCounter(0);
4706 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4707 (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4708 return globalCounter;
4711 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlyGaussDiscretization(std::size_t idOfDisc, std::vector< std::pair<int,int> >& its)
4713 int globalCounter(0);
4714 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4715 (*it)->keepOnlyGaussDiscretization(idOfDisc,globalCounter,its);
4716 return globalCounter;
4719 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
4721 if(_nb_of_tuples_to_be_allocated>=0)
4723 _nb_of_tuples_to_be_allocated=newLgth;
4724 const DataArray *oldArr(getUndergroundDataArray());
4727 MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4728 newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
4730 _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
4734 if(_nb_of_tuples_to_be_allocated==-1)
4736 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4738 const DataArray *oldArr(getUndergroundDataArray());
4739 if(!oldArr || !oldArr->isAllocated())
4740 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4741 MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4742 newArr->alloc(newLgth,getNumberOfComponents());
4744 newArr->copyStringInfoFrom(*oldArr);
4746 for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4748 if((*it).second<(*it).first)
4749 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4750 newArr->setContigPartOfSelectedValuesSlice(pos,oldArr,(*it).first,(*it).second,1);
4751 pos+=(*it).second-(*it).first;
4756 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4759 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
4761 if(_field_per_mesh.empty())
4762 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4763 if(_field_per_mesh.size()>1)
4764 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4765 _field_per_mesh[0]->copyOptionsFrom(opts);
4766 _field_per_mesh[0]->writeLL(fid,nasc);
4770 * 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.
4771 * If false is returned the memory allocation is not required.
4773 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
4775 if(_nb_of_tuples_to_be_allocated>=0)
4777 getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4778 _nb_of_tuples_to_be_allocated=-2;
4781 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4783 if(_nb_of_tuples_to_be_allocated==-1)
4784 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4785 if(_nb_of_tuples_to_be_allocated<-3)
4786 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4787 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4790 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
4792 med_int numdt,numit;
4796 med_int meshnumdt,meshnumit;
4797 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4798 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt));
4799 MEDFILESAFECALLERRD0(MEDfield23ComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit));
4800 if(_iteration!=numdt || _order!=numit)
4801 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4802 _field_per_mesh.resize(nmesh);
4807 std::string meshNameCpp(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
4808 mm=ms->getMeshWithName(meshNameCpp);
4811 for(int i=0;i<nmesh;i++)
4812 _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i,meshnumdt,meshnumit,nasc,mm,entities);
4813 _nb_of_tuples_to_be_allocated=0;
4814 for(int i=0;i<nmesh;i++)
4815 _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4818 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
4820 allocIfNecessaryTheArrayToReceiveDataFromFile();
4821 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4822 (*it)->loadBigArraysRecursively(fid,nasc);
4825 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
4827 if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4828 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4829 (*it)->loadBigArraysRecursively(fid,nasc);
4832 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
4834 loadOnlyStructureOfDataRecursively(fid,nasc,ms,entities);
4835 loadBigArraysRecursively(fid,nasc);
4838 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
4840 DataArray *thisArr(getUndergroundDataArray());
4841 if(thisArr && thisArr->isAllocated())
4843 _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
4844 thisArr->desallocate();
4848 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
4850 return _dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MCAuto< MEDFileFieldPerMesh >);
4853 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
4855 std::vector<const BigMemoryObject *> ret;
4856 if(getUndergroundDataArray())
4857 ret.push_back(getUndergroundDataArray());
4858 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4859 ret.push_back((const MEDFileFieldPerMesh *)*it);
4864 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4865 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4866 * "Sort By Type"), if not, an exception is thrown.
4867 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
4868 * \param [in] arr - the array of values.
4869 * \param [in,out] glob - the global data where profiles and localization present in
4870 * \a field, if any, are added.
4871 * \throw If the name of \a field is empty.
4872 * \throw If the data array of \a field is not set.
4873 * \throw If \a this->_arr is already allocated but has different number of components
4875 * \throw If the underlying mesh of \a field has no name.
4876 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4878 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4880 const MEDCouplingMesh *mesh=field->getMesh();
4882 TypeOfField type=field->getTypeOfField();
4883 std::vector<DataArrayInt *> dummy;
4884 int start=copyTinyInfoFrom(field,arr);
4885 int pos=addNewEntryIfNecessary(mesh);
4888 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4889 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4892 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4896 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4897 * of a given mesh are used as the support of the given field (a real support is not used).
4898 * Elements of the given mesh must be sorted suitable for writing to MED file.
4899 * Order of underlying mesh entities of the given field specified by \a profile parameter
4900 * is not prescribed; this method permutes field values to have them sorted by element
4901 * type as required for writing to MED file. A new profile is added only if no equal
4902 * profile is missing.
4903 * \param [in] field - the field to add to \a this. The field double values are ignored.
4904 * \param [in] arrOfVals - the values of the field \a field used.
4905 * \param [in] mesh - the supporting mesh of \a field.
4906 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4907 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
4908 * \param [in,out] glob - the global data where profiles and localization present in
4909 * \a field, if any, are added.
4910 * \throw If either \a field or \a mesh or \a profile has an empty name.
4911 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4912 * \throw If the data array of \a field is not set.
4913 * \throw If \a this->_arr is already allocated but has different number of components
4915 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4916 * \sa setFieldNoProfileSBT()
4918 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4921 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
4922 if(!arrOfVals || !arrOfVals->isAllocated())
4923 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
4924 TypeOfField type=field->getTypeOfField();
4925 std::vector<DataArrayInt *> idsInPflPerType;
4926 std::vector<DataArrayInt *> idsPerType;
4927 std::vector<int> code,code2;
4928 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
4931 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4932 std::vector< MCAuto<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
4933 std::vector< MCAuto<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin());
4934 std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
4936 MCAuto<MEDCouplingFieldDouble> field2=field->clone(false);
4937 int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
4938 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4940 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4941 throw INTERP_KERNEL::Exception(oss.str());
4944 int start=copyTinyInfoFrom(field,arrOfVals);
4945 code2=m->getDistributionOfTypes();
4947 int pos=addNewEntryIfNecessary(m);
4948 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4952 if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
4953 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
4954 std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
4955 std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
4956 int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
4957 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4959 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4960 throw INTERP_KERNEL::Exception(oss.str());
4962 int start=copyTinyInfoFrom(field,arrOfVals);
4963 int pos=addNewEntryIfNecessary(m);
4964 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4969 * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
4971 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
4973 if(_nb_of_tuples_to_be_allocated>=0)
4974 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 !");
4975 DataArray *arr(getOrCreateAndGetArray());
4976 arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
4977 _nb_of_tuples_to_be_allocated=-3;
4981 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4982 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4983 * larger by the size of \a field. Returns an id of the first not filled
4984 * tuple of \a this->_arr.
4985 * \param [in] field - the field to copy the info on components and the name from.
4986 * \return int - the id of first not initialized tuple of \a this->_arr.
4987 * \throw If the name of \a field is empty.
4988 * \throw If the data array of \a field is not set.
4989 * \throw If \a this->_arr is already allocated but has different number of components
4992 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
4995 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4996 std::string name(field->getName());
4997 setName(name.c_str());
4998 setDtUnit(field->getTimeUnit());
5000 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
5002 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
5003 if(!arr->isAllocated())
5004 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
5005 _dt=field->getTime(_iteration,_order);
5006 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
5007 if(!getOrCreateAndGetArray()->isAllocated())
5009 allocNotFromFile(arr->getNumberOfTuples());
5014 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
5015 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
5016 getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
5017 _nb_of_tuples_to_be_allocated=-3;
5018 return oldNbOfTuples;
5023 * Returns number of components in \a this field
5024 * \return int - the number of components.
5026 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
5028 return getOrCreateAndGetArray()->getNumberOfComponents();
5032 * Change info on components in \a this.
5033 * \throw If size of \a infos is not equal to the number of components already in \a this.
5035 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
5037 DataArray *arr=getOrCreateAndGetArray();
5038 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
5042 * Returns info on components of \a this field.
5043 * \return const std::vector<std::string>& - a sequence of strings each being an
5044 * information on _i_-th component.
5046 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
5048 const DataArray *arr=getOrCreateAndGetArray();
5049 return arr->getInfoOnComponents();
5053 * Returns a mutable info on components of \a this field.
5054 * \return std::vector<std::string>& - a sequence of strings each being an
5055 * information on _i_-th component.
5057 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
5059 DataArray *arr=getOrCreateAndGetArray();
5060 return arr->getInfoOnComponents();
5063 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const
5065 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5067 const MEDFileFieldPerMesh *fpm(*it);
5070 if(fpm->presenceOfMultiDiscPerGeoType())
5076 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfStructureElements() const
5078 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5079 if((*it).isNotNull())
5080 if((*it)->presenceOfStructureElements())
5085 bool MEDFileAnyTypeField1TSWithoutSDA::onlyStructureElements() const
5087 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5088 if((*it).isNotNull())
5089 if(!(*it)->onlyStructureElements())
5094 void MEDFileAnyTypeField1TSWithoutSDA::killStructureElements()
5096 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5097 if((*it).isNotNull())
5098 (*it)->killStructureElements();
5101 void MEDFileAnyTypeField1TSWithoutSDA::keepOnlyStructureElements()
5103 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5104 if((*it).isNotNull())
5105 (*it)->keepOnlyStructureElements();
5108 void MEDFileAnyTypeField1TSWithoutSDA::keepOnlyOnSE(const std::string& seName)
5110 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5111 if((*it).isNotNull())
5112 (*it)->keepOnlyOnSE(seName);
5115 void MEDFileAnyTypeField1TSWithoutSDA::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
5117 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5118 if((*it).isNotNull())
5119 (*it)->getMeshSENames(ps);
5122 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh(const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5124 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 !";
5125 if(_field_per_mesh.empty())
5126 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is empty ! Nothing to extract !");
5127 if(_field_per_mesh.size()>1)
5128 throw INTERP_KERNEL::Exception(MSG0);
5129 if(_field_per_mesh[0].isNull())
5130 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is inconsistent !");
5131 const MEDFileFieldPerMesh *pm(_field_per_mesh[0]);
5132 std::set<TypeOfField> types;
5133 pm->fillTypesOfFieldAvailable(types);
5135 throw INTERP_KERNEL::Exception(MSG0);
5136 TypeOfField type(*types.begin());
5137 int meshDimRelToMax(0);
5142 int myDim(std::numeric_limits<int>::max());
5143 bool isUnique(pm->isUniqueLevel(myDim));
5145 throw INTERP_KERNEL::Exception(MSG0);
5146 meshDimRelToMax=myDim-mesh->getMeshDimension();
5147 if(meshDimRelToMax>0)
5148 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the mesh attached to field is not compatible with the field !");
5150 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,0/*renumPol*/,glob,mesh,arrOut,nasc);
5154 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5155 * \param [in] type - a spatial discretization of the new field.
5156 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5157 * \param [in] mName - a name of the supporting mesh.
5158 * \param [in] renumPol - specifies how to permute values of the result field according to
5159 * the optional numbers of cells and nodes, if any. The valid values are
5160 * - 0 - do not permute.
5161 * - 1 - permute cells.
5162 * - 2 - permute nodes.
5163 * - 3 - permute cells and nodes.
5165 * \param [in] glob - the global data storing profiles and localization.
5166 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5167 * caller is to delete this field using decrRef() as it is no more needed.
5168 * \throw If the MED file is not readable.
5169 * \throw If there is no mesh named \a mName in the MED file.
5170 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5171 * \throw If no field of \a this is lying on the mesh \a mName.
5172 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5174 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5176 MCAuto<MEDFileMesh> mm;
5178 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
5180 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
5181 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
5185 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5186 * \param [in] type - a spatial discretization of the new field.
5187 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5188 * \param [in] renumPol - specifies how to permute values of the result field according to
5189 * the optional numbers of cells and nodes, if any. The valid values are
5190 * - 0 - do not permute.
5191 * - 1 - permute cells.
5192 * - 2 - permute nodes.
5193 * - 3 - permute cells and nodes.
5195 * \param [in] glob - the global data storing profiles and localization.
5196 * \param [in] mesh - the supporting mesh.
5197 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5198 * caller is to delete this field using decrRef() as it is no more needed.
5199 * \throw If the MED file is not readable.
5200 * \throw If no field of \a this is lying on \a mesh.
5201 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5202 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5204 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5206 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax,false));
5207 const DataArrayInt *d(mesh->getNumberFieldAtLevel(meshDimRelToMax)),*e(mesh->getNumberFieldAtLevel(1));
5208 if(meshDimRelToMax==1)
5209 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
5210 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
5214 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
5216 * \param [in] type - a spatial discretization of the new field.
5217 * \param [in] mName - a name of the supporting mesh.
5218 * \param [in] renumPol - specifies how to permute values of the result field according to
5219 * the optional numbers of cells and nodes, if any. The valid values are
5220 * - 0 - do not permute.
5221 * - 1 - permute cells.
5222 * - 2 - permute nodes.
5223 * - 3 - permute cells and nodes.
5225 * \param [in] glob - the global data storing profiles and localization.
5226 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5227 * caller is to delete this field using decrRef() as it is no more needed.
5228 * \throw If the MED file is not readable.
5229 * \throw If there is no mesh named \a mName in the MED file.
5230 * \throw If there are no mesh entities in the mesh.
5231 * \throw If no field values of the given \a type are available.
5233 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5235 MCAuto<MEDFileMesh> mm;
5237 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
5239 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
5240 int absDim=getDimension();
5241 int meshDimRelToMax=absDim-mm->getMeshDimension();
5242 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
5246 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5247 * \param [in] type - a spatial discretization of the new field.
5248 * \param [in] renumPol - specifies how to permute values of the result field according to
5249 * the optional numbers of cells and nodes, if any. The valid values are
5250 * - 0 - do not permute.
5251 * - 1 - permute cells.
5252 * - 2 - permute nodes.
5253 * - 3 - permute cells and nodes.
5255 * \param [in] glob - the global data storing profiles and localization.
5256 * \param [in] mesh - the supporting mesh.
5257 * \param [in] cellRenum - the cell numbers array used for permutation of the result
5258 * field according to \a renumPol.
5259 * \param [in] nodeRenum - the node numbers array used for permutation of the result
5260 * field according to \a renumPol.
5261 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5262 * caller is to delete this field using decrRef() as it is no more needed.
5263 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5264 * \throw If no field of \a this is lying on \a mesh.
5265 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5267 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
5269 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
5270 int meshId=getMeshIdFromMeshName(mesh->getName());
5272 MCAuto<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
5277 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5284 throw INTERP_KERNEL::Exception(msg1);
5285 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5288 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
5290 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5291 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
5292 throw INTERP_KERNEL::Exception(oss.str());
5294 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
5295 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
5296 std::vector<DataArray *> arrOut2(1,arrOut);
5297 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
5298 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
5299 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
5306 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5308 throw INTERP_KERNEL::Exception(msg1);
5311 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
5313 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5314 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
5315 throw INTERP_KERNEL::Exception(oss.str());
5317 MCAuto<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
5318 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
5319 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
5320 ret->renumberNodes(nodeRenumSafe->getConstPointer());
5325 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
5330 * Returns values and a profile of the field of a given type lying on a given support.
5331 * \param [in] type - a spatial discretization of the field.
5332 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5333 * \param [in] mesh - the supporting mesh.
5334 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
5335 * field of interest lies on. If the field lies on all entities of the given
5336 * dimension, all ids in \a pfl are zero. The caller is to delete this array
5337 * using decrRef() as it is no more needed.
5338 * \param [in] glob - the global data storing profiles and localization.
5339 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
5340 * field. The caller is to delete this array using decrRef() as it is no more needed.
5341 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
5342 * \throw If no field of \a this is lying on \a mesh.
5343 * \throw If no field values of the given \a type are available.
5345 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
5347 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
5348 int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
5349 MCAuto<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
5350 ret->setName(nasc.getName().c_str());
5354 //= MEDFileField1TSWithoutSDA
5357 * Throws if a given value is not a valid (non-extended) relative dimension.
5358 * \param [in] meshDimRelToMax - the relative dimension value.
5359 * \throw If \a meshDimRelToMax > 0.
5361 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
5363 if(meshDimRelToMax>0)
5364 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
5368 * Checks if elements of a given mesh are in the order suitable for writing
5369 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
5370 * vector describing types of elements and their number.
5371 * \param [in] mesh - the mesh to check.
5372 * \return std::vector<int> - a vector holding for each element type (1) item of
5373 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
5374 * These values are in full-interlace mode.
5375 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
5377 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
5380 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
5381 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
5382 int nbOfTypes=geoTypes.size();
5383 std::vector<int> code(3*nbOfTypes);
5384 MCAuto<DataArrayInt> arr1=DataArrayInt::New();
5385 arr1->alloc(nbOfTypes,1);
5386 int *arrPtr=arr1->getPointer();
5387 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
5388 for(int i=0;i<nbOfTypes;i++,it++)
5389 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
5390 MCAuto<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
5391 const int *arrPtr2=arr2->getConstPointer();
5393 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
5396 int nbCells=mesh->getNumberOfCellsWithType(*it);
5397 code[3*pos]=(int)(*it);
5398 code[3*pos+1]=nbCells;
5399 code[3*pos+2]=-1;//no profiles
5401 std::vector<const DataArrayInt *> idsPerType;//no profiles
5402 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
5406 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
5411 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5413 return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5417 * Returns all attributes and values of parts of \a this field lying on a given mesh.
5418 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
5419 * item of every of returned sequences refers to the _i_-th part of \a this field.
5420 * Thus all sequences returned by this method are of the same length equal to number
5421 * of different types of supporting entities.<br>
5422 * A field part can include sub-parts with several different spatial discretizations,
5423 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
5424 * for example. Hence, some of the returned sequences contains nested sequences, and an item
5425 * of a nested sequence corresponds to a type of spatial discretization.<br>
5426 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
5427 * The overhead is due to selecting values into new instances of DataArrayDouble.
5428 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
5429 * for the case with only one underlying mesh. (Actually, the number of meshes is
5430 * not checked if \a mname == \c NULL).
5431 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
5432 * a field part is returned.
5433 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
5434 * A field part can include sub-parts with several different spatial discretizations,
5435 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and
5436 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT" for example.
5437 * This sequence is of the same length as \a types.
5438 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
5439 * discretization. A profile name can be empty.
5440 * Length of this and of nested sequences is the same as that of \a typesF.
5441 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
5442 * discretization. A localization name can be empty.
5443 * Length of this and of nested sequences is the same as that of \a typesF.
5444 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
5445 * per each type of spatial discretization within one mesh entity type.
5446 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
5447 * Length of this and of nested sequences is the same as that of \a typesF.
5448 * \throw If no field is lying on \a mname.
5450 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
5454 meshId=getMeshIdFromMeshName(mname);
5456 if(_field_per_mesh.empty())
5457 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
5458 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
5459 int nbOfRet=ret0.size();
5460 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
5461 for(int i=0;i<nbOfRet;i++)
5463 const std::vector< std::pair<int,int> >& p=ret0[i];
5464 int nbOfRet1=p.size();
5465 ret[i].resize(nbOfRet1);
5466 for(int j=0;j<nbOfRet1;j++)
5468 DataArrayDouble *tmp=_arr->selectByTupleIdSafeSlice(p[j].first,p[j].second,1);
5475 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
5480 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
5482 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
5483 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5484 ret->deepCpyLeavesFrom(*this);
5485 const DataArrayDouble *arr(_arr);
5488 MCAuto<DataArrayInt> arr2(arr->convertToIntArr());
5489 ret->setArray(arr2);
5495 * Returns a pointer to the underground DataArrayDouble instance and a
5496 * sequence describing parameters of a support of each part of \a this field. The
5497 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5498 * direct access to the field values. This method is intended for the field lying on one
5500 * \param [in,out] entries - the sequence describing parameters of a support of each
5501 * part of \a this field. Each item of this sequence consists of two parts. The
5502 * first part describes a type of mesh entity and an id of discretization of a
5503 * current field part. The second part describes a range of values [begin,end)
5504 * within the returned array relating to the current field part.
5505 * \return DataArrayDouble * - the pointer to the field values array.
5506 * \throw If the number of underlying meshes is not equal to 1.
5507 * \throw If no field values are available.
5508 * \sa getUndergroundDataArray()
5510 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5512 if(_field_per_mesh.size()!=1)
5513 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5514 if(_field_per_mesh[0]==0)
5515 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5516 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5517 return getUndergroundDataArrayTemplate();
5521 * Returns a pointer to the underground DataArrayDouble instance and a
5522 * sequence describing parameters of a support of each part of \a this field. The
5523 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5524 * direct access to the field values. This method is intended for the field lying on one
5526 * \param [in,out] entries - the sequence describing parameters of a support of each
5527 * part of \a this field. Each item of this sequence consists of two parts. The
5528 * first part describes a type of mesh entity and an id of discretization of a
5529 * current field part. The second part describes a range of values [begin,end)
5530 * within the returned array relating to the current field part.
5531 * \return DataArrayDouble * - the pointer to the field values array.
5532 * \throw If the number of underlying meshes is not equal to 1.
5533 * \throw If no field values are available.
5534 * \sa getUndergroundDataArray()
5536 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5538 return getUndergroundDataArrayDoubleExt(entries);
5541 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<double>(fieldName,csit,iteration,order)
5543 DataArrayDouble *arr(getOrCreateAndGetArrayTemplate());
5544 arr->setInfoAndChangeNbOfCompo(infos);
5547 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<double>()
5551 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
5553 MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
5554 ret->deepCpyLeavesFrom(*this);
5558 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCopy() const
5560 MCAuto<MEDFileField1TSWithoutSDA> ret(shallowCpy());
5561 if(_arr.isNotNull())
5562 ret->_arr=_arr->deepCopy();
5566 //= MEDFileIntField1TSWithoutSDA
5568 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5570 return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5573 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<int>()
5577 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order,
5578 const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<int>(fieldName,csit,iteration,order)
5580 DataArrayInt *arr(getOrCreateAndGetArrayTemplate());
5581 arr->setInfoAndChangeNbOfCompo(infos);
5584 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
5589 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const
5591 MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
5592 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5593 ret->deepCpyLeavesFrom(*this);
5594 const DataArrayInt *arr(_arr);
5597 MCAuto<DataArrayDouble> arr2(arr->convertToDblArr());
5598 ret->setArray(arr2);
5604 * Returns a pointer to the underground DataArrayInt instance and a
5605 * sequence describing parameters of a support of each part of \a this field. The
5606 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5607 * direct access to the field values. This method is intended for the field lying on one
5609 * \param [in,out] entries - the sequence describing parameters of a support of each
5610 * part of \a this field. Each item of this sequence consists of two parts. The
5611 * first part describes a type of mesh entity and an id of discretization of a
5612 * current field part. The second part describes a range of values [begin,end)
5613 * within the returned array relating to the current field part.
5614 * \return DataArrayInt * - the pointer to the field values array.
5615 * \throw If the number of underlying meshes is not equal to 1.
5616 * \throw If no field values are available.
5617 * \sa getUndergroundDataArray()
5619 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5621 return getUndergroundDataArrayIntExt(entries);
5625 * Returns a pointer to the underground DataArrayInt instance and a
5626 * sequence describing parameters of a support of each part of \a this field. The
5627 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5628 * direct access to the field values. This method is intended for the field lying on one
5630 * \param [in,out] entries - the sequence describing parameters of a support of each
5631 * part of \a this field. Each item of this sequence consists of two parts. The
5632 * first part describes a type of mesh entity and an id of discretization of a
5633 * current field part. The second part describes a range of values [begin,end)
5634 * within the returned array relating to the current field part.
5635 * \return DataArrayInt * - the pointer to the field values array.
5636 * \throw If the number of underlying meshes is not equal to 1.
5637 * \throw If no field values are available.
5638 * \sa getUndergroundDataArray()
5640 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5642 if(_field_per_mesh.size()!=1)
5643 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5644 if(_field_per_mesh[0]==0)
5645 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5646 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5647 return getUndergroundDataArrayTemplate();
5650 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5652 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5653 ret->deepCpyLeavesFrom(*this);
5657 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCopy() const
5659 MCAuto<MEDFileIntField1TSWithoutSDA> ret(shallowCpy());
5660 if(_arr.isNotNull())
5661 ret->_arr=_arr->deepCopy();
5665 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5669 //= MEDFileAnyTypeField1TS
5671 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
5673 med_field_type typcha;
5675 std::vector<std::string> infos;
5676 std::string dtunit,fieldName;
5677 LocateField2(fid,0,true,fieldName,typcha,infos,dtunit);
5678 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5683 ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5688 ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5693 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] !";
5694 throw INTERP_KERNEL::Exception(oss.str());
5697 ret->setDtUnit(dtunit.c_str());
5698 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5700 med_int numdt,numit;
5702 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5703 ret->setTime(numdt,numit,dt);
5706 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5708 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5712 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
5713 try:MEDFileFieldGlobsReal(fid)
5715 _content=BuildContentFrom(fid,loadAll,ms);
5718 catch(INTERP_KERNEL::Exception& e)
5723 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5725 med_field_type typcha;
5726 std::vector<std::string> infos;
5729 int nbSteps=LocateField(fid,fieldName,iii,typcha,infos,dtunit);
5730 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5735 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5740 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5745 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] !";
5746 throw INTERP_KERNEL::Exception(oss.str());
5749 ret->setDtUnit(dtunit.c_str());
5750 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5754 std::ostringstream oss; oss << "MEDFileField1TS(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5755 throw INTERP_KERNEL::Exception(oss.str());
5758 med_int numdt,numit;
5760 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5761 ret->setTime(numdt,numit,dt);
5764 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5766 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5770 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5771 try:MEDFileFieldGlobsReal(fid)
5773 _content=BuildContentFrom(fid,fieldName,loadAll,ms);
5776 catch(INTERP_KERNEL::Exception& e)
5781 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c)
5784 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5785 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5787 MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
5788 ret->_content=c; c->incrRef();
5791 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5793 MCAuto<MEDFileIntField1TS> ret(MEDFileIntField1TS::New());
5794 ret->_content=c; c->incrRef();
5797 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5800 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, med_idt fid)
5802 MEDFileAnyTypeField1TS *ret(BuildNewInstanceFromContent(c));
5803 ret->setFileName(FileNameFromFID(fid));
5807 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
5809 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5810 return New(fid,loadAll);
5813 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, bool loadAll)
5815 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
5816 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5817 ret->loadGlobals(fid);
5821 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
5823 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5824 return New(fid,fieldName,loadAll);
5827 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
5829 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0));
5830 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5831 ret->loadGlobals(fid);
5835 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
5837 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5838 return New(fid,fieldName,iteration,order,loadAll);
5841 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
5843 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0));
5844 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5845 ret->loadGlobals(fid);
5849 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5851 med_field_type typcha;
5852 std::vector<std::string> infos;
5855 int nbOfStep2(LocateField(fid,fieldName,iii,typcha,infos,dtunit));
5856 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5861 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5866 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5871 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] !";
5872 throw INTERP_KERNEL::Exception(oss.str());
5875 ret->setDtUnit(dtunit.c_str());
5876 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5879 std::vector< std::pair<int,int> > dtits(nbOfStep2);
5880 for(int i=0;i<nbOfStep2 && !found;i++)
5882 med_int numdt,numit;
5884 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt));
5885 if(numdt==iteration && numit==order)
5891 dtits[i]=std::pair<int,int>(numdt,numit);
5895 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available iterations are : ";
5896 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5897 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5898 throw INTERP_KERNEL::Exception(oss.str());
5901 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5903 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5907 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5908 try:MEDFileFieldGlobsReal(fid)
5910 _content=BuildContentFrom(fid,fieldName,iteration,order,loadAll,ms);
5913 catch(INTERP_KERNEL::Exception& e)
5919 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5920 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5922 * \warning this is a shallow copy constructor
5924 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5926 if(!shallowCopyOfContent)
5928 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5929 otherPtr->incrRef();
5930 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5934 _content=other.shallowCpy();
5938 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)
5942 int nbFields=MEDnField(fid);
5943 if(fieldIdCFormat>=nbFields)
5945 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << FileNameFromFID(fid) << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5946 throw INTERP_KERNEL::Exception(oss.str());
5949 int ncomp(MEDfieldnComponent(fid,fieldIdCFormat+1));
5950 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5951 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5952 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5953 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5954 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5957 MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep));
5958 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5959 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5960 infos.clear(); infos.resize(ncomp);
5961 for(int j=0;j<ncomp;j++)
5962 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5967 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5970 * \return in case of success the number of time steps available for the field with name \a fieldName.
5972 int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const std::string& fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
5974 int nbFields=MEDnField(fid);
5976 std::vector<std::string> fns(nbFields);
5978 for(int i=0;i<nbFields && !found;i++)
5981 nbOfStep2=LocateField2(fid,i,false,tmp,typcha,infos,dtunitOut);
5983 found=(tmp==fieldName);
5989 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available fields are : ";
5990 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5991 oss << "\"" << *it << "\" ";
5992 throw INTERP_KERNEL::Exception(oss.str());
5998 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5999 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
6000 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
6001 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
6002 * to keep a valid instance.
6003 * 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.
6004 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
6005 * 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.
6007 * \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.
6008 * \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.
6009 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
6010 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
6011 * \param [in] newLocName is the new localization name.
6012 * \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.
6013 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
6015 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
6017 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6018 std::string oldPflName=disc->getProfile();
6019 std::vector<std::string> vv=getPflsReallyUsedMulti();
6020 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
6021 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
6023 disc->setProfile(newPflName);
6024 DataArrayInt *pfl=getProfile(oldPflName.c_str());
6025 pfl->setName(newPflName);
6029 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
6030 throw INTERP_KERNEL::Exception(oss.str());
6035 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
6036 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
6037 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
6038 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
6039 * to keep a valid instance.
6040 * 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.
6041 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
6042 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
6043 * 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.
6045 * \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.
6046 * \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.
6047 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
6048 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
6049 * \param [in] newLocName is the new localization name.
6050 * \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.
6051 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
6053 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
6055 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6056 std::string oldLocName=disc->getLocalization();
6057 std::vector<std::string> vv=getLocsReallyUsedMulti();
6058 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
6059 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
6061 disc->setLocalization(newLocName);
6062 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
6063 loc.setName(newLocName);
6067 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
6068 throw INTERP_KERNEL::Exception(oss.str());
6072 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
6074 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
6076 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
6080 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
6082 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
6084 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
6089 * This method alloc the arrays and load potentially huge arrays contained in this field.
6090 * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
6091 * This method can be also called to refresh or reinit values from a file.
6093 * \throw If the fileName is not set or points to a non readable MED file.
6094 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
6096 void MEDFileAnyTypeField1TS::loadArrays()
6098 if(getFileName().empty())
6099 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
6100 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
6101 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
6105 * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
6106 * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
6107 * this method does not throw if \a this does not come from file read.
6109 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
6111 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
6113 if(!getFileName().empty())
6115 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
6116 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
6121 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
6122 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
6123 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
6125 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
6127 void MEDFileAnyTypeField1TS::unloadArrays()
6129 contentNotNullBase()->unloadArrays();
6133 * 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.
6134 * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
6135 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
6137 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
6139 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
6141 if(!getFileName().empty())
6142 contentNotNullBase()->unloadArrays();
6145 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
6147 int nbComp(getNumberOfComponents());
6148 INTERP_KERNEL::AutoPtr<char> comp(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
6149 INTERP_KERNEL::AutoPtr<char> unit(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
6150 for(int i=0;i<nbComp;i++)
6152 std::string info=getInfo()[i];
6154 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
6155 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
6156 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
6158 if(getName().empty())
6159 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
6160 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
6161 writeGlobals(fid,*this);
6162 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
6165 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
6167 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
6170 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
6172 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
6173 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
6178 * Returns a string describing \a this field. This string is outputted
6179 * by \c print Python command.
6181 std::string MEDFileAnyTypeField1TS::simpleRepr() const
6183 std::ostringstream oss;
6184 contentNotNullBase()->simpleRepr(0,oss,-1);
6185 simpleReprGlobs(oss);
6190 * This method returns all profiles whose name is non empty used.
6191 * \b WARNING If profile is used several times it will be reported \b only \b once.
6192 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
6194 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
6196 return contentNotNullBase()->getPflsReallyUsed2();
6200 * This method returns all localizations whose name is non empty used.
6201 * \b WARNING If localization is used several times it will be reported \b only \b once.
6203 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
6205 return contentNotNullBase()->getLocsReallyUsed2();
6209 * This method returns all profiles whose name is non empty used.
6210 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
6212 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
6214 return contentNotNullBase()->getPflsReallyUsedMulti2();
6218 * This method returns all localizations whose name is non empty used.
6219 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
6221 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
6223 return contentNotNullBase()->getLocsReallyUsedMulti2();
6226 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6228 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
6231 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6233 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
6236 int MEDFileAnyTypeField1TS::getDimension() const
6238 return contentNotNullBase()->getDimension();
6241 int MEDFileAnyTypeField1TS::getIteration() const
6243 return contentNotNullBase()->getIteration();
6246 int MEDFileAnyTypeField1TS::getOrder() const
6248 return contentNotNullBase()->getOrder();
6251 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
6253 return contentNotNullBase()->getTime(iteration,order);
6256 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
6258 contentNotNullBase()->setTime(iteration,order,val);
6261 std::string MEDFileAnyTypeField1TS::getName() const
6263 return contentNotNullBase()->getName();
6266 void MEDFileAnyTypeField1TS::setName(const std::string& name)
6268 contentNotNullBase()->setName(name);
6271 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
6273 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
6276 std::string MEDFileAnyTypeField1TS::getDtUnit() const
6278 return contentNotNullBase()->getDtUnit();
6281 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
6283 contentNotNullBase()->setDtUnit(dtUnit);
6286 std::string MEDFileAnyTypeField1TS::getMeshName() const
6288 return contentNotNullBase()->getMeshName();
6291 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
6293 contentNotNullBase()->setMeshName(newMeshName);
6296 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
6298 return contentNotNullBase()->changeMeshNames(modifTab);
6301 int MEDFileAnyTypeField1TS::getMeshIteration() const
6303 return contentNotNullBase()->getMeshIteration();
6306 int MEDFileAnyTypeField1TS::getMeshOrder() const
6308 return contentNotNullBase()->getMeshOrder();
6311 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
6313 return contentNotNullBase()->getNumberOfComponents();
6316 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
6318 return contentNotNullBase()->isDealingTS(iteration,order);
6321 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
6323 return contentNotNullBase()->getDtIt();
6326 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
6328 contentNotNullBase()->fillIteration(p);
6331 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
6333 contentNotNullBase()->fillTypesOfFieldAvailable(types);
6336 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
6338 contentNotNullBase()->setInfo(infos);
6341 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
6343 return contentNotNullBase()->getInfo();
6345 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
6347 return contentNotNullBase()->getInfo();
6350 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
6352 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
6355 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
6357 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6360 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
6362 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6365 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
6367 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
6370 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
6372 return contentNotNullBase()->getTypesOfFieldAvailable();
6375 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,
6376 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6378 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
6382 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
6383 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
6384 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
6386 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
6388 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6390 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
6391 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
6392 std::size_t sz(contentsSplit.size());
6393 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6394 for(std::size_t i=0;i<sz;i++)
6396 ret[i]=shallowCpy();
6397 ret[i]->_content=contentsSplit[i];
6403 * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
6404 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6406 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
6408 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6410 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
6411 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
6412 std::size_t sz(contentsSplit.size());
6413 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6414 for(std::size_t i=0;i<sz;i++)
6416 ret[i]=shallowCpy();
6417 ret[i]->_content=contentsSplit[i];
6423 * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this.
6424 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6426 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const
6428 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6430 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !");
6431 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
6432 std::size_t sz(contentsSplit.size());
6433 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6434 for(std::size_t i=0;i<sz;i++)
6436 ret[i]=shallowCpy();
6437 ret[i]->_content=contentsSplit[i];
6442 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCopy() const
6444 MCAuto<MEDFileAnyTypeField1TS> ret=shallowCpy();
6445 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
6446 ret->_content=_content->deepCopy();
6447 ret->deepCpyGlobs(*this);
6451 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
6453 return contentNotNullBase()->copyTinyInfoFrom(field,arr);
6459 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6460 * the first field that has been read from a specified MED file.
6461 * \param [in] fileName - the name of the MED file to read.
6462 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6463 * is to delete this field using decrRef() as it is no more needed.
6464 * \throw If reading the file fails.
6466 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll)
6468 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6469 return New(fid,loadAll);
6472 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, bool loadAll)
6474 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,loadAll,0));
6475 ret->contentNotNull();
6480 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6481 * a given field that has been read from a specified MED file.
6482 * \param [in] fileName - the name of the MED file to read.
6483 * \param [in] fieldName - the name of the field to read.
6484 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6485 * is to delete this field using decrRef() as it is no more needed.
6486 * \throw If reading the file fails.
6487 * \throw If there is no field named \a fieldName in the file.
6489 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6491 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6492 return New(fid,fieldName,loadAll);
6495 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
6497 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,fieldName,loadAll,0));
6498 ret->contentNotNull();
6503 * Returns a new instance of MEDFileField1TS holding data of a given time step of
6504 * a given field that has been read from a specified MED file.
6505 * \param [in] fileName - the name of the MED file to read.
6506 * \param [in] fieldName - the name of the field to read.
6507 * \param [in] iteration - the iteration number of a required time step.
6508 * \param [in] order - the iteration order number of required time step.
6509 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6510 * is to delete this field using decrRef() as it is no more needed.
6511 * \throw If reading the file fails.
6512 * \throw If there is no field named \a fieldName in the file.
6513 * \throw If the required time step is missing from the file.
6515 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6517 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6518 return New(fid,fieldName,iteration,order,loadAll);
6521 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
6523 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,fieldName,iteration,order,loadAll,0));
6524 ret->contentNotNull();
6529 * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6530 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6532 * Returns a new instance of MEDFileField1TS holding either a shallow copy
6533 * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
6534 * \warning this is a shallow copy constructor
6535 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
6536 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
6537 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6538 * is to delete this field using decrRef() as it is no more needed.
6540 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6542 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(other,shallowCopyOfContent));
6543 ret->contentNotNull();
6548 * Returns a new empty instance of MEDFileField1TS.
6549 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6550 * is to delete this field using decrRef() as it is no more needed.
6552 MEDFileField1TS *MEDFileField1TS::New()
6554 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS);
6555 ret->contentNotNull();
6560 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
6561 * following the given input policy.
6563 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6564 * By default (true) the globals are deeply copied.
6565 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
6567 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
6569 MCAuto<MEDFileIntField1TS> ret;
6570 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6573 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
6575 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
6576 MCAuto<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
6577 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc));
6580 ret=MEDFileIntField1TS::New();
6582 ret->deepCpyGlobs(*this);
6584 ret->shallowCpyGlobs(*this);
6588 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const
6590 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6592 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
6593 const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
6595 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 !");
6599 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull()
6601 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6603 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
6604 MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
6606 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 !");
6610 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
6613 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
6615 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
6616 DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6618 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6619 f->setArray(arrOutC);
6622 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MCAuto<DataArray>& arr)
6625 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
6626 DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6628 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6634 * Return an extraction of \a this using \a extractDef map to specify the extraction.
6635 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
6637 * \return A new object that the caller is responsible to deallocate.
6638 * \sa MEDFileUMesh::deduceNodeSubPartFromCellSubPart , MEDFileUMesh::extractPart
6640 MEDFileField1TS *MEDFileField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
6643 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : input mesh is NULL !");
6644 MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
6645 std::vector<TypeOfField> tof(getTypesOfFieldAvailable());
6646 for(std::vector<TypeOfField>::const_iterator it0=tof.begin();it0!=tof.end();it0++)
6648 if((*it0)!=ON_NODES)
6650 std::vector<int> levs;
6651 getNonEmptyLevels(mm->getName(),levs);
6652 for(std::vector<int>::const_iterator lev=levs.begin();lev!=levs.end();lev++)
6654 std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(*lev));
6655 if(it2!=extractDef.end())
6657 MCAuto<DataArrayInt> t((*it2).second);
6659 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6660 MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_CELLS,(*lev),mm));
6661 MCAuto<MEDCouplingFieldDouble> fOut(f->buildSubPart(t));
6662 ret->setFieldNoProfileSBT(fOut);
6668 std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(1));
6669 if(it2==extractDef.end())
6670 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a NODE field and no extract array available for NODE !");
6671 MCAuto<DataArrayInt> t((*it2).second);
6673 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6674 MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_NODES,0,mm));
6675 MCAuto<MEDCouplingFieldDouble> fOut(f->deepCopy());
6676 DataArrayDouble *arr(f->getArray());
6677 MCAuto<DataArrayDouble> newArr(arr->selectByTupleIdSafe(t->begin(),t->end()));
6678 fOut->setArray(newArr);
6679 ret->setFieldNoProfileSBT(fOut);
6685 MEDFileField1TS::MEDFileField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
6686 try:MEDFileAnyTypeField1TS(fid,loadAll,ms)
6689 catch(INTERP_KERNEL::Exception& e)
6692 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6693 try:MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms)
6696 catch(INTERP_KERNEL::Exception& e)
6699 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6700 try:MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms)
6703 catch(INTERP_KERNEL::Exception& e)
6707 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6708 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6710 * \warning this is a shallow copy constructor
6712 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6713 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6716 catch(INTERP_KERNEL::Exception& e)
6719 MEDFileField1TS::MEDFileField1TS()
6721 _content=new MEDFileField1TSWithoutSDA;
6725 * 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
6726 * method should be called (getFieldOnMeshAtLevel for example).
6727 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
6729 * \param [in] mesh - the mesh the field is lying on
6730 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6731 * caller is to delete this field using decrRef() as it is no more needed.
6733 MEDCouplingFieldDouble *MEDFileField1TS::field(const MEDFileMesh *mesh) const
6735 MCAuto<DataArray> arrOut;
6736 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
6737 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6742 * Returns a new MEDCouplingFieldDouble of a given type lying on
6743 * mesh entities of a given dimension of the first mesh in MED file. If \a this field
6744 * has not been constructed via file reading, an exception is thrown.
6745 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6746 * \param [in] type - a spatial discretization of interest.
6747 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6748 * \param [in] renumPol - specifies how to permute values of the result field according to
6749 * the optional numbers of cells and nodes, if any. The valid values are
6750 * - 0 - do not permute.
6751 * - 1 - permute cells.
6752 * - 2 - permute nodes.
6753 * - 3 - permute cells and nodes.
6755 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6756 * caller is to delete this field using decrRef() as it is no more needed.
6757 * \throw If \a this field has not been constructed via file reading.
6758 * \throw If the MED file is not readable.
6759 * \throw If there is no mesh in the MED file.
6760 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6761 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6762 * \sa getFieldOnMeshAtLevel()
6764 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6766 if(getFileName().empty())
6767 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6768 MCAuto<DataArray> arrOut;
6769 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
6770 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6775 * Returns a new MEDCouplingFieldDouble of a given type lying on
6776 * the top level cells of the first mesh in MED file. If \a this field
6777 * has not been constructed via file reading, an exception is thrown.
6778 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6779 * \param [in] type - a spatial discretization of interest.
6780 * \param [in] renumPol - specifies how to permute values of the result field according to
6781 * the optional numbers of cells and nodes, if any. The valid values are
6782 * - 0 - do not permute.
6783 * - 1 - permute cells.
6784 * - 2 - permute nodes.
6785 * - 3 - permute cells and nodes.
6787 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6788 * caller is to delete this field using decrRef() as it is no more needed.
6789 * \throw If \a this field has not been constructed via file reading.
6790 * \throw If the MED file is not readable.
6791 * \throw If there is no mesh in the MED file.
6792 * \throw If no field values of the given \a type.
6793 * \throw If no field values lying on the top level support.
6794 * \sa getFieldAtLevel()
6796 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
6798 if(getFileName().empty())
6799 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6800 MCAuto<DataArray> arrOut;
6801 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
6802 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6807 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6808 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6809 * \param [in] type - a spatial discretization of the new field.
6810 * \param [in] mesh - the supporting mesh.
6811 * \param [in] renumPol - specifies how to permute values of the result field according to
6812 * the optional numbers of cells and nodes, if any. The valid values are
6813 * - 0 - do not permute.
6814 * - 1 - permute cells.
6815 * - 2 - permute nodes.
6816 * - 3 - permute cells and nodes.
6818 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6819 * caller is to delete this field using decrRef() as it is no more needed.
6820 * \throw If no field of \a this is lying on \a mesh.
6821 * \throw If the mesh is empty.
6822 * \throw If no field values of the given \a type are available.
6823 * \sa getFieldAtLevel()
6824 * \sa getFieldOnMeshAtLevel()
6826 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
6828 MCAuto<DataArray> arrOut;
6829 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
6830 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6835 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6836 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6837 * \param [in] type - a spatial discretization of interest.
6838 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6839 * \param [in] mesh - the supporting mesh.
6840 * \param [in] renumPol - specifies how to permute values of the result field according to
6841 * the optional numbers of cells and nodes, if any. The valid values are
6842 * - 0 - do not permute.
6843 * - 1 - permute cells.
6844 * - 2 - permute nodes.
6845 * - 3 - permute cells and nodes.
6847 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6848 * caller is to delete this field using decrRef() as it is no more needed.
6849 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6850 * \throw If no field of \a this is lying on \a mesh.
6851 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6852 * \sa getFieldAtLevel()
6853 * \sa getFieldOnMeshAtLevel()
6855 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
6857 MCAuto<DataArray> arrOut;
6858 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
6859 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6864 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6865 * This method is called "Old" because in MED3 norm a field has only one meshName
6866 * attached, so this method is for readers of MED2 files. If \a this field
6867 * has not been constructed via file reading, an exception is thrown.
6868 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6869 * \param [in] type - a spatial discretization of interest.
6870 * \param [in] mName - a name of the supporting mesh.
6871 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6872 * \param [in] renumPol - specifies how to permute values of the result field according to
6873 * the optional numbers of cells and nodes, if any. The valid values are
6874 * - 0 - do not permute.
6875 * - 1 - permute cells.
6876 * - 2 - permute nodes.
6877 * - 3 - permute cells and nodes.
6879 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6880 * caller is to delete this field using decrRef() as it is no more needed.
6881 * \throw If the MED file is not readable.
6882 * \throw If there is no mesh named \a mName in the MED file.
6883 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6884 * \throw If \a this field has not been constructed via file reading.
6885 * \throw If no field of \a this is lying on the mesh named \a mName.
6886 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6887 * \sa getFieldAtLevel()
6889 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
6891 if(getFileName().empty())
6892 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6893 MCAuto<DataArray> arrOut;
6894 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull()));
6895 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6900 * Returns values and a profile of the field of a given type lying on a given support.
6901 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6902 * \param [in] type - a spatial discretization of the field.
6903 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6904 * \param [in] mesh - the supporting mesh.
6905 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6906 * field of interest lies on. If the field lies on all entities of the given
6907 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6908 * using decrRef() as it is no more needed.
6909 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6910 * field. The caller is to delete this array using decrRef() as it is no more needed.
6911 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6912 * \throw If no field of \a this is lying on \a mesh.
6913 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6915 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6917 MCAuto<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6918 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
6922 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6923 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6924 * "Sort By Type"), if not, an exception is thrown.
6925 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6926 * \param [in] field - the field to add to \a this.
6927 * \throw If the name of \a field is empty.
6928 * \throw If the data array of \a field is not set.
6929 * \throw If the data array is already allocated but has different number of components
6931 * \throw If the underlying mesh of \a field has no name.
6932 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6934 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
6937 contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
6941 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6942 * can be an aggregation of several MEDCouplingFieldDouble instances.
6943 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6944 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6947 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6948 * A new profile is added only if no equal profile is missing.
6949 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6950 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
6951 * \param [in] mesh - the supporting mesh of \a field.
6952 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6953 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6954 * \throw If either \a field or \a mesh or \a profile has an empty name.
6955 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6956 * \throw If the data array of \a field is not set.
6957 * \throw If the data array of \a this is already allocated but has different number of
6958 * components than \a field.
6959 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6960 * \sa setFieldNoProfileSBT()
6962 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6965 contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6968 MEDFileField1TS *MEDFileField1TS::shallowCpy() const
6970 return new MEDFileField1TS(*this);
6973 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const
6975 return contentNotNull()->getUndergroundDataArrayTemplate();
6978 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
6980 return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
6983 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6984 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6986 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6989 //= MEDFileIntField1TS
6991 MEDFileIntField1TS *MEDFileIntField1TS::New()
6993 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS);
6994 ret->contentNotNull();
6998 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll)
7000 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
7001 return MEDFileIntField1TS::New(fid,loadAll);
7004 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, bool loadAll)
7006 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,loadAll,0));
7007 ret->contentNotNull();
7011 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
7013 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
7014 return MEDFileIntField1TS::New(fid,fieldName,loadAll);
7017 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
7019 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,loadAll,0));
7020 ret->contentNotNull();
7024 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
7026 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
7027 return MEDFileIntField1TS::New(fid,fieldName,iteration,order,loadAll);
7030 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
7032 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,iteration,order,loadAll,0));
7033 ret->contentNotNull();
7037 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
7039 MCAuto<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
7040 ret->contentNotNull();
7044 MEDFileIntField1TS::MEDFileIntField1TS()
7046 _content=new MEDFileIntField1TSWithoutSDA;
7049 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
7050 try:MEDFileAnyTypeField1TS(fid,loadAll,ms)
7053 catch(INTERP_KERNEL::Exception& e)
7056 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
7057 try:MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms)
7060 catch(INTERP_KERNEL::Exception& e)
7063 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
7064 try:MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms)
7067 catch(INTERP_KERNEL::Exception& e)
7071 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
7072 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
7074 * \warning this is a shallow copy constructor
7076 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
7080 MEDFileIntField1TS *MEDFileIntField1TS::shallowCpy() const
7082 return new MEDFileIntField1TS(*this);
7086 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
7087 * following the given input policy.
7089 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
7090 * By default (true) the globals are deeply copied.
7091 * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
7093 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const
7095 MCAuto<MEDFileField1TS> ret;
7096 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
7099 const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
7101 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
7102 MCAuto<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
7103 ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc));
7106 ret=MEDFileField1TS::New();
7108 ret->deepCpyGlobs(*this);
7110 ret->shallowCpyGlobs(*this);
7115 * Adds a MEDCouplingFieldInt to \a this. The underlying mesh of the given field is
7116 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
7117 * "Sort By Type"), if not, an exception is thrown.
7118 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7119 * \param [in] field - the field to add to \a this.
7120 * \throw If the name of \a field is empty.
7121 * \throw If the data array of \a field is not set.
7122 * \throw If the data array is already allocated but has different number of components
7124 * \throw If the underlying mesh of \a field has no name.
7125 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
7127 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldInt *field)
7129 MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
7131 contentNotNull()->setFieldNoProfileSBT(field2,field->getArray(),*this,*contentNotNull());
7135 * Adds a MEDCouplingFieldInt to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
7136 * can be an aggregation of several MEDCouplingFieldDouble instances.
7137 * The mesh support of input parameter \a field is ignored here, it can be NULL.
7138 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
7141 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
7142 * A new profile is added only if no equal profile is missing.
7143 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7144 * \param [in] field - the field to add to \a this.
7145 * \param [in] mesh - the supporting mesh of \a field.
7146 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
7147 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
7148 * \throw If either \a field or \a mesh or \a profile has an empty name.
7149 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7150 * \throw If the data array of \a field is not set.
7151 * \throw If the data array of \a this is already allocated but has different number of
7152 * components than \a field.
7153 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
7154 * \sa setFieldNoProfileSBT()
7156 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
7158 MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
7160 contentNotNull()->setFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
7163 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const
7165 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7167 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
7168 const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
7170 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 !");
7174 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
7176 if(getFileName().empty())
7177 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7178 MCAuto<DataArray> arrOut;
7179 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
7180 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7184 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MCAuto<DataArray>& arr)
7187 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
7188 DataArrayInt *arrC(dynamic_cast<DataArrayInt *>((DataArray *)arr));
7190 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
7195 MCAuto<MEDCouplingFieldInt> MEDFileIntField1TS::SetDataArrayDoubleInIntField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
7198 double t0(f->getTime(t1,t2));
7199 MCAuto<DataArrayInt> arr2(DynamicCastSafe<DataArray,DataArrayInt>(arr));
7200 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
7201 MCAuto<MEDCouplingFieldInt> ret(MEDCouplingFieldInt::New(*ft));
7202 ret->setTime(t0,t1,t2); ret->setArray(arr2);
7206 MCAuto<MEDCouplingFieldDouble> MEDFileIntField1TS::ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f)
7209 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ConvertFieldIntToFieldDouble : null input field !");
7211 double t0(f->getTime(t1,t2));
7212 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
7213 MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(*ft));
7214 ret->setTime(t0,t1,t2);
7218 MEDFileIntField1TS *MEDFileIntField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
7220 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::extractPart : not implemented yet !");
7224 * 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
7225 * method should be called (getFieldOnMeshAtLevel for example).
7226 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
7228 * \param [in] mesh - the mesh the field is lying on
7229 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
7230 * caller is to delete this field using decrRef() as it is no more needed.
7232 MEDCouplingFieldInt *MEDFileIntField1TS::field(const MEDFileMesh *mesh) const
7234 MCAuto<DataArray> arrOut;
7235 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
7236 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7241 * Returns a new MEDCouplingFieldInt of a given type lying on
7242 * the top level cells of the first mesh in MED file. If \a this field
7243 * has not been constructed via file reading, an exception is thrown.
7244 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7245 * \param [in] type - a spatial discretization of interest.
7246 * \param [in] renumPol - specifies how to permute values of the result field according to
7247 * the optional numbers of cells and nodes, if any. The valid values are
7248 * - 0 - do not permute.
7249 * - 1 - permute cells.
7250 * - 2 - permute nodes.
7251 * - 3 - permute cells and nodes.
7253 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7254 * caller is to delete this field using decrRef() as it is no more needed.
7255 * \throw If \a this field has not been constructed via file reading.
7256 * \throw If the MED file is not readable.
7257 * \throw If there is no mesh in the MED file.
7258 * \throw If no field values of the given \a type.
7259 * \throw If no field values lying on the top level support.
7260 * \sa getFieldAtLevel()
7262 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
7264 if(getFileName().empty())
7265 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
7266 MCAuto<DataArray> arrOut;
7267 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
7268 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7273 * Returns a new MEDCouplingFieldInt of given type lying on a given mesh.
7274 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7275 * \param [in] type - a spatial discretization of the new field.
7276 * \param [in] mesh - the supporting mesh.
7277 * \param [in] renumPol - specifies how to permute values of the result field according to
7278 * the optional numbers of cells and nodes, if any. The valid values are
7279 * - 0 - do not permute.
7280 * - 1 - permute cells.
7281 * - 2 - permute nodes.
7282 * - 3 - permute cells and nodes.
7284 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7285 * caller is to delete this field using decrRef() as it is no more needed.
7286 * \throw If no field of \a this is lying on \a mesh.
7287 * \throw If the mesh is empty.
7288 * \throw If no field values of the given \a type are available.
7289 * \sa getFieldAtLevel()
7290 * \sa getFieldOnMeshAtLevel()
7292 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
7294 MCAuto<DataArray> arrOut;
7295 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
7296 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7301 * Returns a new MEDCouplingFieldInt of a given type lying on a given support.
7302 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7303 * \param [in] type - a spatial discretization of interest.
7304 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7305 * \param [in] mesh - the supporting mesh.
7306 * \param [in] renumPol - specifies how to permute values of the result field according to
7307 * the optional numbers of cells and nodes, if any. The valid values are
7308 * - 0 - do not permute.
7309 * - 1 - permute cells.
7310 * - 2 - permute nodes.
7311 * - 3 - permute cells and nodes.
7313 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7314 * caller is to delete this field using decrRef() as it is no more needed.
7315 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7316 * \throw If no field of \a this is lying on \a mesh.
7317 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7318 * \sa getFieldAtLevel()
7319 * \sa getFieldOnMeshAtLevel()
7321 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
7323 MCAuto<DataArray> arrOut;
7324 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
7325 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7330 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
7331 * This method is called "Old" because in MED3 norm a field has only one meshName
7332 * attached, so this method is for readers of MED2 files. If \a this field
7333 * has not been constructed via file reading, an exception is thrown.
7334 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7335 * \param [in] type - a spatial discretization of interest.
7336 * \param [in] mName - a name of the supporting mesh.
7337 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7338 * \param [in] renumPol - specifies how to permute values of the result field according to
7339 * the optional numbers of cells and nodes, if any. The valid values are
7340 * - 0 - do not permute.
7341 * - 1 - permute cells.
7342 * - 2 - permute nodes.
7343 * - 3 - permute cells and nodes.
7345 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7346 * caller is to delete this field using decrRef() as it is no more needed.
7347 * \throw If the MED file is not readable.
7348 * \throw If there is no mesh named \a mName in the MED file.
7349 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7350 * \throw If \a this field has not been constructed via file reading.
7351 * \throw If no field of \a this is lying on the mesh named \a mName.
7352 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7353 * \sa getFieldAtLevel()
7355 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
7357 if(getFileName().empty())
7358 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7359 MCAuto<DataArray> arrOut;
7360 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
7361 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7366 * Returns values and a profile of the field of a given type lying on a given support.
7367 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7368 * \param [in] type - a spatial discretization of the field.
7369 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7370 * \param [in] mesh - the supporting mesh.
7371 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
7372 * field of interest lies on. If the field lies on all entities of the given
7373 * dimension, all ids in \a pfl are zero. The caller is to delete this array
7374 * using decrRef() as it is no more needed.
7375 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
7376 * field. The caller is to delete this array using decrRef() as it is no more needed.
7377 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7378 * \throw If no field of \a this is lying on \a mesh.
7379 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7381 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
7383 MCAuto<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
7384 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
7387 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull()
7389 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7391 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
7392 MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
7394 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 !");
7398 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const
7400 return contentNotNull()->getUndergroundDataArrayTemplate();
7403 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
7405 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
7409 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileFieldNameScope(fieldName)
7414 * \param [in] fieldId field id in C mode
7416 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7418 med_field_type typcha;
7419 std::string dtunitOut;
7420 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fieldId,false,_name,typcha,_infos,dtunitOut));
7421 setDtUnit(dtunitOut.c_str());
7422 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities);
7425 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)
7426 try:MEDFileFieldNameScope(fieldName),_infos(infos)
7428 setDtUnit(dtunit.c_str());
7429 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities);
7431 catch(INTERP_KERNEL::Exception& e)
7436 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
7438 std::size_t ret(_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MCAuto<MEDFileField1TSWithoutSDA>));
7439 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7440 ret+=(*it).capacity();
7444 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
7446 std::vector<const BigMemoryObject *> ret;
7447 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7448 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
7453 * 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
7456 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
7458 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7459 ret->setInfo(_infos);
7460 int sz=(int)_time_steps.size();
7461 for(const int *id=startIds;id!=endIds;id++)
7463 if(*id>=0 && *id<sz)
7465 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
7466 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7470 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7472 ret->pushBackTimeStep(tse2);
7476 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
7477 oss << " ! Should be in [0," << sz << ") !";
7478 throw INTERP_KERNEL::Exception(oss.str());
7481 if(ret->getNumberOfTS()>0)
7482 ret->synchronizeNameScope();
7483 ret->copyNameScope(*this);
7488 * 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
7491 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
7493 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
7494 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7495 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7496 ret->setInfo(_infos);
7497 int sz=(int)_time_steps.size();
7499 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
7503 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
7504 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7508 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7510 ret->pushBackTimeStep(tse2);
7514 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
7515 oss << " ! Should be in [0," << sz << ") !";
7516 throw INTERP_KERNEL::Exception(oss.str());
7519 if(ret->getNumberOfTS()>0)
7520 ret->synchronizeNameScope();
7521 ret->copyNameScope(*this);
7525 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7528 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7529 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7531 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7534 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7535 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
7536 ids->pushBackSilent(id);
7538 return buildFromTimeStepIds(ids->begin(),ids->end());
7541 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7544 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7545 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7547 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7550 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7551 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
7552 ids->pushBackSilent(id);
7554 return buildFromTimeStepIds(ids->begin(),ids->end());
7557 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfStructureElements() const
7559 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7560 if((*it).isNotNull())
7561 if((*it)->presenceOfStructureElements())
7566 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::onlyStructureElements() const
7568 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7569 if((*it).isNotNull())
7570 if(!(*it)->onlyStructureElements())
7575 void MEDFileAnyTypeFieldMultiTSWithoutSDA::killStructureElements()
7577 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
7578 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7579 if((*it).isNotNull())
7581 if((*it)->presenceOfStructureElements())
7583 if(!(*it)->onlyStructureElements())
7585 (*it)->killStructureElements();
7597 void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyStructureElements()
7599 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
7600 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7601 if((*it).isNotNull())
7603 if((*it)->presenceOfStructureElements())
7605 if(!(*it)->onlyStructureElements())
7606 (*it)->keepOnlyStructureElements();
7613 void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyOnSE(const std::string& seName)
7615 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
7616 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7617 if((*it).isNotNull())
7618 (*it)->keepOnlyOnSE(seName);
7621 void MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
7623 std::vector< std::pair<std::string,std::string> > ps2;
7624 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7625 if((*it).isNotNull())
7627 (*it)->getMeshSENames(ps2);
7631 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames : this appears to not contain SE only !");
7632 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7633 if((*it).isNotNull())
7635 std::vector< std::pair<std::string,std::string> > ps3;
7636 (*it)->getMeshSENames(ps3);
7638 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames : For the moment only homogeneous SE def through time managed !");
7640 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=ps2.begin();it!=ps2.end();it++)
7642 std::vector< std::pair<std::string,std::string> >::iterator it2(std::find(ps.begin(),ps.end(),*it));
7648 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
7650 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7652 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7655 if(cur->presenceOfMultiDiscPerGeoType())
7661 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
7666 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
7671 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
7674 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7676 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
7677 if(pt->isDealingTS(iteration,order))
7680 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
7681 std::vector< std::pair<int,int> > vp=getIterations();
7682 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
7683 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
7684 throw INTERP_KERNEL::Exception(oss.str());
7687 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
7689 return *_time_steps[getTimeStepPos(iteration,order)];
7692 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
7694 return *_time_steps[getTimeStepPos(iteration,order)];
7697 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const
7699 if(_time_steps.empty())
7700 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
7701 return _time_steps[0]->getMeshName();
7704 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const std::string& newMeshName)
7706 std::string oldName(getMeshName());
7707 std::vector< std::pair<std::string,std::string> > v(1);
7708 v[0].first=oldName; v[0].second=newMeshName;
7712 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
7715 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7717 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7719 ret=cur->changeMeshNames(modifTab) || ret;
7725 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
7727 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
7729 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
7733 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
7735 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7737 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
7740 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
7741 MEDFileFieldGlobsReal& glob)
7744 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7746 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
7748 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
7753 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7755 std::string startLine(bkOffset,' ');
7756 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
7758 oss << " (" << fmtsId << ")";
7759 oss << " has the following name: \"" << _name << "\"." << std::endl;
7760 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
7761 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7763 oss << startLine << " - \"" << *it << "\"" << std::endl;
7766 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7768 std::string chapter(17,'0'+i);
7769 oss << startLine << chapter << std::endl;
7770 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7772 cur->simpleRepr(bkOffset+2,oss,i);
7774 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
7775 oss << startLine << chapter << std::endl;
7779 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
7781 std::size_t sz=_time_steps.size();
7782 std::vector< std::pair<int,int> > ret(sz);
7784 for(std::size_t i=0;i<sz;i++)
7786 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
7789 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
7793 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
7794 throw INTERP_KERNEL::Exception(oss.str());
7800 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MCAuto<MEDFileAnyTypeField1TSWithoutSDA>& tse)
7802 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
7804 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
7805 checkCoherencyOfType(tse2);
7806 if(_time_steps.empty())
7808 setName(tse2->getName().c_str());
7809 setInfo(tse2->getInfo());
7811 checkThatComponentsMatch(tse2->getInfo());
7812 if(getDtUnit().empty() && !tse->getDtUnit().empty())
7813 setDtUnit(tse->getDtUnit());
7814 _time_steps.push_back(tse);
7817 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
7819 std::size_t nbOfCompo=_infos.size();
7820 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7822 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7825 if((cur->getInfo()).size()!=nbOfCompo)
7827 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
7828 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
7829 throw INTERP_KERNEL::Exception(oss.str());
7831 cur->copyNameScope(*this);
7836 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7838 _time_steps.resize(nbPdt);
7839 for(int i=0;i<nbPdt;i++)
7841 std::vector< std::pair<int,int> > ts;
7842 med_int numdt=0,numo=0;
7844 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt));
7849 _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7854 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7858 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
7861 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities);
7863 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entities);
7864 synchronizeNameScope();
7868 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
7870 if(_time_steps.empty())
7871 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
7872 checkThatNbOfCompoOfTSMatchThis();
7873 std::vector<std::string> infos(getInfo());
7874 int nbComp=infos.size();
7875 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7876 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7877 for(int i=0;i<nbComp;i++)
7879 std::string info=infos[i];
7881 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7882 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7883 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7886 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7887 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
7888 int nbOfTS=_time_steps.size();
7889 for(int i=0;i<nbOfTS;i++)
7890 _time_steps[i]->writeLL(fid,opts,*this);
7893 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
7895 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7897 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7899 elt->loadBigArraysRecursively(fid,nasc);
7903 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
7905 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7907 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7909 elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7913 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
7915 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7917 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7919 elt->unloadArrays();
7923 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7925 return _time_steps.size();
7928 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
7930 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7931 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7933 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7935 newTS.push_back(*it);
7940 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
7942 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7943 int maxId=(int)_time_steps.size();
7945 std::set<int> idsToDel;
7946 for(const int *id=startIds;id!=endIds;id++,ii++)
7948 if(*id>=0 && *id<maxId)
7950 idsToDel.insert(*id);
7954 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7955 throw INTERP_KERNEL::Exception(oss.str());
7958 for(int iii=0;iii<maxId;iii++)
7959 if(idsToDel.find(iii)==idsToDel.end())
7960 newTS.push_back(_time_steps[iii]);
7964 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
7966 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7967 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7968 if(nbOfEntriesToKill==0)
7970 std::size_t sz=_time_steps.size();
7971 std::vector<bool> b(sz,true);
7973 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7975 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7976 for(std::size_t i=0;i<sz;i++)
7978 newTS.push_back(_time_steps[i]);
7982 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
7985 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
7986 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7988 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7992 tmp->getTime(it2,ord);
7993 if(it2==iteration && order==ord)
7996 oss << "(" << it2 << "," << ord << "), ";
7999 throw INTERP_KERNEL::Exception(oss.str());
8002 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
8005 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
8007 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
8009 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
8013 double ti=tmp->getTime(it2,ord);
8014 if(fabs(time-ti)<eps)
8020 throw INTERP_KERNEL::Exception(oss.str());
8023 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
8025 int lgth=_time_steps.size();
8026 std::vector< std::pair<int,int> > ret(lgth);
8027 for(int i=0;i<lgth;i++)
8028 _time_steps[i]->fillIteration(ret[i]);
8033 * 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'
8034 * This method returns two things.
8035 * - The absolute dimension of 'this' in first parameter.
8036 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
8037 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
8039 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
8040 * Only these 3 discretizations will be taken into account here.
8042 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
8043 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
8044 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
8046 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
8047 * 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'.
8049 * Let's consider the typical following case :
8050 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
8051 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
8052 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
8054 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
8056 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
8058 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
8059 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
8060 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
8061 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
8063 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8065 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
8068 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
8070 if(pos<0 || pos>=(int)_time_steps.size())
8072 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
8073 throw INTERP_KERNEL::Exception(oss.str());
8075 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
8078 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
8079 oss << "\nTry to use following method eraseEmptyTS !";
8080 throw INTERP_KERNEL::Exception(oss.str());
8085 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
8087 if(pos<0 || pos>=(int)_time_steps.size())
8089 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
8090 throw INTERP_KERNEL::Exception(oss.str());
8092 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
8095 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
8096 oss << "\nTry to use following method eraseEmptyTS !";
8097 throw INTERP_KERNEL::Exception(oss.str());
8102 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
8104 std::vector<std::string> ret;
8105 std::set<std::string> ret2;
8106 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8108 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
8109 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
8110 if(ret2.find(*it2)==ret2.end())
8112 ret.push_back(*it2);
8119 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
8121 std::vector<std::string> ret;
8122 std::set<std::string> ret2;
8123 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8125 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
8126 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
8127 if(ret2.find(*it2)==ret2.end())
8129 ret.push_back(*it2);
8136 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
8138 std::vector<std::string> ret;
8139 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8141 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
8142 ret.insert(ret.end(),tmp.begin(),tmp.end());
8147 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
8149 std::vector<std::string> ret;
8150 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8152 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
8153 ret.insert(ret.end(),tmp.begin(),tmp.end());
8158 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8160 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8161 (*it)->changePflsRefsNamesGen2(mapOfModif);
8164 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8166 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8167 (*it)->changeLocsRefsNamesGen2(mapOfModif);
8170 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
8172 int lgth=_time_steps.size();
8173 std::vector< std::vector<TypeOfField> > ret(lgth);
8174 for(int i=0;i<lgth;i++)
8175 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
8180 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
8182 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
8184 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
8187 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCopy() const
8189 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
8191 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8193 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
8194 ret->_time_steps[i]=(*it)->deepCopy();
8199 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
8201 std::size_t sz(_infos.size()),sz2(_time_steps.size());
8202 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
8203 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
8204 for(std::size_t i=0;i<sz;i++)
8206 ret[i]=shallowCpy();
8207 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
8209 for(std::size_t i=0;i<sz2;i++)
8211 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
8214 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
8215 throw INTERP_KERNEL::Exception(oss.str());
8219 for(std::size_t i=0;i<sz;i++)
8220 for(std::size_t j=0;j<sz2;j++)
8221 ret[i]->_time_steps[j]=ts[j][i];
8226 * This method splits into discretization each time steps in \a this.
8227 * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
8229 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
8231 std::size_t sz(_time_steps.size());
8232 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
8233 for(std::size_t i=0;i<sz;i++)
8235 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
8238 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
8239 throw INTERP_KERNEL::Exception(oss.str());
8241 items[i]=timeStep->splitDiscretizations();
8244 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
8245 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
8246 std::vector< TypeOfField > types;
8247 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
8248 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
8250 std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
8252 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
8253 std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
8254 if(it2==types.end())
8255 types.push_back(ts[0]);
8257 ret.resize(types.size()); ret2.resize(types.size());
8258 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
8259 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
8261 TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
8262 std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
8263 ret2[pos].push_back(*it1);
8265 for(std::size_t i=0;i<types.size();i++)
8267 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
8268 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
8269 elt->pushBackTimeStep(*it1);//also updates infos in elt
8271 elt->MEDFileFieldNameScope::operator=(*this);
8277 * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
8279 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
8281 std::size_t sz(_time_steps.size());
8282 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
8283 std::size_t szOut(std::numeric_limits<std::size_t>::max());
8284 for(std::size_t i=0;i<sz;i++)
8286 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
8289 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
8290 throw INTERP_KERNEL::Exception(oss.str());
8292 items[i]=timeStep->splitMultiDiscrPerGeoTypes();
8293 if(szOut==std::numeric_limits<std::size_t>::max())
8294 szOut=items[i].size();
8296 if(items[i].size()!=szOut)
8297 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
8299 if(szOut==std::numeric_limits<std::size_t>::max())
8300 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
8301 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
8302 for(std::size_t i=0;i<szOut;i++)
8304 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
8305 for(std::size_t j=0;j<sz;j++)
8306 elt->pushBackTimeStep(items[j][i]);
8308 elt->MEDFileFieldNameScope::operator=(*this);
8313 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
8315 _name=field->getName();
8317 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
8319 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
8320 _infos=arr->getInfoOnComponents();
8323 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
8325 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
8326 if(_name!=field->getName())
8328 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
8329 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
8330 throw INTERP_KERNEL::Exception(oss.str());
8333 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
8334 checkThatComponentsMatch(arr->getInfoOnComponents());
8337 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
8339 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
8340 if(getInfo().size()!=compos.size())
8342 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
8343 oss << " number of components of element to append (" << compos.size() << ") !";
8344 throw INTERP_KERNEL::Exception(oss.str());
8348 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
8349 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
8350 oss << " But compo in input fields are : ";
8351 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
8353 throw INTERP_KERNEL::Exception(oss.str());
8357 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
8359 std::size_t sz=_infos.size();
8361 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
8363 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
8365 if(elt->getInfo().size()!=sz)
8367 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
8368 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
8369 throw INTERP_KERNEL::Exception(oss.str());
8374 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
8377 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8378 if(!_time_steps.empty())
8379 checkCoherencyOfTinyInfo(field,arr);
8380 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8381 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8382 objC->setFieldNoProfileSBT(field,arr,glob,*this);
8383 copyTinyInfoFrom(field,arr);
8384 _time_steps.push_back(obj);
8387 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
8390 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8391 if(!_time_steps.empty())
8392 checkCoherencyOfTinyInfo(field,arr);
8393 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8394 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8395 objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
8396 copyTinyInfoFrom(field,arr);
8397 _time_steps.push_back(obj);
8400 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ts)
8402 int sz=(int)_time_steps.size();
8405 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
8406 throw INTERP_KERNEL::Exception(oss.str());
8408 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
8411 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
8413 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
8414 throw INTERP_KERNEL::Exception(oss.str());
8420 //= MEDFileFieldMultiTSWithoutSDA
8422 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)
8424 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8427 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
8431 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8436 * \param [in] fieldId field id in C mode
8438 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8439 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8442 catch(INTERP_KERNEL::Exception& e)
8445 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)
8446 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8449 catch(INTERP_KERNEL::Exception& e)
8452 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8454 return new MEDFileField1TSWithoutSDA;
8457 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8460 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8461 const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
8463 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8466 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const
8468 return MEDFileField1TSWithoutSDA::TYPE_STR;
8471 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const
8473 return new MEDFileFieldMultiTSWithoutSDA(*this);
8476 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const
8478 return new MEDFileFieldMultiTSWithoutSDA;
8482 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
8483 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
8485 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
8487 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
8488 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8490 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
8491 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
8494 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
8496 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
8497 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8499 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8501 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8504 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
8506 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
8507 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
8508 ret->setIteration(i,elt);
8514 //= MEDFileAnyTypeFieldMultiTS
8516 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
8520 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8521 try:MEDFileFieldGlobsReal(fid)
8523 _content=BuildContentFrom(fid,loadAll,ms);
8526 catch(INTERP_KERNEL::Exception& e)
8531 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8533 med_field_type typcha;
8534 std::vector<std::string> infos;
8537 MEDFileAnyTypeField1TS::LocateField(fid,fieldName,i,typcha,infos,dtunit);
8538 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8543 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8548 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8553 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] !";
8554 throw INTERP_KERNEL::Exception(oss.str());
8557 ret->setDtUnit(dtunit.c_str());
8561 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8563 med_field_type typcha;
8565 std::vector<std::string> infos;
8566 std::string dtunit,fieldName;
8567 MEDFileAnyTypeField1TS::LocateField2(fid,0,true,fieldName,typcha,infos,dtunit);
8568 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8573 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8578 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8583 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] !";
8584 throw INTERP_KERNEL::Exception(oss.str());
8587 ret->setDtUnit(dtunit.c_str());
8591 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c)
8594 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
8595 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
8597 MCAuto<MEDFileFieldMultiTS> ret(MEDFileFieldMultiTS::New());
8598 ret->_content=c; c->incrRef();
8601 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
8603 MCAuto<MEDFileIntFieldMultiTS> ret(MEDFileIntFieldMultiTS::New());
8604 ret->_content=c; c->incrRef();
8607 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
8610 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, med_idt fid)
8612 MEDFileAnyTypeFieldMultiTS *ret(BuildNewInstanceFromContent(c));
8613 std::string fileName(FileNameFromFID(fid));
8614 ret->setFileName(fileName);
8618 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8619 try:MEDFileFieldGlobsReal(fid)
8621 _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
8624 catch(INTERP_KERNEL::Exception& e)
8629 //= MEDFileIntFieldMultiTSWithoutSDA
8631 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)
8633 return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8636 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
8640 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8644 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)
8645 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8648 catch(INTERP_KERNEL::Exception& e)
8652 * \param [in] fieldId field id in C mode
8654 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8655 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8658 catch(INTERP_KERNEL::Exception& e)
8661 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8663 return new MEDFileIntField1TSWithoutSDA;
8666 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8669 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8670 const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
8672 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8675 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const
8677 return MEDFileIntField1TSWithoutSDA::TYPE_STR;
8680 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const
8682 return new MEDFileIntFieldMultiTSWithoutSDA(*this);
8685 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const
8687 return new MEDFileIntFieldMultiTSWithoutSDA;
8690 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const
8692 MCAuto<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
8693 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8695 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8697 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8700 const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
8702 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
8703 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
8704 ret->setIteration(i,elt);
8710 //= MEDFileAnyTypeFieldMultiTS
8713 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
8714 * that has been read from a specified MED file.
8715 * \param [in] fileName - the name of the MED file to read.
8716 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8717 * is to delete this field using decrRef() as it is no more needed.
8718 * \throw If reading the file fails.
8720 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
8722 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8723 return New(fid,loadAll);
8726 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, bool loadAll)
8728 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
8729 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8730 ret->loadGlobals(fid);
8735 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
8736 * that has been read from a specified MED file.
8737 * \param [in] fileName - the name of the MED file to read.
8738 * \param [in] fieldName - the name of the field to read.
8739 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8740 * is to delete this field using decrRef() as it is no more needed.
8741 * \throw If reading the file fails.
8742 * \throw If there is no field named \a fieldName in the file.
8744 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8746 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8747 return New(fid,fieldName,loadAll);
8750 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
8752 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
8753 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8754 ret->loadGlobals(fid);
8759 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8760 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8762 * \warning this is a shallow copy constructor
8764 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8766 if(!shallowCopyOfContent)
8768 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
8769 otherPtr->incrRef();
8770 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
8774 _content=other.shallowCpy();
8778 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
8780 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8782 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
8786 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
8788 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8790 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
8794 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
8796 return contentNotNullBase()->getPflsReallyUsed2();
8799 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
8801 return contentNotNullBase()->getLocsReallyUsed2();
8804 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
8806 return contentNotNullBase()->getPflsReallyUsedMulti2();
8809 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
8811 return contentNotNullBase()->getLocsReallyUsedMulti2();
8814 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8816 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
8819 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8821 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
8824 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
8826 return contentNotNullBase()->getNumberOfTS();
8829 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
8831 contentNotNullBase()->eraseEmptyTS();
8834 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
8836 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
8839 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
8841 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
8844 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
8846 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
8847 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8852 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
8854 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
8855 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8860 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
8862 return contentNotNullBase()->getIterations();
8865 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
8867 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
8868 pushBackTimeStep(*it);
8871 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
8874 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
8875 int nbOfTS(fmts->getNumberOfTS());
8876 for(int i=0;i<nbOfTS;i++)
8878 MCAuto<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
8879 pushBackTimeStep(elt);
8883 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
8886 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
8887 checkCoherencyOfType(f1ts);
8889 MCAuto<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
8890 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
8892 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
8893 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
8894 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
8895 _content->pushBackTimeStep(cSafe);
8896 appendGlobs(*f1ts,1e-12);
8899 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
8901 contentNotNullBase()->synchronizeNameScope();
8904 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
8906 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
8909 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
8911 return contentNotNullBase()->getPosGivenTime(time,eps);
8914 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8916 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
8919 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
8921 return contentNotNullBase()->getTypesOfFieldAvailable();
8924 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
8926 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
8929 std::string MEDFileAnyTypeFieldMultiTS::getName() const
8931 return contentNotNullBase()->getName();
8934 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
8936 contentNotNullBase()->setName(name);
8939 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
8941 return contentNotNullBase()->getDtUnit();
8944 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
8946 contentNotNullBase()->setDtUnit(dtUnit);
8949 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8951 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
8954 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
8956 return contentNotNullBase()->getTimeSteps(ret1);
8959 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
8961 return contentNotNullBase()->getMeshName();
8964 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
8966 contentNotNullBase()->setMeshName(newMeshName);
8969 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
8971 return contentNotNullBase()->changeMeshNames(modifTab);
8974 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
8976 return contentNotNullBase()->getInfo();
8979 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
8981 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
8984 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
8986 return contentNotNullBase()->setInfo(info);
8989 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
8991 const std::vector<std::string> ret=getInfo();
8992 return (int)ret.size();
8995 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
8997 writeGlobals(fid,*this);
8998 contentNotNullBase()->writeLL(fid,*this);
9002 * This method alloc the arrays and load potentially huge arrays contained in this field.
9003 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
9004 * This method can be also called to refresh or reinit values from a file.
9006 * \throw If the fileName is not set or points to a non readable MED file.
9008 void MEDFileAnyTypeFieldMultiTS::loadArrays()
9010 if(getFileName().empty())
9011 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
9012 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
9013 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
9017 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
9018 * But once data loaded once, this method does nothing.
9020 * \throw If the fileName is not set or points to a non readable MED file.
9021 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
9023 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
9025 if(!getFileName().empty())
9027 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
9028 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
9033 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
9034 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
9035 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
9037 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
9039 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
9041 contentNotNullBase()->unloadArrays();
9045 * 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.
9046 * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
9047 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
9049 * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
9051 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
9053 if(!getFileName().empty())
9054 contentNotNullBase()->unloadArrays();
9057 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
9059 std::ostringstream oss;
9060 contentNotNullBase()->simpleRepr(0,oss,-1);
9061 simpleReprGlobs(oss);
9065 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
9067 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
9070 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
9072 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
9073 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
9078 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
9079 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
9080 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
9082 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
9084 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9086 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
9087 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
9088 std::size_t sz(contentsSplit.size());
9089 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
9090 for(std::size_t i=0;i<sz;i++)
9092 ret[i]=shallowCpy();
9093 ret[i]->_content=contentsSplit[i];
9099 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
9100 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
9102 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
9104 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9106 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
9107 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
9108 std::size_t sz(contentsSplit.size());
9109 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
9110 for(std::size_t i=0;i<sz;i++)
9112 ret[i]=shallowCpy();
9113 ret[i]->_content=contentsSplit[i];
9119 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
9120 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
9122 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
9124 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9126 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
9127 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
9128 std::size_t sz(contentsSplit.size());
9129 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
9130 for(std::size_t i=0;i<sz;i++)
9132 ret[i]=shallowCpy();
9133 ret[i]->_content=contentsSplit[i];
9138 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCopy() const
9140 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
9141 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
9142 ret->_content=_content->deepCopy();
9143 ret->deepCpyGlobs(*this);
9147 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
9153 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
9154 * \param [in] iteration - the iteration number of a required time step.
9155 * \param [in] order - the iteration order number of required time step.
9156 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
9157 * delete this field using decrRef() as it is no more needed.
9158 * \throw If there is no required time step in \a this field.
9160 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
9162 int pos=getPosOfTimeStep(iteration,order);
9163 return getTimeStepAtPos(pos);
9167 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
9168 * \param [in] time - the time of the time step of interest.
9169 * \param [in] eps - a precision used to compare time values.
9170 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9171 * delete this field using decrRef() as it is no more needed.
9172 * \throw If there is no required time step in \a this field.
9174 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
9176 int pos=getPosGivenTime(time,eps);
9177 return getTimeStepAtPos(pos);
9181 * 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.
9182 * The float64 value of time attached to the pair of integers are not considered here.
9183 * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
9185 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
9186 * \throw If there is a null pointer in \a vectFMTS.
9188 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
9190 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
9191 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9192 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
9193 while(!lstFMTS.empty())
9195 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
9196 MEDFileAnyTypeFieldMultiTS *curIt(*it);
9198 throw INTERP_KERNEL::Exception(msg);
9199 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
9200 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
9201 elt.push_back(curIt); it=lstFMTS.erase(it);
9202 while(it!=lstFMTS.end())
9206 throw INTERP_KERNEL::Exception(msg);
9207 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
9209 { elt.push_back(curIt); it=lstFMTS.erase(it); }
9219 * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
9220 * All returned instances in a subvector can be safely loaded, rendered along time
9221 * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
9222 * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
9223 * 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).
9224 * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
9225 * 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.
9227 * \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().
9228 * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
9229 * \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.
9230 * \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.
9232 * \throw If an element in \a vectFMTS has not only one spatial discretization set.
9233 * \throw If an element in \a vectFMTS change of spatial discretization along time.
9234 * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
9235 * \thorw If some elements in \a vectFMTS do not have the same times steps.
9236 * \throw If mesh is null.
9237 * \throw If an element in \a vectFMTS is null.
9238 * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
9240 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& fsc)
9242 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
9244 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
9245 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9246 if(vectFMTS.empty())
9248 std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
9249 MEDFileAnyTypeFieldMultiTS *frstElt(*it);
9251 throw INTERP_KERNEL::Exception(msg);
9253 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
9254 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
9255 for(;it!=vectFMTS.end();it++,i++)
9258 throw INTERP_KERNEL::Exception(msg);
9259 TypeOfField tof0,tof1;
9260 if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
9263 vectFMTSNotNodes.push_back(*it);
9265 vectFMTSNodes.push_back(*it);
9268 vectFMTSNotNodes.push_back(*it);
9270 std::vector< MCAuto<MEDFileFastCellSupportComparator> > cmps;
9271 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
9273 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
9276 bool isFetched(false);
9277 for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
9280 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
9281 if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
9282 { ret[i].push_back(*it2); isFetched=true; }
9286 std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
9287 MCAuto<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
9288 ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
9296 * 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.
9297 * \param [out] cmps - same size than the returned vector.
9299 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& cmps)
9301 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9302 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
9303 while(!lstFMTS.empty())
9305 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
9306 MEDFileAnyTypeFieldMultiTS *ref(*it);
9307 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
9308 elt.push_back(ref); it=lstFMTS.erase(it);
9309 MCAuto<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
9310 MCAuto<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
9311 while(it!=lstFMTS.end())
9313 MEDFileAnyTypeFieldMultiTS *curIt(*it);
9314 if(cmp->isEqual(curIt))
9315 { elt.push_back(curIt); it=lstFMTS.erase(it); }
9319 ret.push_back(elt); cmps.push_back(cmp);
9325 * 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.
9326 * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
9328 * \throw If \a f0 or \a f1 has not only one spatial discretization set.
9329 * \throw If \a f0 or \a f1 change of spatial discretization along time.
9330 * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
9331 * \thorw If \a f0 and \a f1 do not have the same times steps.
9332 * \throw If mesh is null.
9333 * \throw If \a f0 or \a f1 is null.
9334 * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
9336 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
9339 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
9341 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
9342 if(f0->getMeshName()!=mesh->getName())
9344 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9345 throw INTERP_KERNEL::Exception(oss.str());
9347 if(f1->getMeshName()!=mesh->getName())
9349 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9350 throw INTERP_KERNEL::Exception(oss.str());
9352 int nts=f0->getNumberOfTS();
9353 if(nts!=f1->getNumberOfTS())
9354 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
9357 for(int i=0;i<nts;i++)
9359 MCAuto<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
9360 MCAuto<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
9361 std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
9362 if(tofs0.size()!=1 || tofs1.size()!=1)
9363 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
9366 if(tof0!=tofs0[0] || tof1!=tofs1[0])
9367 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
9370 { tof0=tofs0[0]; tof1=tofs1[0]; }
9371 if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
9373 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() << ") !";
9374 throw INTERP_KERNEL::Exception(oss.str());
9376 if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
9378 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() << ") !";
9379 throw INTERP_KERNEL::Exception(oss.str());
9381 if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
9383 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() << ") !";
9384 throw INTERP_KERNEL::Exception(oss.str());
9391 * Return an extraction of \a this using \a extractDef map to specify the extraction.
9392 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
9394 * \return A new object that the caller is responsible to deallocate.
9396 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
9399 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::extractPart : mesh is null !");
9400 MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(buildNewEmpty());
9401 int nbTS(getNumberOfTS());
9402 for(int i=0;i<nbTS;i++)
9404 MCAuto<MEDFileAnyTypeField1TS> f1ts(getTimeStepAtPos(i));
9405 MCAuto<MEDFileAnyTypeField1TS> f1tsOut(f1ts->extractPart(extractDef,mm));
9406 fmtsOut->pushBackTimeStep(f1tsOut);
9408 return fmtsOut.retn();
9412 MCAuto<MEDFileAnyTypeField1TS> AggregateHelperF1TS(const std::vector< typename MLFieldTraits<T>::F1TSType const *>& f1tss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9414 MCAuto< typename MLFieldTraits<T>::F1TSType > ret(MLFieldTraits<T>::F1TSType::New());
9416 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : empty vector !");
9417 std::size_t sz(f1tss.size()),i(0);
9418 std::vector< typename MLFieldTraits<T>::F1TSWSDAType const *> f1tsw(sz);
9419 for(typename std::vector< typename MLFieldTraits<T>::F1TSType const *>::const_iterator it=f1tss.begin();it!=f1tss.end();it++,i++)
9421 typename MLFieldTraits<T>::F1TSType const *elt(*it);
9423 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : presence of a null pointer !");
9424 f1tsw[i]=dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType const *>(elt->contentNotNullBase());
9426 typename MLFieldTraits<T>::F1TSWSDAType *retc(dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType *>(ret->contentNotNullBase()));
9428 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : internal error 1 !");
9429 retc->aggregate(f1tsw,dts);
9430 ret->setDtUnit(f1tss[0]->getDtUnit());
9431 return DynamicCast<typename MLFieldTraits<T>::F1TSType , MEDFileAnyTypeField1TS>(ret);
9435 MCAuto< MEDFileAnyTypeFieldMultiTS > AggregateHelperFMTS(const std::vector< typename MLFieldTraits<T>::FMTSType const *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9437 MCAuto< typename MLFieldTraits<T>::FMTSType > ret(MLFieldTraits<T>::FMTSType::New());
9439 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : empty vector !");
9440 std::size_t sz(fmtss.size());
9441 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9443 typename MLFieldTraits<T>::FMTSType const *elt(*it);
9445 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : presence of null pointer !");
9447 int nbTS(fmtss[0]->getNumberOfTS());
9448 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9449 if((*it)->getNumberOfTS()!=nbTS)
9450 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : all fields must have the same number of TS !");
9451 for(int iterTS=0;iterTS<nbTS;iterTS++)
9454 std::vector< typename MLFieldTraits<T>::F1TSType const *> f1tss(sz);
9455 std::vector< MCAuto<typename MLFieldTraits<T>::F1TSType> > f1tss2(sz);
9456 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++,i++)
9457 { f1tss2[i]=(*it)->getTimeStepAtPos(iterTS); f1tss[i]=f1tss2[i]; }
9458 MCAuto<MEDFileAnyTypeField1TS> f1ts(AggregateHelperF1TS<T>(f1tss,dts));
9459 ret->pushBackTimeStep(f1ts);
9460 ret->setDtUnit(f1ts->getDtUnit());
9462 return DynamicCast<typename MLFieldTraits<T>::FMTSType , MEDFileAnyTypeFieldMultiTS>(ret);
9466 * \a dts and \a ftmss are expected to have same size.
9468 MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileAnyTypeFieldMultiTS::Aggregate(const std::vector<const MEDFileAnyTypeFieldMultiTS *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9471 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : input vector is empty !");
9472 std::size_t sz(fmtss.size());
9473 std::vector<const MEDFileFieldMultiTS *> fmtss1;
9474 std::vector<const MEDFileIntFieldMultiTS *> fmtss2;
9475 for(std::vector<const MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9478 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : presence of null instance in input vector !");
9479 const MEDFileFieldMultiTS *elt1(dynamic_cast<const MEDFileFieldMultiTS *>(*it));
9482 fmtss1.push_back(elt1);
9485 const MEDFileIntFieldMultiTS *elt2(dynamic_cast<const MEDFileIntFieldMultiTS *>(*it));
9488 fmtss2.push_back(elt2);
9491 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not recognized type !");
9493 if(fmtss1.size()!=sz && fmtss2.size()!=sz)
9494 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : type of data is not homogeneous !");
9495 if(fmtss1.size()==sz)
9496 return AggregateHelperFMTS<double>(fmtss1,dts);
9497 if(fmtss2.size()!=sz)
9498 return AggregateHelperFMTS<int>(fmtss2,dts);
9499 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not implemented yet !");
9502 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
9504 return new MEDFileAnyTypeFieldMultiTSIterator(this);
9507 //= MEDFileFieldMultiTS
9510 * Returns a new empty instance of MEDFileFieldMultiTS.
9511 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9512 * is to delete this field using decrRef() as it is no more needed.
9514 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
9516 return new MEDFileFieldMultiTS;
9520 * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
9521 * that has been read from a specified MED file.
9522 * \param [in] fileName - the name of the MED file to read.
9523 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9524 * is to delete this field using decrRef() as it is no more needed.
9525 * \throw If reading the file fails.
9527 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll)
9529 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9530 return New(fid,loadAll);
9533 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, bool loadAll)
9535 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,loadAll,0));
9536 ret->contentNotNull();//to check that content type matches with \a this type.
9541 * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
9542 * that has been read from a specified MED file.
9543 * \param [in] fileName - the name of the MED file to read.
9544 * \param [in] fieldName - the name of the field to read.
9545 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9546 * is to delete this field using decrRef() as it is no more needed.
9547 * \throw If reading the file fails.
9548 * \throw If there is no field named \a fieldName in the file.
9550 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9552 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9553 return New(fid,fieldName,loadAll);
9556 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
9558 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0));
9559 ret->contentNotNull();//to check that content type matches with \a this type.
9564 * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9565 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9567 * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
9568 * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9569 * \warning this is a shallow copy constructor
9570 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
9571 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9572 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9573 * is to delete this field using decrRef() as it is no more needed.
9575 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9577 return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
9580 MEDFileFieldMultiTS *MEDFileFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9582 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9583 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
9584 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0,ent));
9585 ret->contentNotNull();//to check that content type matches with \a this type.
9589 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
9591 return new MEDFileFieldMultiTS(*this);
9594 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9597 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9598 const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
9600 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
9604 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
9605 * following the given input policy.
9607 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9608 * By default (true) the globals are deeply copied.
9609 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
9611 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
9613 MCAuto<MEDFileIntFieldMultiTS> ret;
9614 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9617 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
9619 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
9620 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
9621 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc));
9624 ret=MEDFileIntFieldMultiTS::New();
9626 ret->deepCpyGlobs(*this);
9628 ret->shallowCpyGlobs(*this);
9633 * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
9634 * \param [in] pos - a time step id.
9635 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9636 * delete this field using decrRef() as it is no more needed.
9637 * \throw If \a pos is not a valid time step id.
9639 MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const
9641 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9644 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9645 throw INTERP_KERNEL::Exception(oss.str());
9647 const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
9650 MCAuto<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
9651 ret->shallowCpyGlobs(*this);
9654 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
9655 throw INTERP_KERNEL::Exception(oss.str());
9659 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9660 * mesh entities of a given dimension of the first mesh in MED file.
9661 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9662 * \param [in] type - a spatial discretization of interest.
9663 * \param [in] iteration - the iteration number of a required time step.
9664 * \param [in] order - the iteration order number of required time step.
9665 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9666 * \param [in] renumPol - specifies how to permute values of the result field according to
9667 * the optional numbers of cells and nodes, if any. The valid values are
9668 * - 0 - do not permute.
9669 * - 1 - permute cells.
9670 * - 2 - permute nodes.
9671 * - 3 - permute cells and nodes.
9673 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9674 * caller is to delete this field using decrRef() as it is no more needed.
9675 * \throw If the MED file is not readable.
9676 * \throw If there is no mesh in the MED file.
9677 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9678 * \throw If no field values of the required parameters are available.
9680 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9682 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9683 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9685 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
9686 MCAuto<DataArray> arrOut;
9687 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9688 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9693 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9694 * the top level cells of the first mesh in MED file.
9695 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9696 * \param [in] type - a spatial discretization of interest.
9697 * \param [in] iteration - the iteration number of a required time step.
9698 * \param [in] order - the iteration order number of required time step.
9699 * \param [in] renumPol - specifies how to permute values of the result field according to
9700 * the optional numbers of cells and nodes, if any. The valid values are
9701 * - 0 - do not permute.
9702 * - 1 - permute cells.
9703 * - 2 - permute nodes.
9704 * - 3 - permute cells and nodes.
9706 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9707 * caller is to delete this field using decrRef() as it is no more needed.
9708 * \throw If the MED file is not readable.
9709 * \throw If there is no mesh in the MED file.
9710 * \throw If no field values of the required parameters are available.
9712 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9714 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9715 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9717 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
9718 MCAuto<DataArray> arrOut;
9719 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9720 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9725 * 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
9726 * method should be called (getFieldOnMeshAtLevel for example).
9727 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
9729 * \param [in] iteration - the iteration number of a required time step.
9730 * \param [in] order - the iteration order number of required time step.
9731 * \param [in] mesh - the mesh the field is lying on
9732 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9733 * caller is to delete this field using decrRef() as it is no more needed.
9735 MEDCouplingFieldDouble *MEDFileFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
9737 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9738 MCAuto<DataArray> arrOut;
9739 MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
9740 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9745 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9747 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9748 * \param [in] type - a spatial discretization of interest.
9749 * \param [in] iteration - the iteration number of a required time step.
9750 * \param [in] order - the iteration order number of required time step.
9751 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9752 * \param [in] mesh - the supporting mesh.
9753 * \param [in] renumPol - specifies how to permute values of the result field according to
9754 * the optional numbers of cells and nodes, if any. The valid values are
9755 * - 0 - do not permute.
9756 * - 1 - permute cells.
9757 * - 2 - permute nodes.
9758 * - 3 - permute cells and nodes.
9760 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9761 * caller is to delete this field using decrRef() as it is no more needed.
9762 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9763 * \throw If no field of \a this is lying on \a mesh.
9764 * \throw If no field values of the required parameters are available.
9766 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9768 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9769 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9771 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9772 MCAuto<DataArray> arrOut;
9773 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
9774 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9779 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9781 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9782 * \param [in] type - a spatial discretization of the new field.
9783 * \param [in] iteration - the iteration number of a required time step.
9784 * \param [in] order - the iteration order number of required time step.
9785 * \param [in] mesh - the supporting mesh.
9786 * \param [in] renumPol - specifies how to permute values of the result field according to
9787 * the optional numbers of cells and nodes, if any. The valid values are
9788 * - 0 - do not permute.
9789 * - 1 - permute cells.
9790 * - 2 - permute nodes.
9791 * - 3 - permute cells and nodes.
9793 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9794 * caller is to delete this field using decrRef() as it is no more needed.
9795 * \throw If no field of \a this is lying on \a mesh.
9796 * \throw If no field values of the required parameters are available.
9798 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
9800 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9801 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9803 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9804 MCAuto<DataArray> arrOut;
9805 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
9806 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9811 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
9812 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9813 * This method is useful for MED2 file format when field on different mesh was autorized.
9815 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
9817 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9818 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9820 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
9821 MCAuto<DataArray> arrOut;
9822 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
9823 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9828 * Returns values and a profile of the field of a given type, of a given time step,
9829 * lying on a given support.
9830 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9831 * \param [in] type - a spatial discretization of the field.
9832 * \param [in] iteration - the iteration number of a required time step.
9833 * \param [in] order - the iteration order number of required time step.
9834 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9835 * \param [in] mesh - the supporting mesh.
9836 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9837 * field of interest lies on. If the field lies on all entities of the given
9838 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9839 * using decrRef() as it is no more needed.
9840 * \param [in] glob - the global data storing profiles and localization.
9841 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
9842 * field. The caller is to delete this array using decrRef() as it is no more needed.
9843 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9844 * \throw If no field of \a this is lying on \a mesh.
9845 * \throw If no field values of the required parameters are available.
9847 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9849 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9850 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9852 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
9853 MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9854 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
9857 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const
9859 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9861 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
9862 const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
9864 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 !");
9868 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull()
9870 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9872 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
9873 MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
9875 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 !");
9880 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9881 * the given field is checked if its elements are sorted suitable for writing to MED file
9882 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9883 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9884 * \param [in] field - the field to add to \a this.
9885 * \throw If the name of \a field is empty.
9886 * \throw If the data array of \a field is not set.
9887 * \throw If existing time steps have different name or number of components than \a field.
9888 * \throw If the underlying mesh of \a field has no name.
9889 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9891 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
9893 const DataArrayDouble *arr=0;
9895 arr=field->getArray();
9896 contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
9900 * Adds a MEDCouplingFieldDouble to \a this as another time step.
9901 * The mesh support of input parameter \a field is ignored here, it can be NULL.
9902 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9905 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9906 * A new profile is added only if no equal profile is missing.
9907 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9908 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
9909 * \param [in] mesh - the supporting mesh of \a field.
9910 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9911 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
9912 * \throw If either \a field or \a mesh or \a profile has an empty name.
9913 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9914 * \throw If the data array of \a field is not set.
9915 * \throw If the data array of \a this is already allocated but has different number of
9916 * components than \a field.
9917 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9918 * \sa setFieldNoProfileSBT()
9920 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9922 const DataArrayDouble *arr=0;
9924 arr=field->getArray();
9925 contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
9928 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
9930 _content=new MEDFileFieldMultiTSWithoutSDA;
9933 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
9934 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
9937 catch(INTERP_KERNEL::Exception& e)
9940 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
9941 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
9944 catch(INTERP_KERNEL::Exception& e)
9947 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9951 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
9953 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
9956 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9958 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9961 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
9963 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
9966 MEDFileFieldMultiTS *MEDFileFieldMultiTS::buildNewEmpty() const
9968 return MEDFileFieldMultiTS::New();
9971 //= MEDFileAnyTypeFieldMultiTSIterator
9973 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
9978 _nb_iter=fmts->getNumberOfTS();
9982 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
9986 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
9988 if(_iter_id<_nb_iter)
9990 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
9992 return fmts->getTimeStepAtPos(_iter_id++);
10000 //= MEDFileIntFieldMultiTS
10003 * Returns a new empty instance of MEDFileFieldMultiTS.
10004 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
10005 * is to delete this field using decrRef() as it is no more needed.
10007 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
10009 return new MEDFileIntFieldMultiTS;
10013 * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
10014 * that has been read from a specified MED file.
10015 * \param [in] fileName - the name of the MED file to read.
10016 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
10017 * is to delete this field using decrRef() as it is no more needed.
10018 * \throw If reading the file fails.
10020 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll)
10022 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10023 return New(fid,loadAll);
10026 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, bool loadAll)
10028 MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,loadAll,0));
10029 ret->contentNotNull();//to check that content type matches with \a this type.
10034 * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
10035 * that has been read from a specified MED file.
10036 * \param [in] fileName - the name of the MED file to read.
10037 * \param [in] fieldName - the name of the field to read.
10038 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
10039 * is to delete this field using decrRef() as it is no more needed.
10040 * \throw If reading the file fails.
10041 * \throw If there is no field named \a fieldName in the file.
10043 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
10045 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10046 return New(fid,fieldName,loadAll);
10049 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
10051 MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0));
10052 ret->contentNotNull();//to check that content type matches with \a this type.
10057 * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
10058 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
10060 * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
10061 * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
10062 * \warning this is a shallow copy constructor
10063 * \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
10064 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
10065 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
10066 * is to delete this field using decrRef() as it is no more needed.
10068 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
10070 return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
10073 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
10075 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10076 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
10077 MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0,ent));
10078 ret->contentNotNull();//to check that content type matches with \a this type.
10083 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
10084 * following the given input policy.
10086 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
10087 * By default (true) the globals are deeply copied.
10088 * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
10090 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const
10092 MCAuto<MEDFileFieldMultiTS> ret;
10093 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
10096 const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
10098 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
10099 MCAuto<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
10100 ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc));
10103 ret=MEDFileFieldMultiTS::New();
10105 ret->deepCpyGlobs(*this);
10107 ret->shallowCpyGlobs(*this);
10111 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const
10113 return new MEDFileIntFieldMultiTS(*this);
10116 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
10119 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
10120 const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
10122 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
10126 * 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
10127 * method should be called (getFieldOnMeshAtLevel for example).
10128 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
10130 * \param [in] iteration - the iteration number of a required time step.
10131 * \param [in] order - the iteration order number of required time step.
10132 * \param [in] mesh - the mesh the field is lying on
10133 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
10134 * caller is to delete this field using decrRef() as it is no more needed.
10136 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
10138 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10139 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10141 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::field : mismatch of type of field expecting INT32 !");
10142 MCAuto<DataArray> arrOut;
10143 MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
10144 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arrOut));
10145 return ret2.retn();
10149 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
10150 * mesh entities of a given dimension of the first mesh in MED file.
10151 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10152 * \param [in] type - a spatial discretization of interest.
10153 * \param [in] iteration - the iteration number of a required time step.
10154 * \param [in] order - the iteration order number of required time step.
10155 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10156 * \param [in] renumPol - specifies how to permute values of the result field according to
10157 * the optional numbers of cells and nodes, if any. The valid values are
10158 * - 0 - do not permute.
10159 * - 1 - permute cells.
10160 * - 2 - permute nodes.
10161 * - 3 - permute cells and nodes.
10163 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10164 * caller is to delete this field using decrRef() as it is no more needed.
10165 * \throw If the MED file is not readable.
10166 * \throw If there is no mesh in the MED file.
10167 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
10168 * \throw If no field values of the required parameters are available.
10170 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
10172 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10173 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10175 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
10176 MCAuto<DataArray> arr;
10177 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase()));
10178 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10179 return ret2.retn();
10183 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
10184 * the top level cells of the first mesh in MED file.
10185 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10186 * \param [in] type - a spatial discretization of interest.
10187 * \param [in] iteration - the iteration number of a required time step.
10188 * \param [in] order - the iteration order number of required time step.
10189 * \param [in] renumPol - specifies how to permute values of the result field according to
10190 * the optional numbers of cells and nodes, if any. The valid values are
10191 * - 0 - do not permute.
10192 * - 1 - permute cells.
10193 * - 2 - permute nodes.
10194 * - 3 - permute cells and nodes.
10196 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10197 * caller is to delete this field using decrRef() as it is no more needed.
10198 * \throw If the MED file is not readable.
10199 * \throw If there is no mesh in the MED file.
10200 * \throw If no field values of the required parameters are available.
10202 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
10204 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10205 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10207 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
10208 MCAuto<DataArray> arr;
10209 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase()));
10210 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10211 return ret2.retn();
10215 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
10217 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10218 * \param [in] type - a spatial discretization of interest.
10219 * \param [in] iteration - the iteration number of a required time step.
10220 * \param [in] order - the iteration order number of required time step.
10221 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10222 * \param [in] mesh - the supporting mesh.
10223 * \param [in] renumPol - specifies how to permute values of the result field according to
10224 * the optional numbers of cells and nodes, if any. The valid values are
10225 * - 0 - do not permute.
10226 * - 1 - permute cells.
10227 * - 2 - permute nodes.
10228 * - 3 - permute cells and nodes.
10230 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10231 * caller is to delete this field using decrRef() as it is no more needed.
10232 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
10233 * \throw If no field of \a this is lying on \a mesh.
10234 * \throw If no field values of the required parameters are available.
10236 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
10238 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10239 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10241 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10242 MCAuto<DataArray> arr;
10243 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase()));
10244 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10245 return ret2.retn();
10249 * Returns a new MEDCouplingFieldInt of given type, of a given time step, lying on a
10251 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10252 * \param [in] type - a spatial discretization of the new field.
10253 * \param [in] iteration - the iteration number of a required time step.
10254 * \param [in] order - the iteration order number of required time step.
10255 * \param [in] mesh - the supporting mesh.
10256 * \param [out] arrOut - the DataArrayInt containing values of field.
10257 * \param [in] renumPol - specifies how to permute values of the result field according to
10258 * the optional numbers of cells and nodes, if any. The valid values are
10259 * - 0 - do not permute.
10260 * - 1 - permute cells.
10261 * - 2 - permute nodes.
10262 * - 3 - permute cells and nodes.
10264 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10265 * caller is to delete this field using decrRef() as it is no more needed.
10266 * \throw If no field of \a this is lying on \a mesh.
10267 * \throw If no field values of the required parameters are available.
10269 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
10271 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10272 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10274 throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10275 MCAuto<DataArray> arr;
10276 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase()));
10277 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10278 return ret2.retn();
10282 * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
10283 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
10284 * This method is useful for MED2 file format when field on different mesh was autorized.
10286 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol) const
10288 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10289 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10291 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10292 MCAuto<DataArray> arr;
10293 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase()));
10294 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10295 return ret2.retn();
10299 * Returns values and a profile of the field of a given type, of a given time step,
10300 * lying on a given support.
10301 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10302 * \param [in] type - a spatial discretization of the field.
10303 * \param [in] iteration - the iteration number of a required time step.
10304 * \param [in] order - the iteration order number of required time step.
10305 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10306 * \param [in] mesh - the supporting mesh.
10307 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
10308 * field of interest lies on. If the field lies on all entities of the given
10309 * dimension, all ids in \a pfl are zero. The caller is to delete this array
10310 * using decrRef() as it is no more needed.
10311 * \param [in] glob - the global data storing profiles and localization.
10312 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
10313 * field. The caller is to delete this array using decrRef() as it is no more needed.
10314 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10315 * \throw If no field of \a this is lying on \a mesh.
10316 * \throw If no field values of the required parameters are available.
10318 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
10320 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
10321 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
10323 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
10324 MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
10325 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
10329 * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
10330 * \param [in] pos - a time step id.
10331 * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
10332 * delete this field using decrRef() as it is no more needed.
10333 * \throw If \a pos is not a valid time step id.
10335 MEDFileIntField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
10337 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
10340 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
10341 throw INTERP_KERNEL::Exception(oss.str());
10343 const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
10346 MCAuto<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
10347 ret->shallowCpyGlobs(*this);
10350 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
10351 throw INTERP_KERNEL::Exception(oss.str());
10355 * Adds a MEDCouplingFieldInt to \a this as another time step. The underlying mesh of
10356 * the given field is checked if its elements are sorted suitable for writing to MED file
10357 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
10358 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10359 * \param [in] field - the field to add to \a this.
10360 * \throw If the name of \a field is empty.
10361 * \throw If the data array of \a field is not set.
10362 * \throw If existing time steps have different name or number of components than \a field.
10363 * \throw If the underlying mesh of \a field has no name.
10364 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
10366 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldInt *field)
10368 MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
10369 contentNotNull()->appendFieldNoProfileSBT(field2,field->getArray(),*this);
10373 * Adds a MEDCouplingFieldDouble to \a this as another time step.
10374 * The mesh support of input parameter \a field is ignored here, it can be NULL.
10375 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
10378 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
10379 * A new profile is added only if no equal profile is missing.
10380 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10381 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
10382 * \param [in] arrOfVals - the values of the field \a field used.
10383 * \param [in] mesh - the supporting mesh of \a field.
10384 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
10385 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
10386 * \throw If either \a field or \a mesh or \a profile has an empty name.
10387 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10388 * \throw If the data array of \a field is not set.
10389 * \throw If the data array of \a this is already allocated but has different number of
10390 * components than \a field.
10391 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
10392 * \sa setFieldNoProfileSBT()
10394 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
10396 MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
10397 contentNotNull()->appendFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this);
10400 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const
10402 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10404 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
10405 const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10407 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 !");
10411 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull()
10413 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10415 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
10416 MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10418 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 !");
10422 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
10424 _content=new MEDFileIntFieldMultiTSWithoutSDA;
10427 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
10431 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
10432 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
10435 catch(INTERP_KERNEL::Exception& e)
10438 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10439 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
10442 catch(INTERP_KERNEL::Exception& e)
10445 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
10447 return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
10450 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::buildNewEmpty() const
10452 return MEDFileIntFieldMultiTS::New();
10457 MEDFileFields *MEDFileFields::New()
10459 return new MEDFileFields;
10462 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
10464 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10465 return New(fid,loadAll);
10468 MEDFileFields *MEDFileFields::NewWithDynGT(const std::string& fileName, const MEDFileStructureElements *se, bool loadAll)
10470 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10471 return NewWithDynGT(fid,se,loadAll);
10474 MEDFileFields *MEDFileFields::NewWithDynGT(med_idt fid, const MEDFileStructureElements *se, bool loadAll)
10477 throw INTERP_KERNEL::Exception("MEDFileFields::NewWithDynGT : null struct element pointer !");
10478 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> entities(MEDFileEntities::BuildFrom(*se));
10479 return new MEDFileFields(fid,loadAll,0,entities);
10482 MEDFileFields *MEDFileFields::New(med_idt fid, bool loadAll)
10484 return new MEDFileFields(fid,loadAll,0,0);
10487 MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
10489 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10490 return new MEDFileFields(fid,loadAll,ms,0);
10493 MEDFileFields *MEDFileFields::LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
10495 MEDFileUtilities::CheckFileForRead(fileName);
10496 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
10497 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10498 return new MEDFileFields(fid,loadAll,0,ent);
10501 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
10503 std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
10504 ret+=_fields.capacity()*sizeof(MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
10508 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
10510 std::vector<const BigMemoryObject *> ret;
10511 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10512 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
10516 MEDFileFields *MEDFileFields::deepCopy() const
10518 MCAuto<MEDFileFields> ret(shallowCpy());
10520 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10522 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10523 ret->_fields[i]=(*it)->deepCopy();
10525 ret->deepCpyGlobs(*this);
10529 MEDFileFields *MEDFileFields::shallowCpy() const
10531 return new MEDFileFields(*this);
10535 * 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
10536 * 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.
10537 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
10539 * \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.
10540 * \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.
10542 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10544 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
10546 std::set< std::pair<int,int> > s;
10547 bool firstShot=true;
10548 areThereSomeForgottenTS=false;
10549 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10551 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10553 std::vector< std::pair<int,int> > v=(*it)->getIterations();
10554 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
10556 { s=s1; firstShot=false; }
10559 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
10561 areThereSomeForgottenTS=true;
10565 std::vector< std::pair<int,int> > ret;
10566 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
10570 int MEDFileFields::getNumberOfFields() const
10572 return _fields.size();
10575 std::vector<std::string> MEDFileFields::getFieldsNames() const
10577 std::vector<std::string> ret(_fields.size());
10579 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10581 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
10584 ret[i]=f->getName();
10588 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
10589 throw INTERP_KERNEL::Exception(oss.str());
10595 std::vector<std::string> MEDFileFields::getMeshesNames() const
10597 std::vector<std::string> ret;
10598 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10600 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10602 ret.push_back(cur->getMeshName());
10607 std::string MEDFileFields::simpleRepr() const
10609 std::ostringstream oss;
10610 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
10615 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
10617 int nbOfFields(getNumberOfFields());
10618 std::string startLine(bkOffset,' ');
10619 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
10621 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10623 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10626 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
10630 oss << startLine << " - not defined !" << std::endl;
10634 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10636 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10637 std::string chapter(17,'0'+i);
10638 oss << startLine << chapter << std::endl;
10641 cur->simpleRepr(bkOffset+2,oss,i);
10645 oss << startLine << " - not defined !" << std::endl;
10647 oss << startLine << chapter << std::endl;
10649 simpleReprGlobs(oss);
10652 MEDFileFields::MEDFileFields()
10656 MEDFileFields::MEDFileFields(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10657 try:MEDFileFieldGlobsReal(fid)
10659 int nbFields(MEDnField(fid));
10660 _fields.resize(nbFields);
10661 med_field_type typcha;
10662 for(int i=0;i<nbFields;i++)
10664 std::vector<std::string> infos;
10665 std::string fieldName,dtunit;
10666 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,i,false,fieldName,typcha,infos,dtunit));
10671 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10676 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10681 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] !";
10682 throw INTERP_KERNEL::Exception(oss.str());
10686 loadAllGlobals(fid);
10688 catch(INTERP_KERNEL::Exception& e)
10693 void MEDFileFields::writeLL(med_idt fid) const
10696 writeGlobals(fid,*this);
10697 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10699 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
10702 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
10703 throw INTERP_KERNEL::Exception(oss.str());
10705 elt->writeLL(fid,*this);
10710 * This method alloc the arrays and load potentially huge arrays contained in this field.
10711 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
10712 * This method can be also called to refresh or reinit values from a file.
10714 * \throw If the fileName is not set or points to a non readable MED file.
10716 void MEDFileFields::loadArrays()
10718 if(getFileName().empty())
10719 throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
10720 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
10721 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10723 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10725 elt->loadBigArraysRecursively(fid,*elt);
10730 * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
10731 * But once data loaded once, this method does nothing.
10733 * \throw If the fileName is not set or points to a non readable MED file.
10734 * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
10736 void MEDFileFields::loadArraysIfNecessary()
10738 if(!getFileName().empty())
10740 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
10741 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10743 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10745 elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
10751 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
10752 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
10753 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
10755 * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
10757 void MEDFileFields::unloadArrays()
10759 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10761 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10763 elt->unloadArrays();
10768 * 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.
10769 * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
10770 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
10772 * \sa MEDFileFields::loadArraysIfNecessary
10774 void MEDFileFields::unloadArraysWithoutDataLoss()
10776 if(!getFileName().empty())
10780 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
10782 std::vector<std::string> ret;
10783 std::set<std::string> ret2;
10784 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10786 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
10787 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10788 if(ret2.find(*it2)==ret2.end())
10790 ret.push_back(*it2);
10797 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
10799 std::vector<std::string> ret;
10800 std::set<std::string> ret2;
10801 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10803 std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
10804 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10805 if(ret2.find(*it2)==ret2.end())
10807 ret.push_back(*it2);
10814 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
10816 std::vector<std::string> ret;
10817 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10819 std::vector<std::string> tmp((*it)->getPflsReallyUsedMulti2());
10820 ret.insert(ret.end(),tmp.begin(),tmp.end());
10825 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
10827 std::vector<std::string> ret;
10828 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10830 std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
10831 ret.insert(ret.end(),tmp.begin(),tmp.end());
10836 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10838 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10839 (*it)->changePflsRefsNamesGen2(mapOfModif);
10842 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10844 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10845 (*it)->changeLocsRefsNamesGen2(mapOfModif);
10848 void MEDFileFields::resize(int newSize)
10850 _fields.resize(newSize);
10853 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
10855 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
10859 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
10862 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
10863 _fields.push_back(field->getContent());
10864 appendGlobs(*field,1e-12);
10867 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
10870 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
10871 if(i>=(int)_fields.size())
10872 _fields.resize(i+1);
10873 _fields[i]=field->getContent();
10874 appendGlobs(*field,1e-12);
10877 void MEDFileFields::destroyFieldAtPos(int i)
10879 destroyFieldsAtPos(&i,&i+1);
10882 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
10884 std::vector<bool> b(_fields.size(),true);
10885 for(const int *i=startIds;i!=endIds;i++)
10887 if(*i<0 || *i>=(int)_fields.size())
10889 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10890 throw INTERP_KERNEL::Exception(oss.str());
10894 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10896 for(std::size_t i=0;i<_fields.size();i++)
10898 fields[j++]=_fields[i];
10902 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
10904 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
10905 int nbOfEntriesToKill(DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg));
10906 std::vector<bool> b(_fields.size(),true);
10908 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
10910 if(k<0 || k>=(int)_fields.size())
10912 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
10913 throw INTERP_KERNEL::Exception(oss.str());
10917 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10919 for(std::size_t i=0;i<_fields.size();i++)
10921 fields[j++]=_fields[i];
10925 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
10928 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10930 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10932 ret=cur->changeMeshNames(modifTab) || ret;
10938 * \param [in] meshName the name of the mesh that will be renumbered.
10939 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
10940 * This code corresponds to the distribution of types in the corresponding mesh.
10941 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
10942 * \param [in] renumO2N the old to new renumber array.
10943 * \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
10944 * field in \a this.
10946 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
10949 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10951 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
10954 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
10961 * Return an extraction of \a this using \a extractDef map to specify the extraction.
10962 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
10964 * \return A new object that the caller is responsible to deallocate.
10966 MEDFileFields *MEDFileFields::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
10969 throw INTERP_KERNEL::Exception("MEDFileFields::extractPart : input mesh is NULL !");
10970 MCAuto<MEDFileFields> fsOut(MEDFileFields::New());
10971 int nbFields(getNumberOfFields());
10972 for(int i=0;i<nbFields;i++)
10974 MCAuto<MEDFileAnyTypeFieldMultiTS> fmts(getFieldAtPos(i));
10977 std::ostringstream oss; oss << "MEDFileFields::extractPart : at pos #" << i << " field is null !";
10978 throw INTERP_KERNEL::Exception(oss.str());
10980 MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(fmts->extractPart(extractDef,mm));
10981 fsOut->pushField(fmtsOut);
10983 return fsOut.retn();
10986 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
10988 if(i<0 || i>=(int)_fields.size())
10990 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
10991 throw INTERP_KERNEL::Exception(oss.str());
10993 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
10996 MCAuto<MEDFileAnyTypeFieldMultiTS> ret;
10997 const MEDFileFieldMultiTSWithoutSDA *fmtsC(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts));
10998 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts));
11000 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
11002 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
11005 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
11006 throw INTERP_KERNEL::Exception(oss.str());
11008 ret->shallowCpyGlobs(*this);
11013 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
11014 * This method is accessible in python using __getitem__ with a list in input.
11015 * \return a new object that the caller should deal with.
11017 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
11019 MCAuto<MEDFileFields> ret=shallowCpy();
11020 std::size_t sz=std::distance(startIds,endIds);
11021 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
11023 for(const int *i=startIds;i!=endIds;i++,j++)
11025 if(*i<0 || *i>=(int)_fields.size())
11027 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
11028 throw INTERP_KERNEL::Exception(oss.str());
11030 fields[j]=_fields[*i];
11032 ret->_fields=fields;
11036 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
11038 return getFieldAtPos(getPosFromFieldName(fieldName));
11042 * This method removes, if any, fields in \a this having no time steps.
11043 * 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.
11045 * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
11047 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
11049 std::vector<MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
11050 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11052 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
11055 if(elt->getNumberOfTS()>0)
11056 newFields.push_back(*it);
11059 if(_fields.size()==newFields.size())
11066 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
11067 * This method can be seen as a filter applied on \a this, that returns an object containing
11068 * 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
11069 * shallow copied from \a this.
11071 * \param [in] meshName - the name of the mesh on w
11072 * \return a new object that the caller should deal with.
11074 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
11076 MCAuto<MEDFileFields> ret(MEDFileFields::New());
11077 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11079 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
11082 if(cur->getMeshName()==meshName)
11085 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
11086 ret->_fields.push_back(cur2);
11089 ret->shallowCpyOnlyUsedGlobs(*this);
11094 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
11095 * Input time steps are specified using a pair of integer (iteration, order).
11096 * 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,
11097 * but for each multitimestep only the time steps in \a timeSteps are kept.
11098 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
11100 * The returned object points to shallow copy of elements in \a this.
11102 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
11103 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
11104 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
11106 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
11108 MCAuto<MEDFileFields> ret(MEDFileFields::New());
11109 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11111 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
11114 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
11115 ret->_fields.push_back(elt);
11117 ret->shallowCpyOnlyUsedGlobs(*this);
11122 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
11124 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
11126 MCAuto<MEDFileFields> ret=MEDFileFields::New();
11127 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11129 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
11132 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
11133 if(elt->getNumberOfTS()!=0)
11134 ret->_fields.push_back(elt);
11136 ret->shallowCpyOnlyUsedGlobs(*this);
11140 bool MEDFileFields::presenceOfStructureElements() const
11142 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11143 if((*it).isNotNull())
11144 if((*it)->presenceOfStructureElements())
11149 void MEDFileFields::killStructureElements()
11151 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
11152 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11153 if((*it).isNotNull())
11155 if((*it)->presenceOfStructureElements())
11157 if(!(*it)->onlyStructureElements())
11159 (*it)->killStructureElements();
11160 ret.push_back(*it);
11165 ret.push_back(*it);
11171 void MEDFileFields::keepOnlyStructureElements()
11173 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
11174 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11175 if((*it).isNotNull())
11177 if((*it)->presenceOfStructureElements())
11179 if(!(*it)->onlyStructureElements())
11180 (*it)->keepOnlyStructureElements();
11181 ret.push_back(*it);
11187 void MEDFileFields::keepOnlyOnMeshSE(const std::string& meshName, const std::string& seName)
11189 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
11190 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11191 if((*it).isNotNull())
11193 if((*it)->getMeshName()!=meshName)
11195 std::vector< std::pair<std::string,std::string> > ps;
11196 (*it)->getMeshSENames(ps);
11197 std::pair<std::string,std::string> p(meshName,seName);
11198 if(std::find(ps.begin(),ps.end(),p)!=ps.end())
11199 (*it)->keepOnlyOnSE(seName);
11200 ret.push_back(*it);
11205 void MEDFileFields::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
11207 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11208 if((*it).isNotNull())
11209 (*it)->getMeshSENames(ps);
11212 MCAuto<MEDFileFields> MEDFileFields::partOfThisOnStructureElements() const
11214 MCAuto<MEDFileFields> ret(deepCopy());
11215 ret->keepOnlyStructureElements();
11219 MCAuto<MEDFileFields> MEDFileFields::partOfThisLyingOnSpecifiedMeshSEName(const std::string& meshName, const std::string& seName) const
11221 MCAuto<MEDFileFields> ret(deepCopy());
11222 ret->keepOnlyOnMeshSE(meshName,seName);
11226 void MEDFileFields::aggregate(const MEDFileFields& other)
11228 int nbFieldsToAdd(other.getNumberOfFields());
11229 std::vector<std::string> fsn(getFieldsNames());
11230 for(int i=0;i<nbFieldsToAdd;i++)
11232 MCAuto<MEDFileAnyTypeFieldMultiTS> elt(other.getFieldAtPos(i));
11233 std::string name(elt->getName());
11234 if(std::find(fsn.begin(),fsn.end(),name)!=fsn.end())
11236 std::ostringstream oss; oss << "MEDFileFields::aggregate : name \"" << name << "\" already appears !";
11237 throw INTERP_KERNEL::Exception(oss.str());
11243 MEDFileFieldsIterator *MEDFileFields::iterator()
11245 return new MEDFileFieldsIterator(this);
11248 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
11250 std::string tmp(fieldName);
11251 std::vector<std::string> poss;
11252 for(std::size_t i=0;i<_fields.size();i++)
11254 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f(_fields[i]);
11257 std::string fname(f->getName());
11261 poss.push_back(fname);
11264 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
11265 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
11267 throw INTERP_KERNEL::Exception(oss.str());
11270 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
11275 _nb_iter=fs->getNumberOfFields();
11279 MEDFileFieldsIterator::~MEDFileFieldsIterator()
11283 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
11285 if(_iter_id<_nb_iter)
11287 MEDFileFields *fs(_fs);
11289 return fs->getFieldAtPos(_iter_id++);