1 // Copyright (C) 2007-2015 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.hxx"
22 #include "MEDFileMesh.hxx"
23 #include "MEDLoaderBase.hxx"
24 #include "MEDFileUtilities.hxx"
25 #include "MEDFileSafeCaller.txx"
26 #include "MEDFileFieldOverView.hxx"
28 #include "MEDCouplingFieldDouble.hxx"
29 #include "MEDCouplingFieldDiscretization.hxx"
31 #include "InterpKernelAutoPtr.hxx"
32 #include "CellModel.hxx"
37 extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
38 extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
39 extern med_geometry_type typmainoeud[1];
40 extern med_geometry_type typmai3[34];
42 using namespace MEDCoupling;
44 const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64";
45 const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32";
47 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const std::string& locName)
49 return new MEDFileFieldLoc(fid,locName);
52 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, int id)
54 return new MEDFileFieldLoc(fid,id);
57 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)
59 return new MEDFileFieldLoc(locName,geoType,refCoo,gsCoo,w);
62 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, const std::string& locName):_name(locName)
64 med_geometry_type geotype;
65 med_geometry_type sectiongeotype;
67 INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
68 INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
69 MEDlocalizationInfoByName(fid,locName.c_str(),&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
70 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
71 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
72 _nb_node_per_cell=cm.getNumberOfNodes();
73 _ref_coo.resize(_dim*_nb_node_per_cell);
74 _gs_coo.resize(_dim*_nb_gauss_pt);
75 _w.resize(_nb_gauss_pt);
76 MEDlocalizationRd(fid,locName.c_str(),MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
79 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id)
81 med_geometry_type geotype;
82 med_geometry_type sectiongeotype;
84 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
85 INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
86 INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
87 MEDlocalizationInfo(fid,id+1,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
89 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
90 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
91 _nb_node_per_cell=cm.getNumberOfNodes();
92 _ref_coo.resize(_dim*_nb_node_per_cell);
93 _gs_coo.resize(_dim*_nb_gauss_pt);
94 _w.resize(_nb_gauss_pt);
95 MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
98 MEDFileFieldLoc::MEDFileFieldLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType,
99 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),
102 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
103 _dim=cm.getDimension();
104 _nb_node_per_cell=cm.getNumberOfNodes();
105 _nb_gauss_pt=_w.size();
108 MEDFileFieldLoc *MEDFileFieldLoc::deepCopy() const
110 return new MEDFileFieldLoc(*this);
113 std::size_t MEDFileFieldLoc::getHeapMemorySizeWithoutChildren() const
115 return (_ref_coo.capacity()+_gs_coo.capacity()+_w.capacity())*sizeof(double)+_name.capacity();
118 std::vector<const BigMemoryObject *> MEDFileFieldLoc::getDirectChildrenWithNull() const
120 return std::vector<const BigMemoryObject *>();
123 void MEDFileFieldLoc::simpleRepr(std::ostream& oss) const
125 static const char OFF7[]="\n ";
126 oss << "\"" << _name << "\"" << OFF7;
127 oss << "GeoType=" << INTERP_KERNEL::CellModel::GetCellModel(_geo_type).getRepr() << OFF7;
128 oss << "Dimension=" << _dim << OFF7;
129 oss << "Number of Gauss points=" << _nb_gauss_pt << OFF7;
130 oss << "Number of nodes per cell=" << _nb_node_per_cell << OFF7;
131 oss << "RefCoords="; std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
132 oss << "Weights="; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
133 oss << "GaussPtsCoords="; std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," ")); oss << std::endl;
136 void MEDFileFieldLoc::setName(const std::string& name)
141 bool MEDFileFieldLoc::isEqual(const MEDFileFieldLoc& other, double eps) const
143 if(_name!=other._name)
147 if(_nb_gauss_pt!=other._nb_gauss_pt)
149 if(_nb_node_per_cell!=other._nb_node_per_cell)
151 if(_geo_type!=other._geo_type)
153 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_ref_coo,other._ref_coo,eps))
155 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_gs_coo,other._gs_coo,eps))
157 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_w,other._w,eps))
163 void MEDFileFieldLoc::writeLL(med_idt fid) const
165 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);
168 std::string MEDFileFieldLoc::repr() const
170 std::ostringstream oss; oss.precision(15);
171 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
172 oss << "Localization \"" << _name << "\" :\n" << " - Geometric Type : " << cm.getRepr();
173 oss << "\n - Dimension : " << _dim << "\n - Number of gauss points : ";
174 oss << _nb_gauss_pt << "\n - Number of nodes in cell : " << _nb_node_per_cell;
175 oss << "\n - Ref coords are : ";
176 int sz=_ref_coo.size();
179 int nbOfTuples=sz/_dim;
180 for(int i=0;i<nbOfTuples;i++)
183 for(int j=0;j<_dim;j++)
184 { oss << _ref_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
189 std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," "));
190 oss << "\n - Gauss coords in reference element : ";
194 int nbOfTuples=sz/_dim;
195 for(int i=0;i<nbOfTuples;i++)
198 for(int j=0;j<_dim;j++)
199 { oss << _gs_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
204 std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," "));
205 oss << "\n - Weights of Gauss coords are : "; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," "));
209 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
211 _type=field->getTypeOfField();
217 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,offset,offset+nbOfCells,1);
218 _end=_start+nbOfCells;
224 MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
225 const int *arrPtr=arr->getConstPointer();
226 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,arrPtr[offset],arrPtr[offset+nbOfCells],1);
227 _end=_start+(arrPtr[offset+nbOfCells]-arrPtr[offset]);
233 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
234 const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
235 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
237 throw INTERP_KERNEL::Exception("assignFieldNoProfile : invalid call to this method ! Internal Error !");
238 const DataArrayInt *dai=disc2->getArrayOfDiscIds();
239 MCAuto<DataArrayInt> dai2=disc2->getOffsetArr(field->getMesh());
240 const int *dai2Ptr=dai2->getConstPointer();
241 int nbi=gsLoc.getWeights().size();
242 MCAuto<DataArrayInt> da2=dai->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1);
243 MCAuto<DataArrayInt> da3=da2->findIdsEqual(_loc_id);
244 const int *da3Ptr=da3->getConstPointer();
245 if(da3->getNumberOfTuples()!=nbOfCells)
246 {//profile : for gauss even in NoProfile !!!
247 std::ostringstream oss; oss << "Pfl_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
249 da3->setName(_profile.c_str());
250 glob.appendProfile(da3);
252 MCAuto<DataArrayInt> da4=DataArrayInt::New();
253 _nval=da3->getNbOfElems();
254 da4->alloc(_nval*nbi,1);
255 int *da4Ptr=da4->getPointer();
256 for(int i=0;i<_nval;i++)
258 int ref=dai2Ptr[offset+da3Ptr[i]];
259 for(int j=0;j<nbi;j++)
262 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
263 _localization=oss2.str();
264 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,da4);
265 _end=_start+_nval*nbi;
266 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
270 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile : not implemented yet for such discretization type of field !");
276 * Leaf method of field with profile assignement. This method is the most general one. No optimization is done here.
277 * \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).
278 * \param [in] multiTypePfl is the end user profile specified in high level API
279 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
280 * \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.
281 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
282 * \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.
284 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)
287 _type=field->getTypeOfField();
288 std::string pflName(multiTypePfl->getName());
289 std::ostringstream oss; oss << pflName;
293 { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType()); oss << "_" << cm.getRepr(); }
300 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : existing profile with empty name !");
301 if(_type!=ON_GAUSS_PT)
303 locIds->setName(oss.str().c_str());
304 glob.appendProfile(locIds);
313 _nval=idsInPfl->getNumberOfTuples();
314 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,0,arrr->getNumberOfTuples(),1);
320 _nval=idsInPfl->getNumberOfTuples();
321 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,idsInPfl);
327 MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
328 MCAuto<DataArrayInt> arr2=arr->deltaShiftIndex();
329 MCAuto<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->begin(),multiTypePfl->end());
330 arr3->computeOffsetsFull();
331 MCAuto<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
332 int trueNval=tmp->getNumberOfTuples();
333 _nval=idsInPfl->getNumberOfTuples();
334 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
335 _end=_start+trueNval;
340 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(field->getDiscretization());
342 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
343 const DataArrayInt *da1=disc2->getArrayOfDiscIds();
344 const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
345 MCAuto<DataArrayInt> da2=da1->selectByTupleId(idsInPfl->begin(),idsInPfl->end());
346 MCAuto<DataArrayInt> da3=da2->findIdsEqual(_loc_id);
347 MCAuto<DataArrayInt> da4=idsInPfl->selectByTupleId(da3->begin(),da3->end());
349 MCAuto<MEDCouplingMesh> mesh2=mesh->buildPart(multiTypePfl->begin(),multiTypePfl->end());
350 MCAuto<DataArrayInt> arr=disc2->getOffsetArr(mesh2);
352 MCAuto<DataArrayInt> tmp=DataArrayInt::New();
354 for(const int *pt=da4->begin();pt!=da4->end();pt++)
355 trueNval+=arr->getIJ(*pt+1,0)-arr->getIJ(*pt,0);
356 tmp->alloc(trueNval,1);
357 int *tmpPtr=tmp->getPointer();
358 for(const int *pt=da4->begin();pt!=da4->end();pt++)
359 for(int j=arr->getIJ(*pt,0);j<arr->getIJ(*pt+1,0);j++)
362 _nval=da4->getNumberOfTuples();
363 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
364 _end=_start+trueNval;
365 oss << "_loc_" << _loc_id;
368 MCAuto<DataArrayInt> da5=locIds->selectByTupleId(da3->begin(),da3->end());
369 da5->setName(oss.str().c_str());
370 glob.appendProfile(da5);
375 if(!da3->isIota(nbOfEltsInWholeMesh))
377 da3->setName(oss.str().c_str());
378 glob.appendProfile(da3);
382 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
383 _localization=oss2.str();
384 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
388 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for such discretization type of field !");
393 void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob)
396 _nval=arrr->getNumberOfTuples();
397 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,0,_nval,1);
402 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt, const PartDefinition *pd)
404 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt,pd);
407 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId)
409 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string());
412 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(const MEDFileFieldPerMeshPerTypePerDisc& other)
414 return new MEDFileFieldPerMeshPerTypePerDisc(other);
417 std::size_t MEDFileFieldPerMeshPerTypePerDisc::getHeapMemorySizeWithoutChildren() const
419 return _profile.capacity()+_localization.capacity()+sizeof(MEDFileFieldPerMeshPerTypePerDisc);
422 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypePerDisc::getDirectChildrenWithNull() const
424 std::vector<const BigMemoryObject *> ret(1);
425 ret[0]=(const PartDefinition*)_pd;
429 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCopy(MEDFileFieldPerMeshPerType *father) const
431 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret=new MEDFileFieldPerMeshPerTypePerDisc(*this);
436 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField atype, int profileIt, const PartDefinition *pd)
437 try:_type(atype),_father(fath),_profile_it(profileIt),_pd(const_cast<PartDefinition *>(pd))
442 catch(INTERP_KERNEL::Exception& e)
447 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
451 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)
455 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(0),_start(-std::numeric_limits<int>::max()),_end(-std::numeric_limits<int>::max()),
456 _nval(-std::numeric_limits<int>::max()),_loc_id(-std::numeric_limits<int>::max())
460 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)
462 const PartDefinition *pd(_pd);
465 INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
467 med_int nbValsInFile(MEDfieldnValueWithProfileByName(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile.c_str(),MED_COMPACT_PFLMODE,&tmp1,locname,&nbi));
468 if(_end-_start!=nbValsInFile*nbi)
470 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 !";
471 throw INTERP_KERNEL::Exception(oss.str().c_str());
473 MEDFILESAFECALLERRD0(MEDfieldValueWithProfileRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,_profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,startFeedingPtr));
477 if(!_profile.empty())
478 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : not implemented !");
479 INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)),locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
481 int overallNval(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
482 const SlicePartDefinition *spd(dynamic_cast<const SlicePartDefinition *>(pd));
486 spd->getSlice(start,stop,step);
487 int nbOfEltsToLoad(DataArray::GetNumberOfItemGivenBES(start,stop,step,"MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile"));
488 med_filter filter=MED_FILTER_INIT;
489 MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
490 MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
491 /*start*/start+1,/*stride*/step,/*count*/1,/*blocksize*/nbOfEltsToLoad,
492 /*lastblocksize=useless because count=1*/0,&filter);
493 MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,startFeedingPtr));
494 MEDfilterClose(&filter);
497 const DataArrayPartDefinition *dpd(dynamic_cast<const DataArrayPartDefinition *>(pd));
500 dpd->checkConsistencyLight();
501 MCAuto<DataArrayInt> myIds(dpd->toDAI());
502 int a(myIds->getMinValueInArray()),b(myIds->getMaxValueInArray());
503 myIds->applyLin(1,-a);
504 int nbOfEltsToLoad(b-a+1);
505 med_filter filter=MED_FILTER_INIT;
506 {//TODO : manage int32 !
507 MCAuto<DataArrayDouble> tmp(DataArrayDouble::New());
508 tmp->alloc(nbOfEltsToLoad,nbOfCompo);
509 MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
510 MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
511 /*start*/a+1,/*stride*/1,/*count*/1,/*blocksize*/nbOfEltsToLoad,
512 /*lastblocksize=useless because count=1*/0,&filter);
513 MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,reinterpret_cast<unsigned char *>(tmp->getPointer())));
514 MCAuto<DataArrayDouble> feeder(DataArrayDouble::New());
515 feeder->useExternalArrayWithRWAccess(reinterpret_cast<double *>(startFeedingPtr),_nval,nbOfCompo);
516 feeder->setContigPartOfSelectedValues(0,tmp,myIds);
518 MEDfilterClose(&filter);
521 throw INTERP_KERNEL::Exception("Not implemented yet for not slices!");
525 const MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
530 void MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
532 INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
533 INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
534 std::string fieldName(nasc.getName()),meshName(getMeshName());
535 int iteration(getIteration()),order(getOrder());
536 TypeOfField type(getType());
537 INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
539 med_geometry_type mgeoti;
540 med_entity_type menti(MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti));
541 int zeNVal(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
542 _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
543 _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
544 const PartDefinition *pd(_pd);
551 if(!_profile.empty())
552 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively : profiles are not managed yet with part of def !");
553 _nval=pd->getNumberOfElems();
556 _end=start+_nval*nbi;
558 if(type==ON_CELLS && !_localization.empty())
560 if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
561 setType(ON_GAUSS_PT);
564 setType(ON_GAUSS_NE);
565 _localization.clear();
570 void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, const MEDFileFieldNameScope& nasc)
572 std::string fieldName(nasc.getName()),meshName(getMeshName());
573 int iteration(getIteration()),order(getOrder());
574 TypeOfField type(getType());
575 INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
576 med_geometry_type mgeoti;
577 med_entity_type menti(MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti));
579 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !");
582 DataArray *arr(getOrCreateAndGetArray());//arr is not null due to the spec of getOrCreateAndGetArray
583 if(_start<0 || _start>=arr->getNumberOfTuples())
585 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << ") !";
586 throw INTERP_KERNEL::Exception(oss.str().c_str());
588 if(_end<0 || _end>arr->getNumberOfTuples())
590 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !";
591 throw INTERP_KERNEL::Exception(oss.str().c_str());
593 int nbOfCompo(arr->getNumberOfComponents());
594 DataArrayDouble *arrD(dynamic_cast<DataArrayDouble *>(arr));
597 double *startFeeding(arrD->getPointer()+_start*nbOfCompo);
598 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
601 DataArrayInt *arrI(dynamic_cast<DataArrayInt *>(arr));
604 int *startFeeding(arrI->getPointer()+_start*nbOfCompo);
605 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
608 throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
612 * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
614 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart)
616 int delta=_end-_start;
617 _start=newValueOfStart;
621 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
623 return _father->getIteration();
626 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
628 return _father->getOrder();
631 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
633 return _father->getTime();
636 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
638 return _father->getMeshName();
641 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
643 const char startLine[]=" ## ";
644 std::string startLine2(bkOffset,' ');
645 startLine2+=startLine;
646 MEDCouplingFieldDiscretization *tmp=MEDCouplingFieldDiscretization::New(_type);
647 oss << startLine2 << "Localization #" << id << "." << std::endl;
648 oss << startLine2 << " Type=" << tmp->getRepr() << "." << std::endl;
650 oss << startLine2 << " This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
651 oss << startLine2 << " This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
652 oss << startLine2 << " This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
655 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
660 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
665 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
670 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
672 return _father->getGeoType();
675 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
677 return _father->getNumberOfComponents();
680 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
685 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray()
687 return _father->getOrCreateAndGetArray();
690 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const
692 const MEDFileFieldPerMeshPerType *fath=_father;
693 return fath->getOrCreateAndGetArray();
696 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
698 return _father->getInfo();
701 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
706 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const std::string& newPflName)
711 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
713 return _localization;
716 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const std::string& newLocName)
718 _localization=newLocName;
721 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
723 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
725 if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
727 _profile=(*it2).second;
733 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
735 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
737 if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
739 _localization=(*it2).second;
745 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
749 dads.push_back(std::pair<int,int>(_start,_end));
750 geoTypes.push_back(getGeoType());
755 pfls.push_back(glob->getProfile(_profile.c_str()));
757 if(_localization.empty())
761 locs.push_back(glob->getLocalizationId(_localization.c_str()));
765 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
767 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));
771 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
773 TypeOfField type=getType();
774 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
775 med_geometry_type mgeoti;
776 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
777 const DataArray *arr=getOrCreateAndGetArray();
779 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
780 const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
781 const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
782 const unsigned char *locToWrite=0;
784 locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
786 locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
788 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
789 MEDFILESAFECALLERWR0(MEDfieldValueWithProfileWr,(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
790 MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
794 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const
799 dad.first=_start; dad.second=_end;
803 * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
804 * This code corresponds to the distribution of types in the corresponding mesh.
805 * \param [out] ptToFill memory zone where the output will be stored.
806 * \return the size of data pushed into output param \a ptToFill
808 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const
811 std::ostringstream oss;
812 std::size_t nbOfType=codeOfMesh.size()/3;
814 for(std::size_t i=0;i<nbOfType && found==-1;i++)
815 if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
819 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
820 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
821 throw INTERP_KERNEL::Exception(oss.str().c_str());
826 if(_nval!=codeOfMesh[3*found+1])
828 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
829 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
830 oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
831 throw INTERP_KERNEL::Exception(oss.str().c_str());
833 for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
838 const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
839 if(pfl->getNumberOfTuples()!=_nval)
841 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
842 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
844 oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
845 throw INTERP_KERNEL::Exception(oss.str().c_str());
847 int offset2=codeOfMesh[3*found+2];
848 for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
850 if(*pflId<codeOfMesh[3*found+1])
851 *work++=offset2+*pflId;
857 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const
859 for(int i=_start;i<_end;i++)
864 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId)
875 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
879 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
882 std::map<std::pair<std::string,TypeOfField>,int> m;
883 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
884 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
885 if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
886 m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
888 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
889 ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
894 * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
896 * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
897 * \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.
898 * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
899 * \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)
900 * \param [in,out] glob if necessary by the method, new profiles can be added to it
901 * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
902 * \param [out] result All new entries will be appended on it.
903 * \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 !)
905 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
906 const DataArrayInt *explicitIdsInMesh,
907 const std::vector<int>& newCode,
908 MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
909 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >& result)
911 if(entriesOnSameDisc.empty())
913 TypeOfField type=entriesOnSameDisc[0]->getType();
914 int szEntities=0,szTuples=0;
915 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
916 { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
917 int nbi=szTuples/szEntities;
918 if(szTuples%szEntities!=0)
919 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
920 MCAuto<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
921 MCAuto<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
922 std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
923 std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
924 std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
925 std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
926 MCAuto<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
928 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
930 int startOfEltIdOfChunk=(*it)->_start;
931 MCAuto<DataArrayInt> newEltIds=explicitIdsInMesh->subArray(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
932 MCAuto<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
933 MCAuto<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
935 MCAuto<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
936 newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
938 newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
939 newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
941 MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
942 MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
943 MCAuto<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
944 MCAuto<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
946 MCAuto<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
948 MCAuto<DataArrayDouble> arrPart=arr->subArray(offset,offset+szTuples);
949 arrPart->renumberInPlace(renumTupleIds->begin());
950 arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
952 const int *idIt=diffVals->begin();
953 std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
955 for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
957 MCAuto<DataArrayInt> ids=newGeoTypesEltIdsAllGather->findIdsEqual(*idIt);
958 MCAuto<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
959 int nbEntityElts=subIds->getNumberOfTuples();
961 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
962 NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIota(newCode[3*(*idIt)+1]),nbi,
966 result.push_back(eltToAdd);
967 offset2+=nbEntityElts*nbi;
969 ret=ret || li.empty();
974 * \param [in] typeF type of field of new chunk
975 * \param [in] geoType the geometric type of the chunk
976 * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
977 * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
978 * \param [in] nbi number of integration points
979 * \param [in] offset The offset in the **global array of data**.
980 * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
981 * to the new chunk to create.
982 * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
983 * \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
984 * and corresponding entry erased from \a entriesOnSameDisc.
985 * \return a newly allocated chunk
987 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
988 bool isPfl, int nbi, int offset,
989 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
990 MEDFileFieldGlobsReal& glob,
993 int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
994 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
995 for(;it!=entriesOnSameDisc.end();it++)
997 if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
1001 if((*it)->_profile.empty())
1004 if(!(*it)->_profile.empty())
1006 const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
1007 if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
1013 if(it==entriesOnSameDisc.end())
1016 MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
1018 ret->_loc_id=(int)geoType;
1019 ret->_nval=nbMeshEntities;
1021 ret->_end=ret->_start+ret->_nval*nbi;
1024 idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
1025 glob.appendProfile(idsOfMeshElt);
1026 ret->_profile=idsOfMeshElt->getName();
1028 //tony treatment of localization
1033 notInExisting=false;
1034 MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1035 ret->_loc_id=(int)geoType;
1036 ret->setNewStart(offset);
1037 entriesOnSameDisc.erase(it);
1043 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd)
1045 return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc,pd);
1048 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType)
1050 return new MEDFileFieldPerMeshPerType(fath,geoType);
1053 std::size_t MEDFileFieldPerMeshPerType::getHeapMemorySizeWithoutChildren() const
1055 return _field_pm_pt_pd.capacity()*sizeof(MCAuto<MEDFileFieldPerMeshPerTypePerDisc>);
1058 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerType::getDirectChildrenWithNull() const
1060 std::vector<const BigMemoryObject *> ret;
1061 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1062 ret.push_back((const MEDFileFieldPerMeshPerTypePerDisc *)*it);
1066 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCopy(MEDFileFieldPerMesh *father) const
1068 MCAuto<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
1069 ret->_father=father;
1071 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1073 if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
1074 ret->_field_pm_pt_pd[i]=(*it)->deepCopy((MEDFileFieldPerMeshPerType *)ret);
1079 void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1081 std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
1082 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1083 _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1087 * This method is the most general one. No optimization is done here.
1088 * \param [in] multiTypePfl is the end user profile specified in high level API
1089 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1090 * \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.
1091 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1092 * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1093 * \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.
1095 void MEDFileFieldPerMeshPerType::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)
1097 std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1098 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1099 _field_pm_pt_pd[*it]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1102 void MEDFileFieldPerMeshPerType::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1104 _field_pm_pt_pd.resize(1);
1105 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1106 _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1109 void MEDFileFieldPerMeshPerType::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1111 MCAuto<DataArrayInt> pfl2=pfl->deepCopy();
1112 if(!arr || !arr->isAllocated())
1113 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::assignNodeFieldProfile : input array is null, or not allocated !");
1114 _field_pm_pt_pd.resize(1);
1115 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1116 _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.
1119 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1121 TypeOfField type=field->getTypeOfField();
1122 if(type!=ON_GAUSS_PT)
1124 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1125 int sz=_field_pm_pt_pd.size();
1127 for(int j=0;j<sz && !found;j++)
1129 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1131 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1137 _field_pm_pt_pd.resize(sz+1);
1138 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1140 std::vector<int> ret(1,(int)sz);
1145 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1146 int sz2=ret2.size();
1147 std::vector<int> ret3(sz2);
1149 for(int i=0;i<sz2;i++)
1151 int sz=_field_pm_pt_pd.size();
1152 int locIdToFind=ret2[i];
1154 for(int j=0;j<sz && !found;j++)
1156 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1158 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1165 _field_pm_pt_pd.resize(sz+1);
1166 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1174 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1176 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1177 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1179 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1180 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1182 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1183 MCAuto<DataArrayInt> da2=da->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1);
1184 MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1185 if(retTmp->presenceOfValue(-1))
1186 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1187 std::vector<int> ret(retTmp->begin(),retTmp->end());
1191 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1193 TypeOfField type=field->getTypeOfField();
1194 if(type!=ON_GAUSS_PT)
1196 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1197 int sz=_field_pm_pt_pd.size();
1199 for(int j=0;j<sz && !found;j++)
1201 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1203 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1209 _field_pm_pt_pd.resize(sz+1);
1210 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1212 std::vector<int> ret(1,0);
1217 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1218 int sz2=ret2.size();
1219 std::vector<int> ret3(sz2);
1221 for(int i=0;i<sz2;i++)
1223 int sz=_field_pm_pt_pd.size();
1224 int locIdToFind=ret2[i];
1226 for(int j=0;j<sz && !found;j++)
1228 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1230 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1237 _field_pm_pt_pd.resize(sz+1);
1238 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1246 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1248 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1249 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1251 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1252 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1254 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1255 MCAuto<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1256 MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1257 if(retTmp->presenceOfValue(-1))
1258 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1259 std::vector<int> ret(retTmp->begin(),retTmp->end());
1263 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerType::getFather() const
1268 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1270 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1271 int curDim=(int)cm.getDimension();
1272 dim=std::max(dim,curDim);
1275 void MEDFileFieldPerMeshPerType::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1277 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1279 (*it)->fillTypesOfFieldAvailable(types);
1283 void MEDFileFieldPerMeshPerType::fillFieldSplitedByType(std::vector< std::pair<int,int> >& dads, std::vector<TypeOfField>& types, std::vector<std::string>& pfls, std::vector<std::string>& locs) const
1285 int sz=_field_pm_pt_pd.size();
1286 dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1287 for(int i=0;i<sz;i++)
1289 _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1293 int MEDFileFieldPerMeshPerType::getIteration() const
1295 return _father->getIteration();
1298 int MEDFileFieldPerMeshPerType::getOrder() const
1300 return _father->getOrder();
1303 double MEDFileFieldPerMeshPerType::getTime() const
1305 return _father->getTime();
1308 std::string MEDFileFieldPerMeshPerType::getMeshName() const
1310 return _father->getMeshName();
1313 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1315 const char startLine[]=" ## ";
1316 std::string startLine2(bkOffset,' ');
1317 std::string startLine3(startLine2);
1318 startLine3+=startLine;
1319 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1321 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1322 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1325 oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1326 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1328 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1330 const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1332 cur->simpleRepr(bkOffset,oss,i);
1335 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1340 void MEDFileFieldPerMeshPerType::getSizes(int& globalSz, int& nbOfEntries) const
1342 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1344 globalSz+=(*it)->getNumberOfTuples();
1346 nbOfEntries+=(int)_field_pm_pt_pd.size();
1349 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1355 int MEDFileFieldPerMeshPerType::getNumberOfComponents() const
1357 return _father->getNumberOfComponents();
1360 bool MEDFileFieldPerMeshPerType::presenceOfMultiDiscPerGeoType() const
1363 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1365 const MEDFileFieldPerMeshPerTypePerDisc *fmtd(*it);
1372 DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray()
1374 return _father->getOrCreateAndGetArray();
1377 const DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray() const
1379 const MEDFileFieldPerMesh *fath=_father;
1380 return fath->getOrCreateAndGetArray();
1383 const std::vector<std::string>& MEDFileFieldPerMeshPerType::getInfo() const
1385 return _father->getInfo();
1388 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsed() const
1390 std::vector<std::string> ret;
1391 std::set<std::string> ret2;
1392 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1394 std::string tmp=(*it1)->getProfile();
1396 if(ret2.find(tmp)==ret2.end())
1405 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsed() const
1407 std::vector<std::string> ret;
1408 std::set<std::string> ret2;
1409 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1411 std::string tmp=(*it1)->getLocalization();
1412 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1413 if(ret2.find(tmp)==ret2.end())
1422 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsedMulti() const
1424 std::vector<std::string> ret;
1425 std::set<std::string> ret2;
1426 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1428 std::string tmp=(*it1)->getProfile();
1435 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsedMulti() const
1437 std::vector<std::string> ret;
1438 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1440 std::string tmp=(*it1)->getLocalization();
1441 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1447 void MEDFileFieldPerMeshPerType::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1449 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1450 (*it1)->changePflsRefsNamesGen(mapOfModif);
1453 void MEDFileFieldPerMeshPerType::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1455 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1456 (*it1)->changeLocsRefsNamesGen(mapOfModif);
1459 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId)
1461 if(_field_pm_pt_pd.empty())
1463 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1464 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1465 throw INTERP_KERNEL::Exception(oss.str().c_str());
1467 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1468 return _field_pm_pt_pd[locId];
1469 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1470 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1471 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1472 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1473 return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1476 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) const
1478 if(_field_pm_pt_pd.empty())
1480 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1481 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1482 throw INTERP_KERNEL::Exception(oss.str().c_str());
1484 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1485 return _field_pm_pt_pd[locId];
1486 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1487 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1488 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1489 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1490 return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1493 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
1495 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1497 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1498 if(meshDim!=(int)cm.getDimension())
1501 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1502 (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1505 void MEDFileFieldPerMeshPerType::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1508 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1510 (*it)->fillValues(i,startEntryId,entries);
1514 void MEDFileFieldPerMeshPerType::setLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
1516 _field_pm_pt_pd=leaves;
1517 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1518 (*it)->setFather(this);
1522 * \param [in,out] globalNum a global numbering counter for the renumbering.
1523 * \param [out] its - list of pair (start,stop) kept
1524 * \return bool - false if the type of field \a tof is not contained in \a this.
1526 bool MEDFileFieldPerMeshPerType::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
1529 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1530 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1531 if((*it)->getType()==tof)
1533 newPmPtPd.push_back(*it);
1534 std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1535 (*it)->setNewStart(globalNum);
1536 globalNum=(*it)->getEnd();
1537 its.push_back(bgEnd);
1541 _field_pm_pt_pd=newPmPtPd;
1546 * \param [in,out] globalNum a global numbering counter for the renumbering.
1547 * \param [out] its - list of pair (start,stop) kept
1548 * \return bool - false if the type of field \a tof is not contained in \a this.
1550 bool MEDFileFieldPerMeshPerType::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
1552 if(_field_pm_pt_pd.size()<=idOfDisc)
1554 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt(_field_pm_pt_pd[idOfDisc]);
1555 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd(1,elt);
1556 std::pair<int,int> bgEnd; bgEnd.first=_field_pm_pt_pd[idOfDisc]->getStart(); bgEnd.second=_field_pm_pt_pd[idOfDisc]->getEnd();
1557 elt->setNewStart(globalNum);
1558 globalNum=elt->getEnd();
1559 its.push_back(bgEnd);
1560 _field_pm_pt_pd=newPmPtPd;
1564 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType):_father(fath),_geo_type(geoType)
1568 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):_father(fath),_geo_type(geoType)
1570 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1571 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1572 med_geometry_type mgeoti;
1573 med_entity_type menti(ConvertIntoMEDFileType(type,geoType,mgeoti));
1574 int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName));
1575 _field_pm_pt_pd.resize(nbProfiles);
1576 for(int i=0;i<nbProfiles;i++)
1578 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i,pd);
1582 int nbProfiles2(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName));
1583 for(int i=0;i<nbProfiles2;i++)
1584 _field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i,pd));
1588 void MEDFileFieldPerMeshPerType::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
1590 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1591 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1594 void MEDFileFieldPerMeshPerType::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1596 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1597 (*it)->loadBigArray(fid,nasc);
1600 void MEDFileFieldPerMeshPerType::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1602 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1604 (*it)->copyOptionsFrom(*this);
1605 (*it)->writeLL(fid,nasc);
1609 med_entity_type MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1614 medfGeoType=typmai3[(int)ikGeoType];
1617 medfGeoType=MED_NONE;
1620 medfGeoType=typmai3[(int)ikGeoType];
1621 return MED_NODE_ELEMENT;
1623 medfGeoType=typmai3[(int)ikGeoType];
1626 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1628 return MED_UNDEF_ENTITY_TYPE;
1631 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
1633 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm,entities);
1636 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1638 return new MEDFileFieldPerMesh(fath,mesh);
1641 std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
1643 return _mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MCAuto< MEDFileFieldPerMeshPerType >);
1646 std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildrenWithNull() const
1648 std::vector<const BigMemoryObject *> ret;
1649 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1650 ret.push_back((const MEDFileFieldPerMeshPerType *)*it);
1654 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCopy(MEDFileAnyTypeField1TSWithoutSDA *father) const
1656 MCAuto< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1657 ret->_father=father;
1659 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1661 if((const MEDFileFieldPerMeshPerType *)*it)
1662 ret->_field_pm_pt[i]=(*it)->deepCopy((MEDFileFieldPerMesh *)(ret));
1667 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1669 std::string startLine(bkOffset,' ');
1670 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1671 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1673 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1675 const MEDFileFieldPerMeshPerType *cur=*it;
1677 cur->simpleRepr(bkOffset,oss,i);
1680 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1685 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh)
1687 _mesh_name=mesh->getName();
1688 mesh->getTime(_mesh_iteration,_mesh_order);
1691 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1693 int nbOfTypes=code.size()/3;
1695 for(int i=0;i<nbOfTypes;i++)
1697 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1698 int nbOfCells=code[3*i+1];
1699 int pos=addNewEntryIfNecessary(type);
1700 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1706 * This method is the most general one. No optimization is done here.
1707 * \param [in] multiTypePfl is the end user profile specified in high level API
1708 * \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].
1709 * \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.
1710 * \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.
1711 * \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.
1712 * \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.
1714 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)
1716 int nbOfTypes(code.size()/3);
1717 for(int i=0;i<nbOfTypes;i++)
1719 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1720 int pos=addNewEntryIfNecessary(type);
1721 DataArrayInt *pfl=0;
1723 pfl=idsPerType[code[3*i+2]];
1724 int nbOfTupes2=code2.size()/3;
1726 for(;found<nbOfTupes2;found++)
1727 if(code[3*i]==code2[3*found])
1729 if(found==nbOfTupes2)
1730 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1731 _field_pm_pt[pos]->assignFieldProfile(nbOfTypes==1,start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1735 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1737 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1738 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1741 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1743 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1744 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1747 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
1749 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1750 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1753 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1755 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1756 (*it)->loadBigArraysRecursively(fid,nasc);
1759 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1761 int nbOfTypes=_field_pm_pt.size();
1762 for(int i=0;i<nbOfTypes;i++)
1764 _field_pm_pt[i]->copyOptionsFrom(*this);
1765 _field_pm_pt[i]->writeLL(fid,nasc);
1769 void MEDFileFieldPerMesh::getDimension(int& dim) const
1771 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1772 (*it)->getDimension(dim);
1775 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1777 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1778 (*it)->fillTypesOfFieldAvailable(types);
1781 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
1783 int sz=_field_pm_pt.size();
1784 std::vector< std::vector<std::pair<int,int> > > ret(sz);
1785 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1786 for(int i=0;i<sz;i++)
1788 types[i]=_field_pm_pt[i]->getGeoType();
1789 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1794 double MEDFileFieldPerMesh::getTime() const
1797 return _father->getTime(tmp1,tmp2);
1800 int MEDFileFieldPerMesh::getIteration() const
1802 return _father->getIteration();
1805 int MEDFileFieldPerMesh::getOrder() const
1807 return _father->getOrder();
1810 int MEDFileFieldPerMesh::getNumberOfComponents() const
1812 return _father->getNumberOfComponents();
1815 bool MEDFileFieldPerMesh::presenceOfMultiDiscPerGeoType() const
1817 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1819 const MEDFileFieldPerMeshPerType *fpmt(*it);
1822 if(fpmt->presenceOfMultiDiscPerGeoType())
1828 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
1831 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1832 return _father->getOrCreateAndGetArray();
1835 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
1838 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1839 return _father->getOrCreateAndGetArray();
1842 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1844 return _father->getInfo();
1848 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
1849 * 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.
1850 * It returns 2 output vectors :
1851 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
1852 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
1853 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
1855 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)
1857 int notNullPflsSz=0;
1858 int nbOfArrs=geoTypes.size();
1859 for(int i=0;i<nbOfArrs;i++)
1862 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
1863 int nbOfDiffGeoTypes=geoTypes3.size();
1864 code.resize(3*nbOfDiffGeoTypes);
1865 notNullPfls.resize(notNullPflsSz);
1868 for(int i=0;i<nbOfDiffGeoTypes;i++)
1871 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
1872 std::vector<const DataArrayInt *> notNullTmp;
1874 notNullTmp.push_back(pfls[j]);
1876 for(;j<nbOfArrs;j++)
1877 if(geoTypes[j]==refType)
1880 notNullTmp.push_back(pfls[j]);
1884 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
1885 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
1886 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
1887 code[3*i]=(int)refType;
1888 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
1889 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
1890 if(notNullTmp.empty())
1894 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
1895 code[3*i+2]=notNullPflsSz++;
1901 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
1903 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)
1907 for(int i=0;i<sz;i++)
1911 if(type!=ON_GAUSS_NE)
1912 ret+=dads[i].second-dads[i].first;
1915 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
1916 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
1921 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
1922 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
1928 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
1930 std::vector<std::string> ret;
1931 std::set<std::string> ret2;
1932 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1934 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
1935 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1936 if(ret2.find(*it2)==ret2.end())
1938 ret.push_back(*it2);
1945 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
1947 std::vector<std::string> ret;
1948 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1950 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
1951 ret.insert(ret.end(),tmp.begin(),tmp.end());
1956 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
1958 std::vector<std::string> ret;
1959 std::set<std::string> ret2;
1960 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1962 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
1963 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1964 if(ret2.find(*it2)==ret2.end())
1966 ret.push_back(*it2);
1973 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
1975 std::vector<std::string> ret;
1976 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1978 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
1979 ret.insert(ret.end(),tmp.begin(),tmp.end());
1984 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
1986 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
1988 if((*it).first==_mesh_name)
1990 _mesh_name=(*it).second;
1997 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
1998 MEDFileFieldGlobsReal& glob)
2000 if(_mesh_name!=meshName)
2002 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
2003 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
2004 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
2005 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
2006 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
2007 getUndergroundDataArrayExt(entries);
2008 DataArray *arr0=getOrCreateAndGetArray();//tony
2010 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
2011 DataArrayDouble *arr=dynamic_cast<DataArrayDouble *>(arr0);//tony
2013 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
2016 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
2017 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
2019 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
2021 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2022 sz+=(*it).second.second-(*it).second.first;
2025 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2027 MCAuto<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
2028 ////////////////////
2029 MCAuto<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
2030 int *workI2=explicitIdsOldInMesh->getPointer();
2031 int sz1=0,sz2=0,sid=1;
2032 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
2033 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
2034 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
2036 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
2037 MCAuto<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
2038 int *workI=explicitIdsOldInArr->getPointer();
2039 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
2041 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
2042 (*itL2)->setLocId(sz2);
2043 (*itL2)->_tmp_work1=(*itL2)->getStart();
2044 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
2046 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
2048 explicitIdsOldInMesh->reAlloc(sz2);
2049 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
2050 ////////////////////
2051 MCAuto<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
2052 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
2053 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
2054 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
2056 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
2057 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
2058 otherEntriesNew.back()->setLocId((*it)->getGeoType());
2060 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
2061 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
2062 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
2064 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
2065 int newStart=elt->getLocId();
2066 elt->setLocId((*it)->getGeoType());
2067 elt->setNewStart(newStart);
2068 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
2069 entriesKeptNew.push_back(elt);
2070 entriesKeptNew2.push_back(elt);
2072 MCAuto<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
2073 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
2074 MCAuto<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
2075 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
2077 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
2080 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
2082 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
2083 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
2085 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
2086 glob,arr2,otherEntriesNew) || ret;
2090 // Assign new dispatching
2091 assignNewLeaves(otherEntriesNew);
2092 arr->deepCopyFrom(*arr2);
2097 * \param [in,out] globalNum a global numbering counter for the renumbering.
2098 * \param [out] its - list of pair (start,stop) kept
2100 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
2102 std::vector< MCAuto< MEDFileFieldPerMeshPerType > > ret;
2103 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2105 std::vector< std::pair<int,int> > its2;
2106 if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
2109 its.insert(its.end(),its2.begin(),its2.end());
2116 * \param [in,out] globalNum a global numbering counter for the renumbering.
2117 * \param [out] its - list of pair (start,stop) kept
2119 void MEDFileFieldPerMesh::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
2121 std::vector< MCAuto< MEDFileFieldPerMeshPerType > > ret;
2122 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2124 std::vector< std::pair<int,int> > its2;
2125 if((*it)->keepOnlyGaussDiscretization(idOfDisc,globalNum,its2))
2128 its.insert(its.end(),its2.begin(),its2.end());
2134 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
2136 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > > types;
2137 for( std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
2138 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
2140 std::vector< MCAuto< MEDFileFieldPerMeshPerType > > fieldPmPt(types.size());
2141 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
2142 std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it2=fieldPmPt.begin();
2143 for(;it1!=types.end();it1++,it2++)
2145 MCAuto<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
2146 elt->setLeaves((*it1).second);
2149 _field_pm_pt=fieldPmPt;
2152 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2154 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2155 (*it)->changePflsRefsNamesGen(mapOfModif);
2158 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2160 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2161 (*it)->changeLocsRefsNamesGen(mapOfModif);
2165 * \param [in] mesh is the whole mesh
2167 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2169 if(_field_pm_pt.empty())
2170 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2172 std::vector< std::pair<int,int> > dads;
2173 std::vector<const DataArrayInt *> pfls;
2174 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2175 std::vector<int> locs,code;
2176 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2177 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2178 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2180 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2183 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2184 throw INTERP_KERNEL::Exception(oss.str().c_str());
2187 std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2188 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2191 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2193 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2196 MCAuto<DataArrayInt> arr2(arr);
2197 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2203 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2207 if(nb!=mesh->getNumberOfNodes())
2209 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2210 oss << " nodes in mesh !";
2211 throw INTERP_KERNEL::Exception(oss.str().c_str());
2213 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2216 return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2220 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
2222 if(_field_pm_pt.empty())
2223 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2225 std::vector<std::pair<int,int> > dads;
2226 std::vector<const DataArrayInt *> pfls;
2227 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2228 std::vector<int> locs,code;
2229 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2230 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2231 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2233 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2236 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2237 throw INTERP_KERNEL::Exception(oss.str().c_str());
2239 std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2240 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2243 MCAuto<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2244 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2249 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2253 if(nb!=mesh->getNumberOfNodes())
2255 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2256 oss << " nodes in mesh !";
2257 throw INTERP_KERNEL::Exception(oss.str().c_str());
2260 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2266 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
2270 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2272 (*it)->getSizes(globalSz,nbOfEntries);
2274 entries.resize(nbOfEntries);
2276 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2278 (*it)->fillValues(nbOfEntries,entries);
2282 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
2284 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2286 if((*it)->getGeoType()==typ)
2287 return (*it)->getLeafGivenLocId(locId);
2289 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2290 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2291 oss << "Possiblities are : ";
2292 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2294 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2295 oss << "\"" << cm2.getRepr() << "\", ";
2297 throw INTERP_KERNEL::Exception(oss.str().c_str());
2300 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
2302 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2304 if((*it)->getGeoType()==typ)
2305 return (*it)->getLeafGivenLocId(locId);
2307 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2308 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2309 oss << "Possiblities are : ";
2310 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2312 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2313 oss << "\"" << cm2.getRepr() << "\", ";
2315 throw INTERP_KERNEL::Exception(oss.str().c_str());
2318 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2321 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2322 std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it2=_field_pm_pt.begin();
2323 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2325 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2330 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2335 int ret=std::distance(_field_pm_pt.begin(),it2);
2336 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2341 * 'dads' and 'locs' input parameters have the same number of elements
2342 * \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
2344 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2345 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2346 const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2349 MCAuto<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2350 ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2351 MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2352 const std::vector<std::string>& infos=getInfo();
2353 da->setInfoOnComponents(infos);
2355 if(type==ON_GAUSS_PT)
2358 int nbOfArrs=dads.size();
2359 for(int i=0;i<nbOfArrs;i++)
2361 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2362 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2363 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2364 MCAuto<DataArrayInt> di=DataArrayInt::New();
2365 di->alloc(nbOfElems,1);
2367 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2368 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2377 * 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.
2378 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2379 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2380 * The order of cells in the returned field is those imposed by the profile.
2381 * \param [in] mesh is the global mesh.
2383 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2384 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2385 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2386 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2388 if(da->isIota(mesh->getNumberOfCells()))
2389 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2390 MCAuto<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2391 m2->setName(mesh->getName().c_str());
2392 MCAuto<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2398 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2400 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2401 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2402 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2404 if(da->isIota(mesh->getNumberOfNodes()))
2405 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2406 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2407 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2410 if(meshu->getNodalConnectivity()==0)
2412 MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2413 int nb=da->getNbOfElems();
2414 const int *ptr=da->getConstPointer();
2415 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2416 meshuc->allocateCells(nb);
2417 for(int i=0;i<nb;i++)
2418 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2419 meshuc->finishInsertingCells();
2420 ret->setMesh(meshuc);
2421 const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2422 if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2423 disc->checkCoherencyBetween(meshuc,arrOut);
2428 MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2430 DataArrayInt *arr2=0;
2431 MCAuto<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2432 MCAuto<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2433 MCAuto<DataArrayInt> arr3(arr2);
2434 int nnodes=mesh2->getNumberOfNodes();
2435 if(nnodes==(int)da->getNbOfElems())
2437 MCAuto<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2438 arrOut->renumberInPlace(da3->getConstPointer());
2439 mesh2->setName(mesh->getName().c_str());
2440 ret->setMesh(mesh2);
2445 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 !!!";
2446 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2447 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2448 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2449 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2450 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2451 throw INTERP_KERNEL::Exception(oss.str().c_str());
2457 * This method is the most light method of field retrieving.
2459 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
2463 pflOut=DataArrayInt::New();
2464 pflOut->alloc(nbOfElems,1);
2469 pflOut=const_cast<DataArrayInt*>(pflIn);
2472 MCAuto<DataArrayInt> safePfl(pflOut);
2473 MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2474 const std::vector<std::string>& infos=getInfo();
2475 int nbOfComp=infos.size();
2476 for(int i=0;i<nbOfComp;i++)
2477 da->setInfoOnComponent(i,infos[i].c_str());
2488 static MFFPMIter *NewCell(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities);
2489 static bool IsPresenceOfNode(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities);
2490 virtual ~MFFPMIter() { }
2491 virtual void begin() = 0;
2492 virtual bool finished() const = 0;
2493 virtual void next() = 0;
2494 virtual int current() const = 0;
2497 class MFFPMIterSimple : public MFFPMIter
2500 MFFPMIterSimple():_pos(0) { }
2501 void begin() { _pos=0; }
2502 bool finished() const { return _pos>=MED_N_CELL_FIXED_GEO; }
2503 void next() { _pos++; }
2504 int current() const { return _pos; }
2509 class MFFPMIter2 : public MFFPMIter
2512 MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts);
2513 void begin() { _it=_ids.begin(); }
2514 bool finished() const { return _it==_ids.end(); }
2515 void next() { _it++; }
2516 int current() const { return *_it; }
2518 std::vector<int> _ids;
2519 std::vector<int>::const_iterator _it;
2522 MFFPMIter *MFFPMIter::NewCell(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
2525 return new MFFPMIterSimple;
2528 std::vector<INTERP_KERNEL::NormalizedCellType> tmp;
2529 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=(*entities).begin();it!=(*entities).end();it++)
2531 if((*it).first==ON_CELLS || (*it).first==ON_GAUSS_NE || (*it).first==ON_GAUSS_PT)
2532 tmp.push_back((*it).second);
2534 return new MFFPMIter2(tmp);
2538 bool MFFPMIter::IsPresenceOfNode(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
2544 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=(*entities).begin();it!=(*entities).end();it++)
2545 if((*it).first==ON_NODES)
2551 MFFPMIter2::MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts)
2553 std::size_t sz(cts.size());
2555 for(std::size_t i=0;i<sz;i++)
2557 INTERP_KERNEL::NormalizedCellType *loc(std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,cts[i]));
2558 if(loc!=typmai2+MED_N_CELL_FIXED_GEO)
2559 _ids[i]=(int)std::distance(typmai2,loc);
2561 throw INTERP_KERNEL::Exception("MFFPMIter2 : The specified geo type does not exists !");
2567 MEDFileFieldPerMesh::MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities):_mesh_iteration(meshIteration),_mesh_order(meshOrder),
2570 INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2571 INTERP_KERNEL::AutoPtr<char> pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2572 INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2573 const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
2574 INTERP_KERNEL::AutoCppPtr<MFFPMIter> iter0(MFFPMIter::NewCell(entities));
2575 for(iter0->begin();!iter0->finished();iter0->next())
2577 int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL ,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2578 std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2579 int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2580 std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2581 if(nbProfile>0 || nbProfile2>0)
2583 const PartDefinition *pd(0);
2585 pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[iter0->current()]),typmai2[iter0->current()]);
2586 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nasc,pd));
2593 if(MFFPMIter::IsPresenceOfNode(entities))
2595 int nbProfile(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName));
2598 const PartDefinition *pd(0);
2600 pd=mmu->getPartDefAtLevel(1,INTERP_KERNEL::NORM_ERROR);
2601 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd));
2602 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2607 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2609 copyTinyInfoFrom(mesh);
2612 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
2614 if(id>=(int)_pfls.size())
2616 _pfls[id]=DataArrayInt::New();
2617 int lgth(MEDprofileSizeByName(fid,pflName.c_str()));
2618 _pfls[id]->setName(pflName);
2619 _pfls[id]->alloc(lgth,1);
2620 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName.c_str(),_pfls[id]->getPointer()));
2621 _pfls[id]->applyLin(1,-1,0);//Converting into C format
2624 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2626 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2628 MEDFILESAFECALLERRD0(MEDprofileInfo,(fid,i+1,pflName,&sz));
2629 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2630 if(i>=(int)_pfls.size())
2632 _pfls[i]=DataArrayInt::New();
2633 _pfls[i]->alloc(sz,1);
2634 _pfls[i]->setName(pflCpp.c_str());
2635 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName,_pfls[i]->getPointer()));
2636 _pfls[i]->applyLin(1,-1,0);//Converting into C format
2639 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
2641 int nbOfPfls=_pfls.size();
2642 for(int i=0;i<nbOfPfls;i++)
2644 MCAuto<DataArrayInt> cpy=_pfls[i]->deepCopy();
2645 cpy->applyLin(1,1,0);
2646 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2647 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2648 MEDFILESAFECALLERWR0(MEDprofileWr,(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer()));
2651 int nbOfLocs=_locs.size();
2652 for(int i=0;i<nbOfLocs;i++)
2653 _locs[i]->writeLL(fid);
2656 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
2658 std::vector<std::string> pfls=getPfls();
2659 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2661 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2664 _pfls.push_back(*it);
2668 int id=std::distance(pfls.begin(),it2);
2669 if(!(*it)->isEqual(*_pfls[id]))
2671 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2672 throw INTERP_KERNEL::Exception(oss.str().c_str());
2676 std::vector<std::string> locs=getLocs();
2677 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
2679 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2682 _locs.push_back(*it);
2686 int id=std::distance(locs.begin(),it2);
2687 if(!(*it)->isEqual(*_locs[id],eps))
2689 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2690 throw INTERP_KERNEL::Exception(oss.str().c_str());
2696 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
2698 for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
2699 getProfile((*it).c_str());
2702 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
2704 for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
2705 getLocalization((*it).c_str());
2708 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
2710 std::vector<std::string> profiles=real.getPflsReallyUsed();
2711 int sz=profiles.size();
2713 for(int i=0;i<sz;i++)
2714 loadProfileInFile(fid,i,profiles[i].c_str());
2716 std::vector<std::string> locs=real.getLocsReallyUsed();
2719 for(int i=0;i<sz;i++)
2720 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2723 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid)
2725 int nProfil=MEDnProfile(fid);
2726 for(int i=0;i<nProfil;i++)
2727 loadProfileInFile(fid,i);
2728 int sz=MEDnLocalization(fid);
2730 for(int i=0;i<sz;i++)
2732 _locs[i]=MEDFileFieldLoc::New(fid,i);
2736 MEDFileFieldGlobs *MEDFileFieldGlobs::New(const std::string& fname)
2738 return new MEDFileFieldGlobs(fname);
2741 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2743 return new MEDFileFieldGlobs;
2746 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
2748 return _file_name.capacity()+_pfls.capacity()*sizeof(MCAuto<DataArrayInt>)+_locs.capacity()*sizeof(MCAuto<MEDFileFieldLoc>);
2751 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildrenWithNull() const
2753 std::vector<const BigMemoryObject *> ret;
2754 for(std::vector< MCAuto< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2755 ret.push_back((const DataArrayInt *)*it);
2756 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2757 ret.push_back((const MEDFileFieldLoc *)*it);
2761 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCopy() const
2763 MCAuto<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
2765 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2767 if((const DataArrayInt *)*it)
2768 ret->_pfls[i]=(*it)->deepCopy();
2771 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2773 if((const MEDFileFieldLoc*)*it)
2774 ret->_locs[i]=(*it)->deepCopy();
2780 * \throw if a profile in \a pfls in not in \a this.
2781 * \throw if a localization in \a locs in not in \a this.
2782 * \sa MEDFileFieldGlobs::deepCpyPart
2784 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2786 MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2787 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2789 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2791 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
2793 MCAuto<DataArrayInt> pfl2(pfl);
2794 ret->_pfls.push_back(pfl2);
2796 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2798 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2800 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
2802 MCAuto<MEDFileFieldLoc> loc2(loc);
2803 ret->_locs.push_back(loc2);
2805 ret->setFileName(getFileName());
2810 * \throw if a profile in \a pfls in not in \a this.
2811 * \throw if a localization in \a locs in not in \a this.
2812 * \sa MEDFileFieldGlobs::shallowCpyPart
2814 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2816 MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2817 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2819 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2821 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
2822 ret->_pfls.push_back(pfl->deepCopy());
2824 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2826 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2828 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
2829 ret->_locs.push_back(loc->deepCopy());
2831 ret->setFileName(getFileName());
2835 MEDFileFieldGlobs::MEDFileFieldGlobs(const std::string& fname):_file_name(fname)
2839 MEDFileFieldGlobs::MEDFileFieldGlobs()
2843 MEDFileFieldGlobs::~MEDFileFieldGlobs()
2847 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
2849 oss << "Profiles :\n";
2850 std::size_t n=_pfls.size();
2851 for(std::size_t i=0;i<n;i++)
2853 oss << " - #" << i << " ";
2854 const DataArrayInt *pfl=_pfls[i];
2856 oss << "\"" << pfl->getName() << "\"\n";
2861 oss << "Localizations :\n";
2862 for(std::size_t i=0;i<n;i++)
2864 oss << " - #" << i << " ";
2865 const MEDFileFieldLoc *loc=_locs[i];
2867 loc->simpleRepr(oss);
2873 void MEDFileFieldGlobs::setFileName(const std::string& fileName)
2875 _file_name=fileName;
2878 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2880 for(std::vector< MCAuto<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
2882 DataArrayInt *elt(*it);
2885 std::string name(elt->getName());
2886 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2888 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2890 elt->setName((*it2).second.c_str());
2898 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2900 for(std::vector< MCAuto<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
2902 MEDFileFieldLoc *elt(*it);
2905 std::string name(elt->getName());
2906 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2908 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2910 elt->setName((*it2).second.c_str());
2918 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
2920 if(locId<0 || locId>=(int)_locs.size())
2921 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
2922 return _locs[locId]->getNbOfGaussPtPerCell();
2925 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
2927 return getLocalizationFromId(getLocalizationId(locName));
2930 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
2932 if(locId<0 || locId>=(int)_locs.size())
2933 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2934 return *_locs[locId];
2938 namespace MEDCouplingImpl
2943 LocFinder(const std::string& loc):_loc(loc) { }
2944 bool operator() (const MCAuto<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
2946 const std::string &_loc;
2952 PflFinder(const std::string& pfl):_pfl(pfl) { }
2953 bool operator() (const MCAuto<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
2955 const std::string& _pfl;
2960 int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
2962 std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),MEDCouplingImpl::LocFinder(loc));
2965 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
2966 for(it=_locs.begin();it!=_locs.end();it++)
2967 oss << "\"" << (*it)->getName() << "\", ";
2968 throw INTERP_KERNEL::Exception(oss.str().c_str());
2970 return std::distance(_locs.begin(),it);
2974 * The returned value is never null.
2976 const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
2978 std::string pflNameCpp(pflName);
2979 std::vector< MCAuto<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
2982 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2983 for(it=_pfls.begin();it!=_pfls.end();it++)
2984 oss << "\"" << (*it)->getName() << "\", ";
2985 throw INTERP_KERNEL::Exception(oss.str().c_str());
2990 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
2992 if(pflId<0 || pflId>=(int)_pfls.size())
2993 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2994 return _pfls[pflId];
2997 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
2999 if(locId<0 || locId>=(int)_locs.size())
3000 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3001 return *_locs[locId];
3004 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
3006 return getLocalizationFromId(getLocalizationId(locName));
3010 * The returned value is never null.
3012 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
3014 std::string pflNameCpp(pflName);
3015 std::vector< MCAuto<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3018 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3019 for(it=_pfls.begin();it!=_pfls.end();it++)
3020 oss << "\"" << (*it)->getName() << "\", ";
3021 throw INTERP_KERNEL::Exception(oss.str().c_str());
3026 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
3028 if(pflId<0 || pflId>=(int)_pfls.size())
3029 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3030 return _pfls[pflId];
3033 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
3035 std::vector< MCAuto<DataArrayInt> > newPfls;
3037 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3039 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
3040 newPfls.push_back(*it);
3045 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
3047 std::vector< MCAuto<MEDFileFieldLoc> > newLocs;
3049 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3051 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
3052 newLocs.push_back(*it);
3057 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
3059 int sz=_pfls.size();
3060 std::vector<std::string> ret(sz);
3061 for(int i=0;i<sz;i++)
3062 ret[i]=_pfls[i]->getName();
3066 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
3068 int sz=_locs.size();
3069 std::vector<std::string> ret(sz);
3070 for(int i=0;i<sz;i++)
3071 ret[i]=_locs[i]->getName();
3075 bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
3077 std::vector<std::string> v=getPfls();
3078 std::string s(pflName);
3079 return std::find(v.begin(),v.end(),s)!=v.end();
3082 bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
3084 std::vector<std::string> v=getLocs();
3085 std::string s(locName);
3086 return std::find(v.begin(),v.end(),s)!=v.end();
3089 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
3091 std::map<int,std::vector<int> > m;
3093 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3095 const DataArrayInt *tmp=(*it);
3098 m[tmp->getHashCode()].push_back(i);
3101 std::vector< std::vector<int> > ret;
3102 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
3104 if((*it2).second.size()>1)
3106 std::vector<int> ret0;
3107 bool equalityOrNot=false;
3108 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
3110 std::vector<int>::const_iterator it4=it3; it4++;
3111 for(;it4!=(*it2).second.end();it4++)
3113 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
3116 ret0.push_back(*it3);
3117 ret0.push_back(*it4);
3123 ret.push_back(ret0);
3129 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
3131 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
3134 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
3136 std::string name(pfl->getName());
3138 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
3139 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3140 if(name==(*it)->getName())
3142 if(!pfl->isEqual(*(*it)))
3144 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
3145 throw INTERP_KERNEL::Exception(oss.str().c_str());
3149 _pfls.push_back(pfl);
3152 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)
3154 std::string name(locName);
3156 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
3157 MCAuto<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
3158 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3159 if((*it)->isName(locName))
3161 if(!(*it)->isEqual(*obj,1e-12))
3163 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
3164 throw INTERP_KERNEL::Exception(oss.str().c_str());
3167 _locs.push_back(obj);
3170 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
3172 std::vector<std::string> names=getPfls();
3173 return CreateNewNameNotIn("NewPfl_",names);
3176 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
3178 std::vector<std::string> names=getLocs();
3179 return CreateNewNameNotIn("NewLoc_",names);
3182 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
3184 for(std::size_t sz=0;sz<100000;sz++)
3186 std::ostringstream tryName;
3187 tryName << prefix << sz;
3188 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
3189 return tryName.str();
3191 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
3195 * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
3196 * \param [in] fname - the file name.
3198 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(const std::string& fname):_globals(MEDFileFieldGlobs::New(fname))
3203 * Creates an empty MEDFileFieldGlobsReal.
3205 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
3209 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
3214 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildrenWithNull() const
3216 std::vector<const BigMemoryObject *> ret;
3217 ret.push_back((const MEDFileFieldGlobs *)_globals);
3222 * Returns a string describing profiles and Gauss points held in \a this.
3223 * \return std::string - the description string.
3225 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
3227 const MEDFileFieldGlobs *glob=_globals;
3228 std::ostringstream oss2; oss2 << glob;
3229 std::string stars(oss2.str().length(),'*');
3230 oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n";
3232 glob->simpleRepr(oss);
3234 oss << "NO GLOBAL INFORMATION !\n";
3237 void MEDFileFieldGlobsReal::resetContent()
3239 _globals=MEDFileFieldGlobs::New();
3242 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
3247 * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
3248 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3250 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3252 _globals=other._globals;
3256 * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3257 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3259 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3261 const MEDFileFieldGlobs *otherg(other._globals);
3264 _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3268 * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3269 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3271 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3273 const MEDFileFieldGlobs *otherg(other._globals);
3276 _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3279 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3281 _globals=other._globals;
3282 if((const MEDFileFieldGlobs *)_globals)
3283 _globals=other._globals->deepCopy();
3287 * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3288 * \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3289 * \param [in] eps - a precision used to compare Gauss points with same name held by
3290 * \a this and \a other MEDFileFieldGlobsReal.
3291 * \throw If \a this and \a other hold profiles with equal names but different ids.
3292 * \throw If \a this and \a other hold different Gauss points with equal names.
3294 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
3296 const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3297 if(thisGlobals==otherGlobals)
3301 _globals=other._globals;
3304 _globals->appendGlobs(*other._globals,eps);
3307 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
3309 checkGlobsPflsPartCoherency();
3310 checkGlobsLocsPartCoherency();
3313 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
3315 contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3318 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
3320 contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3323 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3325 contentNotNull()->loadProfileInFile(fid,id,pflName);
3328 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3330 contentNotNull()->loadProfileInFile(fid,id);
3333 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
3335 contentNotNull()->loadGlobals(fid,*this);
3338 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid)
3340 contentNotNull()->loadAllGlobals(fid);
3343 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3345 contentNotNull()->writeGlobals(fid,opt);
3349 * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3350 * or getPflsReallyUsedMulti().
3351 * \return std::vector<std::string> - a sequence of names of all profiles.
3353 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3355 return contentNotNull()->getPfls();
3359 * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3360 * or getLocsReallyUsedMulti().
3361 * \return std::vector<std::string> - a sequence of names of all localizations.
3363 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3365 return contentNotNull()->getLocs();
3369 * Checks if the profile with a given name exists.
3370 * \param [in] pflName - the profile name of interest.
3371 * \return bool - \c true if the profile named \a pflName exists.
3373 bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
3375 return contentNotNull()->existsPfl(pflName);
3379 * Checks if the localization with a given name exists.
3380 * \param [in] locName - the localization name of interest.
3381 * \return bool - \c true if the localization named \a locName exists.
3383 bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
3385 return contentNotNull()->existsLoc(locName);
3388 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
3390 return contentNotNull()->createNewNameOfPfl();
3393 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
3395 return contentNotNull()->createNewNameOfLoc();
3399 * Sets the name of a MED file.
3400 * \param [inout] fileName - the file name.
3402 void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
3404 contentNotNull()->setFileName(fileName);
3408 * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3409 * in the same order.
3410 * \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3411 * Each item of this sequence is a vector containing ids of equal profiles.
3413 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3415 return contentNotNull()->whichAreEqualProfiles();
3419 * Finds equal localizations.
3420 * \param [in] eps - a precision used to compare real values of the localizations.
3421 * \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3422 * Each item of this sequence is a vector containing ids of equal localizations.
3424 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3426 return contentNotNull()->whichAreEqualLocs(eps);
3430 * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3431 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3432 * this sequence is a pair whose
3433 * - the first item is a vector of profile names to replace by the second item,
3434 * - the second item is a profile name to replace every profile name of the first item.
3436 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3438 contentNotNull()->changePflsNamesInStruct(mapOfModif);
3442 * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3443 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3444 * this sequence is a pair whose
3445 * - the first item is a vector of localization names to replace by the second item,
3446 * - the second item is a localization name to replace every localization name of the first item.
3448 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3450 contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3454 * Replaces references to some profiles (a reference is a profile name) by references
3455 * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3456 * them-selves accordingly. <br>
3457 * This method is a generalization of changePflName().
3458 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3459 * this sequence is a pair whose
3460 * - the first item is a vector of profile names to replace by the second item,
3461 * - the second item is a profile name to replace every profile of the first item.
3462 * \sa changePflsRefsNamesGen()
3463 * \sa changePflName()
3465 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3467 changePflsRefsNamesGen(mapOfModif);
3468 changePflsNamesInStruct(mapOfModif);
3472 * Replaces references to some localizations (a reference is a localization name) by references
3473 * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3474 * them-selves accordingly. <br>
3475 * This method is a generalization of changeLocName().
3476 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3477 * this sequence is a pair whose
3478 * - the first item is a vector of localization names to replace by the second item,
3479 * - the second item is a localization name to replace every localization of the first item.
3480 * \sa changeLocsRefsNamesGen()
3481 * \sa changeLocName()
3483 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3485 changeLocsRefsNamesGen(mapOfModif);
3486 changeLocsNamesInStruct(mapOfModif);
3490 * Renames the profile having a given name and updates references to this profile.
3491 * \param [in] oldName - the name of the profile to rename.
3492 * \param [in] newName - a new name of the profile.
3493 * \sa changePflsNames().
3495 void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
3497 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3498 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3500 changePflsNames(mapOfModif);
3504 * Renames the localization having a given name and updates references to this localization.
3505 * \param [in] oldName - the name of the localization to rename.
3506 * \param [in] newName - a new name of the localization.
3507 * \sa changeLocsNames().
3509 void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
3511 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3512 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3514 changeLocsNames(mapOfModif);
3518 * Removes duplicated profiles. Returns a map used to update references to removed
3519 * profiles via changePflsRefsNamesGen().
3520 * Equal profiles are found using whichAreEqualProfiles().
3521 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3522 * a sequence describing the performed replacements of profiles. Each element of
3523 * this sequence is a pair whose
3524 * - the first item is a vector of profile names replaced by the second item,
3525 * - the second item is a profile name replacing every profile of the first item.
3527 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
3529 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3530 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3532 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3534 std::vector< std::string > tmp((*it).size());
3536 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3537 tmp[j]=std::string(getProfileFromId(*it2)->getName());
3538 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3540 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3541 killProfileIds(tmp2);
3543 changePflsRefsNamesGen(ret);
3548 * Removes duplicated localizations. Returns a map used to update references to removed
3549 * localizations via changeLocsRefsNamesGen().
3550 * Equal localizations are found using whichAreEqualLocs().
3551 * \param [in] eps - a precision used to compare real values of the localizations.
3552 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3553 * a sequence describing the performed replacements of localizations. Each element of
3554 * this sequence is a pair whose
3555 * - the first item is a vector of localization names replaced by the second item,
3556 * - the second item is a localization name replacing every localization of the first item.
3558 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
3560 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3561 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3563 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3565 std::vector< std::string > tmp((*it).size());
3567 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3568 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3569 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3571 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3572 killLocalizationIds(tmp2);
3574 changeLocsRefsNamesGen(ret);
3579 * Returns number of Gauss points per cell in a given localization.
3580 * \param [in] locId - an id of the localization of interest.
3581 * \return int - the number of the Gauss points per cell.
3583 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
3585 return contentNotNull()->getNbOfGaussPtPerCell(locId);
3589 * Returns an id of a localization by its name.
3590 * \param [in] loc - the localization name of interest.
3591 * \return int - the id of the localization.
3592 * \throw If there is no a localization named \a loc.
3594 int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
3596 return contentNotNull()->getLocalizationId(loc);
3600 * Returns the name of the MED file.
3601 * \return const std::string& - the MED file name.
3603 std::string MEDFileFieldGlobsReal::getFileName() const
3605 return contentNotNull()->getFileName();
3609 * Returns a localization object by its name.
3610 * \param [in] locName - the name of the localization of interest.
3611 * \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3612 * \throw If there is no a localization named \a locName.
3614 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
3616 return contentNotNull()->getLocalization(locName);
3620 * Returns a localization object by its id.
3621 * \param [in] locId - the id of the localization of interest.
3622 * \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3623 * \throw If there is no a localization with id \a locId.
3625 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
3627 return contentNotNull()->getLocalizationFromId(locId);
3631 * Returns a profile array by its name.
3632 * \param [in] pflName - the name of the profile of interest.
3633 * \return const DataArrayInt * - the profile array having the name \a pflName.
3634 * \throw If there is no a profile named \a pflName.
3636 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
3638 return contentNotNull()->getProfile(pflName);
3642 * Returns a profile array by its id.
3643 * \param [in] pflId - the id of the profile of interest.
3644 * \return const DataArrayInt * - the profile array having the id \a pflId.
3645 * \throw If there is no a profile with id \a pflId.
3647 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
3649 return contentNotNull()->getProfileFromId(pflId);
3653 * Returns a localization object, apt for modification, by its id.
3654 * \param [in] locId - the id of the localization of interest.
3655 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3656 * having the id \a locId.
3657 * \throw If there is no a localization with id \a locId.
3659 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
3661 return contentNotNull()->getLocalizationFromId(locId);
3665 * Returns a localization object, apt for modification, by its name.
3666 * \param [in] locName - the name of the localization of interest.
3667 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3668 * having the name \a locName.
3669 * \throw If there is no a localization named \a locName.
3671 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
3673 return contentNotNull()->getLocalization(locName);
3677 * Returns a profile array, apt for modification, by its name.
3678 * \param [in] pflName - the name of the profile of interest.
3679 * \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3680 * \throw If there is no a profile named \a pflName.
3682 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
3684 return contentNotNull()->getProfile(pflName);
3688 * Returns a profile array, apt for modification, by its id.
3689 * \param [in] pflId - the id of the profile of interest.
3690 * \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3691 * \throw If there is no a profile with id \a pflId.
3693 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
3695 return contentNotNull()->getProfileFromId(pflId);
3699 * Removes profiles given by their ids. No data is updated to track this removal.
3700 * \param [in] pflIds - a sequence of ids of the profiles to remove.
3702 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
3704 contentNotNull()->killProfileIds(pflIds);
3708 * Removes localizations given by their ids. No data is updated to track this removal.
3709 * \param [in] locIds - a sequence of ids of the localizations to remove.
3711 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
3713 contentNotNull()->killLocalizationIds(locIds);
3717 * Stores a profile array.
3718 * \param [in] pfl - the profile array to store.
3719 * \throw If the name of \a pfl is empty.
3720 * \throw If a profile with the same name as that of \a pfl already exists but contains
3723 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
3725 contentNotNull()->appendProfile(pfl);
3729 * Adds a new localization of Gauss points.
3730 * \param [in] locName - the name of the new localization.
3731 * \param [in] geoType - a geometrical type of the reference cell.
3732 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
3733 * must be \c nbOfNodesPerCell * \c dimOfType.
3734 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
3735 * must be _wg_.size() * \c dimOfType.
3736 * \param [in] w - the weights of Gauss points.
3737 * \throw If \a locName is empty.
3738 * \throw If a localization with the name \a locName already exists but is
3739 * different form the new one.
3741 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)
3743 contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
3746 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
3748 MEDFileFieldGlobs *g(_globals);
3750 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
3754 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
3756 const MEDFileFieldGlobs *g(_globals);
3758 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
3762 //= MEDFileFieldNameScope
3764 MEDFileFieldNameScope::MEDFileFieldNameScope()
3768 MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName):_name(fieldName)
3773 * Returns the name of \a this field.
3774 * \return std::string - a string containing the field name.
3776 std::string MEDFileFieldNameScope::getName() const
3782 * Sets name of \a this field
3783 * \param [in] name - the new field name.
3785 void MEDFileFieldNameScope::setName(const std::string& fieldName)
3790 std::string MEDFileFieldNameScope::getDtUnit() const
3795 void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
3800 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
3803 _dt_unit=other._dt_unit;
3806 //= MEDFileAnyTypeField1TSWithoutSDA
3808 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
3810 _field_per_mesh.resize(other._field_per_mesh.size());
3812 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
3814 if((const MEDFileFieldPerMesh *)*it)
3815 _field_per_mesh[i]=(*it)->deepCopy(this);
3820 * Prints a string describing \a this field into a stream. This string is outputted
3821 * by \c print Python command.
3822 * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
3823 * \param [in,out] oss - the out stream.
3824 * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
3825 * info id printed, else, not.
3827 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
3829 std::string startOfLine(bkOffset,' ');
3830 oss << startOfLine << "Field ";
3832 oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
3833 oss << "on one time Step ";
3835 oss << "(" << f1tsId << ") ";
3836 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
3837 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
3838 const DataArray *arr=getUndergroundDataArray();
3841 const std::vector<std::string> &comps=arr->getInfoOnComponents();
3844 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
3845 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
3846 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
3848 if(arr->isAllocated())
3850 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
3853 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
3857 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
3859 oss << startOfLine << "----------------------" << std::endl;
3860 if(!_field_per_mesh.empty())
3863 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
3865 const MEDFileFieldPerMesh *cur=(*it2);
3867 cur->simpleRepr(bkOffset,oss,i);
3869 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
3874 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
3876 oss << startOfLine << "----------------------" << std::endl;
3879 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
3881 const DataArray *arr(getUndergroundDataArray());
3883 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
3884 int nbOfCompo=arr->getNumberOfComponents();
3885 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
3886 for(int i=0;i<nbOfCompo;i++)
3889 std::vector<int> v(1,i);
3890 MCAuto<DataArray> arr2=arr->keepSelectedComponents(v);
3891 ret[i]->setArray(arr2);
3896 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)
3900 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
3905 * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
3906 * empty. Returns -1 if this in on nodes.
3907 * \return int - the dimension of \a this.
3909 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
3912 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3913 (*it)->getDimension(ret);
3918 * Returns the mesh name.
3919 * \return std::string - a string holding the mesh name.
3920 * \throw If \c _field_per_mesh.empty()
3922 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const
3924 if(_field_per_mesh.empty())
3925 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
3926 return _field_per_mesh[0]->getMeshName();
3929 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const std::string& newMeshName)
3931 std::string oldName(getMeshName());
3932 std::vector< std::pair<std::string,std::string> > v(1);
3933 v[0].first=oldName; v[0].second=newMeshName;
3937 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
3940 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3942 MEDFileFieldPerMesh *cur(*it);
3944 ret=cur->changeMeshNames(modifTab) || ret;
3950 * Returns the number of iteration of the state of underlying mesh.
3951 * \return int - the iteration number.
3952 * \throw If \c _field_per_mesh.empty()
3954 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
3956 if(_field_per_mesh.empty())
3957 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
3958 return _field_per_mesh[0]->getMeshIteration();
3962 * Returns the order number of iteration of the state of underlying mesh.
3963 * \return int - the order number.
3964 * \throw If \c _field_per_mesh.empty()
3966 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
3968 if(_field_per_mesh.empty())
3969 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
3970 return _field_per_mesh[0]->getMeshOrder();
3974 * Checks if \a this field is tagged by a given iteration number and a given
3975 * iteration order number.
3976 * \param [in] iteration - the iteration number of interest.
3977 * \param [in] order - the iteration order number of interest.
3978 * \return bool - \c true if \a this->getIteration() == \a iteration &&
3979 * \a this->getOrder() == \a order.
3981 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
3983 return iteration==_iteration && order==_order;
3987 * Returns number of iteration and order number of iteration when
3988 * \a this field has been calculated.
3989 * \return std::pair<int,int> - a pair of the iteration number and the iteration
3992 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
3994 std::pair<int,int> p;
4000 * Returns number of iteration and order number of iteration when
4001 * \a this field has been calculated.
4002 * \param [in,out] p - a pair returning the iteration number and the iteration
4005 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
4012 * Returns all types of spatial discretization of \a this field.
4013 * \param [in,out] types - a sequence of types of \a this field.
4015 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
4017 std::set<TypeOfField> types2;
4018 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4020 (*it)->fillTypesOfFieldAvailable(types2);
4022 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
4023 std::copy(types2.begin(),types2.end(),bi);
4027 * Returns all types of spatial discretization of \a this field.
4028 * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
4031 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
4033 std::vector<TypeOfField> ret;
4034 fillTypesOfFieldAvailable(ret);
4038 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
4040 std::vector<std::string> ret;
4041 std::set<std::string> ret2;
4042 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4044 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
4045 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4046 if(ret2.find(*it2)==ret2.end())
4048 ret.push_back(*it2);
4055 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
4057 std::vector<std::string> ret;
4058 std::set<std::string> ret2;
4059 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4061 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
4062 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4063 if(ret2.find(*it2)==ret2.end())
4065 ret.push_back(*it2);
4072 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
4074 std::vector<std::string> ret;
4075 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4077 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
4078 ret.insert(ret.end(),tmp.begin(),tmp.end());
4083 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
4085 std::vector<std::string> ret;
4086 std::set<std::string> ret2;
4087 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4089 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
4090 ret.insert(ret.end(),tmp.begin(),tmp.end());
4095 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4097 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4098 (*it)->changePflsRefsNamesGen(mapOfModif);
4101 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4103 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4104 (*it)->changeLocsRefsNamesGen(mapOfModif);
4108 * Returns all attributes of parts of \a this field lying on a given mesh.
4109 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4110 * item of every of returned sequences refers to the _i_-th part of \a this field.
4111 * Thus all sequences returned by this method are of the same length equal to number
4112 * of different types of supporting entities.<br>
4113 * A field part can include sub-parts with several different spatial discretizations,
4114 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
4115 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4116 * of a nested sequence corresponds to a type of spatial discretization.<br>
4117 * This method allows for iteration over MEDFile DataStructure without any overhead.
4118 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4119 * for the case with only one underlying mesh. (Actually, the number of meshes is
4120 * not checked if \a mname == \c NULL).
4121 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4122 * a field part is returned.
4123 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4124 * This sequence is of the same length as \a types.
4125 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4126 * discretization. A profile name can be empty.
4127 * Length of this and of nested sequences is the same as that of \a typesF.
4128 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4129 * discretization. A localization name can be empty.
4130 * Length of this and of nested sequences is the same as that of \a typesF.
4131 * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
4132 * of ids of tuples within the data array, per each type of spatial
4133 * discretization within one mesh entity type.
4134 * Length of this and of nested sequences is the same as that of \a typesF.
4135 * \throw If no field is lying on \a mname.
4137 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
4141 meshId=getMeshIdFromMeshName(mname);
4143 if(_field_per_mesh.empty())
4144 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4145 return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4149 * Returns dimensions of mesh elements \a this field lies on. The returned value is a
4150 * maximal absolute dimension and values returned via the out parameter \a levs are
4151 * dimensions relative to the maximal absolute dimension. <br>
4152 * This method is designed for MEDFileField1TS instances that have a discretization
4153 * \ref MEDCoupling::ON_CELLS "ON_CELLS",
4154 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT",
4155 * \ref MEDCoupling::ON_GAUSS_NE "ON_GAUSS_NE".
4156 * Only these 3 discretizations will be taken into account here. If \a this is
4157 * \ref MEDCoupling::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
4158 * This method is useful to make the link between the dimension of the underlying mesh
4159 * and the levels of \a this, because it is possible that the highest dimension of \a this
4160 * field is not equal to the dimension of the underlying mesh.
4162 * Let's consider the following case:
4163 * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
4164 * TETRA4, HEXA8, TRI3 and SEG2.
4165 * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
4166 * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
4168 * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
4169 * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
4170 * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
4171 * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
4172 * parameter of getFieldAtLevel() is computed basing on the returned values as this:
4173 * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
4175 * to retrieve the highest level of
4176 * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br>
4177 * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
4178 * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
4179 * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
4180 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4181 * for the case with only one underlying mesh. (Actually, the number of meshes is
4182 * not checked if \a mname == \c NULL).
4183 * \param [in,out] levs - a sequence returning the dimensions relative to the maximal
4184 * absolute one. They are in decreasing order. This sequence is cleared before
4186 * \return int - the maximal absolute dimension of elements \a this fields lies on.
4187 * \throw If no field is lying on \a mname.
4189 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
4192 int meshId=getMeshIdFromMeshName(mname);
4193 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4194 std::vector< std::vector<TypeOfField> > typesF;
4195 std::vector< std::vector<std::string> > pfls, locs;
4196 _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4198 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
4199 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
4200 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
4202 st.erase(INTERP_KERNEL::NORM_ERROR);
4204 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
4206 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
4207 ret1.insert((int)cm.getDimension());
4209 int ret=*std::max_element(ret1.begin(),ret1.end());
4210 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
4211 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
4216 * \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.
4217 * \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.
4218 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4219 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4221 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
4223 int mid=getMeshIdFromMeshName(mName);
4224 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4228 * \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.
4229 * \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.
4230 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4231 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4233 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
4235 int mid=getMeshIdFromMeshName(mName);
4236 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4240 * \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.
4242 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
4244 if(_field_per_mesh.empty())
4245 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4248 std::string mName2(mName);
4250 std::vector<std::string> msg;
4251 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4252 if(mName2==(*it)->getMeshName())
4255 msg.push_back((*it)->getMeshName());
4256 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4257 oss << "Possible meshes are : ";
4258 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4259 oss << "\"" << (*it2) << "\" ";
4260 throw INTERP_KERNEL::Exception(oss.str().c_str());
4263 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
4266 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4267 std::string tmp(mesh->getName());
4269 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4270 std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4272 for(;it!=_field_per_mesh.end();it++,i++)
4274 if((*it)->getMeshName()==tmp)
4277 int sz=_field_per_mesh.size();
4278 _field_per_mesh.resize(sz+1);
4279 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4283 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4284 MEDFileFieldGlobsReal& glob)
4287 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4289 MEDFileFieldPerMesh *fpm(*it);
4291 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4297 * This method splits \a this into several sub-parts so that each sub parts have exactly one spatial discretization. This method implements the minimal
4298 * splitting that leads to single spatial discretization of this.
4300 * \sa splitMultiDiscrPerGeoTypes
4302 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
4304 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4305 std::vector< std::vector<TypeOfField> > typesF;
4306 std::vector< std::vector<std::string> > pfls,locs;
4307 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4308 std::set<TypeOfField> allEnt;
4309 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4310 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4311 allEnt.insert(*it2);
4312 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4313 std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4314 for(std::size_t i=0;i<allEnt.size();i++,it3++)
4316 std::vector< std::pair<int,int> > its;
4317 ret[i]=shallowCpy();
4318 int newLgth(ret[i]->keepOnlySpatialDiscretization(*it3,its));
4319 ret[i]->updateData(newLgth,its);
4325 * This method performs a sub splitting as splitDiscretizations does but finer. This is the finest spliting level that can be done.
4326 * This method implements the minimal splitting so that each returned elements are mono Gauss discretization per geometric type.
4328 * \sa splitDiscretizations
4330 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes() const
4332 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4333 std::vector< std::vector<TypeOfField> > typesF;
4334 std::vector< std::vector<std::string> > pfls,locs;
4335 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4336 std::set<TypeOfField> allEnt;
4337 std::size_t nbOfMDPGT(0),ii(0);
4338 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++,ii++)
4340 nbOfMDPGT=std::max(nbOfMDPGT,locs[ii].size());
4341 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4342 allEnt.insert(*it2);
4344 if(allEnt.size()!=1)
4345 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : this field is expected to be defined only on one spatial discretization !");
4347 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
4350 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret0(1);
4351 ret0[0]=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(this); this->incrRef();
4354 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfMDPGT);
4355 for(std::size_t i=0;i<nbOfMDPGT;i++)
4357 std::vector< std::pair<int,int> > its;
4358 ret[i]=shallowCpy();
4359 int newLgth(ret[i]->keepOnlyGaussDiscretization(i,its));
4360 ret[i]->updateData(newLgth,its);
4365 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
4367 int globalCounter(0);
4368 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4369 (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4370 return globalCounter;
4373 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlyGaussDiscretization(std::size_t idOfDisc, std::vector< std::pair<int,int> >& its)
4375 int globalCounter(0);
4376 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4377 (*it)->keepOnlyGaussDiscretization(idOfDisc,globalCounter,its);
4378 return globalCounter;
4381 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
4383 if(_nb_of_tuples_to_be_allocated>=0)
4385 _nb_of_tuples_to_be_allocated=newLgth;
4386 const DataArray *oldArr(getUndergroundDataArray());
4389 MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4390 newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
4392 _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
4396 if(_nb_of_tuples_to_be_allocated==-1)
4398 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4400 const DataArray *oldArr(getUndergroundDataArray());
4401 if(!oldArr || !oldArr->isAllocated())
4402 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4403 MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4404 newArr->alloc(newLgth,getNumberOfComponents());
4406 newArr->copyStringInfoFrom(*oldArr);
4408 for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4410 if((*it).second<(*it).first)
4411 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4412 newArr->setContigPartOfSelectedValuesSlice(pos,oldArr,(*it).first,(*it).second,1);
4413 pos+=(*it).second-(*it).first;
4418 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4421 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
4423 if(_field_per_mesh.empty())
4424 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4425 if(_field_per_mesh.size()>1)
4426 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4427 _field_per_mesh[0]->copyOptionsFrom(opts);
4428 _field_per_mesh[0]->writeLL(fid,nasc);
4432 * 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.
4433 * If false is returned the memory allocation is not required.
4435 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
4437 if(_nb_of_tuples_to_be_allocated>=0)
4439 getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4440 _nb_of_tuples_to_be_allocated=-2;
4443 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4445 if(_nb_of_tuples_to_be_allocated==-1)
4446 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4447 if(_nb_of_tuples_to_be_allocated<-3)
4448 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4449 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4452 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
4454 med_int numdt,numit;
4458 med_int meshnumdt,meshnumit;
4459 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4460 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt));
4461 MEDFILESAFECALLERRD0(MEDfield23ComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit));
4462 if(_iteration!=numdt || _order!=numit)
4463 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4464 _field_per_mesh.resize(nmesh);
4469 std::string meshNameCpp(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
4470 mm=ms->getMeshWithName(meshNameCpp);
4473 for(int i=0;i<nmesh;i++)
4474 _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i,meshnumdt,meshnumit,nasc,mm,entities);
4475 _nb_of_tuples_to_be_allocated=0;
4476 for(int i=0;i<nmesh;i++)
4477 _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4480 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
4482 allocIfNecessaryTheArrayToReceiveDataFromFile();
4483 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4484 (*it)->loadBigArraysRecursively(fid,nasc);
4487 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
4489 if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4490 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4491 (*it)->loadBigArraysRecursively(fid,nasc);
4494 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
4496 loadOnlyStructureOfDataRecursively(fid,nasc,ms,entities);
4497 loadBigArraysRecursively(fid,nasc);
4500 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
4502 DataArray *thisArr(getUndergroundDataArray());
4503 if(thisArr && thisArr->isAllocated())
4505 _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
4506 thisArr->desallocate();
4510 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
4512 return _dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MCAuto< MEDFileFieldPerMesh >);
4515 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
4517 std::vector<const BigMemoryObject *> ret;
4518 if(getUndergroundDataArray())
4519 ret.push_back(getUndergroundDataArray());
4520 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4521 ret.push_back((const MEDFileFieldPerMesh *)*it);
4526 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4527 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4528 * "Sort By Type"), if not, an exception is thrown.
4529 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
4530 * \param [in] arr - the array of values.
4531 * \param [in,out] glob - the global data where profiles and localization present in
4532 * \a field, if any, are added.
4533 * \throw If the name of \a field is empty.
4534 * \throw If the data array of \a field is not set.
4535 * \throw If \a this->_arr is already allocated but has different number of components
4537 * \throw If the underlying mesh of \a field has no name.
4538 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4540 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4542 const MEDCouplingMesh *mesh=field->getMesh();
4544 TypeOfField type=field->getTypeOfField();
4545 std::vector<DataArrayInt *> dummy;
4546 int start=copyTinyInfoFrom(field,arr);
4547 int pos=addNewEntryIfNecessary(mesh);
4550 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4551 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4554 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4558 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4559 * of a given mesh are used as the support of the given field (a real support is not used).
4560 * Elements of the given mesh must be sorted suitable for writing to MED file.
4561 * Order of underlying mesh entities of the given field specified by \a profile parameter
4562 * is not prescribed; this method permutes field values to have them sorted by element
4563 * type as required for writing to MED file. A new profile is added only if no equal
4564 * profile is missing.
4565 * \param [in] field - the field to add to \a this. The field double values are ignored.
4566 * \param [in] arrOfVals - the values of the field \a field used.
4567 * \param [in] mesh - the supporting mesh of \a field.
4568 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4569 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
4570 * \param [in,out] glob - the global data where profiles and localization present in
4571 * \a field, if any, are added.
4572 * \throw If either \a field or \a mesh or \a profile has an empty name.
4573 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4574 * \throw If the data array of \a field is not set.
4575 * \throw If \a this->_arr is already allocated but has different number of components
4577 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4578 * \sa setFieldNoProfileSBT()
4580 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4583 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
4584 if(!arrOfVals || !arrOfVals->isAllocated())
4585 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
4586 TypeOfField type=field->getTypeOfField();
4587 std::vector<DataArrayInt *> idsInPflPerType;
4588 std::vector<DataArrayInt *> idsPerType;
4589 std::vector<int> code,code2;
4590 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
4593 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4594 std::vector< MCAuto<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
4595 std::vector< MCAuto<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin());
4596 std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
4598 MCAuto<MEDCouplingFieldDouble> field2=field->clone(false);
4599 int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
4600 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4602 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4603 throw INTERP_KERNEL::Exception(oss.str().c_str());
4606 int start=copyTinyInfoFrom(field,arrOfVals);
4607 code2=m->getDistributionOfTypes();
4609 int pos=addNewEntryIfNecessary(m);
4610 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4614 if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
4615 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
4616 std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
4617 std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
4618 int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
4619 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4621 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4622 throw INTERP_KERNEL::Exception(oss.str().c_str());
4624 int start=copyTinyInfoFrom(field,arrOfVals);
4625 int pos=addNewEntryIfNecessary(m);
4626 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4631 * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
4633 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
4635 if(_nb_of_tuples_to_be_allocated>=0)
4636 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 !");
4637 DataArray *arr(getOrCreateAndGetArray());
4638 arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
4639 _nb_of_tuples_to_be_allocated=-3;
4643 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4644 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4645 * larger by the size of \a field. Returns an id of the first not filled
4646 * tuple of \a this->_arr.
4647 * \param [in] field - the field to copy the info on components and the name from.
4648 * \return int - the id of first not initialized tuple of \a this->_arr.
4649 * \throw If the name of \a field is empty.
4650 * \throw If the data array of \a field is not set.
4651 * \throw If \a this->_arr is already allocated but has different number of components
4654 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
4657 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4658 std::string name(field->getName());
4659 setName(name.c_str());
4660 setDtUnit(field->getTimeUnit());
4662 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4664 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4665 if(!arr->isAllocated())
4666 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
4667 _dt=field->getTime(_iteration,_order);
4668 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4669 if(!getOrCreateAndGetArray()->isAllocated())
4671 allocNotFromFile(arr->getNumberOfTuples());
4676 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4677 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4678 getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
4679 _nb_of_tuples_to_be_allocated=-3;
4680 return oldNbOfTuples;
4685 * Returns number of components in \a this field
4686 * \return int - the number of components.
4688 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4690 return getOrCreateAndGetArray()->getNumberOfComponents();
4694 * Change info on components in \a this.
4695 * \throw If size of \a infos is not equal to the number of components already in \a this.
4697 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
4699 DataArray *arr=getOrCreateAndGetArray();
4700 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
4704 * Returns info on components of \a this field.
4705 * \return const std::vector<std::string>& - a sequence of strings each being an
4706 * information on _i_-th component.
4708 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
4710 const DataArray *arr=getOrCreateAndGetArray();
4711 return arr->getInfoOnComponents();
4715 * Returns a mutable info on components of \a this field.
4716 * \return std::vector<std::string>& - a sequence of strings each being an
4717 * information on _i_-th component.
4719 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
4721 DataArray *arr=getOrCreateAndGetArray();
4722 return arr->getInfoOnComponents();
4725 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const
4727 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4729 const MEDFileFieldPerMesh *fpm(*it);
4732 if(fpm->presenceOfMultiDiscPerGeoType())
4739 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4740 * \param [in] type - a spatial discretization of the new field.
4741 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4742 * \param [in] mName - a name of the supporting mesh.
4743 * \param [in] renumPol - specifies how to permute values of the result field according to
4744 * the optional numbers of cells and nodes, if any. The valid values are
4745 * - 0 - do not permute.
4746 * - 1 - permute cells.
4747 * - 2 - permute nodes.
4748 * - 3 - permute cells and nodes.
4750 * \param [in] glob - the global data storing profiles and localization.
4751 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4752 * caller is to delete this field using decrRef() as it is no more needed.
4753 * \throw If the MED file is not readable.
4754 * \throw If there is no mesh named \a mName in the MED file.
4755 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4756 * \throw If no field of \a this is lying on the mesh \a mName.
4757 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4759 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4761 MCAuto<MEDFileMesh> mm;
4763 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4765 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4766 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4770 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4771 * \param [in] type - a spatial discretization of the new field.
4772 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4773 * \param [in] renumPol - specifies how to permute values of the result field according to
4774 * the optional numbers of cells and nodes, if any. The valid values are
4775 * - 0 - do not permute.
4776 * - 1 - permute cells.
4777 * - 2 - permute nodes.
4778 * - 3 - permute cells and nodes.
4780 * \param [in] glob - the global data storing profiles and localization.
4781 * \param [in] mesh - the supporting mesh.
4782 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4783 * caller is to delete this field using decrRef() as it is no more needed.
4784 * \throw If the MED file is not readable.
4785 * \throw If no field of \a this is lying on \a mesh.
4786 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4787 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4789 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4791 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax,false));
4792 const DataArrayInt *d=mesh->getNumberFieldAtLevel(meshDimRelToMax);
4793 const DataArrayInt *e=mesh->getNumberFieldAtLevel(1);
4794 if(meshDimRelToMax==1)
4795 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
4796 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
4800 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
4802 * \param [in] type - a spatial discretization of the new field.
4803 * \param [in] mName - a name of the supporting mesh.
4804 * \param [in] renumPol - specifies how to permute values of the result field according to
4805 * the optional numbers of cells and nodes, if any. The valid values are
4806 * - 0 - do not permute.
4807 * - 1 - permute cells.
4808 * - 2 - permute nodes.
4809 * - 3 - permute cells and nodes.
4811 * \param [in] glob - the global data storing profiles and localization.
4812 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4813 * caller is to delete this field using decrRef() as it is no more needed.
4814 * \throw If the MED file is not readable.
4815 * \throw If there is no mesh named \a mName in the MED file.
4816 * \throw If there are no mesh entities in the mesh.
4817 * \throw If no field values of the given \a type are available.
4819 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4821 MCAuto<MEDFileMesh> mm;
4823 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4825 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4826 int absDim=getDimension();
4827 int meshDimRelToMax=absDim-mm->getMeshDimension();
4828 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4832 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4833 * \param [in] type - a spatial discretization of the new field.
4834 * \param [in] renumPol - specifies how to permute values of the result field according to
4835 * the optional numbers of cells and nodes, if any. The valid values are
4836 * - 0 - do not permute.
4837 * - 1 - permute cells.
4838 * - 2 - permute nodes.
4839 * - 3 - permute cells and nodes.
4841 * \param [in] glob - the global data storing profiles and localization.
4842 * \param [in] mesh - the supporting mesh.
4843 * \param [in] cellRenum - the cell numbers array used for permutation of the result
4844 * field according to \a renumPol.
4845 * \param [in] nodeRenum - the node numbers array used for permutation of the result
4846 * field according to \a renumPol.
4847 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4848 * caller is to delete this field using decrRef() as it is no more needed.
4849 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4850 * \throw If no field of \a this is lying on \a mesh.
4851 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4853 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
4855 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
4856 int meshId=getMeshIdFromMeshName(mesh->getName());
4858 MCAuto<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
4863 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4870 throw INTERP_KERNEL::Exception(msg1);
4871 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4874 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
4876 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4877 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
4878 throw INTERP_KERNEL::Exception(oss.str().c_str());
4880 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
4881 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
4882 std::vector<DataArray *> arrOut2(1,arrOut);
4883 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
4884 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
4885 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
4892 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4894 throw INTERP_KERNEL::Exception(msg1);
4897 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
4899 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4900 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
4901 throw INTERP_KERNEL::Exception(oss.str().c_str());
4903 MCAuto<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
4904 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
4905 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
4906 ret->renumberNodes(nodeRenumSafe->getConstPointer());
4911 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
4916 * Returns values and a profile of the field of a given type lying on a given support.
4917 * \param [in] type - a spatial discretization of the field.
4918 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4919 * \param [in] mesh - the supporting mesh.
4920 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
4921 * field of interest lies on. If the field lies on all entities of the given
4922 * dimension, all ids in \a pfl are zero. The caller is to delete this array
4923 * using decrRef() as it is no more needed.
4924 * \param [in] glob - the global data storing profiles and localization.
4925 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
4926 * field. The caller is to delete this array using decrRef() as it is no more needed.
4927 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4928 * \throw If no field of \a this is lying on \a mesh.
4929 * \throw If no field values of the given \a type are available.
4931 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
4933 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
4934 int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
4935 MCAuto<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
4936 ret->setName(nasc.getName().c_str());
4940 //= MEDFileField1TSWithoutSDA
4943 * Throws if a given value is not a valid (non-extended) relative dimension.
4944 * \param [in] meshDimRelToMax - the relative dimension value.
4945 * \throw If \a meshDimRelToMax > 0.
4947 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
4949 if(meshDimRelToMax>0)
4950 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
4954 * Checks if elements of a given mesh are in the order suitable for writing
4955 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
4956 * vector describing types of elements and their number.
4957 * \param [in] mesh - the mesh to check.
4958 * \return std::vector<int> - a vector holding for each element type (1) item of
4959 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
4960 * These values are in full-interlace mode.
4961 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4963 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
4966 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
4967 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
4968 int nbOfTypes=geoTypes.size();
4969 std::vector<int> code(3*nbOfTypes);
4970 MCAuto<DataArrayInt> arr1=DataArrayInt::New();
4971 arr1->alloc(nbOfTypes,1);
4972 int *arrPtr=arr1->getPointer();
4973 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
4974 for(int i=0;i<nbOfTypes;i++,it++)
4975 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
4976 MCAuto<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
4977 const int *arrPtr2=arr2->getConstPointer();
4979 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
4982 int nbCells=mesh->getNumberOfCellsWithType(*it);
4983 code[3*pos]=(int)(*it);
4984 code[3*pos+1]=nbCells;
4985 code[3*pos+2]=-1;//no profiles
4987 std::vector<const DataArrayInt *> idsPerType;//no profiles
4988 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
4992 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
4997 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
4999 return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5003 * Returns all attributes and values of parts of \a this field lying on a given mesh.
5004 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
5005 * item of every of returned sequences refers to the _i_-th part of \a this field.
5006 * Thus all sequences returned by this method are of the same length equal to number
5007 * of different types of supporting entities.<br>
5008 * A field part can include sub-parts with several different spatial discretizations,
5009 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
5010 * for example. Hence, some of the returned sequences contains nested sequences, and an item
5011 * of a nested sequence corresponds to a type of spatial discretization.<br>
5012 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
5013 * The overhead is due to selecting values into new instances of DataArrayDouble.
5014 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
5015 * for the case with only one underlying mesh. (Actually, the number of meshes is
5016 * not checked if \a mname == \c NULL).
5017 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
5018 * a field part is returned.
5019 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
5020 * A field part can include sub-parts with several different spatial discretizations,
5021 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and
5022 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT" for example.
5023 * This sequence is of the same length as \a types.
5024 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
5025 * discretization. A profile name can be empty.
5026 * Length of this and of nested sequences is the same as that of \a typesF.
5027 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
5028 * discretization. A localization name can be empty.
5029 * Length of this and of nested sequences is the same as that of \a typesF.
5030 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
5031 * per each type of spatial discretization within one mesh entity type.
5032 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
5033 * Length of this and of nested sequences is the same as that of \a typesF.
5034 * \throw If no field is lying on \a mname.
5036 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
5040 meshId=getMeshIdFromMeshName(mname);
5042 if(_field_per_mesh.empty())
5043 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
5044 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
5045 int nbOfRet=ret0.size();
5046 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
5047 for(int i=0;i<nbOfRet;i++)
5049 const std::vector< std::pair<int,int> >& p=ret0[i];
5050 int nbOfRet1=p.size();
5051 ret[i].resize(nbOfRet1);
5052 for(int j=0;j<nbOfRet1;j++)
5054 DataArrayDouble *tmp=_arr->selectByTupleIdSafeSlice(p[j].first,p[j].second,1);
5062 * Returns a pointer to the underground DataArrayDouble instance. So the
5063 * caller should not decrRef() it. This method allows for a direct access to the field
5064 * values. This method is quite unusable if there is more than a nodal field or a cell
5065 * field on single geometric cell type.
5066 * \return DataArrayDouble * - the pointer to the field values array.
5068 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDouble() const
5070 const DataArrayDouble *ret=_arr;
5072 return const_cast<DataArrayDouble *>(ret);
5077 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
5082 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
5084 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
5085 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5086 ret->deepCpyLeavesFrom(*this);
5087 const DataArrayDouble *arr(_arr);
5090 MCAuto<DataArrayInt> arr2(arr->convertToIntArr());
5091 ret->setArray(arr2);
5097 * Returns a pointer to the underground DataArrayDouble instance. So the
5098 * caller should not decrRef() it. This method allows for a direct access to the field
5099 * values. This method is quite unusable if there is more than a nodal field or a cell
5100 * field on single geometric cell type.
5101 * \return DataArrayDouble * - the pointer to the field values array.
5103 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArray() const
5105 return getUndergroundDataArrayDouble();
5109 * Returns a pointer to the underground DataArrayDouble instance and a
5110 * sequence describing parameters of a support of each part of \a this field. The
5111 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5112 * direct access to the field values. This method is intended for the field lying on one
5114 * \param [in,out] entries - the sequence describing parameters of a support of each
5115 * part of \a this field. Each item of this sequence consists of two parts. The
5116 * first part describes a type of mesh entity and an id of discretization of a
5117 * current field part. The second part describes a range of values [begin,end)
5118 * within the returned array relating to the current field part.
5119 * \return DataArrayDouble * - the pointer to the field values array.
5120 * \throw If the number of underlying meshes is not equal to 1.
5121 * \throw If no field values are available.
5122 * \sa getUndergroundDataArray()
5124 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5126 if(_field_per_mesh.size()!=1)
5127 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5128 if(_field_per_mesh[0]==0)
5129 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5130 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5131 return getUndergroundDataArrayDouble();
5135 * Returns a pointer to the underground DataArrayDouble instance and a
5136 * sequence describing parameters of a support of each part of \a this field. The
5137 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5138 * direct access to the field values. This method is intended for the field lying on one
5140 * \param [in,out] entries - the sequence describing parameters of a support of each
5141 * part of \a this field. Each item of this sequence consists of two parts. The
5142 * first part describes a type of mesh entity and an id of discretization of a
5143 * current field part. The second part describes a range of values [begin,end)
5144 * within the returned array relating to the current field part.
5145 * \return DataArrayDouble * - the pointer to the field values array.
5146 * \throw If the number of underlying meshes is not equal to 1.
5147 * \throw If no field values are available.
5148 * \sa getUndergroundDataArray()
5150 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5152 return getUndergroundDataArrayDoubleExt(entries);
5155 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
5157 DataArrayDouble *arr(getOrCreateAndGetArrayDouble());
5158 arr->setInfoAndChangeNbOfCompo(infos);
5161 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
5165 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
5167 MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
5168 ret->deepCpyLeavesFrom(*this);
5172 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCopy() const
5174 MCAuto<MEDFileField1TSWithoutSDA> ret=static_cast<MEDFileField1TSWithoutSDA *>(shallowCpy());
5175 if((const DataArrayDouble *)_arr)
5176 ret->_arr=_arr->deepCopy();
5180 void MEDFileField1TSWithoutSDA::setArray(DataArray *arr)
5184 _nb_of_tuples_to_be_allocated=-1;
5188 DataArrayDouble *arrC=dynamic_cast<DataArrayDouble *>(arr);
5190 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayDouble !");
5192 _nb_of_tuples_to_be_allocated=-3;
5197 DataArray *MEDFileField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
5199 return DataArrayDouble::New();
5202 DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble()
5204 DataArrayDouble *ret=_arr;
5207 _arr=DataArrayDouble::New();
5211 DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray()
5213 return getOrCreateAndGetArrayDouble();
5216 const DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble() const
5218 const DataArrayDouble *ret=_arr;
5221 DataArrayDouble *ret2=DataArrayDouble::New();
5222 const_cast<MEDFileField1TSWithoutSDA *>(this)->_arr=DataArrayDouble::New();
5226 const DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray() const
5228 return getOrCreateAndGetArrayDouble();
5231 //= MEDFileIntField1TSWithoutSDA
5233 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5235 return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5238 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
5242 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order,
5243 const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
5245 DataArrayInt *arr(getOrCreateAndGetArrayInt());
5246 arr->setInfoAndChangeNbOfCompo(infos);
5249 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
5254 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const
5256 MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
5257 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5258 ret->deepCpyLeavesFrom(*this);
5259 const DataArrayInt *arr(_arr);
5262 MCAuto<DataArrayDouble> arr2(arr->convertToDblArr());
5263 ret->setArray(arr2);
5269 * Returns a pointer to the underground DataArrayInt instance. So the
5270 * caller should not decrRef() it. This method allows for a direct access to the field
5271 * values. This method is quite unusable if there is more than a nodal field or a cell
5272 * field on single geometric cell type.
5273 * \return DataArrayInt * - the pointer to the field values array.
5275 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArray() const
5277 return getUndergroundDataArrayInt();
5281 * Returns a pointer to the underground DataArrayInt instance. So the
5282 * caller should not decrRef() it. This method allows for a direct access to the field
5283 * values. This method is quite unusable if there is more than a nodal field or a cell
5284 * field on single geometric cell type.
5285 * \return DataArrayInt * - the pointer to the field values array.
5287 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayInt() const
5289 const DataArrayInt *ret=_arr;
5291 return const_cast<DataArrayInt *>(ret);
5297 * Returns a pointer to the underground DataArrayInt instance and a
5298 * sequence describing parameters of a support of each part of \a this field. The
5299 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5300 * direct access to the field values. This method is intended for the field lying on one
5302 * \param [in,out] entries - the sequence describing parameters of a support of each
5303 * part of \a this field. Each item of this sequence consists of two parts. The
5304 * first part describes a type of mesh entity and an id of discretization of a
5305 * current field part. The second part describes a range of values [begin,end)
5306 * within the returned array relating to the current field part.
5307 * \return DataArrayInt * - the pointer to the field values array.
5308 * \throw If the number of underlying meshes is not equal to 1.
5309 * \throw If no field values are available.
5310 * \sa getUndergroundDataArray()
5312 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5314 return getUndergroundDataArrayIntExt(entries);
5318 * Returns a pointer to the underground DataArrayInt instance and a
5319 * sequence describing parameters of a support of each part of \a this field. The
5320 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5321 * direct access to the field values. This method is intended for the field lying on one
5323 * \param [in,out] entries - the sequence describing parameters of a support of each
5324 * part of \a this field. Each item of this sequence consists of two parts. The
5325 * first part describes a type of mesh entity and an id of discretization of a
5326 * current field part. The second part describes a range of values [begin,end)
5327 * within the returned array relating to the current field part.
5328 * \return DataArrayInt * - the pointer to the field values array.
5329 * \throw If the number of underlying meshes is not equal to 1.
5330 * \throw If no field values are available.
5331 * \sa getUndergroundDataArray()
5333 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5335 if(_field_per_mesh.size()!=1)
5336 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5337 if(_field_per_mesh[0]==0)
5338 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5339 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5340 return getUndergroundDataArrayInt();
5343 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5345 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5346 ret->deepCpyLeavesFrom(*this);
5350 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCopy() const
5352 MCAuto<MEDFileIntField1TSWithoutSDA> ret=static_cast<MEDFileIntField1TSWithoutSDA *>(shallowCpy());
5353 if((const DataArrayInt *)_arr)
5354 ret->_arr=_arr->deepCopy();
5358 void MEDFileIntField1TSWithoutSDA::setArray(DataArray *arr)
5362 _nb_of_tuples_to_be_allocated=-1;
5366 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>(arr);
5368 throw INTERP_KERNEL::Exception("MEDFileIntField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayInt !");
5370 _nb_of_tuples_to_be_allocated=-3;
5375 DataArray *MEDFileIntField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
5377 return DataArrayInt::New();
5380 DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt()
5382 DataArrayInt *ret=_arr;
5385 _arr=DataArrayInt::New();
5389 DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray()
5391 return getOrCreateAndGetArrayInt();
5394 const DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt() const
5396 const DataArrayInt *ret=_arr;
5399 DataArrayInt *ret2=DataArrayInt::New();
5400 const_cast<MEDFileIntField1TSWithoutSDA *>(this)->_arr=DataArrayInt::New();
5404 const DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray() const
5406 return getOrCreateAndGetArrayInt();
5409 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5413 //= MEDFileAnyTypeField1TS
5415 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
5417 med_field_type typcha;
5419 std::vector<std::string> infos;
5420 std::string dtunit,fieldName;
5421 LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
5422 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5427 ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5432 ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5437 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fileName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of the first field is not in [MED_FLOAT64, MED_INT32] !";
5438 throw INTERP_KERNEL::Exception(oss.str().c_str());
5441 ret->setDtUnit(dtunit.c_str());
5442 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5444 med_int numdt,numit;
5446 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5447 ret->setTime(numdt,numit,dt);
5450 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5452 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5456 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
5457 try:MEDFileFieldGlobsReal(fileName)
5459 MEDFileUtilities::CheckFileForRead(fileName);
5460 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5461 _content=BuildContentFrom(fid,fileName,loadAll,ms);
5464 catch(INTERP_KERNEL::Exception& e)
5469 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5471 med_field_type typcha;
5472 std::vector<std::string> infos;
5475 int nbSteps=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5476 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5481 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5486 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5491 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
5492 throw INTERP_KERNEL::Exception(oss.str().c_str());
5495 ret->setDtUnit(dtunit.c_str());
5496 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5500 std::ostringstream oss; oss << "MEDFileField1TS(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5501 throw INTERP_KERNEL::Exception(oss.str().c_str());
5504 med_int numdt,numit;
5506 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5507 ret->setTime(numdt,numit,dt);
5510 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5512 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5516 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5517 try:MEDFileFieldGlobsReal(fileName)
5519 MEDFileUtilities::CheckFileForRead(fileName);
5520 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5521 _content=BuildContentFrom(fid,fileName,fieldName,loadAll,ms);
5524 catch(INTERP_KERNEL::Exception& e)
5529 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, const std::string& fileName)
5532 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5533 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5535 MCAuto<MEDFileField1TS> ret=MEDFileField1TS::New();
5536 ret->setFileName(fileName);
5537 ret->_content=c; c->incrRef();
5540 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5542 MCAuto<MEDFileIntField1TS> ret=MEDFileIntField1TS::New();
5543 ret->setFileName(fileName);
5544 ret->_content=c; c->incrRef();
5547 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5550 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
5552 MEDFileUtilities::CheckFileForRead(fileName);
5553 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5554 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll,0);
5555 MCAuto<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5556 ret->loadGlobals(fid);
5560 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
5562 MEDFileUtilities::CheckFileForRead(fileName);
5563 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5564 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll,0);
5565 MCAuto<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5566 ret->loadGlobals(fid);
5570 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
5572 MEDFileUtilities::CheckFileForRead(fileName);
5573 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5574 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,iteration,order,loadAll,0);
5575 MCAuto<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5576 ret->loadGlobals(fid);
5580 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5582 med_field_type typcha;
5583 std::vector<std::string> infos;
5586 int nbOfStep2=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5587 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5592 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5597 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5602 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fileName,fieldName,iteration,order) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
5603 throw INTERP_KERNEL::Exception(oss.str().c_str());
5606 ret->setDtUnit(dtunit.c_str());
5607 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5610 std::vector< std::pair<int,int> > dtits(nbOfStep2);
5611 for(int i=0;i<nbOfStep2 && !found;i++)
5613 med_int numdt,numit;
5615 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt));
5616 if(numdt==iteration && numit==order)
5622 dtits[i]=std::pair<int,int>(numdt,numit);
5626 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << fileName << "' ! Available iterations are : ";
5627 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5628 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5629 throw INTERP_KERNEL::Exception(oss.str().c_str());
5632 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5634 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5638 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5639 try:MEDFileFieldGlobsReal(fileName)
5641 MEDFileUtilities::CheckFileForRead(fileName);
5642 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5643 _content=BuildContentFrom(fid,fileName.c_str(),fieldName.c_str(),iteration,order,loadAll,ms);
5646 catch(INTERP_KERNEL::Exception& e)
5652 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5653 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5655 * \warning this is a shallow copy constructor
5657 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5659 if(!shallowCopyOfContent)
5661 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5662 otherPtr->incrRef();
5663 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5667 _content=other.shallowCpy();
5671 int MEDFileAnyTypeField1TS::LocateField2(med_idt fid, const std::string& fileName, int fieldIdCFormat, bool checkFieldId, std::string& fieldName, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
5675 int nbFields=MEDnField(fid);
5676 if(fieldIdCFormat>=nbFields)
5678 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << fileName << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5679 throw INTERP_KERNEL::Exception(oss.str().c_str());
5682 int ncomp(MEDfieldnComponent(fid,fieldIdCFormat+1));
5683 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5684 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5685 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5686 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5687 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5690 MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep));
5691 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5692 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5693 infos.clear(); infos.resize(ncomp);
5694 for(int j=0;j<ncomp;j++)
5695 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5700 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5703 * \return in case of success the number of time steps available for the field with name \a fieldName.
5705 int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const std::string& fileName, const std::string& fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
5707 int nbFields=MEDnField(fid);
5709 std::vector<std::string> fns(nbFields);
5711 for(int i=0;i<nbFields && !found;i++)
5714 nbOfStep2=LocateField2(fid,fileName,i,false,tmp,typcha,infos,dtunitOut);
5716 found=(tmp==fieldName);
5722 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
5723 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5724 oss << "\"" << *it << "\" ";
5725 throw INTERP_KERNEL::Exception(oss.str().c_str());
5731 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5732 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5733 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5734 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5735 * to keep a valid instance.
5736 * 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.
5737 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5738 * 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.
5740 * \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.
5741 * \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.
5742 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5743 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5744 * \param [in] newLocName is the new localization name.
5745 * \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.
5746 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5748 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
5750 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5751 std::string oldPflName=disc->getProfile();
5752 std::vector<std::string> vv=getPflsReallyUsedMulti();
5753 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5754 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5756 disc->setProfile(newPflName);
5757 DataArrayInt *pfl=getProfile(oldPflName.c_str());
5758 pfl->setName(newPflName);
5762 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5763 throw INTERP_KERNEL::Exception(oss.str().c_str());
5768 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5769 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5770 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5771 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5772 * to keep a valid instance.
5773 * 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.
5774 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5775 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5776 * 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.
5778 * \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.
5779 * \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.
5780 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5781 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5782 * \param [in] newLocName is the new localization name.
5783 * \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.
5784 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
5786 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
5788 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5789 std::string oldLocName=disc->getLocalization();
5790 std::vector<std::string> vv=getLocsReallyUsedMulti();
5791 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
5792 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
5794 disc->setLocalization(newLocName);
5795 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
5796 loc.setName(newLocName);
5800 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
5801 throw INTERP_KERNEL::Exception(oss.str().c_str());
5805 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
5807 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5809 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
5813 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
5815 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5817 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
5822 * Writes \a this field into a MED file specified by its name.
5823 * \param [in] fileName - the MED file name.
5824 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
5825 * - 2 - erase; an existing file is removed.
5826 * - 1 - append; same data should not be present in an existing file.
5827 * - 0 - overwrite; same data present in an existing file is overwritten.
5828 * \throw If the field name is not set.
5829 * \throw If no field data is set.
5830 * \throw If \a mode == 1 and the same data is present in an existing file.
5832 void MEDFileAnyTypeField1TS::write(const std::string& fileName, int mode) const
5834 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
5835 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
5840 * This method alloc the arrays and load potentially huge arrays contained in this field.
5841 * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
5842 * This method can be also called to refresh or reinit values from a file.
5844 * \throw If the fileName is not set or points to a non readable MED file.
5845 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5847 void MEDFileAnyTypeField1TS::loadArrays()
5849 if(getFileName().empty())
5850 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
5851 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
5852 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
5856 * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
5857 * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
5858 * this method does not throw if \a this does not come from file read.
5860 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
5862 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
5864 if(!getFileName().empty())
5866 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
5867 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
5872 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
5873 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
5874 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
5876 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
5878 void MEDFileAnyTypeField1TS::unloadArrays()
5880 contentNotNullBase()->unloadArrays();
5884 * 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.
5885 * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
5886 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
5888 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5890 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
5892 if(!getFileName().empty())
5893 contentNotNullBase()->unloadArrays();
5896 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
5898 int nbComp=getNumberOfComponents();
5899 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5900 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5901 for(int i=0;i<nbComp;i++)
5903 std::string info=getInfo()[i];
5905 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
5906 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
5907 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
5909 if(getName().empty())
5910 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
5911 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
5912 writeGlobals(fid,*this);
5913 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
5916 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
5918 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
5921 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
5923 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
5924 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
5929 * Returns a string describing \a this field. This string is outputted
5930 * by \c print Python command.
5932 std::string MEDFileAnyTypeField1TS::simpleRepr() const
5934 std::ostringstream oss;
5935 contentNotNullBase()->simpleRepr(0,oss,-1);
5936 simpleReprGlobs(oss);
5941 * This method returns all profiles whose name is non empty used.
5942 * \b WARNING If profile is used several times it will be reported \b only \b once.
5943 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
5945 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
5947 return contentNotNullBase()->getPflsReallyUsed2();
5951 * This method returns all localizations whose name is non empty used.
5952 * \b WARNING If localization is used several times it will be reported \b only \b once.
5954 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
5956 return contentNotNullBase()->getLocsReallyUsed2();
5960 * This method returns all profiles whose name is non empty used.
5961 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
5963 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
5965 return contentNotNullBase()->getPflsReallyUsedMulti2();
5969 * This method returns all localizations whose name is non empty used.
5970 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
5972 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
5974 return contentNotNullBase()->getLocsReallyUsedMulti2();
5977 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5979 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
5982 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5984 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
5987 int MEDFileAnyTypeField1TS::getDimension() const
5989 return contentNotNullBase()->getDimension();
5992 int MEDFileAnyTypeField1TS::getIteration() const
5994 return contentNotNullBase()->getIteration();
5997 int MEDFileAnyTypeField1TS::getOrder() const
5999 return contentNotNullBase()->getOrder();
6002 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
6004 return contentNotNullBase()->getTime(iteration,order);
6007 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
6009 contentNotNullBase()->setTime(iteration,order,val);
6012 std::string MEDFileAnyTypeField1TS::getName() const
6014 return contentNotNullBase()->getName();
6017 void MEDFileAnyTypeField1TS::setName(const std::string& name)
6019 contentNotNullBase()->setName(name);
6022 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
6024 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
6027 std::string MEDFileAnyTypeField1TS::getDtUnit() const
6029 return contentNotNullBase()->getDtUnit();
6032 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
6034 contentNotNullBase()->setDtUnit(dtUnit);
6037 std::string MEDFileAnyTypeField1TS::getMeshName() const
6039 return contentNotNullBase()->getMeshName();
6042 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
6044 contentNotNullBase()->setMeshName(newMeshName);
6047 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
6049 return contentNotNullBase()->changeMeshNames(modifTab);
6052 int MEDFileAnyTypeField1TS::getMeshIteration() const
6054 return contentNotNullBase()->getMeshIteration();
6057 int MEDFileAnyTypeField1TS::getMeshOrder() const
6059 return contentNotNullBase()->getMeshOrder();
6062 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
6064 return contentNotNullBase()->getNumberOfComponents();
6067 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
6069 return contentNotNullBase()->isDealingTS(iteration,order);
6072 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
6074 return contentNotNullBase()->getDtIt();
6077 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
6079 contentNotNullBase()->fillIteration(p);
6082 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
6084 contentNotNullBase()->fillTypesOfFieldAvailable(types);
6087 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
6089 contentNotNullBase()->setInfo(infos);
6092 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
6094 return contentNotNullBase()->getInfo();
6096 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
6098 return contentNotNullBase()->getInfo();
6101 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
6103 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
6106 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
6108 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6111 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
6113 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6116 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
6118 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
6121 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
6123 return contentNotNullBase()->getTypesOfFieldAvailable();
6126 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,
6127 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6129 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
6133 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
6134 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
6135 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
6137 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
6139 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6141 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
6142 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
6143 std::size_t sz(contentsSplit.size());
6144 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6145 for(std::size_t i=0;i<sz;i++)
6147 ret[i]=shallowCpy();
6148 ret[i]->_content=contentsSplit[i];
6154 * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
6155 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6157 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
6159 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6161 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
6162 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
6163 std::size_t sz(contentsSplit.size());
6164 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6165 for(std::size_t i=0;i<sz;i++)
6167 ret[i]=shallowCpy();
6168 ret[i]->_content=contentsSplit[i];
6174 * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this.
6175 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6177 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const
6179 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6181 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !");
6182 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
6183 std::size_t sz(contentsSplit.size());
6184 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6185 for(std::size_t i=0;i<sz;i++)
6187 ret[i]=shallowCpy();
6188 ret[i]->_content=contentsSplit[i];
6193 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCopy() const
6195 MCAuto<MEDFileAnyTypeField1TS> ret=shallowCpy();
6196 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
6197 ret->_content=_content->deepCopy();
6198 ret->deepCpyGlobs(*this);
6202 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
6204 return contentNotNullBase()->copyTinyInfoFrom(field,arr);
6210 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6211 * the first field that has been read from a specified MED file.
6212 * \param [in] fileName - the name of the MED file to read.
6213 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6214 * is to delete this field using decrRef() as it is no more needed.
6215 * \throw If reading the file fails.
6217 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll)
6219 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fileName,loadAll,0));
6220 ret->contentNotNull();
6225 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6226 * a given field that has been read from a specified MED file.
6227 * \param [in] fileName - the name of the MED file to read.
6228 * \param [in] fieldName - the name of the field to read.
6229 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6230 * is to delete this field using decrRef() as it is no more needed.
6231 * \throw If reading the file fails.
6232 * \throw If there is no field named \a fieldName in the file.
6234 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6236 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fileName,fieldName,loadAll,0));
6237 ret->contentNotNull();
6242 * Returns a new instance of MEDFileField1TS holding data of a given time step of
6243 * a given field that has been read from a specified MED file.
6244 * \param [in] fileName - the name of the MED file to read.
6245 * \param [in] fieldName - the name of the field to read.
6246 * \param [in] iteration - the iteration number of a required time step.
6247 * \param [in] order - the iteration order number of required time step.
6248 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6249 * is to delete this field using decrRef() as it is no more needed.
6250 * \throw If reading the file fails.
6251 * \throw If there is no field named \a fieldName in the file.
6252 * \throw If the required time step is missing from the file.
6254 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6256 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fileName,fieldName,iteration,order,loadAll,0));
6257 ret->contentNotNull();
6262 * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6263 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6265 * Returns a new instance of MEDFileField1TS holding either a shallow copy
6266 * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
6267 * \warning this is a shallow copy constructor
6268 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
6269 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
6270 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6271 * is to delete this field using decrRef() as it is no more needed.
6273 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6275 MCAuto<MEDFileField1TS> ret=new MEDFileField1TS(other,shallowCopyOfContent);
6276 ret->contentNotNull();
6281 * Returns a new empty instance of MEDFileField1TS.
6282 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6283 * is to delete this field using decrRef() as it is no more needed.
6285 MEDFileField1TS *MEDFileField1TS::New()
6287 MCAuto<MEDFileField1TS> ret=new MEDFileField1TS;
6288 ret->contentNotNull();
6293 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
6294 * following the given input policy.
6296 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6297 * By default (true) the globals are deeply copied.
6298 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
6300 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
6302 MCAuto<MEDFileIntField1TS> ret;
6303 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6306 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
6308 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
6309 MCAuto<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
6310 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc,getFileName()));
6313 ret=MEDFileIntField1TS::New();
6315 ret->deepCpyGlobs(*this);
6317 ret->shallowCpyGlobs(*this);
6321 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const
6323 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6325 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
6326 const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
6328 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 !");
6332 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull()
6334 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6336 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
6337 MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
6339 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 !");
6343 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
6346 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
6347 if(!((DataArray*)arr))
6348 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
6349 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
6351 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6352 f->setArray(arrOutC);
6355 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MCAuto<DataArray>& arr)
6357 if(!((DataArray*)arr))
6358 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
6359 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
6361 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6366 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
6367 try:MEDFileAnyTypeField1TS(fileName,loadAll,ms)
6370 catch(INTERP_KERNEL::Exception& e)
6373 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6374 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll,ms)
6377 catch(INTERP_KERNEL::Exception& e)
6380 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6381 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll,ms)
6384 catch(INTERP_KERNEL::Exception& e)
6388 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6389 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6391 * \warning this is a shallow copy constructor
6393 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6394 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6397 catch(INTERP_KERNEL::Exception& e)
6400 MEDFileField1TS::MEDFileField1TS()
6402 _content=new MEDFileField1TSWithoutSDA;
6406 * Returns a new MEDCouplingFieldDouble of a given type lying on
6407 * mesh entities of a given dimension of the first mesh in MED file. If \a this field
6408 * has not been constructed via file reading, an exception is thrown.
6409 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6410 * \param [in] type - a spatial discretization of interest.
6411 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6412 * \param [in] renumPol - specifies how to permute values of the result field according to
6413 * the optional numbers of cells and nodes, if any. The valid values are
6414 * - 0 - do not permute.
6415 * - 1 - permute cells.
6416 * - 2 - permute nodes.
6417 * - 3 - permute cells and nodes.
6419 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6420 * caller is to delete this field using decrRef() as it is no more needed.
6421 * \throw If \a this field has not been constructed via file reading.
6422 * \throw If the MED file is not readable.
6423 * \throw If there is no mesh in the MED file.
6424 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6425 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6426 * \sa getFieldOnMeshAtLevel()
6428 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6430 if(getFileName().empty())
6431 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6432 MCAuto<DataArray> arrOut;
6433 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull());
6434 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6439 * Returns a new MEDCouplingFieldDouble of a given type lying on
6440 * the top level cells of the first mesh in MED file. If \a this field
6441 * has not been constructed via file reading, an exception is thrown.
6442 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6443 * \param [in] type - a spatial discretization of interest.
6444 * \param [in] renumPol - specifies how to permute values of the result field according to
6445 * the optional numbers of cells and nodes, if any. The valid values are
6446 * - 0 - do not permute.
6447 * - 1 - permute cells.
6448 * - 2 - permute nodes.
6449 * - 3 - permute cells and nodes.
6451 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6452 * caller is to delete this field using decrRef() as it is no more needed.
6453 * \throw If \a this field has not been constructed via file reading.
6454 * \throw If the MED file is not readable.
6455 * \throw If there is no mesh in the MED file.
6456 * \throw If no field values of the given \a type.
6457 * \throw If no field values lying on the top level support.
6458 * \sa getFieldAtLevel()
6460 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
6462 if(getFileName().empty())
6463 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6464 MCAuto<DataArray> arrOut;
6465 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull());
6466 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6471 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6472 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6473 * \param [in] type - a spatial discretization of the new field.
6474 * \param [in] mesh - the supporting mesh.
6475 * \param [in] renumPol - specifies how to permute values of the result field according to
6476 * the optional numbers of cells and nodes, if any. The valid values are
6477 * - 0 - do not permute.
6478 * - 1 - permute cells.
6479 * - 2 - permute nodes.
6480 * - 3 - permute cells and nodes.
6482 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6483 * caller is to delete this field using decrRef() as it is no more needed.
6484 * \throw If no field of \a this is lying on \a mesh.
6485 * \throw If the mesh is empty.
6486 * \throw If no field values of the given \a type are available.
6487 * \sa getFieldAtLevel()
6488 * \sa getFieldOnMeshAtLevel()
6490 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
6492 MCAuto<DataArray> arrOut;
6493 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull());
6494 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6499 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6500 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6501 * \param [in] type - a spatial discretization of interest.
6502 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6503 * \param [in] mesh - the supporting mesh.
6504 * \param [in] renumPol - specifies how to permute values of the result field according to
6505 * the optional numbers of cells and nodes, if any. The valid values are
6506 * - 0 - do not permute.
6507 * - 1 - permute cells.
6508 * - 2 - permute nodes.
6509 * - 3 - permute cells and nodes.
6511 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6512 * caller is to delete this field using decrRef() as it is no more needed.
6513 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6514 * \throw If no field of \a this is lying on \a mesh.
6515 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6516 * \sa getFieldAtLevel()
6517 * \sa getFieldOnMeshAtLevel()
6519 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
6521 MCAuto<DataArray> arrOut;
6522 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull());
6523 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6528 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6529 * This method is called "Old" because in MED3 norm a field has only one meshName
6530 * attached, so this method is for readers of MED2 files. If \a this field
6531 * has not been constructed via file reading, an exception is thrown.
6532 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6533 * \param [in] type - a spatial discretization of interest.
6534 * \param [in] mName - a name of the supporting mesh.
6535 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6536 * \param [in] renumPol - specifies how to permute values of the result field according to
6537 * the optional numbers of cells and nodes, if any. The valid values are
6538 * - 0 - do not permute.
6539 * - 1 - permute cells.
6540 * - 2 - permute nodes.
6541 * - 3 - permute cells and nodes.
6543 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6544 * caller is to delete this field using decrRef() as it is no more needed.
6545 * \throw If the MED file is not readable.
6546 * \throw If there is no mesh named \a mName in the MED file.
6547 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6548 * \throw If \a this field has not been constructed via file reading.
6549 * \throw If no field of \a this is lying on the mesh named \a mName.
6550 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6551 * \sa getFieldAtLevel()
6553 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
6555 if(getFileName().empty())
6556 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6557 MCAuto<DataArray> arrOut;
6558 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
6559 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6564 * Returns values and a profile of the field of a given type lying on a given support.
6565 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6566 * \param [in] type - a spatial discretization of the field.
6567 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6568 * \param [in] mesh - the supporting mesh.
6569 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6570 * field of interest lies on. If the field lies on all entities of the given
6571 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6572 * using decrRef() as it is no more needed.
6573 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6574 * field. The caller is to delete this array using decrRef() as it is no more needed.
6575 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6576 * \throw If no field of \a this is lying on \a mesh.
6577 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6579 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6581 MCAuto<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6582 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
6586 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6587 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6588 * "Sort By Type"), if not, an exception is thrown.
6589 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6590 * \param [in] field - the field to add to \a this.
6591 * \throw If the name of \a field is empty.
6592 * \throw If the data array of \a field is not set.
6593 * \throw If the data array is already allocated but has different number of components
6595 * \throw If the underlying mesh of \a field has no name.
6596 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6598 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
6601 contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
6605 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6606 * can be an aggregation of several MEDCouplingFieldDouble instances.
6607 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6608 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6611 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6612 * A new profile is added only if no equal profile is missing.
6613 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6614 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
6615 * \param [in] mesh - the supporting mesh of \a field.
6616 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6617 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6618 * \throw If either \a field or \a mesh or \a profile has an empty name.
6619 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6620 * \throw If the data array of \a field is not set.
6621 * \throw If the data array of \a this is already allocated but has different number of
6622 * components than \a field.
6623 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6624 * \sa setFieldNoProfileSBT()
6626 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6629 contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6632 MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const
6634 return new MEDFileField1TS(*this);
6637 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const
6639 return contentNotNull()->getUndergroundDataArrayDouble();
6642 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
6644 return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
6647 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6648 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6650 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6653 //= MEDFileIntField1TS
6655 MEDFileIntField1TS *MEDFileIntField1TS::New()
6657 MCAuto<MEDFileIntField1TS> ret=new MEDFileIntField1TS;
6658 ret->contentNotNull();
6662 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll)
6664 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,loadAll,0));
6665 ret->contentNotNull();
6669 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6671 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,fieldName,loadAll,0));
6672 ret->contentNotNull();
6676 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6678 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,fieldName,iteration,order,loadAll,0));
6679 ret->contentNotNull();
6683 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6685 MCAuto<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6686 ret->contentNotNull();
6690 MEDFileIntField1TS::MEDFileIntField1TS()
6692 _content=new MEDFileIntField1TSWithoutSDA;
6695 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
6696 try:MEDFileAnyTypeField1TS(fileName,loadAll,ms)
6699 catch(INTERP_KERNEL::Exception& e)
6702 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6703 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll,ms)
6706 catch(INTERP_KERNEL::Exception& e)
6709 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6710 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll,ms)
6713 catch(INTERP_KERNEL::Exception& e)
6717 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6718 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6720 * \warning this is a shallow copy constructor
6722 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6726 MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const
6728 return new MEDFileIntField1TS(*this);
6732 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
6733 * following the given input policy.
6735 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6736 * By default (true) the globals are deeply copied.
6737 * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
6739 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const
6741 MCAuto<MEDFileField1TS> ret;
6742 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6745 const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
6747 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
6748 MCAuto<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
6749 ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc,getFileName()));
6752 ret=MEDFileField1TS::New();
6754 ret->deepCpyGlobs(*this);
6756 ret->shallowCpyGlobs(*this);
6761 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6762 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6763 * "Sort By Type"), if not, an exception is thrown.
6764 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6765 * \param [in] field - the field to add to \a this. The field double values are ignored.
6766 * \param [in] arrOfVals - the values of the field \a field used.
6767 * \throw If the name of \a field is empty.
6768 * \throw If the data array of \a field is not set.
6769 * \throw If the data array is already allocated but has different number of components
6771 * \throw If the underlying mesh of \a field has no name.
6772 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6774 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals)
6777 contentNotNull()->setFieldNoProfileSBT(field,arrOfVals,*this,*contentNotNull());
6781 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6782 * can be an aggregation of several MEDCouplingFieldDouble instances.
6783 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6784 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6787 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6788 * A new profile is added only if no equal profile is missing.
6789 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6790 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
6791 * \param [in] arrOfVals - the values of the field \a field used.
6792 * \param [in] mesh - the supporting mesh of \a field.
6793 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6794 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6795 * \throw If either \a field or \a mesh or \a profile has an empty name.
6796 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6797 * \throw If the data array of \a field is not set.
6798 * \throw If the data array of \a this is already allocated but has different number of
6799 * components than \a field.
6800 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6801 * \sa setFieldNoProfileSBT()
6803 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6806 contentNotNull()->setFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6809 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const
6811 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6813 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
6814 const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
6816 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 !");
6820 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
6822 if(getFileName().empty())
6823 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6824 MCAuto<DataArray> arrOut2;
6825 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut2,*contentNotNull());
6826 DataArrayInt *arrOutC=dynamic_cast<DataArrayInt *>((DataArray *)arrOut2);
6828 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : mismatch between dataArrays type and MEDFileIntField1TS ! Expected int32 !");
6830 arrOut->incrRef(); // arrOut2 dies at the end of the func
6834 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MCAuto<DataArray>& arr)
6836 if(!((DataArray *)arr))
6837 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
6838 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>((DataArray *)arr);
6840 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
6846 * Returns a new MEDCouplingFieldDouble of a given type lying on
6847 * the top level cells of the first mesh in MED file. If \a this field
6848 * has not been constructed via file reading, an exception is thrown.
6849 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6850 * \param [in] type - a spatial discretization of interest.
6851 * \param [out] arrOut - the DataArrayInt containing values of field.
6852 * \param [in] renumPol - specifies how to permute values of the result field according to
6853 * the optional numbers of cells and nodes, if any. The valid values are
6854 * - 0 - do not permute.
6855 * - 1 - permute cells.
6856 * - 2 - permute nodes.
6857 * - 3 - permute cells and nodes.
6859 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6860 * caller is to delete this field using decrRef() as it is no more needed.
6861 * \throw If \a this field has not been constructed via file reading.
6862 * \throw If the MED file is not readable.
6863 * \throw If there is no mesh in the MED file.
6864 * \throw If no field values of the given \a type.
6865 * \throw If no field values lying on the top level support.
6866 * \sa getFieldAtLevel()
6868 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, DataArrayInt* &arrOut, int renumPol) const
6870 if(getFileName().empty())
6871 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6872 MCAuto<DataArray> arr;
6873 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNull());
6874 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6879 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6880 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6881 * \param [in] type - a spatial discretization of the new field.
6882 * \param [in] mesh - the supporting mesh.
6883 * \param [out] arrOut - the DataArrayInt containing values of field.
6884 * \param [in] renumPol - specifies how to permute values of the result field according to
6885 * the optional numbers of cells and nodes, if any. The valid values are
6886 * - 0 - do not permute.
6887 * - 1 - permute cells.
6888 * - 2 - permute nodes.
6889 * - 3 - permute cells and nodes.
6891 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6892 * caller is to delete this field using decrRef() as it is no more needed.
6893 * \throw If no field of \a this is lying on \a mesh.
6894 * \throw If the mesh is empty.
6895 * \throw If no field values of the given \a type are available.
6896 * \sa getFieldAtLevel()
6897 * \sa getFieldOnMeshAtLevel()
6899 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
6901 MCAuto<DataArray> arr;
6902 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNull());
6903 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6908 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6909 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6910 * \param [in] type - a spatial discretization of interest.
6911 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6912 * \param [out] arrOut - the DataArrayInt containing values of field.
6913 * \param [in] mesh - the supporting mesh.
6914 * \param [in] renumPol - specifies how to permute values of the result field according to
6915 * the optional numbers of cells and nodes, if any. The valid values are
6916 * - 0 - do not permute.
6917 * - 1 - permute cells.
6918 * - 2 - permute nodes.
6919 * - 3 - permute cells and nodes.
6921 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6922 * caller is to delete this field using decrRef() as it is no more needed.
6923 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6924 * \throw If no field of \a this is lying on \a mesh.
6925 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6926 * \sa getFieldAtLevel()
6927 * \sa getFieldOnMeshAtLevel()
6929 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
6931 MCAuto<DataArray> arr;
6932 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNull());
6933 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6938 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6939 * This method is called "Old" because in MED3 norm a field has only one meshName
6940 * attached, so this method is for readers of MED2 files. If \a this field
6941 * has not been constructed via file reading, an exception is thrown.
6942 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6943 * \param [in] type - a spatial discretization of interest.
6944 * \param [in] mName - a name of the supporting mesh.
6945 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6946 * \param [out] arrOut - the DataArrayInt containing values of field.
6947 * \param [in] renumPol - specifies how to permute values of the result field according to
6948 * the optional numbers of cells and nodes, if any. The valid values are
6949 * - 0 - do not permute.
6950 * - 1 - permute cells.
6951 * - 2 - permute nodes.
6952 * - 3 - permute cells and nodes.
6954 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6955 * caller is to delete this field using decrRef() as it is no more needed.
6956 * \throw If the MED file is not readable.
6957 * \throw If there is no mesh named \a mName in the MED file.
6958 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6959 * \throw If \a this field has not been constructed via file reading.
6960 * \throw If no field of \a this is lying on the mesh named \a mName.
6961 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6962 * \sa getFieldAtLevel()
6964 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
6966 if(getFileName().empty())
6967 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6968 MCAuto<DataArray> arr;
6969 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNull());
6970 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6975 * Returns values and a profile of the field of a given type lying on a given support.
6976 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6977 * \param [in] type - a spatial discretization of the field.
6978 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6979 * \param [in] mesh - the supporting mesh.
6980 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6981 * field of interest lies on. If the field lies on all entities of the given
6982 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6983 * using decrRef() as it is no more needed.
6984 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
6985 * field. The caller is to delete this array using decrRef() as it is no more needed.
6986 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6987 * \throw If no field of \a this is lying on \a mesh.
6988 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6990 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6992 MCAuto<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6993 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6996 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull()
6998 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7000 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
7001 MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
7003 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 !");
7007 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const
7009 return contentNotNull()->getUndergroundDataArrayInt();
7012 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
7014 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
7018 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileFieldNameScope(fieldName)
7023 * \param [in] fieldId field id in C mode
7025 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
7027 med_field_type typcha;
7028 std::string dtunitOut;
7029 int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,"",fieldId,false,_name,typcha,_infos,dtunitOut);
7030 setDtUnit(dtunitOut.c_str());
7031 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities);
7034 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 std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
7035 try:MEDFileFieldNameScope(fieldName),_infos(infos)
7037 setDtUnit(dtunit.c_str());
7038 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities);
7040 catch(INTERP_KERNEL::Exception& e)
7045 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
7047 std::size_t ret(_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MCAuto<MEDFileField1TSWithoutSDA>));
7048 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7049 ret+=(*it).capacity();
7053 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
7055 std::vector<const BigMemoryObject *> ret;
7056 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7057 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
7062 * 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
7065 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
7067 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7068 ret->setInfo(_infos);
7069 int sz=(int)_time_steps.size();
7070 for(const int *id=startIds;id!=endIds;id++)
7072 if(*id>=0 && *id<sz)
7074 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
7075 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7079 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7081 ret->pushBackTimeStep(tse2);
7085 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
7086 oss << " ! Should be in [0," << sz << ") !";
7087 throw INTERP_KERNEL::Exception(oss.str().c_str());
7090 if(ret->getNumberOfTS()>0)
7091 ret->synchronizeNameScope();
7092 ret->copyNameScope(*this);
7097 * 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
7100 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
7102 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
7103 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7104 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7105 ret->setInfo(_infos);
7106 int sz=(int)_time_steps.size();
7108 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
7112 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
7113 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7117 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7119 ret->pushBackTimeStep(tse2);
7123 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
7124 oss << " ! Should be in [0," << sz << ") !";
7125 throw INTERP_KERNEL::Exception(oss.str().c_str());
7128 if(ret->getNumberOfTS()>0)
7129 ret->synchronizeNameScope();
7130 ret->copyNameScope(*this);
7134 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7137 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7138 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7140 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7143 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7144 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
7145 ids->pushBackSilent(id);
7147 return buildFromTimeStepIds(ids->begin(),ids->end());
7150 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7153 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7154 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7156 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7159 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7160 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
7161 ids->pushBackSilent(id);
7163 return buildFromTimeStepIds(ids->begin(),ids->end());
7166 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
7168 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7170 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7173 if(cur->presenceOfMultiDiscPerGeoType())
7179 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
7184 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
7189 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
7192 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7194 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
7195 if(pt->isDealingTS(iteration,order))
7198 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
7199 std::vector< std::pair<int,int> > vp=getIterations();
7200 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
7201 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
7202 throw INTERP_KERNEL::Exception(oss.str().c_str());
7205 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
7207 return *_time_steps[getTimeStepPos(iteration,order)];
7210 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
7212 return *_time_steps[getTimeStepPos(iteration,order)];
7215 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const
7217 if(_time_steps.empty())
7218 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
7219 return _time_steps[0]->getMeshName();
7222 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const std::string& newMeshName)
7224 std::string oldName(getMeshName());
7225 std::vector< std::pair<std::string,std::string> > v(1);
7226 v[0].first=oldName; v[0].second=newMeshName;
7230 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
7233 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7235 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7237 ret=cur->changeMeshNames(modifTab) || ret;
7243 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
7245 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
7247 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
7251 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
7253 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7255 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
7258 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
7259 MEDFileFieldGlobsReal& glob)
7262 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7264 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
7266 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
7271 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7273 std::string startLine(bkOffset,' ');
7274 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
7276 oss << " (" << fmtsId << ")";
7277 oss << " has the following name: \"" << _name << "\"." << std::endl;
7278 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
7279 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7281 oss << startLine << " - \"" << *it << "\"" << std::endl;
7284 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7286 std::string chapter(17,'0'+i);
7287 oss << startLine << chapter << std::endl;
7288 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7290 cur->simpleRepr(bkOffset+2,oss,i);
7292 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
7293 oss << startLine << chapter << std::endl;
7297 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
7299 std::size_t sz=_time_steps.size();
7300 std::vector< std::pair<int,int> > ret(sz);
7302 for(std::size_t i=0;i<sz;i++)
7304 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
7307 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
7311 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
7312 throw INTERP_KERNEL::Exception(oss.str().c_str());
7318 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MCAuto<MEDFileAnyTypeField1TSWithoutSDA>& tse)
7320 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
7322 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
7323 checkCoherencyOfType(tse2);
7324 if(_time_steps.empty())
7326 setName(tse2->getName().c_str());
7327 setInfo(tse2->getInfo());
7329 checkThatComponentsMatch(tse2->getInfo());
7330 _time_steps.push_back(tse);
7333 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
7335 std::size_t nbOfCompo=_infos.size();
7336 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7338 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7341 if((cur->getInfo()).size()!=nbOfCompo)
7343 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
7344 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
7345 throw INTERP_KERNEL::Exception(oss.str().c_str());
7347 cur->copyNameScope(*this);
7352 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
7354 _time_steps.resize(nbPdt);
7355 for(int i=0;i<nbPdt;i++)
7357 std::vector< std::pair<int,int> > ts;
7358 med_int numdt=0,numo=0;
7359 med_int meshIt=0,meshOrder=0;
7361 MEDFILESAFECALLERRD0(MEDfieldComputingStepMeshInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder));
7366 _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7371 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7375 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
7378 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities);
7380 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entities);
7384 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
7386 if(_time_steps.empty())
7387 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
7388 checkThatNbOfCompoOfTSMatchThis();
7389 std::vector<std::string> infos(getInfo());
7390 int nbComp=infos.size();
7391 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7392 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7393 for(int i=0;i<nbComp;i++)
7395 std::string info=infos[i];
7397 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7398 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7399 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7402 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7403 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
7404 int nbOfTS=_time_steps.size();
7405 for(int i=0;i<nbOfTS;i++)
7406 _time_steps[i]->writeLL(fid,opts,*this);
7409 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
7411 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7413 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7415 elt->loadBigArraysRecursively(fid,nasc);
7419 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
7421 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7423 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7425 elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7429 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
7431 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7433 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7435 elt->unloadArrays();
7439 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7441 return _time_steps.size();
7444 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
7446 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7447 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7449 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7451 newTS.push_back(*it);
7456 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
7458 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7459 int maxId=(int)_time_steps.size();
7461 std::set<int> idsToDel;
7462 for(const int *id=startIds;id!=endIds;id++,ii++)
7464 if(*id>=0 && *id<maxId)
7466 idsToDel.insert(*id);
7470 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7471 throw INTERP_KERNEL::Exception(oss.str().c_str());
7474 for(int iii=0;iii<maxId;iii++)
7475 if(idsToDel.find(iii)==idsToDel.end())
7476 newTS.push_back(_time_steps[iii]);
7480 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
7482 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7483 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7484 if(nbOfEntriesToKill==0)
7486 std::size_t sz=_time_steps.size();
7487 std::vector<bool> b(sz,true);
7489 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7491 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7492 for(std::size_t i=0;i<sz;i++)
7494 newTS.push_back(_time_steps[i]);
7498 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
7501 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
7502 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7504 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7508 tmp->getTime(it2,ord);
7509 if(it2==iteration && order==ord)
7512 oss << "(" << it2 << "," << ord << "), ";
7515 throw INTERP_KERNEL::Exception(oss.str().c_str());
7518 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
7521 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
7523 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7525 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7529 double ti=tmp->getTime(it2,ord);
7530 if(fabs(time-ti)<eps)
7536 throw INTERP_KERNEL::Exception(oss.str().c_str());
7539 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
7541 int lgth=_time_steps.size();
7542 std::vector< std::pair<int,int> > ret(lgth);
7543 for(int i=0;i<lgth;i++)
7544 _time_steps[i]->fillIteration(ret[i]);
7549 * 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'
7550 * This method returns two things.
7551 * - The absolute dimension of 'this' in first parameter.
7552 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7553 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
7555 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7556 * Only these 3 discretizations will be taken into account here.
7558 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7559 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7560 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7562 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7563 * 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'.
7565 * Let's consider the typical following case :
7566 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7567 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7568 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7570 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7572 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7574 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7575 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7576 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7577 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7579 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
7581 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7584 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
7586 if(pos<0 || pos>=(int)_time_steps.size())
7588 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7589 throw INTERP_KERNEL::Exception(oss.str().c_str());
7591 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7594 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7595 oss << "\nTry to use following method eraseEmptyTS !";
7596 throw INTERP_KERNEL::Exception(oss.str().c_str());
7601 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
7603 if(pos<0 || pos>=(int)_time_steps.size())
7605 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7606 throw INTERP_KERNEL::Exception(oss.str().c_str());
7608 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7611 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7612 oss << "\nTry to use following method eraseEmptyTS !";
7613 throw INTERP_KERNEL::Exception(oss.str().c_str());
7618 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
7620 std::vector<std::string> ret;
7621 std::set<std::string> ret2;
7622 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7624 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
7625 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7626 if(ret2.find(*it2)==ret2.end())
7628 ret.push_back(*it2);
7635 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
7637 std::vector<std::string> ret;
7638 std::set<std::string> ret2;
7639 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7641 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
7642 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7643 if(ret2.find(*it2)==ret2.end())
7645 ret.push_back(*it2);
7652 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
7654 std::vector<std::string> ret;
7655 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7657 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
7658 ret.insert(ret.end(),tmp.begin(),tmp.end());
7663 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
7665 std::vector<std::string> ret;
7666 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7668 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
7669 ret.insert(ret.end(),tmp.begin(),tmp.end());
7674 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7676 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7677 (*it)->changePflsRefsNamesGen2(mapOfModif);
7680 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7682 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7683 (*it)->changeLocsRefsNamesGen2(mapOfModif);
7686 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
7688 int lgth=_time_steps.size();
7689 std::vector< std::vector<TypeOfField> > ret(lgth);
7690 for(int i=0;i<lgth;i++)
7691 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
7696 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
7698 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
7700 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
7703 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCopy() const
7705 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
7707 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7709 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
7710 ret->_time_steps[i]=(*it)->deepCopy();
7715 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
7717 std::size_t sz(_infos.size()),sz2(_time_steps.size());
7718 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7719 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7720 for(std::size_t i=0;i<sz;i++)
7722 ret[i]=shallowCpy();
7723 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7725 for(std::size_t i=0;i<sz2;i++)
7727 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7730 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7731 throw INTERP_KERNEL::Exception(oss.str().c_str());
7735 for(std::size_t i=0;i<sz;i++)
7736 for(std::size_t j=0;j<sz2;j++)
7737 ret[i]->_time_steps[j]=ts[j][i];
7742 * This method splits into discretization each time steps in \a this.
7743 * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
7745 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
7747 std::size_t sz(_time_steps.size());
7748 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7749 for(std::size_t i=0;i<sz;i++)
7751 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7754 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
7755 throw INTERP_KERNEL::Exception(oss.str().c_str());
7757 items[i]=timeStep->splitDiscretizations();
7760 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
7761 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
7762 std::vector< TypeOfField > types;
7763 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7764 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7766 std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
7768 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
7769 std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
7770 if(it2==types.end())
7771 types.push_back(ts[0]);
7773 ret.resize(types.size()); ret2.resize(types.size());
7774 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7775 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7777 TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
7778 std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
7779 ret2[pos].push_back(*it1);
7781 for(std::size_t i=0;i<types.size();i++)
7783 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7784 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
7785 elt->pushBackTimeStep(*it1);//also updates infos in elt
7787 elt->MEDFileFieldNameScope::operator=(*this);
7793 * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
7795 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
7797 std::size_t sz(_time_steps.size());
7798 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7799 std::size_t szOut(std::numeric_limits<std::size_t>::max());
7800 for(std::size_t i=0;i<sz;i++)
7802 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7805 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
7806 throw INTERP_KERNEL::Exception(oss.str().c_str());
7808 items[i]=timeStep->splitMultiDiscrPerGeoTypes();
7809 if(szOut==std::numeric_limits<std::size_t>::max())
7810 szOut=items[i].size();
7812 if(items[i].size()!=szOut)
7813 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
7815 if(szOut==std::numeric_limits<std::size_t>::max())
7816 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
7817 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
7818 for(std::size_t i=0;i<szOut;i++)
7820 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7821 for(std::size_t j=0;j<sz;j++)
7822 elt->pushBackTimeStep(items[j][i]);
7824 elt->MEDFileFieldNameScope::operator=(*this);
7829 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
7831 _name=field->getName();
7833 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
7835 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
7836 _infos=arr->getInfoOnComponents();
7839 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
7841 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
7842 if(_name!=field->getName())
7844 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
7845 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
7846 throw INTERP_KERNEL::Exception(oss.str().c_str());
7849 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
7850 checkThatComponentsMatch(arr->getInfoOnComponents());
7853 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
7855 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
7856 if(getInfo().size()!=compos.size())
7858 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
7859 oss << " number of components of element to append (" << compos.size() << ") !";
7860 throw INTERP_KERNEL::Exception(oss.str().c_str());
7864 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
7865 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
7866 oss << " But compo in input fields are : ";
7867 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
7869 throw INTERP_KERNEL::Exception(oss.str().c_str());
7873 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
7875 std::size_t sz=_infos.size();
7877 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
7879 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7881 if(elt->getInfo().size()!=sz)
7883 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
7884 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
7885 throw INTERP_KERNEL::Exception(oss.str().c_str());
7890 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
7893 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7894 if(!_time_steps.empty())
7895 checkCoherencyOfTinyInfo(field,arr);
7896 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
7897 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7898 objC->setFieldNoProfileSBT(field,arr,glob,*this);
7899 copyTinyInfoFrom(field,arr);
7900 _time_steps.push_back(obj);
7903 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
7906 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7907 if(!_time_steps.empty())
7908 checkCoherencyOfTinyInfo(field,arr);
7909 MEDFileField1TSWithoutSDA *objC=new MEDFileField1TSWithoutSDA;
7910 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7911 objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
7912 copyTinyInfoFrom(field,arr);
7913 _time_steps.push_back(obj);
7916 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ts)
7918 int sz=(int)_time_steps.size();
7921 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
7922 throw INTERP_KERNEL::Exception(oss.str().c_str());
7924 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
7927 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
7929 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
7930 throw INTERP_KERNEL::Exception(oss.str().c_str());
7936 //= MEDFileFieldMultiTSWithoutSDA
7938 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 std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
7940 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
7943 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
7947 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7952 * \param [in] fieldId field id in C mode
7954 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
7955 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
7958 catch(INTERP_KERNEL::Exception& e)
7961 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 std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
7962 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
7965 catch(INTERP_KERNEL::Exception& e)
7968 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
7970 return new MEDFileField1TSWithoutSDA;
7973 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
7976 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7977 const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
7979 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
7982 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const
7984 return MEDFileField1TSWithoutSDA::TYPE_STR;
7987 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const
7989 return new MEDFileFieldMultiTSWithoutSDA(*this);
7992 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const
7994 return new MEDFileFieldMultiTSWithoutSDA;
7998 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
7999 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
8001 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
8003 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
8004 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8006 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
8007 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
8010 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
8012 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
8013 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8015 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8017 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8020 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
8022 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
8023 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
8024 ret->setIteration(i,elt);
8030 //= MEDFileAnyTypeFieldMultiTS
8032 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
8036 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
8037 try:MEDFileFieldGlobsReal(fileName)
8039 MEDFileUtilities::CheckFileForRead(fileName);
8040 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8041 _content=BuildContentFrom(fid,fileName,loadAll,ms);
8044 catch(INTERP_KERNEL::Exception& e)
8049 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8051 med_field_type typcha;
8052 std::vector<std::string> infos;
8055 MEDFileAnyTypeField1TS::LocateField(fid,fileName,fieldName,i,typcha,infos,dtunit);
8056 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8061 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8066 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8071 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::BuildContentFrom(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
8072 throw INTERP_KERNEL::Exception(oss.str().c_str());
8075 ret->setDtUnit(dtunit.c_str());
8079 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
8081 med_field_type typcha;
8083 std::vector<std::string> infos;
8084 std::string dtunit,fieldName;
8085 MEDFileAnyTypeField1TS::LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
8086 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8091 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8096 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8101 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::BuildContentFrom(fileName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of the first field is not in [MED_FLOAT64, MED_INT32] !";
8102 throw INTERP_KERNEL::Exception(oss.str().c_str());
8105 ret->setDtUnit(dtunit.c_str());
8109 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, const std::string& fileName)
8112 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
8113 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
8115 MCAuto<MEDFileFieldMultiTS> ret=MEDFileFieldMultiTS::New();
8116 ret->setFileName(fileName);
8117 ret->_content=c; c->incrRef();
8120 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
8122 MCAuto<MEDFileIntFieldMultiTS> ret=MEDFileIntFieldMultiTS::New();
8123 ret->setFileName(fileName);
8124 ret->_content=c; c->incrRef();
8127 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
8130 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8131 try:MEDFileFieldGlobsReal(fileName)
8133 MEDFileUtilities::CheckFileForRead(fileName);
8134 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8135 _content=BuildContentFrom(fid,fileName,fieldName,loadAll,ms,entities);
8138 catch(INTERP_KERNEL::Exception& e)
8143 //= MEDFileIntFieldMultiTSWithoutSDA
8145 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 std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8147 return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8150 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
8154 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8158 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 std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8159 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8162 catch(INTERP_KERNEL::Exception& e)
8166 * \param [in] fieldId field id in C mode
8168 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8169 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8172 catch(INTERP_KERNEL::Exception& e)
8175 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8177 return new MEDFileIntField1TSWithoutSDA;
8180 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8183 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8184 const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
8186 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8189 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const
8191 return MEDFileIntField1TSWithoutSDA::TYPE_STR;
8194 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const
8196 return new MEDFileIntFieldMultiTSWithoutSDA(*this);
8199 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const
8201 return new MEDFileIntFieldMultiTSWithoutSDA;
8204 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const
8206 MCAuto<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
8207 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8209 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8211 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8214 const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
8216 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
8217 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
8218 ret->setIteration(i,elt);
8224 //= MEDFileAnyTypeFieldMultiTS
8227 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
8228 * that has been read from a specified MED file.
8229 * \param [in] fileName - the name of the MED file to read.
8230 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8231 * is to delete this field using decrRef() as it is no more needed.
8232 * \throw If reading the file fails.
8234 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
8236 MEDFileUtilities::CheckFileForRead(fileName);
8237 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8238 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll,0);
8239 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
8240 ret->loadGlobals(fid);
8245 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
8246 * that has been read from a specified MED file.
8247 * \param [in] fileName - the name of the MED file to read.
8248 * \param [in] fieldName - the name of the field to read.
8249 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8250 * is to delete this field using decrRef() as it is no more needed.
8251 * \throw If reading the file fails.
8252 * \throw If there is no field named \a fieldName in the file.
8254 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8256 MEDFileUtilities::CheckFileForRead(fileName);
8257 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8258 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fileName,fieldName,loadAll,0,0));
8259 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
8260 ret->loadGlobals(fid);
8265 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8266 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8268 * \warning this is a shallow copy constructor
8270 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8272 if(!shallowCopyOfContent)
8274 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
8275 otherPtr->incrRef();
8276 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
8280 _content=other.shallowCpy();
8284 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
8286 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8288 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
8292 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
8294 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8296 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
8300 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
8302 return contentNotNullBase()->getPflsReallyUsed2();
8305 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
8307 return contentNotNullBase()->getLocsReallyUsed2();
8310 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
8312 return contentNotNullBase()->getPflsReallyUsedMulti2();
8315 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
8317 return contentNotNullBase()->getLocsReallyUsedMulti2();
8320 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8322 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
8325 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8327 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
8330 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
8332 return contentNotNullBase()->getNumberOfTS();
8335 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
8337 contentNotNullBase()->eraseEmptyTS();
8340 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
8342 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
8345 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
8347 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
8350 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
8352 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
8353 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8358 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
8360 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
8361 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8366 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
8368 return contentNotNullBase()->getIterations();
8371 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
8373 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
8374 pushBackTimeStep(*it);
8377 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
8380 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
8381 int nbOfTS(fmts->getNumberOfTS());
8382 for(int i=0;i<nbOfTS;i++)
8384 MCAuto<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
8385 pushBackTimeStep(elt);
8389 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
8392 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
8393 checkCoherencyOfType(f1ts);
8395 MCAuto<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
8396 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
8398 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
8399 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
8400 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
8401 _content->pushBackTimeStep(cSafe);
8402 appendGlobs(*f1ts,1e-12);
8405 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
8407 contentNotNullBase()->synchronizeNameScope();
8410 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
8412 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
8415 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
8417 return contentNotNullBase()->getPosGivenTime(time,eps);
8420 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8422 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
8425 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
8427 return contentNotNullBase()->getTypesOfFieldAvailable();
8430 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
8432 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
8435 std::string MEDFileAnyTypeFieldMultiTS::getName() const
8437 return contentNotNullBase()->getName();
8440 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
8442 contentNotNullBase()->setName(name);
8445 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
8447 return contentNotNullBase()->getDtUnit();
8450 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
8452 contentNotNullBase()->setDtUnit(dtUnit);
8455 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8457 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
8460 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
8462 return contentNotNullBase()->getTimeSteps(ret1);
8465 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
8467 return contentNotNullBase()->getMeshName();
8470 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
8472 contentNotNullBase()->setMeshName(newMeshName);
8475 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
8477 return contentNotNullBase()->changeMeshNames(modifTab);
8480 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
8482 return contentNotNullBase()->getInfo();
8485 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
8487 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
8490 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
8492 return contentNotNullBase()->setInfo(info);
8495 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
8497 const std::vector<std::string> ret=getInfo();
8498 return (int)ret.size();
8501 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
8503 writeGlobals(fid,*this);
8504 contentNotNullBase()->writeLL(fid,*this);
8508 * Writes \a this field into a MED file specified by its name.
8509 * \param [in] fileName - the MED file name.
8510 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
8511 * - 2 - erase; an existing file is removed.
8512 * - 1 - append; same data should not be present in an existing file.
8513 * - 0 - overwrite; same data present in an existing file is overwritten.
8514 * \throw If the field name is not set.
8515 * \throw If no field data is set.
8516 * \throw If \a mode == 1 and the same data is present in an existing file.
8518 void MEDFileAnyTypeFieldMultiTS::write(const std::string& fileName, int mode) const
8520 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
8521 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
8526 * This method alloc the arrays and load potentially huge arrays contained in this field.
8527 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
8528 * This method can be also called to refresh or reinit values from a file.
8530 * \throw If the fileName is not set or points to a non readable MED file.
8532 void MEDFileAnyTypeFieldMultiTS::loadArrays()
8534 if(getFileName().empty())
8535 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
8536 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
8537 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
8541 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
8542 * But once data loaded once, this method does nothing.
8544 * \throw If the fileName is not set or points to a non readable MED file.
8545 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
8547 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
8549 if(!getFileName().empty())
8551 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
8552 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
8557 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
8558 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
8559 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
8561 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
8563 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
8565 contentNotNullBase()->unloadArrays();
8569 * 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.
8570 * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
8571 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
8573 * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
8575 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
8577 if(!getFileName().empty())
8578 contentNotNullBase()->unloadArrays();
8581 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
8583 std::ostringstream oss;
8584 contentNotNullBase()->simpleRepr(0,oss,-1);
8585 simpleReprGlobs(oss);
8589 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
8591 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
8594 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
8596 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
8597 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
8602 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
8603 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8604 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
8606 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
8608 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8610 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
8611 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
8612 std::size_t sz(contentsSplit.size());
8613 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8614 for(std::size_t i=0;i<sz;i++)
8616 ret[i]=shallowCpy();
8617 ret[i]->_content=contentsSplit[i];
8623 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
8624 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8626 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
8628 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8630 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
8631 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
8632 std::size_t sz(contentsSplit.size());
8633 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8634 for(std::size_t i=0;i<sz;i++)
8636 ret[i]=shallowCpy();
8637 ret[i]->_content=contentsSplit[i];
8643 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
8644 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8646 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
8648 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8650 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
8651 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
8652 std::size_t sz(contentsSplit.size());
8653 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8654 for(std::size_t i=0;i<sz;i++)
8656 ret[i]=shallowCpy();
8657 ret[i]->_content=contentsSplit[i];
8662 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCopy() const
8664 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8665 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
8666 ret->_content=_content->deepCopy();
8667 ret->deepCpyGlobs(*this);
8671 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
8677 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8678 * \param [in] iteration - the iteration number of a required time step.
8679 * \param [in] order - the iteration order number of required time step.
8680 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
8681 * delete this field using decrRef() as it is no more needed.
8682 * \throw If there is no required time step in \a this field.
8684 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
8686 int pos=getPosOfTimeStep(iteration,order);
8687 return getTimeStepAtPos(pos);
8691 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8692 * \param [in] time - the time of the time step of interest.
8693 * \param [in] eps - a precision used to compare time values.
8694 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8695 * delete this field using decrRef() as it is no more needed.
8696 * \throw If there is no required time step in \a this field.
8698 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
8700 int pos=getPosGivenTime(time,eps);
8701 return getTimeStepAtPos(pos);
8705 * 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.
8706 * The float64 value of time attached to the pair of integers are not considered here.
8707 * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
8709 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
8710 * \throw If there is a null pointer in \a vectFMTS.
8712 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
8714 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
8715 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8716 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8717 while(!lstFMTS.empty())
8719 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8720 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8722 throw INTERP_KERNEL::Exception(msg);
8723 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
8724 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8725 elt.push_back(curIt); it=lstFMTS.erase(it);
8726 while(it!=lstFMTS.end())
8730 throw INTERP_KERNEL::Exception(msg);
8731 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
8733 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8743 * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
8744 * All returned instances in a subvector can be safely loaded, rendered along time
8745 * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
8746 * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
8747 * 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).
8748 * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
8749 * 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.
8751 * \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().
8752 * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
8753 * \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.
8754 * \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.
8756 * \throw If an element in \a vectFMTS has not only one spatial discretization set.
8757 * \throw If an element in \a vectFMTS change of spatial discretization along time.
8758 * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
8759 * \thorw If some elements in \a vectFMTS do not have the same times steps.
8760 * \throw If mesh is null.
8761 * \throw If an element in \a vectFMTS is null.
8762 * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
8764 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& fsc)
8766 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
8768 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
8769 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8770 if(vectFMTS.empty())
8772 std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
8773 MEDFileAnyTypeFieldMultiTS *frstElt(*it);
8775 throw INTERP_KERNEL::Exception(msg);
8777 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
8778 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
8779 for(;it!=vectFMTS.end();it++,i++)
8782 throw INTERP_KERNEL::Exception(msg);
8783 TypeOfField tof0,tof1;
8784 if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
8787 vectFMTSNotNodes.push_back(*it);
8789 vectFMTSNodes.push_back(*it);
8792 vectFMTSNotNodes.push_back(*it);
8794 std::vector< MCAuto<MEDFileFastCellSupportComparator> > cmps;
8795 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
8797 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
8800 bool isFetched(false);
8801 for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
8804 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
8805 if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
8806 { ret[i].push_back(*it2); isFetched=true; }
8810 std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
8811 MCAuto<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
8812 ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
8820 * 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.
8821 * \param [out] cmps - same size than the returned vector.
8823 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& cmps)
8825 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8826 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8827 while(!lstFMTS.empty())
8829 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8830 MEDFileAnyTypeFieldMultiTS *ref(*it);
8831 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8832 elt.push_back(ref); it=lstFMTS.erase(it);
8833 MCAuto<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
8834 MCAuto<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
8835 while(it!=lstFMTS.end())
8837 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8838 if(cmp->isEqual(curIt))
8839 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8843 ret.push_back(elt); cmps.push_back(cmp);
8849 * 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.
8850 * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
8852 * \throw If \a f0 or \a f1 has not only one spatial discretization set.
8853 * \throw If \a f0 or \a f1 change of spatial discretization along time.
8854 * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
8855 * \thorw If \a f0 and \a f1 do not have the same times steps.
8856 * \throw If mesh is null.
8857 * \throw If \a f0 or \a f1 is null.
8858 * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
8860 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
8863 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
8865 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
8866 if(f0->getMeshName()!=mesh->getName())
8868 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8869 throw INTERP_KERNEL::Exception(oss.str().c_str());
8871 if(f1->getMeshName()!=mesh->getName())
8873 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8874 throw INTERP_KERNEL::Exception(oss.str().c_str());
8876 int nts=f0->getNumberOfTS();
8877 if(nts!=f1->getNumberOfTS())
8878 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
8881 for(int i=0;i<nts;i++)
8883 MCAuto<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
8884 MCAuto<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
8885 std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
8886 if(tofs0.size()!=1 || tofs1.size()!=1)
8887 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
8890 if(tof0!=tofs0[0] || tof1!=tofs1[0])
8891 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
8894 { tof0=tofs0[0]; tof1=tofs1[0]; }
8895 if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
8897 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() << ") !";
8898 throw INTERP_KERNEL::Exception(oss.str().c_str());
8900 if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
8902 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() << ") !";
8903 throw INTERP_KERNEL::Exception(oss.str().c_str());
8905 if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
8907 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() << ") !";
8908 throw INTERP_KERNEL::Exception(oss.str().c_str());
8914 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
8916 return new MEDFileAnyTypeFieldMultiTSIterator(this);
8919 //= MEDFileFieldMultiTS
8922 * Returns a new empty instance of MEDFileFieldMultiTS.
8923 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8924 * is to delete this field using decrRef() as it is no more needed.
8926 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
8928 return new MEDFileFieldMultiTS;
8932 * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
8933 * that has been read from a specified MED file.
8934 * \param [in] fileName - the name of the MED file to read.
8935 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8936 * is to delete this field using decrRef() as it is no more needed.
8937 * \throw If reading the file fails.
8939 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll)
8941 MCAuto<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,loadAll,0);
8942 ret->contentNotNull();//to check that content type matches with \a this type.
8947 * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
8948 * that has been read from a specified MED file.
8949 * \param [in] fileName - the name of the MED file to read.
8950 * \param [in] fieldName - the name of the field to read.
8951 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8952 * is to delete this field using decrRef() as it is no more needed.
8953 * \throw If reading the file fails.
8954 * \throw If there is no field named \a fieldName in the file.
8956 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8958 MCAuto<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,fieldName,loadAll,0);
8959 ret->contentNotNull();//to check that content type matches with \a this type.
8964 * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8965 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8967 * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
8968 * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
8969 * \warning this is a shallow copy constructor
8970 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
8971 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
8972 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8973 * is to delete this field using decrRef() as it is no more needed.
8975 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8977 return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
8980 MEDFileFieldMultiTS *MEDFileFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
8982 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fileName,fieldName,loadAll,0,&entities));
8983 ret->contentNotNull();//to check that content type matches with \a this type.
8987 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
8989 return new MEDFileFieldMultiTS(*this);
8992 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
8995 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8996 const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
8998 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
9002 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
9003 * following the given input policy.
9005 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9006 * By default (true) the globals are deeply copied.
9007 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
9009 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
9011 MCAuto<MEDFileIntFieldMultiTS> ret;
9012 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9015 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
9017 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
9018 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
9019 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc,getFileName()));
9022 ret=MEDFileIntFieldMultiTS::New();
9024 ret->deepCpyGlobs(*this);
9026 ret->shallowCpyGlobs(*this);
9031 * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
9032 * \param [in] pos - a time step id.
9033 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9034 * delete this field using decrRef() as it is no more needed.
9035 * \throw If \a pos is not a valid time step id.
9037 MEDFileAnyTypeField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const
9039 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9042 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9043 throw INTERP_KERNEL::Exception(oss.str().c_str());
9045 const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
9048 MCAuto<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
9049 ret->shallowCpyGlobs(*this);
9052 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
9053 throw INTERP_KERNEL::Exception(oss.str().c_str());
9057 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9058 * mesh entities of a given dimension of the first mesh in MED file.
9059 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9060 * \param [in] type - a spatial discretization of interest.
9061 * \param [in] iteration - the iteration number of a required time step.
9062 * \param [in] order - the iteration order number of required time step.
9063 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9064 * \param [in] renumPol - specifies how to permute values of the result field according to
9065 * the optional numbers of cells and nodes, if any. The valid values are
9066 * - 0 - do not permute.
9067 * - 1 - permute cells.
9068 * - 2 - permute nodes.
9069 * - 3 - permute cells and nodes.
9071 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9072 * caller is to delete this field using decrRef() as it is no more needed.
9073 * \throw If the MED file is not readable.
9074 * \throw If there is no mesh in the MED file.
9075 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9076 * \throw If no field values of the required parameters are available.
9078 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9080 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9081 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9083 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
9084 MCAuto<DataArray> arrOut;
9085 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9086 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9091 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9092 * the top level cells of the first mesh in MED file.
9093 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9094 * \param [in] type - a spatial discretization of interest.
9095 * \param [in] iteration - the iteration number of a required time step.
9096 * \param [in] order - the iteration order number of required time step.
9097 * \param [in] renumPol - specifies how to permute values of the result field according to
9098 * the optional numbers of cells and nodes, if any. The valid values are
9099 * - 0 - do not permute.
9100 * - 1 - permute cells.
9101 * - 2 - permute nodes.
9102 * - 3 - permute cells and nodes.
9104 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9105 * caller is to delete this field using decrRef() as it is no more needed.
9106 * \throw If the MED file is not readable.
9107 * \throw If there is no mesh in the MED file.
9108 * \throw If no field values of the required parameters are available.
9110 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9112 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9113 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9115 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
9116 MCAuto<DataArray> arrOut;
9117 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9118 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9123 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9125 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9126 * \param [in] type - a spatial discretization of interest.
9127 * \param [in] iteration - the iteration number of a required time step.
9128 * \param [in] order - the iteration order number of required time step.
9129 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9130 * \param [in] mesh - the supporting mesh.
9131 * \param [in] renumPol - specifies how to permute values of the result field according to
9132 * the optional numbers of cells and nodes, if any. The valid values are
9133 * - 0 - do not permute.
9134 * - 1 - permute cells.
9135 * - 2 - permute nodes.
9136 * - 3 - permute cells and nodes.
9138 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9139 * caller is to delete this field using decrRef() as it is no more needed.
9140 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9141 * \throw If no field of \a this is lying on \a mesh.
9142 * \throw If no field values of the required parameters are available.
9144 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9146 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9147 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9149 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9150 MCAuto<DataArray> arrOut;
9151 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
9152 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9157 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9159 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9160 * \param [in] type - a spatial discretization of the new field.
9161 * \param [in] iteration - the iteration number of a required time step.
9162 * \param [in] order - the iteration order number of required time step.
9163 * \param [in] mesh - the supporting mesh.
9164 * \param [in] renumPol - specifies how to permute values of the result field according to
9165 * the optional numbers of cells and nodes, if any. The valid values are
9166 * - 0 - do not permute.
9167 * - 1 - permute cells.
9168 * - 2 - permute nodes.
9169 * - 3 - permute cells and nodes.
9171 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9172 * caller is to delete this field using decrRef() as it is no more needed.
9173 * \throw If no field of \a this is lying on \a mesh.
9174 * \throw If no field values of the required parameters are available.
9176 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
9178 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9179 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9181 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9182 MCAuto<DataArray> arrOut;
9183 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
9184 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9189 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
9190 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9191 * This method is useful for MED2 file format when field on different mesh was autorized.
9193 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
9195 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9196 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9198 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
9199 MCAuto<DataArray> arrOut;
9200 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
9201 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9206 * Returns values and a profile of the field of a given type, of a given time step,
9207 * lying on a given support.
9208 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9209 * \param [in] type - a spatial discretization of the field.
9210 * \param [in] iteration - the iteration number of a required time step.
9211 * \param [in] order - the iteration order number of required time step.
9212 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9213 * \param [in] mesh - the supporting mesh.
9214 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9215 * field of interest lies on. If the field lies on all entities of the given
9216 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9217 * using decrRef() as it is no more needed.
9218 * \param [in] glob - the global data storing profiles and localization.
9219 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
9220 * field. The caller is to delete this array using decrRef() as it is no more needed.
9221 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9222 * \throw If no field of \a this is lying on \a mesh.
9223 * \throw If no field values of the required parameters are available.
9225 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9227 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9228 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9230 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
9231 MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9232 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
9235 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const
9237 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9239 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
9240 const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
9242 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 !");
9246 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull()
9248 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9250 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
9251 MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
9253 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 !");
9258 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9259 * the given field is checked if its elements are sorted suitable for writing to MED file
9260 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9261 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9262 * \param [in] field - the field to add to \a this.
9263 * \throw If the name of \a field is empty.
9264 * \throw If the data array of \a field is not set.
9265 * \throw If existing time steps have different name or number of components than \a field.
9266 * \throw If the underlying mesh of \a field has no name.
9267 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9269 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
9271 const DataArrayDouble *arr=0;
9273 arr=field->getArray();
9274 contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
9278 * Adds a MEDCouplingFieldDouble to \a this as another time step.
9279 * The mesh support of input parameter \a field is ignored here, it can be NULL.
9280 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9283 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9284 * A new profile is added only if no equal profile is missing.
9285 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9286 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
9287 * \param [in] mesh - the supporting mesh of \a field.
9288 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9289 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
9290 * \throw If either \a field or \a mesh or \a profile has an empty name.
9291 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9292 * \throw If the data array of \a field is not set.
9293 * \throw If the data array of \a this is already allocated but has different number of
9294 * components than \a field.
9295 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9296 * \sa setFieldNoProfileSBT()
9298 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9300 const DataArrayDouble *arr=0;
9302 arr=field->getArray();
9303 contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
9306 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
9308 _content=new MEDFileFieldMultiTSWithoutSDA;
9311 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9312 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll,ms)
9315 catch(INTERP_KERNEL::Exception& e)
9318 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
9319 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll,ms,entities)
9322 catch(INTERP_KERNEL::Exception& e)
9325 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9329 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
9331 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
9334 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9336 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9339 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
9341 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
9344 //= MEDFileAnyTypeFieldMultiTSIterator
9346 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
9351 _nb_iter=fmts->getNumberOfTS();
9355 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
9359 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
9361 if(_iter_id<_nb_iter)
9363 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
9365 return fmts->getTimeStepAtPos(_iter_id++);
9373 //= MEDFileIntFieldMultiTS
9376 * Returns a new empty instance of MEDFileFieldMultiTS.
9377 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9378 * is to delete this field using decrRef() as it is no more needed.
9380 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
9382 return new MEDFileIntFieldMultiTS;
9386 * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
9387 * that has been read from a specified MED file.
9388 * \param [in] fileName - the name of the MED file to read.
9389 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9390 * is to delete this field using decrRef() as it is no more needed.
9391 * \throw If reading the file fails.
9393 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll)
9395 MCAuto<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,loadAll,0);
9396 ret->contentNotNull();//to check that content type matches with \a this type.
9401 * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
9402 * that has been read from a specified MED file.
9403 * \param [in] fileName - the name of the MED file to read.
9404 * \param [in] fieldName - the name of the field to read.
9405 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9406 * is to delete this field using decrRef() as it is no more needed.
9407 * \throw If reading the file fails.
9408 * \throw If there is no field named \a fieldName in the file.
9410 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9412 MCAuto<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll,0);
9413 ret->contentNotNull();//to check that content type matches with \a this type.
9418 * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9419 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9421 * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
9422 * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9423 * \warning this is a shallow copy constructor
9424 * \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
9425 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9426 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9427 * is to delete this field using decrRef() as it is no more needed.
9429 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9431 return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
9434 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9436 MCAuto<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll,0,&entities);
9437 ret->contentNotNull();//to check that content type matches with \a this type.
9442 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
9443 * following the given input policy.
9445 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9446 * By default (true) the globals are deeply copied.
9447 * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
9449 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const
9451 MCAuto<MEDFileFieldMultiTS> ret;
9452 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9455 const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
9457 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
9458 MCAuto<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
9459 ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc,getFileName()));
9462 ret=MEDFileFieldMultiTS::New();
9464 ret->deepCpyGlobs(*this);
9466 ret->shallowCpyGlobs(*this);
9470 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const
9472 return new MEDFileIntFieldMultiTS(*this);
9475 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9478 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9479 const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
9481 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
9485 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9486 * mesh entities of a given dimension of the first mesh in MED file.
9487 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9488 * \param [in] type - a spatial discretization of interest.
9489 * \param [in] iteration - the iteration number of a required time step.
9490 * \param [in] order - the iteration order number of required time step.
9491 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9492 * \param [out] arrOut - the DataArrayInt containing values of field.
9493 * \param [in] renumPol - specifies how to permute values of the result field according to
9494 * the optional numbers of cells and nodes, if any. The valid values are
9495 * - 0 - do not permute.
9496 * - 1 - permute cells.
9497 * - 2 - permute nodes.
9498 * - 3 - permute cells and nodes.
9500 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9501 * caller is to delete this field using decrRef() as it is no more needed.
9502 * \throw If the MED file is not readable.
9503 * \throw If there is no mesh in the MED file.
9504 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9505 * \throw If no field values of the required parameters are available.
9507 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
9509 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9510 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9512 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
9513 MCAuto<DataArray> arr;
9514 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase());
9515 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9520 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9521 * the top level cells of the first mesh in MED file.
9522 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9523 * \param [in] type - a spatial discretization of interest.
9524 * \param [in] iteration - the iteration number of a required time step.
9525 * \param [in] order - the iteration order number of required time step.
9526 * \param [out] arrOut - the DataArrayInt containing values of field.
9527 * \param [in] renumPol - specifies how to permute values of the result field according to
9528 * the optional numbers of cells and nodes, if any. The valid values are
9529 * - 0 - do not permute.
9530 * - 1 - permute cells.
9531 * - 2 - permute nodes.
9532 * - 3 - permute cells and nodes.
9534 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9535 * caller is to delete this field using decrRef() as it is no more needed.
9536 * \throw If the MED file is not readable.
9537 * \throw If there is no mesh in the MED file.
9538 * \throw If no field values of the required parameters are available.
9540 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, DataArrayInt* &arrOut, int renumPol) const
9542 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9543 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9545 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
9546 MCAuto<DataArray> arr;
9547 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase());
9548 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9553 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9555 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9556 * \param [in] type - a spatial discretization of interest.
9557 * \param [in] iteration - the iteration number of a required time step.
9558 * \param [in] order - the iteration order number of required time step.
9559 * \param [out] arrOut - the DataArrayInt containing values of field.
9560 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9561 * \param [in] mesh - the supporting mesh.
9562 * \param [in] renumPol - specifies how to permute values of the result field according to
9563 * the optional numbers of cells and nodes, if any. The valid values are
9564 * - 0 - do not permute.
9565 * - 1 - permute cells.
9566 * - 2 - permute nodes.
9567 * - 3 - permute cells and nodes.
9569 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9570 * caller is to delete this field using decrRef() as it is no more needed.
9571 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9572 * \throw If no field of \a this is lying on \a mesh.
9573 * \throw If no field values of the required parameters are available.
9575 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
9577 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9578 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9580 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9581 MCAuto<DataArray> arr;
9582 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase());
9583 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9588 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9590 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9591 * \param [in] type - a spatial discretization of the new field.
9592 * \param [in] iteration - the iteration number of a required time step.
9593 * \param [in] order - the iteration order number of required time step.
9594 * \param [in] mesh - the supporting mesh.
9595 * \param [out] arrOut - the DataArrayInt containing values of field.
9596 * \param [in] renumPol - specifies how to permute values of the result field according to
9597 * the optional numbers of cells and nodes, if any. The valid values are
9598 * - 0 - do not permute.
9599 * - 1 - permute cells.
9600 * - 2 - permute nodes.
9601 * - 3 - permute cells and nodes.
9603 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9604 * caller is to delete this field using decrRef() as it is no more needed.
9605 * \throw If no field of \a this is lying on \a mesh.
9606 * \throw If no field values of the required parameters are available.
9608 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
9610 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9611 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9613 throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9614 MCAuto<DataArray> arr;
9615 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase());
9616 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9621 * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
9622 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9623 * This method is useful for MED2 file format when field on different mesh was autorized.
9625 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
9627 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9628 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9630 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9631 MCAuto<DataArray> arr;
9632 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase());
9633 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9638 * Returns values and a profile of the field of a given type, of a given time step,
9639 * lying on a given support.
9640 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9641 * \param [in] type - a spatial discretization of the field.
9642 * \param [in] iteration - the iteration number of a required time step.
9643 * \param [in] order - the iteration order number of required time step.
9644 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9645 * \param [in] mesh - the supporting mesh.
9646 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9647 * field of interest lies on. If the field lies on all entities of the given
9648 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9649 * using decrRef() as it is no more needed.
9650 * \param [in] glob - the global data storing profiles and localization.
9651 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
9652 * field. The caller is to delete this array using decrRef() as it is no more needed.
9653 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9654 * \throw If no field of \a this is lying on \a mesh.
9655 * \throw If no field values of the required parameters are available.
9657 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9659 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9660 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9662 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
9663 MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9664 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
9668 * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
9669 * \param [in] pos - a time step id.
9670 * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
9671 * delete this field using decrRef() as it is no more needed.
9672 * \throw If \a pos is not a valid time step id.
9674 MEDFileAnyTypeField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
9676 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9679 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9680 throw INTERP_KERNEL::Exception(oss.str().c_str());
9682 const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
9685 MCAuto<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
9686 ret->shallowCpyGlobs(*this);
9689 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
9690 throw INTERP_KERNEL::Exception(oss.str().c_str());
9694 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9695 * the given field is checked if its elements are sorted suitable for writing to MED file
9696 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9697 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9698 * \param [in] field - the field to add to \a this.
9699 * \throw If the name of \a field is empty.
9700 * \throw If the data array of \a field is not set.
9701 * \throw If existing time steps have different name or number of components than \a field.
9702 * \throw If the underlying mesh of \a field has no name.
9703 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9705 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals)
9707 contentNotNull()->appendFieldNoProfileSBT(field,arrOfVals,*this);
9711 * Adds a MEDCouplingFieldDouble to \a this as another time step.
9712 * The mesh support of input parameter \a field is ignored here, it can be NULL.
9713 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9716 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9717 * A new profile is added only if no equal profile is missing.
9718 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9719 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
9720 * \param [in] arrOfVals - the values of the field \a field used.
9721 * \param [in] mesh - the supporting mesh of \a field.
9722 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9723 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
9724 * \throw If either \a field or \a mesh or \a profile has an empty name.
9725 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9726 * \throw If the data array of \a field is not set.
9727 * \throw If the data array of \a this is already allocated but has different number of
9728 * components than \a field.
9729 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9730 * \sa setFieldNoProfileSBT()
9732 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9734 contentNotNull()->appendFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this);
9737 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const
9739 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9741 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
9742 const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9744 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 !");
9748 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull()
9750 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9752 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
9753 MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9755 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 !");
9759 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
9761 _content=new MEDFileIntFieldMultiTSWithoutSDA;
9764 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9768 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9769 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll,ms)
9772 catch(INTERP_KERNEL::Exception& e)
9775 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
9776 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll,ms,entities)
9779 catch(INTERP_KERNEL::Exception& e)
9782 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9784 return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9789 MEDFileFields *MEDFileFields::New()
9791 return new MEDFileFields;
9794 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
9796 return new MEDFileFields(fileName,loadAll,0,0);
9799 MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9801 return new MEDFileFields(fileName,loadAll,ms,0);
9804 MEDFileFields *MEDFileFields::LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9806 return new MEDFileFields(fileName,loadAll,0,&entities);
9809 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
9811 std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
9812 ret+=_fields.capacity()*sizeof(MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
9816 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
9818 std::vector<const BigMemoryObject *> ret;
9819 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9820 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
9824 MEDFileFields *MEDFileFields::deepCopy() const
9826 MCAuto<MEDFileFields> ret=shallowCpy();
9828 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9830 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9831 ret->_fields[i]=(*it)->deepCopy();
9833 ret->deepCpyGlobs(*this);
9837 MEDFileFields *MEDFileFields::shallowCpy() const
9839 return new MEDFileFields(*this);
9843 * 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
9844 * 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.
9845 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
9847 * \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.
9848 * \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.
9850 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9852 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
9854 std::set< std::pair<int,int> > s;
9855 bool firstShot=true;
9856 areThereSomeForgottenTS=false;
9857 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9859 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9861 std::vector< std::pair<int,int> > v=(*it)->getIterations();
9862 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
9864 { s=s1; firstShot=false; }
9867 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
9869 areThereSomeForgottenTS=true;
9873 std::vector< std::pair<int,int> > ret;
9874 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
9878 int MEDFileFields::getNumberOfFields() const
9880 return _fields.size();
9883 std::vector<std::string> MEDFileFields::getFieldsNames() const
9885 std::vector<std::string> ret(_fields.size());
9887 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9889 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
9892 ret[i]=f->getName();
9896 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
9897 throw INTERP_KERNEL::Exception(oss.str().c_str());
9903 std::vector<std::string> MEDFileFields::getMeshesNames() const
9905 std::vector<std::string> ret;
9906 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9908 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9910 ret.push_back(cur->getMeshName());
9915 std::string MEDFileFields::simpleRepr() const
9917 std::ostringstream oss;
9918 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
9923 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
9925 int nbOfFields=getNumberOfFields();
9926 std::string startLine(bkOffset,' ');
9927 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
9929 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9931 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9934 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
9938 oss << startLine << " - not defined !" << std::endl;
9942 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9944 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9945 std::string chapter(17,'0'+i);
9946 oss << startLine << chapter << std::endl;
9949 cur->simpleRepr(bkOffset+2,oss,i);
9953 oss << startLine << " - not defined !" << std::endl;
9955 oss << startLine << chapter << std::endl;
9957 simpleReprGlobs(oss);
9960 MEDFileFields::MEDFileFields()
9964 MEDFileFields::MEDFileFields(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
9965 try:MEDFileFieldGlobsReal(fileName)
9967 MEDFileUtilities::CheckFileForRead(fileName);
9968 MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY));
9969 int nbFields(MEDnField(fid));
9970 _fields.resize(nbFields);
9971 med_field_type typcha;
9972 for(int i=0;i<nbFields;i++)
9974 std::vector<std::string> infos;
9975 std::string fieldName,dtunit;
9976 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fileName,i,false,fieldName,typcha,infos,dtunit));
9981 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
9986 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
9991 std::ostringstream oss; oss << "constructor MEDFileFields(fileName) : file \'" << fileName << "\' at pos #" << i << " field has name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
9992 throw INTERP_KERNEL::Exception(oss.str().c_str());
9996 loadAllGlobals(fid);
9998 catch(INTERP_KERNEL::Exception& e)
10003 void MEDFileFields::writeLL(med_idt fid) const
10006 writeGlobals(fid,*this);
10007 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10009 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
10012 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
10013 throw INTERP_KERNEL::Exception(oss.str().c_str());
10015 elt->writeLL(fid,*this);
10019 void MEDFileFields::write(const std::string& fileName, int mode) const
10021 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
10022 MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),medmod));
10027 * This method alloc the arrays and load potentially huge arrays contained in this field.
10028 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
10029 * This method can be also called to refresh or reinit values from a file.
10031 * \throw If the fileName is not set or points to a non readable MED file.
10033 void MEDFileFields::loadArrays()
10035 if(getFileName().empty())
10036 throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
10037 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
10038 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10040 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10042 elt->loadBigArraysRecursively(fid,*elt);
10047 * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
10048 * But once data loaded once, this method does nothing.
10050 * \throw If the fileName is not set or points to a non readable MED file.
10051 * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
10053 void MEDFileFields::loadArraysIfNecessary()
10055 if(!getFileName().empty())
10057 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
10058 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10060 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10062 elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
10068 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
10069 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
10070 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
10072 * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
10074 void MEDFileFields::unloadArrays()
10076 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10078 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10080 elt->unloadArrays();
10085 * 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.
10086 * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
10087 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
10089 * \sa MEDFileFields::loadArraysIfNecessary
10091 void MEDFileFields::unloadArraysWithoutDataLoss()
10093 if(!getFileName().empty())
10097 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
10099 std::vector<std::string> ret;
10100 std::set<std::string> ret2;
10101 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10103 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
10104 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10105 if(ret2.find(*it2)==ret2.end())
10107 ret.push_back(*it2);
10114 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
10116 std::vector<std::string> ret;
10117 std::set<std::string> ret2;
10118 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10120 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
10121 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10122 if(ret2.find(*it2)==ret2.end())
10124 ret.push_back(*it2);
10131 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
10133 std::vector<std::string> ret;
10134 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10136 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
10137 ret.insert(ret.end(),tmp.begin(),tmp.end());
10142 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
10144 std::vector<std::string> ret;
10145 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10147 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
10148 ret.insert(ret.end(),tmp.begin(),tmp.end());
10153 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10155 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10156 (*it)->changePflsRefsNamesGen2(mapOfModif);
10159 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10161 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10162 (*it)->changeLocsRefsNamesGen2(mapOfModif);
10165 void MEDFileFields::resize(int newSize)
10167 _fields.resize(newSize);
10170 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
10172 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
10176 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
10179 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
10180 _fields.push_back(field->getContent());
10181 appendGlobs(*field,1e-12);
10184 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
10187 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
10188 if(i>=(int)_fields.size())
10189 _fields.resize(i+1);
10190 _fields[i]=field->getContent();
10191 appendGlobs(*field,1e-12);
10194 void MEDFileFields::destroyFieldAtPos(int i)
10196 destroyFieldsAtPos(&i,&i+1);
10199 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
10201 std::vector<bool> b(_fields.size(),true);
10202 for(const int *i=startIds;i!=endIds;i++)
10204 if(*i<0 || *i>=(int)_fields.size())
10206 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10207 throw INTERP_KERNEL::Exception(oss.str().c_str());
10211 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10213 for(std::size_t i=0;i<_fields.size();i++)
10215 fields[j++]=_fields[i];
10219 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
10221 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
10222 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
10223 std::vector<bool> b(_fields.size(),true);
10225 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
10227 if(k<0 || k>=(int)_fields.size())
10229 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
10230 throw INTERP_KERNEL::Exception(oss.str().c_str());
10234 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10236 for(std::size_t i=0;i<_fields.size();i++)
10238 fields[j++]=_fields[i];
10242 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
10245 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10247 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10249 ret=cur->changeMeshNames(modifTab) || ret;
10255 * \param [in] meshName the name of the mesh that will be renumbered.
10256 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
10257 * This code corresponds to the distribution of types in the corresponding mesh.
10258 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
10259 * \param [in] renumO2N the old to new renumber array.
10260 * \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
10261 * field in \a this.
10263 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
10266 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10268 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
10271 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
10277 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
10279 if(i<0 || i>=(int)_fields.size())
10281 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
10282 throw INTERP_KERNEL::Exception(oss.str().c_str());
10284 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
10287 MCAuto<MEDFileAnyTypeFieldMultiTS> ret;
10288 const MEDFileFieldMultiTSWithoutSDA *fmtsC=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts);
10289 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts);
10291 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
10293 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
10296 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
10297 throw INTERP_KERNEL::Exception(oss.str().c_str());
10299 ret->shallowCpyGlobs(*this);
10304 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
10305 * This method is accessible in python using __getitem__ with a list in input.
10306 * \return a new object that the caller should deal with.
10308 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
10310 MCAuto<MEDFileFields> ret=shallowCpy();
10311 std::size_t sz=std::distance(startIds,endIds);
10312 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
10314 for(const int *i=startIds;i!=endIds;i++,j++)
10316 if(*i<0 || *i>=(int)_fields.size())
10318 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10319 throw INTERP_KERNEL::Exception(oss.str().c_str());
10321 fields[j]=_fields[*i];
10323 ret->_fields=fields;
10327 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
10329 return getFieldAtPos(getPosFromFieldName(fieldName));
10333 * This method removes, if any, fields in \a this having no time steps.
10334 * 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.
10336 * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
10338 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
10340 std::vector<MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
10341 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10343 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10346 if(elt->getNumberOfTS()>0)
10347 newFields.push_back(*it);
10350 if(_fields.size()==newFields.size())
10357 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
10358 * This method can be seen as a filter applied on \a this, that returns an object containing
10359 * 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
10360 * shallow copied from \a this.
10362 * \param [in] meshName - the name of the mesh on w
10363 * \return a new object that the caller should deal with.
10365 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
10367 MCAuto<MEDFileFields> ret=MEDFileFields::New();
10368 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10370 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10373 if(cur->getMeshName()==meshName)
10376 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
10377 ret->_fields.push_back(cur2);
10380 ret->shallowCpyOnlyUsedGlobs(*this);
10385 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
10386 * Input time steps are specified using a pair of integer (iteration, order).
10387 * 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,
10388 * but for each multitimestep only the time steps in \a timeSteps are kept.
10389 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
10391 * The returned object points to shallow copy of elements in \a this.
10393 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
10394 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
10395 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10397 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10399 MCAuto<MEDFileFields> ret=MEDFileFields::New();
10400 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10402 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10405 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
10406 ret->_fields.push_back(elt);
10408 ret->shallowCpyOnlyUsedGlobs(*this);
10413 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
10415 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10417 MCAuto<MEDFileFields> ret=MEDFileFields::New();
10418 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10420 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10423 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
10424 if(elt->getNumberOfTS()!=0)
10425 ret->_fields.push_back(elt);
10427 ret->shallowCpyOnlyUsedGlobs(*this);
10431 MEDFileFieldsIterator *MEDFileFields::iterator()
10433 return new MEDFileFieldsIterator(this);
10436 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
10438 std::string tmp(fieldName);
10439 std::vector<std::string> poss;
10440 for(std::size_t i=0;i<_fields.size();i++)
10442 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=_fields[i];
10445 std::string fname(f->getName());
10449 poss.push_back(fname);
10452 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
10453 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
10455 throw INTERP_KERNEL::Exception(oss.str().c_str());
10458 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
10463 _nb_iter=fs->getNumberOfFields();
10467 MEDFileFieldsIterator::~MEDFileFieldsIterator()
10471 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
10473 if(_iter_id<_nb_iter)
10475 MEDFileFields *fs(_fs);
10477 return fs->getFieldAtPos(_iter_id++);