1 // Copyright (C) 2007-2013 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.
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"
26 #include "MEDCouplingFieldDouble.hxx"
27 #include "MEDCouplingFieldDiscretization.hxx"
29 #include "InterpKernelAutoPtr.hxx"
30 #include "CellModel.hxx"
35 extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
36 extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
37 extern med_geometry_type typmainoeud[1];
38 extern med_geometry_type typmai3[32];
40 using namespace ParaMEDMEM;
42 const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64";
43 const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32";
45 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const char *locName)
47 return new MEDFileFieldLoc(fid,locName);
50 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, int id)
52 return new MEDFileFieldLoc(fid,id);
55 MEDFileFieldLoc *MEDFileFieldLoc::New(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
57 return new MEDFileFieldLoc(locName,geoType,refCoo,gsCoo,w);
60 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, const char *locName):_name(locName)
62 med_geometry_type geotype;
63 med_geometry_type sectiongeotype;
65 INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
66 INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
67 MEDlocalizationInfoByName(fid,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
68 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+32,geotype)));
69 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
70 _nb_node_per_cell=cm.getNumberOfNodes();
71 _ref_coo.resize(_dim*_nb_node_per_cell);
72 _gs_coo.resize(_dim*_nb_gauss_pt);
73 _w.resize(_nb_gauss_pt);
74 MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
77 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id)
79 med_geometry_type geotype;
80 med_geometry_type sectiongeotype;
82 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
83 INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
84 INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
85 MEDlocalizationInfo(fid,id+1,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
87 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+32,geotype)));
88 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
89 _nb_node_per_cell=cm.getNumberOfNodes();
90 _ref_coo.resize(_dim*_nb_node_per_cell);
91 _gs_coo.resize(_dim*_nb_gauss_pt);
92 _w.resize(_nb_gauss_pt);
93 MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
96 MEDFileFieldLoc::MEDFileFieldLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType,
97 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),
100 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
101 _dim=cm.getDimension();
102 _nb_node_per_cell=cm.getNumberOfNodes();
103 _nb_gauss_pt=_w.size();
106 MEDFileFieldLoc *MEDFileFieldLoc::deepCpy() const
108 return new MEDFileFieldLoc(*this);
111 std::size_t MEDFileFieldLoc::getHeapMemorySize() const
113 return (_ref_coo.capacity()+_gs_coo.capacity()+_w.capacity())*sizeof(double)+_name.capacity();
116 void MEDFileFieldLoc::simpleRepr(std::ostream& oss) const
118 static const char OFF7[]="\n ";
119 oss << "\"" << _name << "\"" << OFF7;
120 oss << "GeoType=" << INTERP_KERNEL::CellModel::GetCellModel(_geo_type).getRepr() << OFF7;
121 oss << "Dimension=" << _dim << OFF7;
122 oss << "Number of Gauss points=" << _nb_gauss_pt << OFF7;
123 oss << "Number of nodes per cell=" << _nb_node_per_cell << OFF7;
124 oss << "RefCoords="; std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
125 oss << "Weights="; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
126 oss << "GaussPtsCoords="; std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," ")); oss << std::endl;
129 void MEDFileFieldLoc::setName(const char *name)
134 bool MEDFileFieldLoc::isEqual(const MEDFileFieldLoc& other, double eps) const
136 if(_name!=other._name)
140 if(_nb_gauss_pt!=other._nb_gauss_pt)
142 if(_nb_node_per_cell!=other._nb_node_per_cell)
144 if(_geo_type!=other._geo_type)
146 if(MEDCouplingGaussLocalization::AreAlmostEqual(_ref_coo,other._ref_coo,eps))
148 if(MEDCouplingGaussLocalization::AreAlmostEqual(_gs_coo,other._gs_coo,eps))
150 if(MEDCouplingGaussLocalization::AreAlmostEqual(_w,other._w,eps))
156 void MEDFileFieldLoc::writeLL(med_idt fid) const
158 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);
161 std::string MEDFileFieldLoc::repr() const
163 std::ostringstream oss; oss.precision(15);
164 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
165 oss << "Localization \"" << _name << "\" :\n" << " - Geometric Type : " << cm.getRepr();
166 oss << "\n - Dimension : " << _dim << "\n - Number of gauss points : ";
167 oss << _nb_gauss_pt << "\n - Number of nodes in cell : " << _nb_node_per_cell;
168 oss << "\n - Ref coords are : ";
169 int sz=_ref_coo.size();
172 int nbOfTuples=sz/_dim;
173 for(int i=0;i<nbOfTuples;i++)
176 for(int j=0;j<_dim;j++)
177 { oss << _ref_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
182 std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," "));
183 oss << "\n - Gauss coords in reference element : ";
187 int nbOfTuples=sz/_dim;
188 for(int i=0;i<nbOfTuples;i++)
191 for(int j=0;j<_dim;j++)
192 { oss << _gs_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
197 std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," "));
198 oss << "\n - Weights of Gauss coords are : "; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," "));
202 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
204 _type=field->getTypeOfField();
210 getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,offset,offset+nbOfCells,1);
211 _end=_start+nbOfCells;
217 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
218 const int *arrPtr=arr->getConstPointer();
219 getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,arrPtr[offset],arrPtr[offset+nbOfCells],1);
220 _end=_start+(arrPtr[offset+nbOfCells]-arrPtr[offset]);
226 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
227 const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
228 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
230 throw INTERP_KERNEL::Exception("assignFieldNoProfile : invalid call to this method ! Internal Error !");
231 const DataArrayInt *dai=disc2->getArrayOfDiscIds();
232 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> dai2=disc2->getOffsetArr(field->getMesh());
233 const int *dai2Ptr=dai2->getConstPointer();
234 int nbi=gsLoc.getWeights().size();
235 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=dai->selectByTupleId2(offset,offset+nbOfCells,1);
236 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da2->getIdsEqual(_loc_id);
237 const int *da3Ptr=da3->getConstPointer();
238 if(da3->getNumberOfTuples()!=nbOfCells)
239 {//profile : for gauss even in NoProfile !!!
240 std::ostringstream oss; oss << "Pfl_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
242 da3->setName(_profile.c_str());
243 glob.appendProfile(da3);
245 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da4=DataArrayInt::New();
246 _nval=da3->getNbOfElems();
247 da4->alloc(_nval*nbi,1);
248 int *da4Ptr=da4->getPointer();
249 for(int i=0;i<_nval;i++)
251 int ref=dai2Ptr[offset+da3Ptr[i]];
252 for(int j=0;j<nbi;j++)
255 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
256 _localization=oss2.str();
257 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,da4);
258 _end=_start+_nval*nbi;
259 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
263 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile : not implemented yet for such discretization type of field !");
269 * Leaf method of field with profile assignement. This method is the most general one. No optimization is done here.
270 * \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).
271 * \param [in] multiTypePfl is the end user profile specified in high level API
272 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
273 * \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.
274 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
275 * \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.
277 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(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) throw(INTERP_KERNEL::Exception)
280 _type=field->getTypeOfField();
281 std::string pflName(multiTypePfl->getName());
282 std::ostringstream oss; oss << pflName;
283 if(_type!=ON_NODES) { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType()); oss << "_" << cm.getRepr(); } else { oss << "_NODE"; }
287 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : existing profile with empty name !");
288 if(_type!=ON_GAUSS_PT)
290 locIds->setName(oss.str().c_str());
291 glob.appendProfile(locIds);
300 _nval=idsInPfl->getNumberOfTuples();
301 getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,0,arrr->getNumberOfTuples(),1);
307 _nval=idsInPfl->getNumberOfTuples();
308 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,idsInPfl);
314 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
315 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr->deltaShiftIndex();
316 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->begin(),multiTypePfl->end());
317 arr3->computeOffsets2();
318 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
319 int trueNval=tmp->getNumberOfTuples();
320 _nval=idsInPfl->getNumberOfTuples();
321 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
322 _end=_start+trueNval;
327 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(field->getDiscretization());
329 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
330 const DataArrayInt *da1=disc2->getArrayOfDiscIds();
331 const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
332 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da1->selectByTupleId(idsInPfl->begin(),idsInPfl->end());
333 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da2->getIdsEqual(_loc_id);
334 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da4=idsInPfl->selectByTupleId(da3->begin(),da3->end());
336 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPart(multiTypePfl->begin(),multiTypePfl->end());
337 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=disc2->getOffsetArr(mesh2);
339 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=DataArrayInt::New();
341 for(const int *pt=da4->begin();pt!=da4->end();pt++)
342 trueNval+=arr->getIJ(*pt+1,0)-arr->getIJ(*pt,0);
343 tmp->alloc(trueNval,1);
344 int *tmpPtr=tmp->getPointer();
345 for(const int *pt=da4->begin();pt!=da4->end();pt++)
346 for(int j=arr->getIJ(*pt,0);j<arr->getIJ(*pt+1,0);j++)
349 _nval=da4->getNumberOfTuples();
350 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
351 _end=_start+trueNval;
352 oss << "_loc_" << _loc_id;
355 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da5=locIds->selectByTupleId(da3->begin(),da3->end());
356 da5->setName(oss.str().c_str());
357 glob.appendProfile(da5);
362 if(da3->getNumberOfTuples()!=nbOfEltsInWholeMesh || !da3->isIdentity())
364 da3->setName(oss.str().c_str());
365 glob.appendProfile(da3);
369 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
370 _localization=oss2.str();
371 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
375 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for such discretization type of field !");
380 void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
383 _nval=arrr->getNumberOfTuples();
384 getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,0,_nval,1);
389 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt) throw(INTERP_KERNEL::Exception)
391 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt);
394 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId)
396 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string());
399 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(const MEDFileFieldPerMeshPerTypePerDisc& other)
401 return new MEDFileFieldPerMeshPerTypePerDisc(other);
404 std::size_t MEDFileFieldPerMeshPerTypePerDisc::getHeapMemorySize() const
406 return _profile.capacity()+_localization.capacity()+5*sizeof(int);
409 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCpy(MEDFileFieldPerMeshPerType *father) const throw(INTERP_KERNEL::Exception)
411 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> ret=new MEDFileFieldPerMeshPerTypePerDisc(*this);
416 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField atype, int profileIt) throw(INTERP_KERNEL::Exception)
417 try:_type(atype),_father(fath)
420 catch(INTERP_KERNEL::Exception& e)
425 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
429 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(const MEDFileFieldPerMeshPerTypePerDisc& 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),_tmp_work1(other._tmp_work1)
433 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(0),_start(-std::numeric_limits<int>::max()),_end(-std::numeric_limits<int>::max()),
434 _nval(-std::numeric_limits<int>::max()),_loc_id(-std::numeric_limits<int>::max())
438 const MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
443 void MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively(med_idt fid, int profileIt, int& start, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
445 INTERP_KERNEL::AutoPtr<char> locname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
446 INTERP_KERNEL::AutoPtr<char> pflname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
447 std::string fieldName=nasc.getName();
448 std::string meshName=getMeshName();
449 int iteration=getIteration();
450 int order=getOrder();
451 TypeOfField type=getType();
452 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
454 med_geometry_type mgeoti;
455 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
456 _nval=MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,profileIt,MED_COMPACT_PFLMODE,
457 pflname,&profilesize,locname,&nbi);
458 _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
459 _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
461 _end=start+_nval*nbi;
463 if(type==ON_CELLS && !_localization.empty())
465 if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
466 setType(ON_GAUSS_PT);
469 setType(ON_GAUSS_NE);
470 _localization.clear();
475 void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, int profileIt, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
477 std::string fieldName=nasc.getName();
478 std::string meshName=getMeshName();
479 int iteration=getIteration();
480 int order=getOrder();
481 TypeOfField type=getType();
482 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
483 med_geometry_type mgeoti;
484 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
485 DataArray *arr=getOrCreateAndGetArray();
487 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !");
488 if(_start<0 || _start>=arr->getNumberOfTuples())
490 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << ") !";
491 throw INTERP_KERNEL::Exception(oss.str().c_str());
493 if(_end<0 || _end>arr->getNumberOfTuples())
495 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !";
496 throw INTERP_KERNEL::Exception(oss.str().c_str());
498 DataArrayDouble *arrD=dynamic_cast<DataArrayDouble *>(arr);
501 double *startFeeding=arrD->getPointer()+_start*arrD->getNumberOfComponents();
502 MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,
503 _profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast<unsigned char*>(startFeeding));
506 DataArrayInt *arrI=dynamic_cast<DataArrayInt *>(arr);
509 int *startFeeding=arrI->getPointer()+_start*arrI->getNumberOfComponents();
510 MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,
511 _profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast<unsigned char*>(startFeeding));
514 throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
518 * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
520 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart) throw(INTERP_KERNEL::Exception)
522 int delta=_end-_start;
523 _start=newValueOfStart;
527 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
529 return _father->getIteration();
532 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
534 return _father->getOrder();
537 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
539 return _father->getTime();
542 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
544 return _father->getMeshName();
547 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
549 const char startLine[]=" ## ";
550 std::string startLine2(bkOffset,' ');
551 startLine2+=startLine;
552 MEDCouplingFieldDiscretization *tmp=MEDCouplingFieldDiscretization::New(_type);
553 oss << startLine2 << "Localization #" << id << "." << std::endl;
554 oss << startLine2 << " Type=" << tmp->getRepr() << "." << std::endl;
556 oss << startLine2 << " This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
557 oss << startLine2 << " This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
558 oss << startLine2 << " This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
561 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
566 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
571 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
576 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
578 return _father->getGeoType();
581 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
583 return _father->getNumberOfComponents();
586 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
591 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray()
593 return _father->getOrCreateAndGetArray();
596 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const
598 const MEDFileFieldPerMeshPerType *fath=_father;
599 return fath->getOrCreateAndGetArray();
602 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
604 return _father->getInfo();
607 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
612 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const char *newPflName)
617 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
619 return _localization;
622 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const char *newLocName)
624 _localization=newLocName;
627 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
629 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
631 if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
633 _profile=(*it2).second;
639 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
641 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
643 if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
645 _localization=(*it2).second;
651 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
655 dads.push_back(std::pair<int,int>(_start,_end));
656 geoTypes.push_back(getGeoType());
661 pfls.push_back(glob->getProfile(_profile.c_str()));
663 if(_localization.empty())
667 locs.push_back(glob->getLocalizationId(_localization.c_str()));
671 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
673 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));
677 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
679 TypeOfField type=getType();
680 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
681 med_geometry_type mgeoti;
682 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
683 const DataArray *arr=getOrCreateAndGetArray();
685 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
686 const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
687 const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
688 const unsigned char *locToWrite=0;
690 locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
692 locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
694 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
695 MEDfieldValueWithProfileWr(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
696 MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
700 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const throw(INTERP_KERNEL::Exception)
705 dad.first=_start; dad.second=_end;
709 * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
710 * This code corresponds to the distribution of types in the corresponding mesh.
711 * \param [out] ptToFill memory zone where the output will be stored.
712 * \return the size of data pushed into output param \a ptToFill
714 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const throw(INTERP_KERNEL::Exception)
717 std::ostringstream oss;
718 std::size_t nbOfType=codeOfMesh.size()/3;
720 for(std::size_t i=0;i<nbOfType && found==-1;i++)
721 if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
725 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
726 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
727 throw INTERP_KERNEL::Exception(oss.str().c_str());
732 if(_nval!=codeOfMesh[3*found+1])
734 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
735 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
736 oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
737 throw INTERP_KERNEL::Exception(oss.str().c_str());
739 for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
744 const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
745 if(pfl->getNumberOfTuples()!=_nval)
747 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
748 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
750 oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
751 throw INTERP_KERNEL::Exception(oss.str().c_str());
753 int offset2=codeOfMesh[3*found+2];
754 for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
756 if(*pflId<codeOfMesh[3*found+1])
757 *work++=offset2+*pflId;
763 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const throw(INTERP_KERNEL::Exception)
765 for(int i=_start;i<_end;i++)
770 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId) throw(INTERP_KERNEL::Exception)
781 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
785 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
788 std::map<std::pair<std::string,TypeOfField>,int> m;
789 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
790 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
791 if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
792 m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
794 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
795 ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
800 * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
802 * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
803 * \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.
804 * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
805 * \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)
806 * \param [in,out] glob if necessary by the method, new profiles can be added to it
807 * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
808 * \param [out] result All new entries will be appended on it.
809 * \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 !)
811 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
812 const DataArrayInt *explicitIdsInMesh,
813 const std::vector<int>& newCode,
814 MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
815 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >& result)
817 if(entriesOnSameDisc.empty())
819 TypeOfField type=entriesOnSameDisc[0]->getType();
820 int szEntities=0,szTuples=0;
821 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
822 { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
823 int nbi=szTuples/szEntities;
824 if(szTuples%szEntities!=0)
825 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
826 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
827 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
828 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
829 std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
830 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
831 std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
832 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
834 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
836 int startOfEltIdOfChunk=(*it)->_start;
837 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newEltIds=explicitIdsInMesh->substr(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
838 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
839 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
841 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
842 newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
844 newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
845 newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
847 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
848 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
849 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
850 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
852 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
854 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arrPart=arr->substr(offset,offset+szTuples);
855 arrPart->renumberInPlace(renumTupleIds->begin());
856 arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
858 const int *idIt=diffVals->begin();
859 std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
861 for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
863 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=newGeoTypesEltIdsAllGather->getIdsEqual(*idIt);
864 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
865 int nbEntityElts=subIds->getNumberOfTuples();
867 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
868 NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIdentity() || nbEntityElts!=newCode[3*(*idIt)+1],nbi,
872 result.push_back(eltToAdd);
873 offset2+=nbEntityElts*nbi;
875 ret=ret || li.empty();
880 * \param [in] typeF type of field of new chunk
881 * \param [in] geoType the geometric type of the chunk
882 * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
883 * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
884 * \param [in] nbi number of integration points
885 * \param [in] offset The offset in the **global array of data**.
886 * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
887 * to the new chunk to create.
888 * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
889 * \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
890 * and corresponding entry erased from \a entriesOnSameDisc.
891 * \return a newly allocated chunk
893 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
894 bool isPfl, int nbi, int offset,
895 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
896 MEDFileFieldGlobsReal& glob,
897 bool ¬InExisting) throw(INTERP_KERNEL::Exception)
899 int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
900 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
901 for(;it!=entriesOnSameDisc.end();it++)
903 if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
907 if((*it)->_profile.empty())
910 if(!(*it)->_profile.empty())
912 const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
913 if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
919 if(it==entriesOnSameDisc.end())
922 MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
924 ret->_loc_id=(int)geoType;
925 ret->_nval=nbMeshEntities;
927 ret->_end=ret->_start+ret->_nval*nbi;
930 idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
931 glob.appendProfile(idsOfMeshElt);
932 ret->_profile=idsOfMeshElt->getName();
934 //tony treatment of localization
940 MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
941 ret->_loc_id=(int)geoType;
942 ret->setNewStart(offset);
943 entriesOnSameDisc.erase(it);
949 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
951 return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc);
954 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception)
956 return new MEDFileFieldPerMeshPerType(fath,geoType);
959 std::size_t MEDFileFieldPerMeshPerType::getHeapMemorySize() const
961 std::size_t ret=_field_pm_pt_pd.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc>);
962 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
963 ret+=(*it)->getHeapMemorySize();
967 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCpy(MEDFileFieldPerMesh *father) const throw(INTERP_KERNEL::Exception)
969 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
972 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
974 if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
975 ret->_field_pm_pt_pd[i]=(*it)->deepCpy((MEDFileFieldPerMeshPerType *)ret);
980 void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
982 std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
983 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
984 _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
988 * This method is the most general one. No optimization is done here.
989 * \param [in] multiTypePfl is the end user profile specified in high level API
990 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
991 * \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.
992 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
993 * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
994 * \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.
996 void MEDFileFieldPerMeshPerType::assignFieldProfile(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) throw(INTERP_KERNEL::Exception)
998 std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
999 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1000 _field_pm_pt_pd[*it]->assignFieldProfile(start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1003 void MEDFileFieldPerMeshPerType::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1005 _field_pm_pt_pd.resize(1);
1006 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1007 _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1010 void MEDFileFieldPerMeshPerType::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1012 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2=pfl->deepCpy();
1014 _field_pm_pt_pd.resize(1);
1015 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1016 _field_pm_pt_pd[0]->assignFieldProfile(start,pfl,pfl2,pfl2,-1,field,arr,0,glob,nasc);//mesh is not requested so 0 is send.
1019 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception)
1021 TypeOfField type=field->getTypeOfField();
1022 if(type!=ON_GAUSS_PT)
1024 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1025 int sz=_field_pm_pt_pd.size();
1027 for(int j=0;j<sz && !found;j++)
1029 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1031 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1037 _field_pm_pt_pd.resize(sz+1);
1038 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1040 std::vector<int> ret(1,0);
1045 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1046 int sz2=ret2.size();
1047 std::vector<int> ret3(sz2);
1049 for(int i=0;i<sz2;i++)
1051 int sz=_field_pm_pt_pd.size();
1052 int locIdToFind=ret2[i];
1054 for(int j=0;j<sz && !found;j++)
1056 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1058 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1065 _field_pm_pt_pd.resize(sz+1);
1066 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1074 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception)
1076 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1077 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1079 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1080 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1082 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1083 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleId2(offset,offset+nbOfCells,1);
1084 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1085 if(retTmp->presenceOfValue(-1))
1086 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1087 std::vector<int> ret(retTmp->begin(),retTmp->end());
1091 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) throw(INTERP_KERNEL::Exception)
1093 TypeOfField type=field->getTypeOfField();
1094 if(type!=ON_GAUSS_PT)
1096 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1097 int sz=_field_pm_pt_pd.size();
1099 for(int j=0;j<sz && !found;j++)
1101 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1103 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1109 _field_pm_pt_pd.resize(sz+1);
1110 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1112 std::vector<int> ret(1,0);
1117 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1118 int sz2=ret2.size();
1119 std::vector<int> ret3(sz2);
1121 for(int i=0;i<sz2;i++)
1123 int sz=_field_pm_pt_pd.size();
1124 int locIdToFind=ret2[i];
1126 for(int j=0;j<sz && !found;j++)
1128 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1130 _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);
1146 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) throw(INTERP_KERNEL::Exception)
1148 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1149 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1151 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1152 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1154 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1155 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1156 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1157 if(retTmp->presenceOfValue(-1))
1158 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1159 std::vector<int> ret(retTmp->begin(),retTmp->end());
1163 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerType::getFather() const
1168 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1170 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1171 int curDim=(int)cm.getDimension();
1172 dim=std::max(dim,curDim);
1175 void MEDFileFieldPerMeshPerType::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
1177 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1179 (*it)->fillTypesOfFieldAvailable(types);
1183 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 throw(INTERP_KERNEL::Exception)
1185 int sz=_field_pm_pt_pd.size();
1186 dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1187 for(int i=0;i<sz;i++)
1189 _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1193 int MEDFileFieldPerMeshPerType::getIteration() const
1195 return _father->getIteration();
1198 int MEDFileFieldPerMeshPerType::getOrder() const
1200 return _father->getOrder();
1203 double MEDFileFieldPerMeshPerType::getTime() const
1205 return _father->getTime();
1208 std::string MEDFileFieldPerMeshPerType::getMeshName() const
1210 return _father->getMeshName();
1213 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1215 const char startLine[]=" ## ";
1216 std::string startLine2(bkOffset,' ');
1217 std::string startLine3(startLine2);
1218 startLine3+=startLine;
1219 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1221 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1222 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1225 oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1226 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1228 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1230 const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1232 cur->simpleRepr(bkOffset,oss,i);
1235 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1240 void MEDFileFieldPerMeshPerType::getSizes(int& globalSz, int& nbOfEntries) const
1242 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1244 globalSz+=(*it)->getNumberOfTuples();
1246 nbOfEntries+=(int)_field_pm_pt_pd.size();
1249 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1255 int MEDFileFieldPerMeshPerType::getNumberOfComponents() const
1257 return _father->getNumberOfComponents();
1260 DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray()
1262 return _father->getOrCreateAndGetArray();
1265 const DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray() const
1267 const MEDFileFieldPerMesh *fath=_father;
1268 return fath->getOrCreateAndGetArray();
1271 const std::vector<std::string>& MEDFileFieldPerMeshPerType::getInfo() const
1273 return _father->getInfo();
1276 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsed() const
1278 std::vector<std::string> ret;
1279 std::set<std::string> ret2;
1280 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1282 std::string tmp=(*it1)->getProfile();
1284 if(ret2.find(tmp)==ret2.end())
1293 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsed() const
1295 std::vector<std::string> ret;
1296 std::set<std::string> ret2;
1297 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1299 std::string tmp=(*it1)->getLocalization();
1300 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1301 if(ret2.find(tmp)==ret2.end())
1310 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsedMulti() const
1312 std::vector<std::string> ret;
1313 std::set<std::string> ret2;
1314 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1316 std::string tmp=(*it1)->getProfile();
1323 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsedMulti() const
1325 std::vector<std::string> ret;
1326 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1328 std::string tmp=(*it1)->getLocalization();
1329 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1335 void MEDFileFieldPerMeshPerType::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1337 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1338 (*it1)->changePflsRefsNamesGen(mapOfModif);
1341 void MEDFileFieldPerMeshPerType::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1343 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1344 (*it1)->changeLocsRefsNamesGen(mapOfModif);
1347 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) throw(INTERP_KERNEL::Exception)
1349 if(_field_pm_pt_pd.empty())
1351 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1352 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1353 throw INTERP_KERNEL::Exception(oss.str().c_str());
1355 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1356 return _field_pm_pt_pd[locId];
1357 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1358 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1359 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1360 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1361 return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1364 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) const throw(INTERP_KERNEL::Exception)
1366 if(_field_pm_pt_pd.empty())
1368 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1369 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1370 throw INTERP_KERNEL::Exception(oss.str().c_str());
1372 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1373 return _field_pm_pt_pd[locId];
1374 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1375 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1376 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1377 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1378 return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1381 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
1383 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1385 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1386 if(meshDim!=(int)cm.getDimension())
1389 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1390 (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1393 void MEDFileFieldPerMeshPerType::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1396 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1398 (*it)->fillValues(i,startEntryId,entries);
1402 void MEDFileFieldPerMeshPerType::setLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves) throw(INTERP_KERNEL::Exception)
1404 _field_pm_pt_pd=leaves;
1405 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1406 (*it)->setFather(this);
1409 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception):_father(fath),_geo_type(geoType)
1413 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception):_father(fath),_geo_type(geoType)
1415 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1416 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1417 med_geometry_type mgeoti;
1418 med_entity_type menti=ConvertIntoMEDFileType(type,geoType,mgeoti);
1419 int nbProfiles=MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName);
1420 _field_pm_pt_pd.resize(nbProfiles);
1421 for(int i=0;i<nbProfiles;i++)
1423 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i+1);
1427 void MEDFileFieldPerMeshPerType::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1430 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,pflId++)
1432 (*it)->loadOnlyStructureOfDataRecursively(fid,pflId+1,start,nasc);//tony
1436 void MEDFileFieldPerMeshPerType::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1439 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,pflId++)
1441 (*it)->loadBigArray(fid,pflId+1,nasc);//tony
1445 void MEDFileFieldPerMeshPerType::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
1447 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1449 (*it)->copyOptionsFrom(*this);
1450 (*it)->writeLL(fid,nasc);
1454 med_entity_type MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1459 medfGeoType=typmai3[(int)ikGeoType];
1462 medfGeoType=MED_NONE;
1465 medfGeoType=typmai3[(int)ikGeoType];
1466 return MED_NODE_ELEMENT;
1468 medfGeoType=typmai3[(int)ikGeoType];
1471 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1473 return MED_UNDEF_ENTITY_TYPE;
1476 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1478 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc);
1481 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1483 return new MEDFileFieldPerMesh(fath,mesh);
1486 std::size_t MEDFileFieldPerMesh::getHeapMemorySize() const
1488 std::size_t ret=_mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType >);
1489 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1490 if((const MEDFileFieldPerMeshPerType *)*it)
1491 ret+=(*it)->getHeapMemorySize();
1495 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCpy(MEDFileAnyTypeField1TSWithoutSDA *father) const throw(INTERP_KERNEL::Exception)
1497 MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1498 ret->_father=father;
1500 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1502 if((const MEDFileFieldPerMeshPerType *)*it)
1503 ret->_field_pm_pt[i]=(*it)->deepCpy((MEDFileFieldPerMesh *)(ret));
1508 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1510 std::string startLine(bkOffset,' ');
1511 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1512 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1514 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1516 const MEDFileFieldPerMeshPerType *cur=*it;
1518 cur->simpleRepr(bkOffset,oss,i);
1521 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1526 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
1528 _mesh_name=mesh->getName();
1529 mesh->getTime(_mesh_iteration,_mesh_order);
1532 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1534 int nbOfTypes=code.size()/3;
1536 for(int i=0;i<nbOfTypes;i++)
1538 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1539 int nbOfCells=code[3*i+1];
1540 int pos=addNewEntryIfNecessary(type);
1541 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1547 * This method is the most general one. No optimization is done here.
1548 * \param [in] multiTypePfl is the end user profile specified in high level API
1549 * \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].
1550 * \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.
1551 * \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.
1552 * \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.
1553 * \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.
1555 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) throw(INTERP_KERNEL::Exception)
1557 int nbOfTypes=code.size()/3;
1558 for(int i=0;i<nbOfTypes;i++)
1560 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1561 int pos=addNewEntryIfNecessary(type);
1562 DataArrayInt *pfl=0;
1564 pfl=idsPerType[code[3*i+2]];
1565 int nbOfTupes2=code2.size()/3;
1567 for(;found<nbOfTupes2;found++)
1568 if(code[3*i]==code2[3*found])
1570 if(found==nbOfTupes2)
1571 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1572 _field_pm_pt[pos]->assignFieldProfile(start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1576 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1578 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1579 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1582 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1584 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1585 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1588 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1590 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1591 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1594 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1596 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1597 (*it)->loadBigArraysRecursively(fid,nasc);
1600 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
1602 int nbOfTypes=_field_pm_pt.size();
1603 for(int i=0;i<nbOfTypes;i++)
1605 _field_pm_pt[i]->copyOptionsFrom(*this);
1606 _field_pm_pt[i]->writeLL(fid,nasc);
1610 void MEDFileFieldPerMesh::getDimension(int& dim) const
1612 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1613 (*it)->getDimension(dim);
1616 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
1618 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1619 (*it)->fillTypesOfFieldAvailable(types);
1622 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 throw(INTERP_KERNEL::Exception)
1624 int sz=_field_pm_pt.size();
1625 std::vector< std::vector<std::pair<int,int> > > ret(sz);
1626 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1627 for(int i=0;i<sz;i++)
1629 types[i]=_field_pm_pt[i]->getGeoType();
1630 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1635 double MEDFileFieldPerMesh::getTime() const
1638 return _father->getTime(tmp1,tmp2);
1641 int MEDFileFieldPerMesh::getIteration() const
1643 return _father->getIteration();
1646 int MEDFileFieldPerMesh::getOrder() const
1648 return _father->getOrder();
1651 int MEDFileFieldPerMesh::getNumberOfComponents() const
1653 return _father->getNumberOfComponents();
1656 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
1659 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1660 return _father->getOrCreateAndGetArray();
1663 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
1666 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1667 return _father->getOrCreateAndGetArray();
1670 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1672 return _father->getInfo();
1676 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
1677 * 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.
1678 * It returns 2 output vectors :
1679 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
1680 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
1681 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
1683 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)
1685 int notNullPflsSz=0;
1686 int nbOfArrs=geoTypes.size();
1687 for(int i=0;i<nbOfArrs;i++)
1690 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
1691 int nbOfDiffGeoTypes=geoTypes3.size();
1692 code.resize(3*nbOfDiffGeoTypes);
1693 notNullPfls.resize(notNullPflsSz);
1696 for(int i=0;i<nbOfDiffGeoTypes;i++)
1699 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
1700 std::vector<const DataArrayInt *> notNullTmp;
1702 notNullTmp.push_back(pfls[j]);
1704 for(;j<nbOfArrs;j++)
1705 if(geoTypes[j]==refType)
1708 notNullTmp.push_back(pfls[j]);
1712 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
1713 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
1714 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
1715 code[3*i]=(int)refType;
1716 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
1717 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
1718 if(notNullTmp.empty())
1722 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
1723 code[3*i+2]=notNullPflsSz++;
1729 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
1731 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) throw(INTERP_KERNEL::Exception)
1735 for(int i=0;i<sz;i++)
1739 if(type!=ON_GAUSS_NE)
1740 ret+=dads[i].second-dads[i].first;
1743 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
1744 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
1749 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
1750 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
1756 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
1758 std::vector<std::string> ret;
1759 std::set<std::string> ret2;
1760 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1762 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
1763 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1764 if(ret2.find(*it2)==ret2.end())
1766 ret.push_back(*it2);
1773 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
1775 std::vector<std::string> ret;
1776 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1778 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
1779 ret.insert(ret.end(),tmp.begin(),tmp.end());
1784 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
1786 std::vector<std::string> ret;
1787 std::set<std::string> ret2;
1788 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1790 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
1791 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1792 if(ret2.find(*it2)==ret2.end())
1794 ret.push_back(*it2);
1801 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
1803 std::vector<std::string> ret;
1804 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1806 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
1807 ret.insert(ret.end(),tmp.begin(),tmp.end());
1812 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
1814 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
1816 if((*it).first==_mesh_name)
1818 _mesh_name=(*it).second;
1825 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
1826 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1828 if(_mesh_name!=meshName)
1830 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
1831 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
1832 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
1833 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
1834 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
1835 getUndergroundDataArrayExt(entries);
1836 DataArray *arr0=getOrCreateAndGetArray();//tony
1838 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
1839 DataArrayDouble *arr=dynamic_cast<DataArrayDouble *>(arr0);//tony
1841 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
1844 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
1845 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
1847 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
1849 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1850 sz+=(*it).second.second-(*it).second.first;
1853 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1855 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
1856 ////////////////////
1857 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
1858 int *workI2=explicitIdsOldInMesh->getPointer();
1859 int sz1=0,sz2=0,sid=1;
1860 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
1861 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
1862 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
1864 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
1865 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
1866 int *workI=explicitIdsOldInArr->getPointer();
1867 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
1869 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
1870 (*itL2)->setLocId(sz2);
1871 (*itL2)->_tmp_work1=(*itL2)->getStart();
1872 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
1874 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
1876 explicitIdsOldInMesh->reAlloc(sz2);
1877 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
1878 ////////////////////
1879 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
1880 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
1881 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
1882 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
1884 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
1885 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
1886 otherEntriesNew.back()->setLocId((*it)->getGeoType());
1888 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
1889 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
1890 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
1892 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1893 int newStart=elt->getLocId();
1894 elt->setLocId((*it)->getGeoType());
1895 elt->setNewStart(newStart);
1896 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
1897 entriesKeptNew.push_back(elt);
1898 entriesKeptNew2.push_back(elt);
1900 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
1901 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
1902 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
1903 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
1905 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
1908 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
1910 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
1911 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
1913 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
1914 glob,arr2,otherEntriesNew) || ret;
1918 // Assign new dispatching
1919 assignNewLeaves(otherEntriesNew);
1920 arr->cpyFrom(*arr2);
1924 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves) throw(INTERP_KERNEL::Exception)
1926 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > > types;
1927 for( std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
1928 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
1930 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > fieldPmPt(types.size());
1931 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
1932 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=fieldPmPt.begin();
1933 for(;it1!=types.end();it1++,it2++)
1935 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
1936 elt->setLeaves((*it1).second);
1939 _field_pm_pt=fieldPmPt;
1942 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1944 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1945 (*it)->changePflsRefsNamesGen(mapOfModif);
1948 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1950 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1951 (*it)->changeLocsRefsNamesGen(mapOfModif);
1955 * \param [in] mesh is the whole mesh
1957 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
1959 if(_field_pm_pt.empty())
1960 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
1962 std::vector< std::pair<int,int> > dads;
1963 std::vector<const DataArrayInt *> pfls;
1964 std::vector<DataArrayInt *> notNullPflsPerGeoType;
1965 std::vector<int> locs,code;
1966 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
1967 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1968 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
1970 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
1973 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
1974 throw INTERP_KERNEL::Exception(oss.str().c_str());
1977 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
1978 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
1981 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
1983 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
1986 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr);
1987 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
1993 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
1997 if(nb!=mesh->getNumberOfNodes())
1999 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2000 oss << " nodes in mesh !";
2001 throw INTERP_KERNEL::Exception(oss.str().c_str());
2003 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2006 return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2010 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2012 if(_field_pm_pt.empty())
2013 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2015 std::vector<std::pair<int,int> > dads;
2016 std::vector<const DataArrayInt *> pfls;
2017 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2018 std::vector<int> locs,code;
2019 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2020 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2021 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2023 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2026 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2027 throw INTERP_KERNEL::Exception(oss.str().c_str());
2029 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2030 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2033 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2034 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2039 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2043 if(nb!=mesh->getNumberOfNodes())
2045 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2046 oss << " nodes in mesh !";
2047 throw INTERP_KERNEL::Exception(oss.str().c_str());
2050 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2056 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
2060 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2062 (*it)->getSizes(globalSz,nbOfEntries);
2064 entries.resize(nbOfEntries);
2066 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2068 (*it)->fillValues(nbOfEntries,entries);
2072 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
2074 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2076 if((*it)->getGeoType()==typ)
2077 return (*it)->getLeafGivenLocId(locId);
2079 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2080 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2081 oss << "Possiblities are : ";
2082 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2084 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2085 oss << "\"" << cm2.getRepr() << "\", ";
2087 throw INTERP_KERNEL::Exception(oss.str().c_str());
2090 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
2092 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2094 if((*it)->getGeoType()==typ)
2095 return (*it)->getLeafGivenLocId(locId);
2097 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2098 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2099 oss << "Possiblities are : ";
2100 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2102 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2103 oss << "\"" << cm2.getRepr() << "\", ";
2105 throw INTERP_KERNEL::Exception(oss.str().c_str());
2108 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2111 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2112 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=_field_pm_pt.begin();
2113 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2115 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2120 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2125 int ret=std::distance(_field_pm_pt.begin(),it2);
2126 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2131 * 'dads' and 'locs' input parameters have the same number of elements
2132 * \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
2134 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2135 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2136 const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2139 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2140 ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2141 MEDCouplingAutoRefCountObjectPtr<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2142 const std::vector<std::string>& infos=getInfo();
2143 da->setInfoOnComponents(infos);
2145 if(type==ON_GAUSS_PT)
2148 int nbOfArrs=dads.size();
2149 for(int i=0;i<nbOfArrs;i++)
2151 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2152 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2153 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2154 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> di=DataArrayInt::New();
2155 di->alloc(nbOfElems,1);
2157 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2158 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2167 * 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.
2168 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2169 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2170 * The order of cells in the returned field is those imposed by the profile.
2171 * \param [in] mesh is the global mesh.
2173 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2174 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2175 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2176 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2178 if(da->isIdentity())
2180 int nbOfTuples=da->getNumberOfTuples();
2181 if(nbOfTuples==mesh->getNumberOfCells())
2182 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2184 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2185 m2->setName(mesh->getName());
2186 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2192 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2194 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2195 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2196 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2198 if(da->isIdentity())
2200 int nbOfTuples=da->getNumberOfTuples();
2201 if(nbOfTuples==mesh->getNumberOfNodes())//No problem for NORM_ERROR because it is in context of node
2202 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2204 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2205 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2208 if(meshu->getNodalConnectivity()==0)
2210 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2211 int nb=da->getNbOfElems();
2212 const int *ptr=da->getConstPointer();
2213 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2214 meshuc->allocateCells(nb);
2215 for(int i=0;i<nb;i++)
2216 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2217 meshuc->finishInsertingCells();
2218 ret->setMesh(meshuc);
2219 const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2220 if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2221 disc->checkCoherencyBetween(meshuc,arrOut);
2226 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2228 DataArrayInt *arr2=0;
2229 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2230 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2231 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3(arr2);
2232 int nnodes=mesh2->getNumberOfNodes();
2233 if(nnodes==(int)da->getNbOfElems())
2235 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2236 arrOut->renumberInPlace(da3->getConstPointer());
2237 mesh2->setName(mesh->getName());
2238 ret->setMesh(mesh2);
2243 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 !!!";
2244 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2245 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2246 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2247 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2248 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2249 throw INTERP_KERNEL::Exception(oss.str().c_str());
2255 * This method is the most light method of field retrieving.
2257 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const throw(INTERP_KERNEL::Exception)
2261 pflOut=DataArrayInt::New();
2262 pflOut->alloc(nbOfElems,1);
2267 pflOut=const_cast<DataArrayInt*>(pflIn);
2270 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> safePfl(pflOut);
2271 MEDCouplingAutoRefCountObjectPtr<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2272 const std::vector<std::string>& infos=getInfo();
2273 int nbOfComp=infos.size();
2274 for(int i=0;i<nbOfComp;i++)
2275 da->setInfoOnComponent(i,infos[i].c_str());
2280 MEDFileFieldPerMesh::MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception):_mesh_iteration(meshIteration),_mesh_order(meshOrder),
2281 _mesh_csit(meshCsit),_father(fath)
2283 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2284 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2285 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2286 for(int i=0;i<MED_N_CELL_FIXED_GEO;i++)
2288 int nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL,typmai[i],_mesh_csit,meshName,pflName,locName);
2291 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[i],nasc));
2292 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2294 nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[i],_mesh_csit,meshName,pflName,locName);
2297 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_GAUSS_NE,typmai2[i],nasc));
2298 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2301 int nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,_mesh_csit,meshName,pflName,locName);
2304 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc));
2305 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2309 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2311 copyTinyInfoFrom(mesh);
2314 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception)
2316 if(id>=(int)_pfls.size())
2318 _pfls[id]=DataArrayInt::New();
2319 int lgth=MEDprofileSizeByName(fid,pflName);
2320 _pfls[id]->setName(pflName);
2321 _pfls[id]->alloc(lgth,1);
2322 MEDprofileRd(fid,pflName,_pfls[id]->getPointer());
2323 _pfls[id]->applyLin(1,-1,0);//Converting into C format
2326 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2328 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2330 MEDprofileInfo(fid,i+1,pflName,&sz);
2331 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2332 if(i>=(int)_pfls.size())
2334 _pfls[i]=DataArrayInt::New();
2335 _pfls[i]->alloc(sz,1);
2336 _pfls[i]->setName(pflCpp.c_str());
2337 MEDprofileRd(fid,pflName,_pfls[i]->getPointer());
2338 _pfls[i]->applyLin(1,-1,0);//Converting into C format
2341 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception)
2343 int nbOfPfls=_pfls.size();
2344 for(int i=0;i<nbOfPfls;i++)
2346 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cpy=_pfls[i]->deepCpy();
2347 cpy->applyLin(1,1,0);
2348 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2349 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2350 MEDprofileWr(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer());
2353 int nbOfLocs=_locs.size();
2354 for(int i=0;i<nbOfLocs;i++)
2355 _locs[i]->writeLL(fid);
2358 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps) throw(INTERP_KERNEL::Exception)
2360 std::vector<std::string> pfls=getPfls();
2361 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2363 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2366 _pfls.push_back(*it);
2370 int id=std::distance(pfls.begin(),it2);
2371 if(!(*it)->isEqual(*_pfls[id]))
2373 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2374 throw INTERP_KERNEL::Exception(oss.str().c_str());
2378 std::vector<std::string> locs=getLocs();
2379 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2381 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2384 _locs.push_back(*it);
2388 int id=std::distance(locs.begin(),it2);
2389 if(!(*it)->isEqual(*_locs[id],eps))
2391 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2392 throw INTERP_KERNEL::Exception(oss.str().c_str());
2398 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const throw(INTERP_KERNEL::Exception)
2400 for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
2401 getProfile((*it).c_str());
2404 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const throw(INTERP_KERNEL::Exception)
2406 for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
2407 getLocalization((*it).c_str());
2410 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real) throw(INTERP_KERNEL::Exception)
2412 std::vector<std::string> profiles=real.getPflsReallyUsed();
2413 int sz=profiles.size();
2415 for(int i=0;i<sz;i++)
2416 loadProfileInFile(fid,i,profiles[i].c_str());
2418 std::vector<std::string> locs=real.getLocsReallyUsed();
2421 for(int i=0;i<sz;i++)
2422 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2425 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
2427 int nProfil=MEDnProfile(fid);
2428 for(int i=0;i<nProfil;i++)
2429 loadProfileInFile(fid,i);
2430 int sz=MEDnLocalization(fid);
2432 for(int i=0;i<sz;i++)
2434 _locs[i]=MEDFileFieldLoc::New(fid,i);
2438 MEDFileFieldGlobs *MEDFileFieldGlobs::New(const char *fname)
2440 return new MEDFileFieldGlobs(fname);
2443 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2445 return new MEDFileFieldGlobs;
2448 std::size_t MEDFileFieldGlobs::getHeapMemorySize() const
2450 std::size_t ret=_file_name.capacity()+_pfls.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<DataArrayInt>)+_locs.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>);
2451 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2452 ret+=(*it)->getHeapMemorySize();
2453 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2454 ret+=(*it)->getHeapMemorySize();
2458 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpy() const throw(INTERP_KERNEL::Exception)
2460 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
2462 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2464 if((const DataArrayInt *)*it)
2465 ret->_pfls[i]=(*it)->deepCpy();
2468 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2470 if((const MEDFileFieldLoc*)*it)
2471 ret->_locs[i]=(*it)->deepCpy();
2477 * \throw if a profile in \a pfls in not in \a this.
2478 * \throw if a localization in \a locs in not in \a this.
2479 * \sa MEDFileFieldGlobs::deepCpyPart
2481 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const throw(INTERP_KERNEL::Exception)
2483 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2484 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2486 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2488 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
2490 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2(pfl);
2491 ret->_pfls.push_back(pfl2);
2493 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2495 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2497 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
2499 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> loc2(loc);
2500 ret->_locs.push_back(loc2);
2502 ret->setFileName(getFileName());
2507 * \throw if a profile in \a pfls in not in \a this.
2508 * \throw if a localization in \a locs in not in \a this.
2509 * \sa MEDFileFieldGlobs::shallowCpyPart
2511 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const throw(INTERP_KERNEL::Exception)
2513 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2514 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2516 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2518 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
2519 ret->_pfls.push_back(pfl->deepCpy());
2521 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2523 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2525 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
2526 ret->_locs.push_back(loc->deepCpy());
2528 ret->setFileName(getFileName());
2532 MEDFileFieldGlobs::MEDFileFieldGlobs(const char *fname):_file_name(fname)
2536 MEDFileFieldGlobs::MEDFileFieldGlobs()
2540 MEDFileFieldGlobs::~MEDFileFieldGlobs()
2544 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
2546 oss << "Profiles :\n";
2547 std::size_t n=_pfls.size();
2548 for(std::size_t i=0;i<n;i++)
2550 oss << " - #" << i << " ";
2551 const DataArrayInt *pfl=_pfls[i];
2553 oss << "\"" << pfl->getName() << "\"\n";
2558 oss << "Localizations :\n";
2559 for(std::size_t i=0;i<n;i++)
2561 oss << " - #" << i << " ";
2562 const MEDFileFieldLoc *loc=_locs[i];
2564 loc->simpleRepr(oss);
2570 void MEDFileFieldGlobs::setFileName(const char *fileName)
2572 _file_name=fileName;
2575 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2577 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
2579 DataArrayInt *elt(*it);
2582 std::string name(elt->getName());
2583 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2585 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2587 elt->setName((*it2).second.c_str());
2595 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2597 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
2599 MEDFileFieldLoc *elt(*it);
2602 std::string name(elt->getName());
2603 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2605 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2607 elt->setName((*it2).second.c_str());
2615 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception)
2617 if(locId<0 || locId>=(int)_locs.size())
2618 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
2619 return _locs[locId]->getNbOfGaussPtPerCell();
2622 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception)
2624 return getLocalizationFromId(getLocalizationId(locName));
2627 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception)
2629 if(locId<0 || locId>=(int)_locs.size())
2630 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2631 return *_locs[locId];
2634 namespace ParaMEDMEMImpl
2639 LocFinder(const char *loc):_loc(loc) { }
2640 bool operator() (const MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
2648 PflFinder(const std::string& pfl):_pfl(pfl) { }
2649 bool operator() (const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
2651 const std::string& _pfl;
2655 int MEDFileFieldGlobs::getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception)
2657 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),ParaMEDMEMImpl::LocFinder(loc));
2660 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
2661 for(it=_locs.begin();it!=_locs.end();it++)
2662 oss << "\"" << (*it)->getName() << "\", ";
2663 throw INTERP_KERNEL::Exception(oss.str().c_str());
2665 return std::distance(_locs.begin(),it);
2669 * The returned value is never null.
2671 const DataArrayInt *MEDFileFieldGlobs::getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception)
2673 std::string pflNameCpp(pflName);
2674 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2677 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2678 for(it=_pfls.begin();it!=_pfls.end();it++)
2679 oss << "\"" << (*it)->getName() << "\", ";
2680 throw INTERP_KERNEL::Exception(oss.str().c_str());
2685 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception)
2687 if(pflId<0 || pflId>=(int)_pfls.size())
2688 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2689 return _pfls[pflId];
2692 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception)
2694 if(locId<0 || locId>=(int)_locs.size())
2695 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2696 return *_locs[locId];
2699 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const char *locName) throw(INTERP_KERNEL::Exception)
2701 return getLocalizationFromId(getLocalizationId(locName));
2705 * The returned value is never null.
2707 DataArrayInt *MEDFileFieldGlobs::getProfile(const char *pflName) throw(INTERP_KERNEL::Exception)
2709 std::string pflNameCpp(pflName);
2710 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2713 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2714 for(it=_pfls.begin();it!=_pfls.end();it++)
2715 oss << "\"" << (*it)->getName() << "\", ";
2716 throw INTERP_KERNEL::Exception(oss.str().c_str());
2721 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception)
2723 if(pflId<0 || pflId>=(int)_pfls.size())
2724 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2725 return _pfls[pflId];
2728 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds) throw(INTERP_KERNEL::Exception)
2730 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newPfls;
2732 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2734 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
2735 newPfls.push_back(*it);
2740 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds) throw(INTERP_KERNEL::Exception)
2742 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> > newLocs;
2744 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2746 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
2747 newLocs.push_back(*it);
2752 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
2754 int sz=_pfls.size();
2755 std::vector<std::string> ret(sz);
2756 for(int i=0;i<sz;i++)
2757 ret[i]=_pfls[i]->getName();
2761 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
2763 int sz=_locs.size();
2764 std::vector<std::string> ret(sz);
2765 for(int i=0;i<sz;i++)
2766 ret[i]=_locs[i]->getName();
2770 bool MEDFileFieldGlobs::existsPfl(const char *pflName) const
2772 std::vector<std::string> v=getPfls();
2773 std::string s(pflName);
2774 return std::find(v.begin(),v.end(),s)!=v.end();
2777 bool MEDFileFieldGlobs::existsLoc(const char *locName) const
2779 std::vector<std::string> v=getLocs();
2780 std::string s(locName);
2781 return std::find(v.begin(),v.end(),s)!=v.end();
2784 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
2786 std::map<int,std::vector<int> > m;
2788 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2790 const DataArrayInt *tmp=(*it);
2793 m[tmp->getHashCode()].push_back(i);
2796 std::vector< std::vector<int> > ret;
2797 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
2799 if((*it2).second.size()>1)
2801 std::vector<int> ret0;
2802 bool equalityOrNot=false;
2803 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
2805 std::vector<int>::const_iterator it4=it3; it4++;
2806 for(;it4!=(*it2).second.end();it4++)
2808 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
2811 ret0.push_back(*it3);
2812 ret0.push_back(*it4);
2818 ret.push_back(ret0);
2824 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
2826 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
2829 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception)
2831 std::string name(pfl->getName());
2833 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
2834 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2835 if(name==(*it)->getName())
2837 if(!pfl->isEqual(*(*it)))
2839 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
2840 throw INTERP_KERNEL::Exception(oss.str().c_str());
2844 _pfls.push_back(pfl);
2847 void MEDFileFieldGlobs::appendLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w) throw(INTERP_KERNEL::Exception)
2849 std::string name(locName);
2851 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
2852 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
2853 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2854 if((*it)->isName(locName))
2856 if(!(*it)->isEqual(*obj,1e-12))
2858 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
2859 throw INTERP_KERNEL::Exception(oss.str().c_str());
2862 _locs.push_back(obj);
2865 std::string MEDFileFieldGlobs::createNewNameOfPfl() const throw(INTERP_KERNEL::Exception)
2867 std::vector<std::string> names=getPfls();
2868 return CreateNewNameNotIn("NewPfl_",names);
2871 std::string MEDFileFieldGlobs::createNewNameOfLoc() const throw(INTERP_KERNEL::Exception)
2873 std::vector<std::string> names=getLocs();
2874 return CreateNewNameNotIn("NewLoc_",names);
2877 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const char *prefix, const std::vector<std::string>& namesToAvoid) throw(INTERP_KERNEL::Exception)
2879 for(std::size_t sz=0;sz<100000;sz++)
2881 std::ostringstream tryName;
2882 tryName << prefix << sz;
2883 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
2884 return tryName.str();
2886 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
2890 * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
2891 * \param [in] fname - the file name.
2893 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(const char *fname):_globals(MEDFileFieldGlobs::New(fname))
2898 * Creates an empty MEDFileFieldGlobsReal.
2900 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
2904 std::size_t MEDFileFieldGlobsReal::getHeapMemorySize() const
2907 if((const MEDFileFieldGlobs *)_globals)
2908 ret+=_globals->getHeapMemorySize();
2913 * Returns a string describing profiles and Gauss points held in \a this.
2914 * \return std::string - the description string.
2916 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
2918 const MEDFileFieldGlobs *glob=_globals;
2919 std::ostringstream oss2; oss2 << glob;
2920 std::string stars(oss2.str().length(),'*');
2921 oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n";
2923 glob->simpleRepr(oss);
2925 oss << "NO GLOBAL INFORMATION !\n";
2928 void MEDFileFieldGlobsReal::resetContent()
2930 _globals=MEDFileFieldGlobs::New();
2933 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
2938 * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
2939 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
2941 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
2943 _globals=other._globals;
2947 * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
2948 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
2950 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other) throw(INTERP_KERNEL::Exception)
2952 const MEDFileFieldGlobs *otherg(other._globals);
2955 _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
2959 * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
2960 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
2962 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other) throw(INTERP_KERNEL::Exception)
2964 const MEDFileFieldGlobs *otherg(other._globals);
2967 _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
2970 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
2972 _globals=other._globals;
2973 if((const MEDFileFieldGlobs *)_globals)
2974 _globals=other._globals->deepCpy();
2978 * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
2979 * \param [in] other - the MEDFileFieldGlobsReal to copy data from.
2980 * \param [in] eps - a precision used to compare Gauss points with same name held by
2981 * \a this and \a other MEDFileFieldGlobsReal.
2982 * \throw If \a this and \a other hold profiles with equal names but different ids.
2983 * \throw If \a this and \a other hold different Gauss points with equal names.
2985 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps) throw(INTERP_KERNEL::Exception)
2987 const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
2988 if(thisGlobals==otherGlobals)
2992 _globals=other._globals;
2995 _globals->appendGlobs(*other._globals,eps);
2998 void MEDFileFieldGlobsReal::checkGlobsCoherency() const throw(INTERP_KERNEL::Exception)
3000 checkGlobsPflsPartCoherency();
3001 checkGlobsLocsPartCoherency();
3004 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const throw(INTERP_KERNEL::Exception)
3006 contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3009 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const throw(INTERP_KERNEL::Exception)
3011 contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3014 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception)
3016 contentNotNull()->loadProfileInFile(fid,id,pflName);
3019 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3021 contentNotNull()->loadProfileInFile(fid,id);
3024 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
3026 contentNotNull()->loadGlobals(fid,*this);
3029 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
3031 contentNotNull()->loadAllGlobals(fid);
3034 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception)
3036 contentNotNull()->writeGlobals(fid,opt);
3040 * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3041 * or getPflsReallyUsedMulti().
3042 * \return std::vector<std::string> - a sequence of names of all profiles.
3044 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3046 return contentNotNull()->getPfls();
3050 * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3051 * or getLocsReallyUsedMulti().
3052 * \return std::vector<std::string> - a sequence of names of all localizations.
3054 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3056 return contentNotNull()->getLocs();
3060 * Checks if the profile with a given name exists.
3061 * \param [in] pflName - the profile name of interest.
3062 * \return bool - \c true if the profile named \a pflName exists.
3064 bool MEDFileFieldGlobsReal::existsPfl(const char *pflName) const
3066 return contentNotNull()->existsPfl(pflName);
3070 * Checks if the localization with a given name exists.
3071 * \param [in] locName - the localization name of interest.
3072 * \return bool - \c true if the localization named \a locName exists.
3074 bool MEDFileFieldGlobsReal::existsLoc(const char *locName) const
3076 return contentNotNull()->existsLoc(locName);
3079 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const throw(INTERP_KERNEL::Exception)
3081 return contentNotNull()->createNewNameOfPfl();
3084 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const throw(INTERP_KERNEL::Exception)
3086 return contentNotNull()->createNewNameOfLoc();
3090 * Sets the name of a MED file.
3091 * \param [inout] fileName - the file name.
3093 void MEDFileFieldGlobsReal::setFileName(const char *fileName)
3095 contentNotNull()->setFileName(fileName);
3099 * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3100 * in the same order.
3101 * \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3102 * Each item of this sequence is a vector containing ids of equal profiles.
3104 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3106 return contentNotNull()->whichAreEqualProfiles();
3110 * Finds equal localizations.
3111 * \param [in] eps - a precision used to compare real values of the localizations.
3112 * \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3113 * Each item of this sequence is a vector containing ids of equal localizations.
3115 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3117 return contentNotNull()->whichAreEqualLocs(eps);
3121 * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3122 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3123 * this sequence is a pair whose
3124 * - the first item is a vector of profile names to replace by the second item,
3125 * - the second item is a profile name to replace every profile name of the first item.
3127 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3129 contentNotNull()->changePflsNamesInStruct(mapOfModif);
3133 * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3134 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3135 * this sequence is a pair whose
3136 * - the first item is a vector of localization names to replace by the second item,
3137 * - the second item is a localization name to replace every localization name of the first item.
3139 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3141 contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3145 * Replaces references to some profiles (a reference is a profile name) by references
3146 * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3147 * them-selves accordingly. <br>
3148 * This method is a generalization of changePflName().
3149 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3150 * this sequence is a pair whose
3151 * - the first item is a vector of profile names to replace by the second item,
3152 * - the second item is a profile name to replace every profile of the first item.
3153 * \sa changePflsRefsNamesGen()
3154 * \sa changePflName()
3156 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3158 changePflsRefsNamesGen(mapOfModif);
3159 changePflsNamesInStruct(mapOfModif);
3163 * Replaces references to some localizations (a reference is a localization name) by references
3164 * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3165 * them-selves accordingly. <br>
3166 * This method is a generalization of changeLocName().
3167 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3168 * this sequence is a pair whose
3169 * - the first item is a vector of localization names to replace by the second item,
3170 * - the second item is a localization name to replace every localization of the first item.
3171 * \sa changeLocsRefsNamesGen()
3172 * \sa changeLocName()
3174 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3176 changeLocsRefsNamesGen(mapOfModif);
3177 changeLocsNamesInStruct(mapOfModif);
3181 * Renames the profile having a given name and updates references to this profile.
3182 * \param [in] oldName - the name of the profile to rename.
3183 * \param [in] newName - a new name of the profile.
3184 * \sa changePflsNames().
3186 void MEDFileFieldGlobsReal::changePflName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
3188 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3189 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3191 changePflsNames(mapOfModif);
3195 * Renames the localization having a given name and updates references to this localization.
3196 * \param [in] oldName - the name of the localization to rename.
3197 * \param [in] newName - a new name of the localization.
3198 * \sa changeLocsNames().
3200 void MEDFileFieldGlobsReal::changeLocName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
3202 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3203 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3205 changeLocsNames(mapOfModif);
3209 * Removes duplicated profiles. Returns a map used to update references to removed
3210 * profiles via changePflsRefsNamesGen().
3211 * Equal profiles are found using whichAreEqualProfiles().
3212 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3213 * a sequence describing the performed replacements of profiles. Each element of
3214 * this sequence is a pair whose
3215 * - the first item is a vector of profile names replaced by the second item,
3216 * - the second item is a profile name replacing every profile of the first item.
3218 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames() throw(INTERP_KERNEL::Exception)
3220 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3221 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3223 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3225 std::vector< std::string > tmp((*it).size());
3227 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3228 tmp[j]=std::string(getProfileFromId(*it2)->getName());
3229 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3231 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3232 killProfileIds(tmp2);
3234 changePflsRefsNamesGen(ret);
3239 * Removes duplicated localizations. Returns a map used to update references to removed
3240 * localizations via changeLocsRefsNamesGen().
3241 * Equal localizations are found using whichAreEqualLocs().
3242 * \param [in] eps - a precision used to compare real values of the localizations.
3243 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3244 * a sequence describing the performed replacements of localizations. Each element of
3245 * this sequence is a pair whose
3246 * - the first item is a vector of localization names replaced by the second item,
3247 * - the second item is a localization name replacing every localization of the first item.
3249 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps) throw(INTERP_KERNEL::Exception)
3251 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3252 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3254 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3256 std::vector< std::string > tmp((*it).size());
3258 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3259 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3260 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3262 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3263 killLocalizationIds(tmp2);
3265 changeLocsRefsNamesGen(ret);
3270 * Returns number of Gauss points per cell in a given localization.
3271 * \param [in] locId - an id of the localization of interest.
3272 * \return int - the number of the Gauss points per cell.
3274 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception)
3276 return contentNotNull()->getNbOfGaussPtPerCell(locId);
3280 * Returns an id of a localization by its name.
3281 * \param [in] loc - the localization name of interest.
3282 * \return int - the id of the localization.
3283 * \throw If there is no a localization named \a loc.
3285 int MEDFileFieldGlobsReal::getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception)
3287 return contentNotNull()->getLocalizationId(loc);
3291 * Returns the name of the MED file.
3292 * \return const char * - the MED file name.
3294 const char *MEDFileFieldGlobsReal::getFileName() const
3296 return contentNotNull()->getFileName();
3299 std::string MEDFileFieldGlobsReal::getFileName2() const
3301 return contentNotNull()->getFileName2();
3305 * Returns a localization object by its name.
3306 * \param [in] locName - the name of the localization of interest.
3307 * \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3308 * \throw If there is no a localization named \a locName.
3310 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception)
3312 return contentNotNull()->getLocalization(locName);
3316 * Returns a localization object by its id.
3317 * \param [in] locId - the id of the localization of interest.
3318 * \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3319 * \throw If there is no a localization with id \a locId.
3321 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception)
3323 return contentNotNull()->getLocalizationFromId(locId);
3327 * Returns a profile array by its name.
3328 * \param [in] pflName - the name of the profile of interest.
3329 * \return const DataArrayInt * - the profile array having the name \a pflName.
3330 * \throw If there is no a profile named \a pflName.
3332 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception)
3334 return contentNotNull()->getProfile(pflName);
3338 * Returns a profile array by its id.
3339 * \param [in] pflId - the id of the profile of interest.
3340 * \return const DataArrayInt * - the profile array having the id \a pflId.
3341 * \throw If there is no a profile with id \a pflId.
3343 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception)
3345 return contentNotNull()->getProfileFromId(pflId);
3349 * Returns a localization object, apt for modification, by its id.
3350 * \param [in] locId - the id of the localization of interest.
3351 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3352 * having the id \a locId.
3353 * \throw If there is no a localization with id \a locId.
3355 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception)
3357 return contentNotNull()->getLocalizationFromId(locId);
3361 * Returns a localization object, apt for modification, by its name.
3362 * \param [in] locName - the name of the localization of interest.
3363 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3364 * having the name \a locName.
3365 * \throw If there is no a localization named \a locName.
3367 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const char *locName) throw(INTERP_KERNEL::Exception)
3369 return contentNotNull()->getLocalization(locName);
3373 * Returns a profile array, apt for modification, by its name.
3374 * \param [in] pflName - the name of the profile of interest.
3375 * \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3376 * \throw If there is no a profile named \a pflName.
3378 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const char *pflName) throw(INTERP_KERNEL::Exception)
3380 return contentNotNull()->getProfile(pflName);
3384 * Returns a profile array, apt for modification, by its id.
3385 * \param [in] pflId - the id of the profile of interest.
3386 * \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3387 * \throw If there is no a profile with id \a pflId.
3389 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception)
3391 return contentNotNull()->getProfileFromId(pflId);
3395 * Removes profiles given by their ids. No data is updated to track this removal.
3396 * \param [in] pflIds - a sequence of ids of the profiles to remove.
3398 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds) throw(INTERP_KERNEL::Exception)
3400 contentNotNull()->killProfileIds(pflIds);
3404 * Removes localizations given by their ids. No data is updated to track this removal.
3405 * \param [in] locIds - a sequence of ids of the localizations to remove.
3407 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds) throw(INTERP_KERNEL::Exception)
3409 contentNotNull()->killLocalizationIds(locIds);
3413 * Stores a profile array.
3414 * \param [in] pfl - the profile array to store.
3415 * \throw If the name of \a pfl is empty.
3416 * \throw If a profile with the same name as that of \a pfl already exists but contains
3419 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception)
3421 contentNotNull()->appendProfile(pfl);
3425 * Adds a new localization of Gauss points.
3426 * \param [in] locName - the name of the new localization.
3427 * \param [in] geoType - a geometrical type of the reference cell.
3428 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
3429 * must be \c nbOfNodesPerCell * \c dimOfType.
3430 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
3431 * must be _wg_.size() * \c dimOfType.
3432 * \param [in] w - the weights of Gauss points.
3433 * \throw If \a locName is empty.
3434 * \throw If a localization with the name \a locName already exists but is
3435 * different form the new one.
3437 void MEDFileFieldGlobsReal::appendLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w) throw(INTERP_KERNEL::Exception)
3439 contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
3442 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() throw(INTERP_KERNEL::Exception)
3444 MEDFileFieldGlobs *g(_globals);
3446 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
3450 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const throw(INTERP_KERNEL::Exception)
3452 const MEDFileFieldGlobs *g(_globals);
3454 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
3458 //= MEDFileFieldNameScope
3460 MEDFileFieldNameScope::MEDFileFieldNameScope()
3464 MEDFileFieldNameScope::MEDFileFieldNameScope(const char *fieldName):_name(fieldName)
3469 * Returns the name of \a this field.
3470 * \return std::string - a string containing the field name.
3472 std::string MEDFileFieldNameScope::getName() const throw(INTERP_KERNEL::Exception)
3478 * Sets name of \a this field
3479 * \param [in] name - the new field name.
3481 void MEDFileFieldNameScope::setName(const char *fieldName) throw(INTERP_KERNEL::Exception)
3486 std::string MEDFileFieldNameScope::getDtUnit() const throw(INTERP_KERNEL::Exception)
3491 void MEDFileFieldNameScope::setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception)
3496 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
3499 _dt_unit=other._dt_unit;
3502 //= MEDFileAnyTypeField1TSWithoutSDA
3504 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other) throw(INTERP_KERNEL::Exception)
3506 _field_per_mesh.resize(other._field_per_mesh.size());
3508 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
3510 if((const MEDFileFieldPerMesh *)*it)
3511 _field_per_mesh[i]=(*it)->deepCpy(this);
3516 * Prints a string describing \a this field into a stream. This string is outputted
3517 * by \c print Python command.
3518 * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
3519 * \param [in,out] oss - the out stream.
3520 * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
3521 * info id printed, else, not.
3523 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
3525 std::string startOfLine(bkOffset,' ');
3526 oss << startOfLine << "Field ";
3528 oss << "[Type=" << getTypeStr() << "] ";
3529 oss << "on One time Step ";
3531 oss << "(" << f1tsId << ") ";
3532 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
3533 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
3534 const DataArray *arr=getUndergroundDataArray();
3537 const std::vector<std::string> &comps=arr->getInfoOnComponents();
3540 oss << startOfLine << "Field Name : \"" << arr->getName() << "\"." << std::endl;
3541 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
3542 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
3543 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
3545 if(arr->isAllocated())
3547 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
3550 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
3554 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
3556 oss << startOfLine << "----------------------" << std::endl;
3557 if(!_field_per_mesh.empty())
3560 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
3562 const MEDFileFieldPerMesh *cur=(*it2);
3564 cur->simpleRepr(bkOffset,oss,i);
3566 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
3571 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
3573 oss << startOfLine << "----------------------" << std::endl;
3576 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const throw(INTERP_KERNEL::Exception)
3578 const DataArray *arr(getUndergroundDataArray());
3580 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
3581 int nbOfCompo=arr->getNumberOfComponents();
3582 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
3583 for(int i=0;i<nbOfCompo;i++)
3586 std::vector<int> v(1,i);
3587 MEDCouplingAutoRefCountObjectPtr<DataArray> arr2=arr->keepSelectedComponents(v);
3588 ret[i]->setArray(arr2);
3593 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order):MEDFileFieldNameScope(fieldName),_iteration(iteration),_order(order),_csit(csit),_nb_of_tuples_to_be_allocated(-2)
3597 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
3602 * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
3603 * empty. Returns -1 if this in on nodes.
3604 * \return int - the dimension of \a this.
3606 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
3609 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3610 (*it)->getDimension(ret);
3615 * Returns the mesh name.
3616 * \return std::string - a string holding the mesh name.
3617 * \throw If \c _field_per_mesh.empty()
3619 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const throw(INTERP_KERNEL::Exception)
3621 if(_field_per_mesh.empty())
3622 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
3623 return _field_per_mesh[0]->getMeshName();
3626 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
3628 std::string oldName(getMeshName());
3629 std::vector< std::pair<std::string,std::string> > v(1);
3630 v[0].first=oldName; v[0].second=newMeshName;
3634 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
3637 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3639 MEDFileFieldPerMesh *cur(*it);
3641 ret=cur->changeMeshNames(modifTab) || ret;
3647 * Returns the number of iteration of the state of underlying mesh.
3648 * \return int - the iteration number.
3649 * \throw If \c _field_per_mesh.empty()
3651 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const throw(INTERP_KERNEL::Exception)
3653 if(_field_per_mesh.empty())
3654 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
3655 return _field_per_mesh[0]->getMeshIteration();
3659 * Returns the order number of iteration of the state of underlying mesh.
3660 * \return int - the order number.
3661 * \throw If \c _field_per_mesh.empty()
3663 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const throw(INTERP_KERNEL::Exception)
3665 if(_field_per_mesh.empty())
3666 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
3667 return _field_per_mesh[0]->getMeshOrder();
3671 * Checks if \a this field is tagged by a given iteration number and a given
3672 * iteration order number.
3673 * \param [in] iteration - the iteration number of interest.
3674 * \param [in] order - the iteration order number of interest.
3675 * \return bool - \c true if \a this->getIteration() == \a iteration &&
3676 * \a this->getOrder() == \a order.
3678 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
3680 return iteration==_iteration && order==_order;
3684 * Returns number of iteration and order number of iteration when
3685 * \a this field has been calculated.
3686 * \return std::pair<int,int> - a pair of the iteration number and the iteration
3689 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
3691 std::pair<int,int> p;
3697 * Returns number of iteration and order number of iteration when
3698 * \a this field has been calculated.
3699 * \param [in,out] p - a pair returning the iteration number and the iteration
3702 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
3709 * Returns all types of spatial discretization of \a this field.
3710 * \param [in,out] types - a sequence of types of \a this field.
3712 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
3714 std::set<TypeOfField> types2;
3715 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3717 (*it)->fillTypesOfFieldAvailable(types2);
3719 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
3720 std::copy(types2.begin(),types2.end(),bi);
3724 * Returns all types of spatial discretization of \a this field.
3725 * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
3728 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
3730 std::vector<TypeOfField> ret;
3731 fillTypesOfFieldAvailable(ret);
3735 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
3737 std::vector<std::string> ret;
3738 std::set<std::string> ret2;
3739 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3741 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
3742 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3743 if(ret2.find(*it2)==ret2.end())
3745 ret.push_back(*it2);
3752 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
3754 std::vector<std::string> ret;
3755 std::set<std::string> ret2;
3756 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3758 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
3759 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3760 if(ret2.find(*it2)==ret2.end())
3762 ret.push_back(*it2);
3769 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
3771 std::vector<std::string> ret;
3772 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3774 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
3775 ret.insert(ret.end(),tmp.begin(),tmp.end());
3780 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
3782 std::vector<std::string> ret;
3783 std::set<std::string> ret2;
3784 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3786 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
3787 ret.insert(ret.end(),tmp.begin(),tmp.end());
3792 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3794 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3795 (*it)->changePflsRefsNamesGen(mapOfModif);
3798 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3800 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3801 (*it)->changeLocsRefsNamesGen(mapOfModif);
3805 * Returns all attributes of parts of \a this field lying on a given mesh.
3806 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
3807 * item of every of returned sequences refers to the _i_-th part of \a this field.
3808 * Thus all sequences returned by this method are of the same length equal to number
3809 * of different types of supporting entities.<br>
3810 * A field part can include sub-parts with several different spatial discretizations,
3811 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
3812 * for example. Hence, some of the returned sequences contains nested sequences, and an item
3813 * of a nested sequence corresponds to a type of spatial discretization.<br>
3814 * This method allows for iteration over MEDFile DataStructure without any overhead.
3815 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
3816 * for the case with only one underlying mesh. (Actually, the number of meshes is
3817 * not checked if \a mname == \c NULL).
3818 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
3819 * a field part is returned.
3820 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
3821 * This sequence is of the same length as \a types.
3822 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
3823 * discretization. A profile name can be empty.
3824 * Length of this and of nested sequences is the same as that of \a typesF.
3825 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
3826 * discretization. A localization name can be empty.
3827 * Length of this and of nested sequences is the same as that of \a typesF.
3828 * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
3829 * of ids of tuples within the data array, per each type of spatial
3830 * discretization within one mesh entity type.
3831 * Length of this and of nested sequences is the same as that of \a typesF.
3832 * \throw If no field is lying on \a mname.
3834 std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeField1TSWithoutSDA::getFieldSplitedByType(const char *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 throw(INTERP_KERNEL::Exception)
3838 meshId=getMeshIdFromMeshName(mname);
3840 if(_field_per_mesh.empty())
3841 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
3842 return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3846 * Returns dimensions of mesh elements \a this field lies on. The returned value is a
3847 * maximal absolute dimension and values returned via the out parameter \a levs are
3848 * dimensions relative to the maximal absolute dimension. <br>
3849 * This method is designed for MEDFileField1TS instances that have a discretization
3850 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS",
3851 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT",
3852 * \ref ParaMEDMEM::ON_GAUSS_NE "ON_GAUSS_NE".
3853 * Only these 3 discretizations will be taken into account here. If \a this is
3854 * \ref ParaMEDMEM::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
3855 * This method is useful to make the link between the dimension of the underlying mesh
3856 * and the levels of \a this, because it is possible that the highest dimension of \a this
3857 * field is not equal to the dimension of the underlying mesh.
3859 * Let's consider the following case:
3860 * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
3861 * TETRA4, HEXA8, TRI3 and SEG2.
3862 * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
3863 * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
3865 * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
3866 * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
3867 * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
3868 * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
3869 * parameter of getFieldAtLevel() is computed basing on the returned values as this:
3870 * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
3872 * to retrieve the highest level of
3873 * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br>
3874 * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
3875 * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
3876 * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
3877 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
3878 * for the case with only one underlying mesh. (Actually, the number of meshes is
3879 * not checked if \a mname == \c NULL).
3880 * \param [in,out] levs - a sequence returning the dimensions relative to the maximal
3881 * absolute one. They are in decreasing order. This sequence is cleared before
3883 * \return int - the maximal absolute dimension of elements \a this fields lies on.
3884 * \throw If no field is lying on \a mname.
3886 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
3889 int meshId=getMeshIdFromMeshName(mname);
3890 std::vector<INTERP_KERNEL::NormalizedCellType> types;
3891 std::vector< std::vector<TypeOfField> > typesF;
3892 std::vector< std::vector<std::string> > pfls, locs;
3893 _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3895 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
3896 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
3897 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
3899 st.erase(INTERP_KERNEL::NORM_ERROR);
3901 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
3903 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
3904 ret1.insert((int)cm.getDimension());
3906 int ret=*std::max_element(ret1.begin(),ret1.end());
3907 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
3908 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
3913 * \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.
3914 * \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.
3915 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
3916 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
3918 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
3920 int mid=getMeshIdFromMeshName(mName);
3921 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
3925 * \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.
3926 * \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.
3927 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
3928 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
3930 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
3932 int mid=getMeshIdFromMeshName(mName);
3933 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
3937 * \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.
3939 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const char *mName) const throw(INTERP_KERNEL::Exception)
3941 if(_field_per_mesh.empty())
3942 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
3945 std::string mName2(mName);
3947 std::vector<std::string> msg;
3948 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
3949 if(mName2==(*it)->getMeshName())
3952 msg.push_back((*it)->getMeshName());
3953 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
3954 oss << "Possible meshes are : ";
3955 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
3956 oss << "\"" << (*it2) << "\" ";
3957 throw INTERP_KERNEL::Exception(oss.str().c_str());
3960 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
3963 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
3964 std::string tmp(mesh->getName());
3966 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
3967 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
3969 for(;it!=_field_per_mesh.end();it++,i++)
3971 if((*it)->getMeshName()==tmp)
3974 int sz=_field_per_mesh.size();
3975 _field_per_mesh.resize(sz+1);
3976 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
3980 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
3981 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
3984 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3986 MEDFileFieldPerMesh *fpm(*it);
3988 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
3993 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
3995 if(_field_per_mesh.empty())
3996 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
3997 if(_field_per_mesh.size()>1)
3998 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
3999 _field_per_mesh[0]->copyOptionsFrom(opts);
4000 _field_per_mesh[0]->writeLL(fid,nasc);
4003 void MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile() throw(INTERP_KERNEL::Exception)
4005 if(_nb_of_tuples_to_be_allocated>=0)
4007 getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4008 _nb_of_tuples_to_be_allocated=-2;
4011 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4013 if(_nb_of_tuples_to_be_allocated==-1)
4014 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4015 if(_nb_of_tuples_to_be_allocated<-3)
4016 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4020 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4022 med_int numdt,numit;
4026 med_int meshnumdt,meshnumit;
4027 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4028 MEDfieldComputingStepInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt);
4029 MEDfield23ComputingStepMeshInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit);
4030 if(_iteration!=numdt || _order!=numit)
4031 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4032 _field_per_mesh.resize(nmesh);
4033 for(int i=0;i<nmesh;i++)
4034 _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i+1,meshnumdt,meshnumit,nasc);//tony
4035 _nb_of_tuples_to_be_allocated=0;
4036 for(int i=0;i<nmesh;i++)
4037 _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4040 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4042 allocIfNecessaryTheArrayToReceiveDataFromFile();
4043 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4044 (*it)->loadBigArraysRecursively(fid,nasc);
4047 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4049 loadOnlyStructureOfDataRecursively(fid,nasc);
4050 loadBigArraysRecursively(fid,nasc);
4053 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySize() const
4055 std::size_t ret=_dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh >);
4056 if(getUndergroundDataArray())
4057 ret+=getUndergroundDataArray()->getHeapMemorySize();
4058 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4059 ret+=(*it)->getHeapMemorySize();
4064 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4065 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4066 * "Sort By Type"), if not, an exception is thrown.
4067 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
4068 * \param [in] arr - the array of values.
4069 * \param [in,out] glob - the global data where profiles and localization present in
4070 * \a field, if any, are added.
4071 * \throw If the name of \a field is empty.
4072 * \throw If the data array of \a field is not set.
4073 * \throw If \a this->_arr is already allocated but has different number of components
4075 * \throw If the underlying mesh of \a field has no name.
4076 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4078 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4080 const MEDCouplingMesh *mesh=field->getMesh();
4082 TypeOfField type=field->getTypeOfField();
4083 std::vector<DataArrayInt *> dummy;
4084 int start=copyTinyInfoFrom(field,arr);
4085 int pos=addNewEntryIfNecessary(mesh);
4088 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4089 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4092 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4096 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4097 * of a given mesh are used as the support of the given field (a real support is not used).
4098 * Elements of the given mesh must be sorted suitable for writing to MED file.
4099 * Order of underlying mesh entities of the given field specified by \a profile parameter
4100 * is not prescribed; this method permutes field values to have them sorted by element
4101 * type as required for writing to MED file. A new profile is added only if no equal
4102 * profile is missing.
4103 * \param [in] field - the field to add to \a this. The field double values are ignored.
4104 * \param [in] arrOfVals - the values of the field \a field used.
4105 * \param [in] mesh - the supporting mesh of \a field.
4106 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4107 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
4108 * \param [in,out] glob - the global data where profiles and localization present in
4109 * \a field, if any, are added.
4110 * \throw If either \a field or \a mesh or \a profile has an empty name.
4111 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4112 * \throw If the data array of \a field is not set.
4113 * \throw If \a this->_arr is already allocated but has different number of components
4115 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4116 * \sa setFieldNoProfileSBT()
4118 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4120 TypeOfField type=field->getTypeOfField();
4121 int start=copyTinyInfoFrom(field,arrOfVals);
4122 std::vector<DataArrayInt *> idsInPflPerType;
4123 std::vector<DataArrayInt *> idsPerType;
4124 std::vector<int> code,code2;
4125 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4128 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4129 code2=m->getDistributionOfTypes();
4131 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size());
4132 for(std::size_t i=0;i<idsInPflPerType.size();i++)
4133 idsInPflPerType2[i]=idsInPflPerType[i];
4134 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsPerType2(idsPerType.size());
4135 for(std::size_t i=0;i<idsPerType.size();i++)
4136 idsPerType2[i]=idsPerType[i];
4138 int pos=addNewEntryIfNecessary(m);
4139 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4143 int pos=addNewEntryIfNecessary(m);
4144 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4149 * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
4151 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples) throw(INTERP_KERNEL::Exception)
4153 if(_nb_of_tuples_to_be_allocated>=0)
4154 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 !");
4155 DataArray *arr(getOrCreateAndGetArray());
4156 arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
4157 _nb_of_tuples_to_be_allocated=-3;
4161 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4162 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4163 * larger by the size of \a field. Returns an id of the first not filled
4164 * tuple of \a this->_arr.
4165 * \param [in] field - the field to copy the info on components and the name from.
4166 * \return int - the id of first not initialized tuple of \a this->_arr.
4167 * \throw If the name of \a field is empty.
4168 * \throw If the data array of \a field is not set.
4169 * \throw If \a this->_arr is already allocated but has different number of components
4172 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception)
4175 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4176 std::string name(field->getName());
4177 setName(name.c_str());
4178 setDtUnit(field->getTimeUnit());
4180 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4182 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4183 if(!arr->isAllocated())
4184 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
4185 _dt=field->getTime(_iteration,_order);
4186 int nbOfComponents=arr->getNumberOfComponents();
4187 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4188 if(!getOrCreateAndGetArray()->isAllocated())
4190 allocNotFromFile(arr->getNumberOfTuples());
4195 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4196 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4197 getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
4198 _nb_of_tuples_to_be_allocated=-3;
4199 return oldNbOfTuples;
4204 * Returns number of components in \a this field
4205 * \return int - the number of components.
4207 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4209 return getOrCreateAndGetArray()->getNumberOfComponents();
4213 * Change info on components in \a this.
4214 * \throw If size of \a infos is not equal to the number of components already in \a this.
4216 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos) throw(INTERP_KERNEL::Exception)
4218 DataArray *arr=getOrCreateAndGetArray();
4219 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
4223 * Returns info on components of \a this field.
4224 * \return const std::vector<std::string>& - a sequence of strings each being an
4225 * information on _i_-th component.
4227 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
4229 const DataArray *arr=getOrCreateAndGetArray();
4230 return arr->getInfoOnComponents();
4234 * Returns a mutable info on components of \a this field.
4235 * \return std::vector<std::string>& - a sequence of strings each being an
4236 * information on _i_-th component.
4238 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
4240 DataArray *arr=getOrCreateAndGetArray();
4241 return arr->getInfoOnComponents();
4245 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4246 * \param [in] type - a spatial discretization of the new field.
4247 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4248 * \param [in] mName - a name of the supporting mesh.
4249 * \param [in] renumPol - specifies how to permute values of the result field according to
4250 * the optional numbers of cells and nodes, if any. The valid values are
4251 * - 0 - do not permute.
4252 * - 1 - permute cells.
4253 * - 2 - permute nodes.
4254 * - 3 - permute cells and nodes.
4256 * \param [in] glob - the global data storing profiles and localization.
4257 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4258 * caller is to delete this field using decrRef() as it is no more needed.
4259 * \throw If the MED file is not readable.
4260 * \throw If there is no mesh named \a mName in the MED file.
4261 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4262 * \throw If no field of \a this is lying on the mesh \a mName.
4263 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4265 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4267 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4269 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4271 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4272 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4276 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4277 * \param [in] type - a spatial discretization of the new field.
4278 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4279 * \param [in] renumPol - specifies how to permute values of the result field according to
4280 * the optional numbers of cells and nodes, if any. The valid values are
4281 * - 0 - do not permute.
4282 * - 1 - permute cells.
4283 * - 2 - permute nodes.
4284 * - 3 - permute cells and nodes.
4286 * \param [in] glob - the global data storing profiles and localization.
4287 * \param [in] mesh - the supporting mesh.
4288 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4289 * caller is to delete this field using decrRef() as it is no more needed.
4290 * \throw If the MED file is not readable.
4291 * \throw If no field of \a this is lying on \a mesh.
4292 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4293 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4295 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4297 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax,false);
4298 const DataArrayInt *d=mesh->getNumberFieldAtLevel(meshDimRelToMax);
4299 const DataArrayInt *e=mesh->getNumberFieldAtLevel(1);
4300 if(meshDimRelToMax==1)
4301 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
4302 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
4306 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
4308 * \param [in] type - a spatial discretization of the new field.
4309 * \param [in] mName - a name of the supporting mesh.
4310 * \param [in] renumPol - specifies how to permute values of the result field according to
4311 * the optional numbers of cells and nodes, if any. The valid values are
4312 * - 0 - do not permute.
4313 * - 1 - permute cells.
4314 * - 2 - permute nodes.
4315 * - 3 - permute cells and nodes.
4317 * \param [in] glob - the global data storing profiles and localization.
4318 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4319 * caller is to delete this field using decrRef() as it is no more needed.
4320 * \throw If the MED file is not readable.
4321 * \throw If there is no mesh named \a mName in the MED file.
4322 * \throw If there are no mesh entities in the mesh.
4323 * \throw If no field values of the given \a type are available.
4325 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4327 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4329 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4331 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4332 int absDim=getDimension();
4333 int meshDimRelToMax=absDim-mm->getMeshDimension();
4334 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4338 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4339 * \param [in] type - a spatial discretization of the new field.
4340 * \param [in] renumPol - specifies how to permute values of the result field according to
4341 * the optional numbers of cells and nodes, if any. The valid values are
4342 * - 0 - do not permute.
4343 * - 1 - permute cells.
4344 * - 2 - permute nodes.
4345 * - 3 - permute cells and nodes.
4347 * \param [in] glob - the global data storing profiles and localization.
4348 * \param [in] mesh - the supporting mesh.
4349 * \param [in] cellRenum - the cell numbers array used for permutation of the result
4350 * field according to \a renumPol.
4351 * \param [in] nodeRenum - the node numbers array used for permutation of the result
4352 * field according to \a renumPol.
4353 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4354 * caller is to delete this field using decrRef() as it is no more needed.
4355 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4356 * \throw If no field of \a this is lying on \a mesh.
4357 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4359 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, const DataArrayInt *cellRenum, const DataArrayInt *nodeRenum, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4361 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
4362 int meshId=getMeshIdFromMeshName(mesh->getName());
4364 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
4369 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4376 throw INTERP_KERNEL::Exception(msg1);
4377 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4380 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
4382 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4383 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
4384 throw INTERP_KERNEL::Exception(oss.str().c_str());
4386 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
4387 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
4388 std::vector<DataArray *> arrOut2(1,arrOut);
4389 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
4390 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
4391 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
4398 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4400 throw INTERP_KERNEL::Exception(msg1);
4403 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
4405 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4406 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
4407 throw INTERP_KERNEL::Exception(oss.str().c_str());
4409 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
4410 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
4411 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
4412 ret->renumberNodes(nodeRenumSafe->getConstPointer());
4417 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
4422 * Returns values and a profile of the field of a given type lying on a given support.
4423 * \param [in] type - a spatial discretization of the field.
4424 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4425 * \param [in] mesh - the supporting mesh.
4426 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
4427 * field of interest lies on. If the field lies on all entities of the given
4428 * dimension, all ids in \a pfl are zero. The caller is to delete this array
4429 * using decrRef() as it is no more needed.
4430 * \param [in] glob - the global data storing profiles and localization.
4431 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
4432 * field. The caller is to delete this array using decrRef() as it is no more needed.
4433 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4434 * \throw If no field of \a this is lying on \a mesh.
4435 * \throw If no field values of the given \a type are available.
4437 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4439 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4440 int meshId=getMeshIdFromMeshName(mesh->getName());
4441 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
4442 ret->setName(nasc.getName().c_str());
4446 //= MEDFileField1TSWithoutSDA
4449 * Throws if a given value is not a valid (non-extended) relative dimension.
4450 * \param [in] meshDimRelToMax - the relative dimension value.
4451 * \throw If \a meshDimRelToMax > 0.
4453 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax) throw(INTERP_KERNEL::Exception)
4455 if(meshDimRelToMax>0)
4456 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
4460 * Checks if elements of a given mesh are in the order suitable for writing
4461 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
4462 * vector describing types of elements and their number.
4463 * \param [in] mesh - the mesh to check.
4464 * \return std::vector<int> - a vector holding for each element type (1) item of
4465 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
4466 * These values are in full-interlace mode.
4467 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4469 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
4472 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
4473 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
4474 int nbOfTypes=geoTypes.size();
4475 std::vector<int> code(3*nbOfTypes);
4476 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr1=DataArrayInt::New();
4477 arr1->alloc(nbOfTypes,1);
4478 int *arrPtr=arr1->getPointer();
4479 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
4480 for(int i=0;i<nbOfTypes;i++,it++)
4481 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
4482 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
4483 const int *arrPtr2=arr2->getConstPointer();
4485 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
4488 int nbCells=mesh->getNumberOfCellsWithType(*it);
4489 code[3*pos]=(int)(*it);
4490 code[3*pos+1]=nbCells;
4491 code[3*pos+2]=-1;//no profiles
4493 std::vector<const DataArrayInt *> idsPerType;//no profiles
4494 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
4498 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
4503 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const char *fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
4505 return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
4509 * Returns all attributes and values of parts of \a this field lying on a given mesh.
4510 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4511 * item of every of returned sequences refers to the _i_-th part of \a this field.
4512 * Thus all sequences returned by this method are of the same length equal to number
4513 * of different types of supporting entities.<br>
4514 * A field part can include sub-parts with several different spatial discretizations,
4515 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
4516 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4517 * of a nested sequence corresponds to a type of spatial discretization.<br>
4518 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
4519 * The overhead is due to selecting values into new instances of DataArrayDouble.
4520 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4521 * for the case with only one underlying mesh. (Actually, the number of meshes is
4522 * not checked if \a mname == \c NULL).
4523 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4524 * a field part is returned.
4525 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4526 * A field part can include sub-parts with several different spatial discretizations,
4527 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and
4528 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT" for example.
4529 * This sequence is of the same length as \a types.
4530 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4531 * discretization. A profile name can be empty.
4532 * Length of this and of nested sequences is the same as that of \a typesF.
4533 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4534 * discretization. A localization name can be empty.
4535 * Length of this and of nested sequences is the same as that of \a typesF.
4536 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
4537 * per each type of spatial discretization within one mesh entity type.
4538 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
4539 * Length of this and of nested sequences is the same as that of \a typesF.
4540 * \throw If no field is lying on \a mname.
4542 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TSWithoutSDA::getFieldSplitedByType2(const char *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 throw(INTERP_KERNEL::Exception)
4546 meshId=getMeshIdFromMeshName(mname);
4548 if(_field_per_mesh.empty())
4549 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4550 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4551 int nbOfRet=ret0.size();
4552 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
4553 for(int i=0;i<nbOfRet;i++)
4555 const std::vector< std::pair<int,int> >& p=ret0[i];
4556 int nbOfRet1=p.size();
4557 ret[i].resize(nbOfRet1);
4558 for(int j=0;j<nbOfRet1;j++)
4560 DataArrayDouble *tmp=_arr->selectByTupleId2(p[j].first,p[j].second,1);
4568 * Returns a pointer to the underground DataArrayDouble instance. So the
4569 * caller should not decrRef() it. This method allows for a direct access to the field
4570 * values. This method is quite unusable if there is more than a nodal field or a cell
4571 * field on single geometric cell type.
4572 * \return DataArrayDouble * - the pointer to the field values array.
4574 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDouble() const throw(INTERP_KERNEL::Exception)
4576 const DataArrayDouble *ret=_arr;
4578 return const_cast<DataArrayDouble *>(ret);
4583 const char *MEDFileField1TSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
4588 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const throw(INTERP_KERNEL::Exception)
4590 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
4591 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
4592 ret->deepCpyLeavesFrom(*this);
4593 const DataArrayDouble *arr(_arr);
4596 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr->convertToIntArr());
4597 ret->setArray(arr2);
4603 * Returns a pointer to the underground DataArrayDouble instance. So the
4604 * caller should not decrRef() it. This method allows for a direct access to the field
4605 * values. This method is quite unusable if there is more than a nodal field or a cell
4606 * field on single geometric cell type.
4607 * \return DataArrayDouble * - the pointer to the field values array.
4609 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
4611 return getUndergroundDataArrayDouble();
4615 * Returns a pointer to the underground DataArrayDouble instance and a
4616 * sequence describing parameters of a support of each part of \a this field. The
4617 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
4618 * direct access to the field values. This method is intended for the field lying on one
4620 * \param [in,out] entries - the sequence describing parameters of a support of each
4621 * part of \a this field. Each item of this sequence consists of two parts. The
4622 * first part describes a type of mesh entity and an id of discretization of a
4623 * current field part. The second part describes a range of values [begin,end)
4624 * within the returned array relating to the current field part.
4625 * \return DataArrayDouble * - the pointer to the field values array.
4626 * \throw If the number of underlying meshes is not equal to 1.
4627 * \throw If no field values are available.
4628 * \sa getUndergroundDataArray()
4630 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4632 if(_field_per_mesh.size()!=1)
4633 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
4634 if(_field_per_mesh[0]==0)
4635 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
4636 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
4637 return getUndergroundDataArrayDouble();
4641 * Returns a pointer to the underground DataArrayDouble instance and a
4642 * sequence describing parameters of a support of each part of \a this field. The
4643 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
4644 * direct access to the field values. This method is intended for the field lying on one
4646 * \param [in,out] entries - the sequence describing parameters of a support of each
4647 * part of \a this field. Each item of this sequence consists of two parts. The
4648 * first part describes a type of mesh entity and an id of discretization of a
4649 * current field part. The second part describes a range of values [begin,end)
4650 * within the returned array relating to the current field part.
4651 * \return DataArrayDouble * - the pointer to the field values array.
4652 * \throw If the number of underlying meshes is not equal to 1.
4653 * \throw If no field values are available.
4654 * \sa getUndergroundDataArray()
4656 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4658 return getUndergroundDataArrayDoubleExt(entries);
4661 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order,
4662 const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
4664 DataArrayDouble *arr=getOrCreateAndGetArrayDouble();
4665 arr->setInfoAndChangeNbOfCompo(infos);
4668 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
4672 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
4674 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
4675 ret->deepCpyLeavesFrom(*this);
4679 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
4681 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret=static_cast<MEDFileField1TSWithoutSDA *>(shallowCpy());
4682 if((const DataArrayDouble *)_arr)
4683 ret->_arr=_arr->deepCpy();
4687 void MEDFileField1TSWithoutSDA::setArray(DataArray *arr) throw(INTERP_KERNEL::Exception)
4691 DataArrayDouble *arrC=dynamic_cast<DataArrayDouble *>(arr);
4693 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayDouble !");
4698 DataArray *MEDFileField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
4700 return DataArrayDouble::New();
4703 DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble()
4705 DataArrayDouble *ret=_arr;
4708 _arr=DataArrayDouble::New();
4712 DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray()
4714 return getOrCreateAndGetArrayDouble();
4717 const DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble() const
4719 const DataArrayDouble *ret=_arr;
4722 DataArrayDouble *ret2=DataArrayDouble::New();
4723 const_cast<MEDFileField1TSWithoutSDA *>(this)->_arr=DataArrayDouble::New();
4727 const DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray() const
4729 return getOrCreateAndGetArrayDouble();
4732 //= MEDFileIntField1TSWithoutSDA
4734 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const char *fieldName, int csit, int iteration, int order,
4735 const std::vector<std::string>& infos)
4737 return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
4740 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
4744 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order,
4745 const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
4747 DataArrayInt *arr=getOrCreateAndGetArrayInt();
4748 arr->setInfoAndChangeNbOfCompo(infos);
4751 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
4756 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const throw(INTERP_KERNEL::Exception)
4758 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
4759 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
4760 ret->deepCpyLeavesFrom(*this);
4761 const DataArrayInt *arr(_arr);
4764 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2(arr->convertToDblArr());
4765 ret->setArray(arr2);
4771 * Returns a pointer to the underground DataArrayInt instance. So the
4772 * caller should not decrRef() it. This method allows for a direct access to the field
4773 * values. This method is quite unusable if there is more than a nodal field or a cell
4774 * field on single geometric cell type.
4775 * \return DataArrayInt * - the pointer to the field values array.
4777 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
4779 return getUndergroundDataArrayInt();
4783 * Returns a pointer to the underground DataArrayInt instance. So the
4784 * caller should not decrRef() it. This method allows for a direct access to the field
4785 * values. This method is quite unusable if there is more than a nodal field or a cell
4786 * field on single geometric cell type.
4787 * \return DataArrayInt * - the pointer to the field values array.
4789 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayInt() const throw(INTERP_KERNEL::Exception)
4791 const DataArrayInt *ret=_arr;
4793 return const_cast<DataArrayInt *>(ret);
4799 * Returns a pointer to the underground DataArrayInt instance and a
4800 * sequence describing parameters of a support of each part of \a this field. The
4801 * caller should not decrRef() the returned DataArrayInt. This method allows for a
4802 * direct access to the field values. This method is intended for the field lying on one
4804 * \param [in,out] entries - the sequence describing parameters of a support of each
4805 * part of \a this field. Each item of this sequence consists of two parts. The
4806 * first part describes a type of mesh entity and an id of discretization of a
4807 * current field part. The second part describes a range of values [begin,end)
4808 * within the returned array relating to the current field part.
4809 * \return DataArrayInt * - the pointer to the field values array.
4810 * \throw If the number of underlying meshes is not equal to 1.
4811 * \throw If no field values are available.
4812 * \sa getUndergroundDataArray()
4814 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4816 return getUndergroundDataArrayIntExt(entries);
4820 * Returns a pointer to the underground DataArrayInt instance and a
4821 * sequence describing parameters of a support of each part of \a this field. The
4822 * caller should not decrRef() the returned DataArrayInt. This method allows for a
4823 * direct access to the field values. This method is intended for the field lying on one
4825 * \param [in,out] entries - the sequence describing parameters of a support of each
4826 * part of \a this field. Each item of this sequence consists of two parts. The
4827 * first part describes a type of mesh entity and an id of discretization of a
4828 * current field part. The second part describes a range of values [begin,end)
4829 * within the returned array relating to the current field part.
4830 * \return DataArrayInt * - the pointer to the field values array.
4831 * \throw If the number of underlying meshes is not equal to 1.
4832 * \throw If no field values are available.
4833 * \sa getUndergroundDataArray()
4835 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4837 if(_field_per_mesh.size()!=1)
4838 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
4839 if(_field_per_mesh[0]==0)
4840 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
4841 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
4842 return getUndergroundDataArrayInt();
4845 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
4847 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
4848 ret->deepCpyLeavesFrom(*this);
4852 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
4854 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret=static_cast<MEDFileIntField1TSWithoutSDA *>(shallowCpy());
4855 if((const DataArrayInt *)_arr)
4856 ret->_arr=_arr->deepCpy();
4860 void MEDFileIntField1TSWithoutSDA::setArray(DataArray *arr) throw(INTERP_KERNEL::Exception)
4864 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>(arr);
4866 throw INTERP_KERNEL::Exception("MEDFileIntField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayInt !");
4871 DataArray *MEDFileIntField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
4873 return DataArrayInt::New();
4876 DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt()
4878 DataArrayInt *ret=_arr;
4881 _arr=DataArrayInt::New();
4885 DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray()
4887 return getOrCreateAndGetArrayInt();
4890 const DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt() const
4892 const DataArrayInt *ret=_arr;
4895 DataArrayInt *ret2=DataArrayInt::New();
4896 const_cast<MEDFileIntField1TSWithoutSDA *>(this)->_arr=DataArrayInt::New();
4900 const DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray() const
4902 return getOrCreateAndGetArrayInt();
4905 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
4909 //= MEDFileAnyTypeField1TS
4911 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
4913 med_field_type typcha;
4915 std::vector<std::string> infos;
4916 std::string dtunit,fieldName;
4917 LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
4918 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
4923 ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
4928 ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
4933 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] !";
4934 throw INTERP_KERNEL::Exception(oss.str().c_str());
4937 ret->setDtUnit(dtunit.c_str());
4938 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
4940 med_int numdt,numit;
4942 MEDfieldComputingStepInfo(fid,fieldName.c_str(),1,&numdt,&numit,&dt);
4943 ret->setTime(numdt,numit,dt);
4946 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
4948 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
4952 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
4953 try:MEDFileFieldGlobsReal(fileName)
4955 MEDFileUtilities::CheckFileForRead(fileName);
4956 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
4957 _content=BuildContentFrom(fid,fileName,loadAll);
4960 catch(INTERP_KERNEL::Exception& e)
4965 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
4967 med_field_type typcha;
4968 std::vector<std::string> infos;
4971 int nbSteps=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
4972 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
4977 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
4982 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
4987 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] !";
4988 throw INTERP_KERNEL::Exception(oss.str().c_str());
4991 ret->setDtUnit(dtunit.c_str());
4992 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
4996 std::ostringstream oss; oss << "MEDFileField1TS(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
4997 throw INTERP_KERNEL::Exception(oss.str().c_str());
5000 med_int numdt,numit;
5002 MEDfieldComputingStepInfo(fid,fieldName,1,&numdt,&numit,&dt);
5003 ret->setTime(numdt,numit,dt);
5006 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5008 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5012 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5013 try:MEDFileFieldGlobsReal(fileName)
5015 MEDFileUtilities::CheckFileForRead(fileName);
5016 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5017 _content=BuildContentFrom(fid,fileName,fieldName,loadAll);
5020 catch(INTERP_KERNEL::Exception& e)
5025 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, const char *fileName) throw(INTERP_KERNEL::Exception)
5028 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5029 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5031 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New();
5032 ret->setFileName(fileName);
5033 ret->_content=c; c->incrRef();
5036 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5038 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New();
5039 ret->setFileName(fileName);
5040 ret->_content=c; c->incrRef();
5043 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5046 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
5048 MEDFileUtilities::CheckFileForRead(fileName);
5049 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5050 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll);
5051 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5052 ret->loadGlobals(fid);
5056 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5058 MEDFileUtilities::CheckFileForRead(fileName);
5059 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5060 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll);
5061 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5062 ret->loadGlobals(fid);
5066 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
5068 MEDFileUtilities::CheckFileForRead(fileName);
5069 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5070 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,iteration,order,loadAll);
5071 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5072 ret->loadGlobals(fid);
5076 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
5078 med_field_type typcha;
5079 std::vector<std::string> infos;
5082 int nbOfStep2=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5083 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5088 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5093 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5098 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] !";
5099 throw INTERP_KERNEL::Exception(oss.str().c_str());
5102 ret->setDtUnit(dtunit.c_str());
5103 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5106 std::vector< std::pair<int,int> > dtits(nbOfStep2);
5107 for(int i=0;i<nbOfStep2 && !found;i++)
5109 med_int numdt,numit;
5111 MEDfieldComputingStepInfo(fid,fieldName,i+1,&numdt,&numit,&dt);
5112 if(numdt==iteration && numit==order)
5118 dtits[i]=std::pair<int,int>(numdt,numit);
5122 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << fileName << "' ! Available iterations are : ";
5123 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5124 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5125 throw INTERP_KERNEL::Exception(oss.str().c_str());
5127 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5131 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
5132 try:MEDFileFieldGlobsReal(fileName)
5134 MEDFileUtilities::CheckFileForRead(fileName);
5135 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5136 _content=BuildContentFrom(fid,fileName,fieldName,iteration,order,loadAll);
5139 catch(INTERP_KERNEL::Exception& e)
5145 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5146 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5148 * \warning this is a shallow copy constructor
5150 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5152 if(!shallowCopyOfContent)
5154 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5155 otherPtr->incrRef();
5156 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5160 _content=other.shallowCpy();
5164 int MEDFileAnyTypeField1TS::LocateField2(med_idt fid, const char *fileName, int fieldIdCFormat, bool checkFieldId, std::string& fieldName, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut) throw(INTERP_KERNEL::Exception)
5168 int nbFields=MEDnField(fid);
5169 if(fieldIdCFormat>=nbFields)
5171 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << fileName << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5172 throw INTERP_KERNEL::Exception(oss.str().c_str());
5175 int ncomp=MEDfieldnComponent(fid,fieldIdCFormat+1);
5176 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5177 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5178 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5179 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5180 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5183 MEDfieldInfo(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
5184 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5185 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5186 infos.clear(); infos.resize(ncomp);
5187 for(int j=0;j<ncomp;j++)
5188 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5193 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5196 * \return in case of success the number of time steps available for the field with name \a fieldName.
5198 int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const char *fileName, const char *fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut) throw(INTERP_KERNEL::Exception)
5200 int nbFields=MEDnField(fid);
5202 std::vector<std::string> fns(nbFields);
5204 for(int i=0;i<nbFields && !found;i++)
5207 nbOfStep2=LocateField2(fid,fileName,i,false,tmp,typcha,infos,dtunitOut);
5209 found=(tmp==fieldName);
5215 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
5216 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5217 oss << "\"" << *it << "\" ";
5218 throw INTERP_KERNEL::Exception(oss.str().c_str());
5224 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5225 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5226 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5227 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5228 * to keep a valid instance.
5229 * 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.
5230 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5231 * 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.
5233 * \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.
5234 * \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.
5235 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5236 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5237 * \param [in] newLocName is the new localization name.
5238 * \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.
5239 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5241 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newPflName, bool forceRenameOnGlob) throw(INTERP_KERNEL::Exception)
5243 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5244 std::string oldPflName=disc->getProfile();
5245 std::vector<std::string> vv=getPflsReallyUsedMulti();
5246 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5247 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5249 disc->setProfile(newPflName);
5250 DataArrayInt *pfl=getProfile(oldPflName.c_str());
5251 pfl->setName(newPflName);
5255 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5256 throw INTERP_KERNEL::Exception(oss.str().c_str());
5261 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5262 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5263 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5264 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5265 * to keep a valid instance.
5266 * 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.
5267 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5268 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5269 * 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.
5271 * \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.
5272 * \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.
5273 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5274 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5275 * \param [in] newLocName is the new localization name.
5276 * \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.
5277 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
5279 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newLocName, bool forceRenameOnGlob) throw(INTERP_KERNEL::Exception)
5281 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5282 std::string oldLocName=disc->getLocalization();
5283 std::vector<std::string> vv=getLocsReallyUsedMulti();
5284 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
5285 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
5287 disc->setLocalization(newLocName);
5288 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
5289 loc.setName(newLocName);
5293 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
5294 throw INTERP_KERNEL::Exception(oss.str().c_str());
5298 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() throw(INTERP_KERNEL::Exception)
5300 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5302 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
5306 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const throw(INTERP_KERNEL::Exception)
5308 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5310 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
5315 * Writes \a this field into a MED file specified by its name.
5316 * \param [in] fileName - the MED file name.
5317 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
5318 * - 2 - erase; an existing file is removed.
5319 * - 1 - append; same data should not be present in an existing file.
5320 * - 0 - overwrite; same data present in an existing file is overwritten.
5321 * \throw If the field name is not set.
5322 * \throw If no field data is set.
5323 * \throw If \a mode == 1 and the same data is present in an existing file.
5325 void MEDFileAnyTypeField1TS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
5327 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
5328 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
5332 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
5334 int nbComp=getNumberOfComponents();
5335 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5336 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5337 for(int i=0;i<nbComp;i++)
5339 std::string info=getInfo()[i];
5341 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
5342 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
5343 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
5345 if(getName().empty())
5346 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
5347 MEDfieldCr(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
5348 writeGlobals(fid,*this);
5349 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
5352 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySize() const
5355 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
5356 ret+=_content->getHeapMemorySize();
5357 return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
5361 * Returns a string describing \a this field. This string is outputted
5362 * by \c print Python command.
5364 std::string MEDFileAnyTypeField1TS::simpleRepr() const
5366 std::ostringstream oss;
5367 contentNotNullBase()->simpleRepr(0,oss,-1);
5368 simpleReprGlobs(oss);
5373 * This method returns all profiles whose name is non empty used.
5374 * \b WARNING If profile is used several times it will be reported \b only \b once.
5375 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
5377 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
5379 return contentNotNullBase()->getPflsReallyUsed2();
5383 * This method returns all localizations whose name is non empty used.
5384 * \b WARNING If localization is used several times it will be reported \b only \b once.
5386 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
5388 return contentNotNullBase()->getLocsReallyUsed2();
5392 * This method returns all profiles whose name is non empty used.
5393 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
5395 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
5397 return contentNotNullBase()->getPflsReallyUsedMulti2();
5401 * This method returns all localizations whose name is non empty used.
5402 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
5404 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
5406 return contentNotNullBase()->getLocsReallyUsedMulti2();
5409 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5411 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
5414 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5416 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
5419 int MEDFileAnyTypeField1TS::getDimension() const
5421 return contentNotNullBase()->getDimension();
5424 int MEDFileAnyTypeField1TS::getIteration() const
5426 return contentNotNullBase()->getIteration();
5429 int MEDFileAnyTypeField1TS::getOrder() const
5431 return contentNotNullBase()->getOrder();
5434 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
5436 return contentNotNullBase()->getTime(iteration,order);
5439 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
5441 contentNotNullBase()->setTime(iteration,order,val);
5444 std::string MEDFileAnyTypeField1TS::getName() const
5446 return contentNotNullBase()->getName();
5449 void MEDFileAnyTypeField1TS::setName(const char *name)
5451 contentNotNullBase()->setName(name);
5454 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
5456 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
5459 std::string MEDFileAnyTypeField1TS::getDtUnit() const throw(INTERP_KERNEL::Exception)
5461 return contentNotNullBase()->getDtUnit();
5464 void MEDFileAnyTypeField1TS::setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception)
5466 contentNotNullBase()->setDtUnit(dtUnit);
5469 std::string MEDFileAnyTypeField1TS::getMeshName() const throw(INTERP_KERNEL::Exception)
5471 return contentNotNullBase()->getMeshName();
5474 void MEDFileAnyTypeField1TS::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
5476 contentNotNullBase()->setMeshName(newMeshName);
5479 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
5481 return contentNotNullBase()->changeMeshNames(modifTab);
5484 int MEDFileAnyTypeField1TS::getMeshIteration() const throw(INTERP_KERNEL::Exception)
5486 return contentNotNullBase()->getMeshIteration();
5489 int MEDFileAnyTypeField1TS::getMeshOrder() const throw(INTERP_KERNEL::Exception)
5491 return contentNotNullBase()->getMeshOrder();
5494 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
5496 return contentNotNullBase()->getNumberOfComponents();
5499 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
5501 return contentNotNullBase()->isDealingTS(iteration,order);
5504 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
5506 return contentNotNullBase()->getDtIt();
5509 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
5511 contentNotNullBase()->fillIteration(p);
5514 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
5516 contentNotNullBase()->fillTypesOfFieldAvailable(types);
5519 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos) throw(INTERP_KERNEL::Exception)
5521 contentNotNullBase()->setInfo(infos);
5524 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
5526 return contentNotNullBase()->getInfo();
5528 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
5530 return contentNotNullBase()->getInfo();
5533 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
5535 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5538 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
5540 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5543 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
5545 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
5548 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
5550 return contentNotNullBase()->getTypesOfFieldAvailable();
5553 std::vector< std::vector<std::pair<int,int> > > MEDFileAnyTypeField1TS::getFieldSplitedByType(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
5554 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
5556 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
5560 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
5561 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
5562 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
5564 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const throw(INTERP_KERNEL::Exception)
5566 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5568 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
5569 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
5570 std::size_t sz(contentsSplit.size());
5571 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
5572 for(std::size_t i=0;i<sz;i++)
5574 ret[i]=shallowCpy();
5575 ret[i]->_content=contentsSplit[i];
5580 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCpy() const throw(INTERP_KERNEL::Exception)
5582 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=shallowCpy();
5583 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
5584 ret->_content=_content->deepCpy();
5585 ret->deepCpyGlobs(*this);
5589 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception)
5591 return contentNotNullBase()->copyTinyInfoFrom(field,arr);
5597 * Returns a new instance of MEDFileField1TS holding data of the first time step of
5598 * the first field that has been read from a specified MED file.
5599 * \param [in] fileName - the name of the MED file to read.
5600 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5601 * is to delete this field using decrRef() as it is no more needed.
5602 * \throw If reading the file fails.
5604 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
5606 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,loadAll);
5607 ret->contentNotNull();
5612 * Returns a new instance of MEDFileField1TS holding data of the first time step of
5613 * a given field that has been read from a specified MED file.
5614 * \param [in] fileName - the name of the MED file to read.
5615 * \param [in] fieldName - the name of the field to read.
5616 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5617 * is to delete this field using decrRef() as it is no more needed.
5618 * \throw If reading the file fails.
5619 * \throw If there is no field named \a fieldName in the file.
5621 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5623 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,fieldName,loadAll);
5624 ret->contentNotNull();
5629 * Returns a new instance of MEDFileField1TS holding data of a given time step of
5630 * a given field that has been read from a specified MED file.
5631 * \param [in] fileName - the name of the MED file to read.
5632 * \param [in] fieldName - the name of the field to read.
5633 * \param [in] iteration - the iteration number of a required time step.
5634 * \param [in] order - the iteration order number of required time step.
5635 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5636 * is to delete this field using decrRef() as it is no more needed.
5637 * \throw If reading the file fails.
5638 * \throw If there is no field named \a fieldName in the file.
5639 * \throw If the required time step is missing from the file.
5641 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
5643 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,fieldName,iteration,order,loadAll);
5644 ret->contentNotNull();
5649 * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5650 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5652 * Returns a new instance of MEDFileField1TS holding either a shallow copy
5653 * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
5654 * \warning this is a shallow copy constructor
5655 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
5656 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
5657 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
5658 * is to delete this field using decrRef() as it is no more needed.
5660 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
5662 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(other,shallowCopyOfContent);
5663 ret->contentNotNull();
5668 * Returns a new empty instance of MEDFileField1TS.
5669 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
5670 * is to delete this field using decrRef() as it is no more needed.
5672 MEDFileField1TS *MEDFileField1TS::New()
5674 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS;
5675 ret->contentNotNull();
5680 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
5681 * following the given input policy.
5683 * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
5684 * By default (true) the globals are deeply copied.
5685 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
5687 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
5689 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret;
5690 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5693 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
5695 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
5696 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
5697 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc,getFileName()));
5700 ret=MEDFileIntField1TS::New();
5702 ret->deepCpyGlobs(*this);
5704 ret->shallowCpyGlobs(*this);
5708 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const throw(INTERP_KERNEL::Exception)
5710 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
5712 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
5713 const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
5715 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 !");
5719 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() throw(INTERP_KERNEL::Exception)
5721 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
5723 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
5724 MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
5726 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 !");
5730 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception)
5733 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
5734 if(!((DataArray*)arr))
5735 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
5736 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
5738 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
5739 f->setArray(arrOutC);
5742 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception)
5744 if(!((DataArray*)arr))
5745 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
5746 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
5748 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
5753 MEDFileField1TS::MEDFileField1TS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
5754 try:MEDFileAnyTypeField1TS(fileName,loadAll)
5757 catch(INTERP_KERNEL::Exception& e)
5760 MEDFileField1TS::MEDFileField1TS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5761 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll)
5764 catch(INTERP_KERNEL::Exception& e)
5767 MEDFileField1TS::MEDFileField1TS(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
5768 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll)
5771 catch(INTERP_KERNEL::Exception& e)
5775 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5776 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5778 * \warning this is a shallow copy constructor
5780 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
5781 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
5784 catch(INTERP_KERNEL::Exception& e)
5787 MEDFileField1TS::MEDFileField1TS()
5789 _content=new MEDFileField1TSWithoutSDA;
5793 * Returns a new MEDCouplingFieldDouble of a given type lying on
5794 * mesh entities of a given dimension of the first mesh in MED file. If \a this field
5795 * has not been constructed via file reading, an exception is thrown.
5796 * For more info, see \ref AdvMEDLoaderAPIFieldRW
5797 * \param [in] type - a spatial discretization of interest.
5798 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5799 * \param [in] renumPol - specifies how to permute values of the result field according to
5800 * the optional numbers of cells and nodes, if any. The valid values are
5801 * - 0 - do not permute.
5802 * - 1 - permute cells.
5803 * - 2 - permute nodes.
5804 * - 3 - permute cells and nodes.
5806 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5807 * caller is to delete this field using decrRef() as it is no more needed.
5808 * \throw If \a this field has not been constructed via file reading.
5809 * \throw If the MED file is not readable.
5810 * \throw If there is no mesh in the MED file.
5811 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5812 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5813 * \sa getFieldOnMeshAtLevel()
5815 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
5817 if(getFileName2().empty())
5818 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
5819 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
5820 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut,*contentNotNull());
5821 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
5826 * Returns a new MEDCouplingFieldDouble of a given type lying on
5827 * the top level cells of the first mesh in MED file. If \a this field
5828 * has not been constructed via file reading, an exception is thrown.
5829 * For more info, see \ref AdvMEDLoaderAPIFieldRW
5830 * \param [in] type - a spatial discretization of interest.
5831 * \param [in] renumPol - specifies how to permute values of the result field according to
5832 * the optional numbers of cells and nodes, if any. The valid values are
5833 * - 0 - do not permute.
5834 * - 1 - permute cells.
5835 * - 2 - permute nodes.
5836 * - 3 - permute cells and nodes.
5838 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5839 * caller is to delete this field using decrRef() as it is no more needed.
5840 * \throw If \a this field has not been constructed via file reading.
5841 * \throw If the MED file is not readable.
5842 * \throw If there is no mesh in the MED file.
5843 * \throw If no field values of the given \a type.
5844 * \throw If no field values lying on the top level support.
5845 * \sa getFieldAtLevel()
5847 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const throw(INTERP_KERNEL::Exception)
5849 if(getFileName2().empty())
5850 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
5851 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
5852 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,0,renumPol,this,arrOut,*contentNotNull());
5853 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
5858 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
5859 * For more info, see \ref AdvMEDLoaderAPIFieldRW
5860 * \param [in] type - a spatial discretization of the new field.
5861 * \param [in] mesh - the supporting mesh.
5862 * \param [in] renumPol - specifies how to permute values of the result field according to
5863 * the optional numbers of cells and nodes, if any. The valid values are
5864 * - 0 - do not permute.
5865 * - 1 - permute cells.
5866 * - 2 - permute nodes.
5867 * - 3 - permute cells and nodes.
5869 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5870 * caller is to delete this field using decrRef() as it is no more needed.
5871 * \throw If no field of \a this is lying on \a mesh.
5872 * \throw If the mesh is empty.
5873 * \throw If no field values of the given \a type are available.
5874 * \sa getFieldAtLevel()
5875 * \sa getFieldOnMeshAtLevel()
5877 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
5879 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
5880 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull());
5881 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
5886 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
5887 * For more info, see \ref AdvMEDLoaderAPIFieldRW
5888 * \param [in] type - a spatial discretization of interest.
5889 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5890 * \param [in] mesh - the supporting mesh.
5891 * \param [in] renumPol - specifies how to permute values of the result field according to
5892 * the optional numbers of cells and nodes, if any. The valid values are
5893 * - 0 - do not permute.
5894 * - 1 - permute cells.
5895 * - 2 - permute nodes.
5896 * - 3 - permute cells and nodes.
5898 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5899 * caller is to delete this field using decrRef() as it is no more needed.
5900 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5901 * \throw If no field of \a this is lying on \a mesh.
5902 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5903 * \sa getFieldAtLevel()
5904 * \sa getFieldOnMeshAtLevel()
5906 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
5908 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
5909 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull());
5910 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
5915 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
5916 * This method is called "Old" because in MED3 norm a field has only one meshName
5917 * attached, so this method is for readers of MED2 files. If \a this field
5918 * has not been constructed via file reading, an exception is thrown.
5919 * For more info, see \ref AdvMEDLoaderAPIFieldRW
5920 * \param [in] type - a spatial discretization of interest.
5921 * \param [in] mName - a name of the supporting mesh.
5922 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5923 * \param [in] renumPol - specifies how to permute values of the result field according to
5924 * the optional numbers of cells and nodes, if any. The valid values are
5925 * - 0 - do not permute.
5926 * - 1 - permute cells.
5927 * - 2 - permute nodes.
5928 * - 3 - permute cells and nodes.
5930 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5931 * caller is to delete this field using decrRef() as it is no more needed.
5932 * \throw If the MED file is not readable.
5933 * \throw If there is no mesh named \a mName in the MED file.
5934 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5935 * \throw If \a this field has not been constructed via file reading.
5936 * \throw If no field of \a this is lying on the mesh named \a mName.
5937 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5938 * \sa getFieldAtLevel()
5940 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
5942 if(getFileName2().empty())
5943 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
5944 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
5945 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
5946 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
5951 * Returns values and a profile of the field of a given type lying on a given support.
5952 * For more info, see \ref AdvMEDLoaderAPIFieldRW
5953 * \param [in] type - a spatial discretization of the field.
5954 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5955 * \param [in] mesh - the supporting mesh.
5956 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
5957 * field of interest lies on. If the field lies on all entities of the given
5958 * dimension, all ids in \a pfl are zero. The caller is to delete this array
5959 * using decrRef() as it is no more needed.
5960 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
5961 * field. The caller is to delete this array using decrRef() as it is no more needed.
5962 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
5963 * \throw If no field of \a this is lying on \a mesh.
5964 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5966 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
5968 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
5969 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
5973 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
5974 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
5975 * "Sort By Type"), if not, an exception is thrown.
5976 * For more info, see \ref AdvMEDLoaderAPIFieldRW
5977 * \param [in] field - the field to add to \a this.
5978 * \throw If the name of \a field is empty.
5979 * \throw If the data array of \a field is not set.
5980 * \throw If the data array is already allocated but has different number of components
5982 * \throw If the underlying mesh of \a field has no name.
5983 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
5985 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
5988 contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
5992 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
5993 * of a given mesh are used as the support of the given field (a real support is not used).
5994 * Elements of the given mesh must be sorted suitable for writing to MED file.
5995 * Order of underlying mesh entities of the given field specified by \a profile parameter
5996 * is not prescribed; this method permutes field values to have them sorted by element
5997 * type as required for writing to MED file. A new profile is added only if no equal
5998 * profile is missing.
5999 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6000 * \param [in] field - the field to add to \a this.
6001 * \param [in] mesh - the supporting mesh of \a field.
6002 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
6003 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6004 * \throw If either \a field or \a mesh or \a profile has an empty name.
6005 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6006 * \throw If the data array of \a field is not set.
6007 * \throw If the data array of \a this is already allocated but has different number of
6008 * components than \a field.
6009 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6010 * \sa setFieldNoProfileSBT()
6012 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
6015 contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6018 MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const throw(INTERP_KERNEL::Exception)
6020 return new MEDFileField1TS(*this);
6023 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
6025 return contentNotNull()->getUndergroundDataArrayDouble();
6028 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
6030 return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
6033 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6034 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
6036 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6039 //= MEDFileIntField1TS
6041 MEDFileIntField1TS *MEDFileIntField1TS::New()
6043 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS;
6044 ret->contentNotNull();
6048 MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
6050 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,loadAll);
6051 ret->contentNotNull();
6055 MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
6057 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,fieldName,loadAll);
6058 ret->contentNotNull();
6062 MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
6064 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,fieldName,iteration,order,loadAll);
6065 ret->contentNotNull();
6069 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6071 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6072 ret->contentNotNull();
6076 MEDFileIntField1TS::MEDFileIntField1TS()
6078 _content=new MEDFileIntField1TSWithoutSDA;
6081 MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
6082 try:MEDFileAnyTypeField1TS(fileName,loadAll)
6085 catch(INTERP_KERNEL::Exception& e)
6088 MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
6089 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll)
6092 catch(INTERP_KERNEL::Exception& e)
6095 MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
6096 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll)
6099 catch(INTERP_KERNEL::Exception& e)
6103 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6104 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6106 * \warning this is a shallow copy constructor
6108 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6112 MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const throw(INTERP_KERNEL::Exception)
6114 return new MEDFileIntField1TS(*this);
6118 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
6119 * following the given input policy.
6121 * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6122 * By default (true) the globals are deeply copied.
6123 * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
6125 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
6127 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret;
6128 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6131 const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
6133 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
6134 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
6135 ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc,getFileName()));
6138 ret=MEDFileField1TS::New();
6140 ret->deepCpyGlobs(*this);
6142 ret->shallowCpyGlobs(*this);
6147 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6148 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6149 * "Sort By Type"), if not, an exception is thrown.
6150 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6151 * \param [in] field - the field to add to \a this. The field double values are ignored.
6152 * \param [in] arrOfVals - the values of the field \a field used.
6153 * \throw If the name of \a field is empty.
6154 * \throw If the data array of \a field is not set.
6155 * \throw If the data array is already allocated but has different number of components
6157 * \throw If the underlying mesh of \a field has no name.
6158 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6160 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals) throw(INTERP_KERNEL::Exception)
6163 contentNotNull()->setFieldNoProfileSBT(field,arrOfVals,*this,*contentNotNull());
6167 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
6168 * of a given mesh are used as the support of the given field (a real support is not used).
6169 * Elements of the given mesh must be sorted suitable for writing to MED file.
6170 * Order of underlying mesh entities of the given field specified by \a profile parameter
6171 * is not prescribed; this method permutes field values to have them sorted by element
6172 * type as required for writing to MED file. A new profile is added only if no equal
6173 * profile is missing.
6174 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6175 * \param [in] field - the field to add to \a this. The field double values are ignored.
6176 * \param [in] arrOfVals - the values of the field \a field used.
6177 * \param [in] mesh - the supporting mesh of \a field.
6178 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
6179 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6180 * \throw If either \a field or \a mesh or \a profile has an empty name.
6181 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6182 * \throw If the data array of \a field is not set.
6183 * \throw If the data array of \a this is already allocated but has different number of
6184 * components than \a field.
6185 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6186 * \sa setFieldNoProfileSBT()
6188 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
6191 contentNotNull()->setFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6194 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const throw(INTERP_KERNEL::Exception)
6196 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6198 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
6199 const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
6201 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 !");
6205 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6207 if(getFileName2().empty())
6208 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6209 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut2;
6210 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut2,*contentNotNull());
6211 DataArrayInt *arrOutC=dynamic_cast<DataArrayInt *>((DataArray *)arrOut2);
6213 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : mismatch between dataArrays type and MEDFileIntField1TS ! Expected int32 !");
6218 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception)
6220 if(!((DataArray *)arr))
6221 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
6222 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>((DataArray *)arr);
6224 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
6230 * Returns a new MEDCouplingFieldDouble of a given type lying on
6231 * the top level cells of the first mesh in MED file. If \a this field
6232 * has not been constructed via file reading, an exception is thrown.
6233 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6234 * \param [in] type - a spatial discretization of interest.
6235 * \param [out] arrOut - the DataArrayInt containing values of field.
6236 * \param [in] renumPol - specifies how to permute values of the result field according to
6237 * the optional numbers of cells and nodes, if any. The valid values are
6238 * - 0 - do not permute.
6239 * - 1 - permute cells.
6240 * - 2 - permute nodes.
6241 * - 3 - permute cells and nodes.
6243 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6244 * caller is to delete this field using decrRef() as it is no more needed.
6245 * \throw If \a this field has not been constructed via file reading.
6246 * \throw If the MED file is not readable.
6247 * \throw If there is no mesh in the MED file.
6248 * \throw If no field values of the given \a type.
6249 * \throw If no field values lying on the top level support.
6250 * \sa getFieldAtLevel()
6252 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6254 if(getFileName2().empty())
6255 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6256 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6257 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,0,renumPol,this,arr,*contentNotNull());
6258 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6263 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6264 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6265 * \param [in] type - a spatial discretization of the new field.
6266 * \param [in] mesh - the supporting mesh.
6267 * \param [out] arrOut - the DataArrayInt containing values of field.
6268 * \param [in] renumPol - specifies how to permute values of the result field according to
6269 * the optional numbers of cells and nodes, if any. The valid values are
6270 * - 0 - do not permute.
6271 * - 1 - permute cells.
6272 * - 2 - permute nodes.
6273 * - 3 - permute cells and nodes.
6275 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6276 * caller is to delete this field using decrRef() as it is no more needed.
6277 * \throw If no field of \a this is lying on \a mesh.
6278 * \throw If the mesh is empty.
6279 * \throw If no field values of the given \a type are available.
6280 * \sa getFieldAtLevel()
6281 * \sa getFieldOnMeshAtLevel()
6283 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6285 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6286 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNull());
6287 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6292 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6293 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6294 * \param [in] type - a spatial discretization of interest.
6295 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6296 * \param [out] arrOut - the DataArrayInt containing values of field.
6297 * \param [in] mesh - the supporting mesh.
6298 * \param [in] renumPol - specifies how to permute values of the result field according to
6299 * the optional numbers of cells and nodes, if any. The valid values are
6300 * - 0 - do not permute.
6301 * - 1 - permute cells.
6302 * - 2 - permute nodes.
6303 * - 3 - permute cells and nodes.
6305 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6306 * caller is to delete this field using decrRef() as it is no more needed.
6307 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6308 * \throw If no field of \a this is lying on \a mesh.
6309 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6310 * \sa getFieldAtLevel()
6311 * \sa getFieldOnMeshAtLevel()
6313 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6315 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6316 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNull());
6317 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6322 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6323 * This method is called "Old" because in MED3 norm a field has only one meshName
6324 * attached, so this method is for readers of MED2 files. If \a this field
6325 * has not been constructed via file reading, an exception is thrown.
6326 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6327 * \param [in] type - a spatial discretization of interest.
6328 * \param [in] mName - a name of the supporting mesh.
6329 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6330 * \param [out] arrOut - the DataArrayInt containing values of field.
6331 * \param [in] renumPol - specifies how to permute values of the result field according to
6332 * the optional numbers of cells and nodes, if any. The valid values are
6333 * - 0 - do not permute.
6334 * - 1 - permute cells.
6335 * - 2 - permute nodes.
6336 * - 3 - permute cells and nodes.
6338 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6339 * caller is to delete this field using decrRef() as it is no more needed.
6340 * \throw If the MED file is not readable.
6341 * \throw If there is no mesh named \a mName in the MED file.
6342 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6343 * \throw If \a this field has not been constructed via file reading.
6344 * \throw If no field of \a this is lying on the mesh named \a mName.
6345 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6346 * \sa getFieldAtLevel()
6348 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6350 if(getFileName2().empty())
6351 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6352 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6353 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNull());
6354 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6359 * Returns values and a profile of the field of a given type lying on a given support.
6360 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6361 * \param [in] type - a spatial discretization of the field.
6362 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6363 * \param [in] mesh - the supporting mesh.
6364 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6365 * field of interest lies on. If the field lies on all entities of the given
6366 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6367 * using decrRef() as it is no more needed.
6368 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
6369 * field. The caller is to delete this array using decrRef() as it is no more needed.
6370 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6371 * \throw If no field of \a this is lying on \a mesh.
6372 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6374 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
6376 MEDCouplingAutoRefCountObjectPtr<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6377 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6380 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() throw(INTERP_KERNEL::Exception)
6382 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6384 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
6385 MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
6387 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 !");
6391 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
6393 return contentNotNull()->getUndergroundDataArrayInt();
6396 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
6398 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
6402 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const char *fieldName):MEDFileFieldNameScope(fieldName)
6407 * \param [in] fieldId field id in C mode
6409 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll) throw(INTERP_KERNEL::Exception)
6411 med_field_type typcha;
6412 std::string dtunitOut;
6413 int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,"",fieldId,false,_name,typcha,_infos,dtunitOut);
6414 setDtUnit(dtunitOut.c_str());
6415 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll);
6418 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll) throw(INTERP_KERNEL::Exception)
6419 try:MEDFileFieldNameScope(fieldName),_infos(infos)
6421 setDtUnit(dtunit.c_str());
6422 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll);
6424 catch(INTERP_KERNEL::Exception& e)
6429 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySize() const
6431 std::size_t ret=_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA>);
6432 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
6433 ret+=(*it).capacity();
6434 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6435 if((const MEDFileAnyTypeField1TSWithoutSDA *)(*it))
6436 ret+=(*it)->getHeapMemorySize();
6441 * 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
6444 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception)
6446 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6447 ret->setInfo(_infos);
6448 int sz=(int)_time_steps.size();
6449 for(const int *id=startIds;id!=endIds;id++)
6451 if(*id>=0 && *id<sz)
6453 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
6454 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6458 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6460 ret->pushBackTimeStep(tse2);
6464 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
6465 oss << " ! Should be in [0," << sz << ") !";
6466 throw INTERP_KERNEL::Exception(oss.str().c_str());
6469 if(ret->getNumberOfTS()>0)
6470 ret->synchronizeNameScope();
6471 ret->copyNameScope(*this);
6476 * 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
6479 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const throw(INTERP_KERNEL::Exception)
6481 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
6482 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
6483 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6484 ret->setInfo(_infos);
6485 int sz=(int)_time_steps.size();
6487 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
6491 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
6492 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6496 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6498 ret->pushBackTimeStep(tse2);
6502 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
6503 oss << " ! Should be in [0," << sz << ") !";
6504 throw INTERP_KERNEL::Exception(oss.str().c_str());
6507 if(ret->getNumberOfTS()>0)
6508 ret->synchronizeNameScope();
6509 ret->copyNameScope(*this);
6513 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
6516 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
6517 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
6519 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6522 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
6523 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
6524 ids->pushBackSilent(id);
6526 return buildFromTimeStepIds(ids->begin(),ids->end());
6529 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
6532 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
6533 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
6535 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6538 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
6539 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
6540 ids->pushBackSilent(id);
6542 return buildFromTimeStepIds(ids->begin(),ids->end());
6545 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const throw(INTERP_KERNEL::Exception)
6550 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception)
6555 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6558 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
6560 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
6561 if(pt->isDealingTS(iteration,order))
6564 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
6565 std::vector< std::pair<int,int> > vp=getIterations();
6566 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
6567 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
6568 throw INTERP_KERNEL::Exception(oss.str().c_str());
6571 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6573 return *_time_steps[getTimeStepPos(iteration,order)];
6576 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) throw(INTERP_KERNEL::Exception)
6578 return *_time_steps[getTimeStepPos(iteration,order)];
6581 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const throw(INTERP_KERNEL::Exception)
6583 if(_time_steps.empty())
6584 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
6585 return _time_steps[0]->getMeshName();
6588 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
6590 std::string oldName(getMeshName());
6591 std::vector< std::pair<std::string,std::string> > v(1);
6592 v[0].first=oldName; v[0].second=newMeshName;
6596 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
6599 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6601 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6603 ret=cur->changeMeshNames(modifTab) || ret;
6609 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
6611 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6613 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
6617 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
6619 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
6621 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
6624 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
6625 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
6628 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6630 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
6632 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
6637 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
6639 std::string startLine(bkOffset,' ');
6640 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
6642 oss << " (" << fmtsId << ")";
6643 oss << " has the following name: \"" << _name << "\"." << std::endl;
6644 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
6645 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
6647 oss << startLine << " - \"" << *it << "\"" << std::endl;
6650 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
6652 std::string chapter(17,'0'+i);
6653 oss << startLine << chapter << std::endl;
6654 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
6656 cur->simpleRepr(bkOffset+2,oss,i);
6658 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
6659 oss << startLine << chapter << std::endl;
6663 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception)
6665 std::size_t sz=_time_steps.size();
6666 std::vector< std::pair<int,int> > ret(sz);
6668 for(std::size_t i=0;i<sz;i++)
6670 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
6673 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
6677 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
6678 throw INTERP_KERNEL::Exception(oss.str().c_str());
6684 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>& tse) throw(INTERP_KERNEL::Exception)
6686 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
6688 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
6689 checkCoherencyOfType(tse2);
6690 if(_time_steps.empty())
6692 setName(tse2->getName().c_str());
6693 setInfo(tse2->getInfo());
6695 checkThatComponentsMatch(tse2->getInfo());
6696 _time_steps.push_back(tse);
6699 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope() throw(INTERP_KERNEL::Exception)
6701 std::size_t nbOfCompo=_infos.size();
6702 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6704 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
6707 if((cur->getInfo()).size()!=nbOfCompo)
6709 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
6710 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
6711 throw INTERP_KERNEL::Exception(oss.str().c_str());
6713 cur->copyNameScope(*this);
6718 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll) throw(INTERP_KERNEL::Exception)
6720 _time_steps.resize(nbPdt);
6721 for(int i=0;i<nbPdt;i++)
6723 std::vector< std::pair<int,int> > ts;
6724 med_int numdt=0,numo=0;
6725 med_int meshIt=0,meshOrder=0;
6727 MEDfieldComputingStepMeshInfo(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder);
6732 _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
6737 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
6741 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
6744 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this);
6746 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this);
6750 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const throw(INTERP_KERNEL::Exception)
6752 if(_time_steps.empty())
6753 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
6754 checkThatNbOfCompoOfTSMatchThis();
6755 std::vector<std::string> infos(getInfo());
6756 int nbComp=infos.size();
6757 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
6758 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
6759 for(int i=0;i<nbComp;i++)
6761 std::string info=infos[i];
6763 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
6764 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
6765 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
6768 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
6769 MEDfieldCr(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
6770 int nbOfTS=_time_steps.size();
6771 for(int i=0;i<nbOfTS;i++)
6772 _time_steps[i]->writeLL(fid,opts,*this);
6775 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
6777 return _time_steps.size();
6780 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS() throw(INTERP_KERNEL::Exception)
6782 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
6783 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6785 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
6787 newTS.push_back(*it);
6792 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
6794 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
6795 int maxId=(int)_time_steps.size();
6797 std::set<int> idsToDel;
6798 for(const int *id=startIds;id!=endIds;id++,ii++)
6800 if(*id>=0 && *id<maxId)
6802 idsToDel.insert(*id);
6806 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
6807 throw INTERP_KERNEL::Exception(oss.str().c_str());
6810 for(int iii=0;iii<maxId;iii++)
6811 if(idsToDel.find(iii)==idsToDel.end())
6812 newTS.push_back(_time_steps[iii]);
6816 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step) throw(INTERP_KERNEL::Exception)
6818 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
6819 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
6820 if(nbOfEntriesToKill==0)
6822 std::size_t sz=_time_steps.size();
6823 std::vector<bool> b(sz,true);
6825 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
6827 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
6828 for(std::size_t i=0;i<sz;i++)
6830 newTS.push_back(_time_steps[i]);
6834 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6837 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
6838 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
6840 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
6844 tmp->getTime(it2,ord);
6845 if(it2==iteration && order==ord)
6848 oss << "(" << it2 << "," << ord << "), ";
6851 throw INTERP_KERNEL::Exception(oss.str().c_str());
6854 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
6857 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
6859 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
6861 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
6865 double ti=tmp->getTime(it2,ord);
6866 if(fabs(time-ti)<eps)
6872 throw INTERP_KERNEL::Exception(oss.str().c_str());
6875 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
6877 int lgth=_time_steps.size();
6878 std::vector< std::pair<int,int> > ret(lgth);
6879 for(int i=0;i<lgth;i++)
6880 _time_steps[i]->fillIteration(ret[i]);
6885 * 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'
6886 * This method returns two things.
6887 * - The absolute dimension of 'this' in first parameter.
6888 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
6889 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
6891 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
6892 * Only these 3 discretizations will be taken into account here.
6894 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
6895 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
6896 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
6898 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
6899 * 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'.
6901 * Let's consider the typical following case :
6902 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
6903 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
6904 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
6906 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
6908 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
6910 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
6911 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
6912 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
6913 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
6915 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
6917 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
6920 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const throw(INTERP_KERNEL::Exception)
6922 if(pos<0 || pos>=(int)_time_steps.size())
6924 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
6925 throw INTERP_KERNEL::Exception(oss.str().c_str());
6927 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
6930 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
6931 oss << "\nTry to use following method eraseEmptyTS !";
6932 throw INTERP_KERNEL::Exception(oss.str().c_str());
6937 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) throw(INTERP_KERNEL::Exception)
6939 if(pos<0 || pos>=(int)_time_steps.size())
6941 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
6942 throw INTERP_KERNEL::Exception(oss.str().c_str());
6944 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
6947 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
6948 oss << "\nTry to use following method eraseEmptyTS !";
6949 throw INTERP_KERNEL::Exception(oss.str().c_str());
6954 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
6956 std::vector<std::string> ret;
6957 std::set<std::string> ret2;
6958 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6960 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
6961 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
6962 if(ret2.find(*it2)==ret2.end())
6964 ret.push_back(*it2);
6971 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
6973 std::vector<std::string> ret;
6974 std::set<std::string> ret2;
6975 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6977 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
6978 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
6979 if(ret2.find(*it2)==ret2.end())
6981 ret.push_back(*it2);
6988 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
6990 std::vector<std::string> ret;
6991 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6993 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
6994 ret.insert(ret.end(),tmp.begin(),tmp.end());
6999 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
7001 std::vector<std::string> ret;
7002 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7004 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
7005 ret.insert(ret.end(),tmp.begin(),tmp.end());
7010 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7012 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7013 (*it)->changePflsRefsNamesGen2(mapOfModif);
7016 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7018 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7019 (*it)->changeLocsRefsNamesGen2(mapOfModif);
7022 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
7024 int lgth=_time_steps.size();
7025 std::vector< std::vector<TypeOfField> > ret(lgth);
7026 for(int i=0;i<lgth;i++)
7027 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
7032 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
7034 std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeFieldMultiTSWithoutSDA::getFieldSplitedByType(int iteration, int order, const char *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 throw(INTERP_KERNEL::Exception)
7036 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
7039 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
7041 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
7043 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7045 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
7046 ret->_time_steps[i]=(*it)->deepCpy();
7051 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const throw(INTERP_KERNEL::Exception)
7053 std::size_t sz(_infos.size()),sz2(_time_steps.size());
7054 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7055 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7056 for(std::size_t i=0;i<sz;i++)
7058 ret[i]=shallowCpy();
7059 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7061 for(std::size_t i=0;i<sz2;i++)
7063 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7066 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7067 throw INTERP_KERNEL::Exception(oss.str().c_str());
7071 for(std::size_t i=0;i<sz;i++)
7072 for(std::size_t j=0;j<sz2;j++)
7073 ret[i]->_time_steps[j]=ts[j][i];
7077 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception)
7079 _name=field->getName();
7081 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
7083 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
7084 _infos=arr->getInfoOnComponents();
7087 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const throw(INTERP_KERNEL::Exception)
7089 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
7090 if(_name!=field->getName())
7092 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
7093 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
7094 throw INTERP_KERNEL::Exception(oss.str().c_str());
7097 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
7098 checkThatComponentsMatch(arr->getInfoOnComponents());
7101 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const throw(INTERP_KERNEL::Exception)
7103 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
7104 if(getInfo().size()!=compos.size())
7106 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
7107 oss << " number of components of element to append (" << compos.size() << ") !";
7108 throw INTERP_KERNEL::Exception(oss.str().c_str());
7112 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
7113 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
7114 oss << " But compo in input fields are : ";
7115 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
7117 throw INTERP_KERNEL::Exception(oss.str().c_str());
7121 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const throw(INTERP_KERNEL::Exception)
7123 std::size_t sz=_infos.size();
7125 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
7127 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7129 if(elt->getInfo().size()!=sz)
7131 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
7132 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
7133 throw INTERP_KERNEL::Exception(oss.str().c_str());
7138 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
7141 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7142 if(!_time_steps.empty())
7143 checkCoherencyOfTinyInfo(field,arr);
7144 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
7145 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7146 objC->setFieldNoProfileSBT(field,arr,glob,*this);
7147 copyTinyInfoFrom(field,arr);
7148 _time_steps.push_back(obj);
7151 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
7154 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7155 if(!_time_steps.empty())
7156 checkCoherencyOfTinyInfo(field,arr);
7157 MEDFileField1TSWithoutSDA *objC=new MEDFileField1TSWithoutSDA;
7158 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7159 objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
7160 copyTinyInfoFrom(field,arr);
7161 _time_steps.push_back(obj);
7164 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ts) throw(INTERP_KERNEL::Exception)
7166 int sz=(int)_time_steps.size();
7169 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
7170 throw INTERP_KERNEL::Exception(oss.str().c_str());
7172 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
7175 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
7177 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
7178 throw INTERP_KERNEL::Exception(oss.str().c_str());
7184 //= MEDFileFieldMultiTSWithoutSDA
7186 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::New(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll) throw(INTERP_KERNEL::Exception)
7188 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll);
7191 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
7195 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const char *fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7200 * \param [in] fieldId field id in C mode
7202 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll) throw(INTERP_KERNEL::Exception)
7203 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll)
7206 catch(INTERP_KERNEL::Exception& e)
7209 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll) throw(INTERP_KERNEL::Exception)
7210 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll)
7213 catch(INTERP_KERNEL::Exception& e)
7216 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const throw(INTERP_KERNEL::Exception)
7218 return new MEDFileField1TSWithoutSDA;
7221 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const throw(INTERP_KERNEL::Exception)
7224 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7225 const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
7227 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
7230 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
7232 return MEDFileField1TSWithoutSDA::TYPE_STR;
7235 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
7237 return new MEDFileFieldMultiTSWithoutSDA(*this);
7240 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const throw(INTERP_KERNEL::Exception)
7242 return new MEDFileFieldMultiTSWithoutSDA;
7246 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
7247 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
7249 std::vector< std::vector<DataArrayDouble *> > MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2(int iteration, int order, const char *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 throw(INTERP_KERNEL::Exception)
7251 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
7252 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
7254 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
7255 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
7258 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const throw(INTERP_KERNEL::Exception)
7260 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
7261 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
7263 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7265 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
7268 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
7270 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
7271 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
7272 ret->setIteration(i,elt);
7278 //= MEDFileAnyTypeFieldMultiTS
7280 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
7284 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
7285 try:MEDFileFieldGlobsReal(fileName)
7287 MEDFileUtilities::CheckFileForRead(fileName);
7288 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7289 _content=BuildContentFrom(fid,fileName,loadAll);
7292 catch(INTERP_KERNEL::Exception& e)
7297 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
7299 med_field_type typcha;
7300 std::vector<std::string> infos;
7303 MEDFileAnyTypeField1TS::LocateField(fid,fileName,fieldName,i,typcha,infos,dtunit);
7304 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7309 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll);
7314 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll);
7319 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] !";
7320 throw INTERP_KERNEL::Exception(oss.str().c_str());
7323 ret->setDtUnit(dtunit.c_str());
7327 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
7329 med_field_type typcha;
7331 std::vector<std::string> infos;
7332 std::string dtunit,fieldName;
7333 MEDFileAnyTypeField1TS::LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
7334 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7339 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll);
7344 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll);
7349 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] !";
7350 throw INTERP_KERNEL::Exception(oss.str().c_str());
7353 ret->setDtUnit(dtunit.c_str());
7357 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, const char *fileName) throw(INTERP_KERNEL::Exception)
7360 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
7361 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
7363 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=MEDFileFieldMultiTS::New();
7364 ret->setFileName(fileName);
7365 ret->_content=c; c->incrRef();
7368 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
7370 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=MEDFileIntFieldMultiTS::New();
7371 ret->setFileName(fileName);
7372 ret->_content=c; c->incrRef();
7375 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
7378 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
7379 try:MEDFileFieldGlobsReal(fileName)
7381 MEDFileUtilities::CheckFileForRead(fileName);
7382 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7383 _content=BuildContentFrom(fid,fileName,fieldName,loadAll);
7386 catch(INTERP_KERNEL::Exception& e)
7391 //= MEDFileIntFieldMultiTSWithoutSDA
7393 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::New(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll) throw(INTERP_KERNEL::Exception)
7395 return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll);
7398 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
7402 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const char *fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7406 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll) throw(INTERP_KERNEL::Exception)
7407 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll)
7410 catch(INTERP_KERNEL::Exception& e)
7414 * \param [in] fieldId field id in C mode
7416 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll) throw(INTERP_KERNEL::Exception)
7417 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll)
7420 catch(INTERP_KERNEL::Exception& e)
7423 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const throw(INTERP_KERNEL::Exception)
7425 return new MEDFileIntField1TSWithoutSDA;
7428 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const throw(INTERP_KERNEL::Exception)
7431 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7432 const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
7434 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
7437 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
7439 return MEDFileIntField1TSWithoutSDA::TYPE_STR;
7442 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
7444 return new MEDFileIntFieldMultiTSWithoutSDA(*this);
7447 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const throw(INTERP_KERNEL::Exception)
7449 return new MEDFileIntFieldMultiTSWithoutSDA;
7452 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const throw(INTERP_KERNEL::Exception)
7454 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
7455 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
7457 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7459 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
7462 const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
7464 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
7465 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
7466 ret->setIteration(i,elt);
7472 //= MEDFileAnyTypeFieldMultiTS
7475 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
7476 * that has been read from a specified MED file.
7477 * \param [in] fileName - the name of the MED file to read.
7478 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
7479 * is to delete this field using decrRef() as it is no more needed.
7480 * \throw If reading the file fails.
7482 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
7484 MEDFileUtilities::CheckFileForRead(fileName);
7485 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7486 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll);
7487 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
7488 ret->loadGlobals(fid);
7493 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
7494 * that has been read from a specified MED file.
7495 * \param [in] fileName - the name of the MED file to read.
7496 * \param [in] fieldName - the name of the field to read.
7497 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
7498 * is to delete this field using decrRef() as it is no more needed.
7499 * \throw If reading the file fails.
7500 * \throw If there is no field named \a fieldName in the file.
7502 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
7504 MEDFileUtilities::CheckFileForRead(fileName);
7505 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7506 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName);
7507 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
7508 ret->loadGlobals(fid);
7513 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
7514 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
7516 * \warning this is a shallow copy constructor
7518 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
7520 if(!shallowCopyOfContent)
7522 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
7523 otherPtr->incrRef();
7524 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
7528 _content=other.shallowCpy();
7532 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() throw(INTERP_KERNEL::Exception)
7534 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
7536 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
7540 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const throw(INTERP_KERNEL::Exception)
7542 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
7544 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
7548 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
7550 return contentNotNullBase()->getPflsReallyUsed2();
7553 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
7555 return contentNotNullBase()->getLocsReallyUsed2();
7558 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
7560 return contentNotNullBase()->getPflsReallyUsedMulti2();
7563 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
7565 return contentNotNullBase()->getLocsReallyUsedMulti2();
7568 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7570 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
7573 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7575 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
7578 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
7580 return contentNotNullBase()->getNumberOfTS();
7583 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS() throw(INTERP_KERNEL::Exception)
7585 contentNotNullBase()->eraseEmptyTS();
7588 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
7590 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
7593 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step) throw(INTERP_KERNEL::Exception)
7595 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
7598 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception)
7600 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
7601 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
7606 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const throw(INTERP_KERNEL::Exception)
7608 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
7609 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
7614 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
7616 return contentNotNullBase()->getIterations();
7619 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts) throw(INTERP_KERNEL::Exception)
7621 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
7622 pushBackTimeStep(*it);
7625 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts) throw(INTERP_KERNEL::Exception)
7628 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
7629 checkCoherencyOfType(f1ts);
7631 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
7632 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
7634 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
7635 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
7636 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
7637 _content->pushBackTimeStep(cSafe);
7638 appendGlobs(*f1ts,1e-12);
7641 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope() throw(INTERP_KERNEL::Exception)
7643 contentNotNullBase()->synchronizeNameScope();
7646 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
7648 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
7651 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
7653 return contentNotNullBase()->getPosGivenTime(time,eps);
7656 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
7658 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
7661 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
7663 return contentNotNullBase()->getTypesOfFieldAvailable();
7666 std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeFieldMultiTS::getFieldSplitedByType(int iteration, int order, const char *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 throw(INTERP_KERNEL::Exception)
7668 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
7671 std::string MEDFileAnyTypeFieldMultiTS::getName() const
7673 return contentNotNullBase()->getName();
7676 void MEDFileAnyTypeFieldMultiTS::setName(const char *name)
7678 contentNotNullBase()->setName(name);
7681 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const throw(INTERP_KERNEL::Exception)
7683 return contentNotNullBase()->getDtUnit();
7686 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception)
7688 contentNotNullBase()->setDtUnit(dtUnit);
7691 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7693 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
7696 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception)
7698 return contentNotNullBase()->getTimeSteps(ret1);
7701 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const throw(INTERP_KERNEL::Exception)
7703 return contentNotNullBase()->getMeshName();
7706 void MEDFileAnyTypeFieldMultiTS::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
7708 contentNotNullBase()->setMeshName(newMeshName);
7711 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
7713 return contentNotNullBase()->changeMeshNames(modifTab);
7716 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const throw(INTERP_KERNEL::Exception)
7718 return contentNotNullBase()->getInfo();
7721 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception)
7723 return contentNotNullBase()->setInfo(info);
7726 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const throw(INTERP_KERNEL::Exception)
7728 const std::vector<std::string> ret=getInfo();
7729 return (int)ret.size();
7732 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
7734 writeGlobals(fid,*this);
7735 contentNotNullBase()->writeLL(fid,*this);
7739 * Writes \a this field into a MED file specified by its name.
7740 * \param [in] fileName - the MED file name.
7741 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
7742 * - 2 - erase; an existing file is removed.
7743 * - 1 - append; same data should not be present in an existing file.
7744 * - 0 - overwrite; same data present in an existing file is overwritten.
7745 * \throw If the field name is not set.
7746 * \throw If no field data is set.
7747 * \throw If \a mode == 1 and the same data is present in an existing file.
7749 void MEDFileAnyTypeFieldMultiTS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
7751 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
7752 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
7756 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
7758 std::ostringstream oss;
7759 contentNotNullBase()->simpleRepr(0,oss,-1);
7760 simpleReprGlobs(oss);
7764 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySize() const
7767 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)_content)
7768 ret+=_content->getHeapMemorySize();
7769 return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
7773 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
7774 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
7775 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
7777 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const throw(INTERP_KERNEL::Exception)
7779 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
7781 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
7782 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
7783 std::size_t sz(contentsSplit.size());
7784 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
7785 for(std::size_t i=0;i<sz;i++)
7787 ret[i]=shallowCpy();
7788 ret[i]->_content=contentsSplit[i];
7793 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCpy() const throw(INTERP_KERNEL::Exception)
7795 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
7796 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
7797 ret->_content=_content->deepCpy();
7798 ret->deepCpyGlobs(*this);
7802 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
7808 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
7809 * \param [in] iteration - the iteration number of a required time step.
7810 * \param [in] order - the iteration order number of required time step.
7811 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
7812 * delete this field using decrRef() as it is no more needed.
7813 * \throw If there is no required time step in \a this field.
7815 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
7817 int pos=getPosOfTimeStep(iteration,order);
7818 return getTimeStepAtPos(pos);
7822 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
7823 * \param [in] time - the time of the time step of interest.
7824 * \param [in] eps - a precision used to compare time values.
7825 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
7826 * delete this field using decrRef() as it is no more needed.
7827 * \throw If there is no required time step in \a this field.
7829 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
7831 int pos=getPosGivenTime(time,eps);
7832 return getTimeStepAtPos(pos);
7835 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator() throw(INTERP_KERNEL::Exception)
7837 return new MEDFileAnyTypeFieldMultiTSIterator(this);
7840 //= MEDFileFieldMultiTS
7843 * Returns a new empty instance of MEDFileFieldMultiTS.
7844 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
7845 * is to delete this field using decrRef() as it is no more needed.
7847 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
7849 return new MEDFileFieldMultiTS;
7853 * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
7854 * that has been read from a specified MED file.
7855 * \param [in] fileName - the name of the MED file to read.
7856 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
7857 * is to delete this field using decrRef() as it is no more needed.
7858 * \throw If reading the file fails.
7860 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
7862 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,loadAll);
7863 ret->contentNotNull();//to check that content type matches with \a this type.
7868 * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
7869 * that has been read from a specified MED file.
7870 * \param [in] fileName - the name of the MED file to read.
7871 * \param [in] fieldName - the name of the field to read.
7872 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
7873 * is to delete this field using decrRef() as it is no more needed.
7874 * \throw If reading the file fails.
7875 * \throw If there is no field named \a fieldName in the file.
7877 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
7879 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,fieldName,loadAll);
7880 ret->contentNotNull();//to check that content type matches with \a this type.
7885 * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
7886 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
7888 * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
7889 * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
7890 * \warning this is a shallow copy constructor
7891 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
7892 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
7893 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
7894 * is to delete this field using decrRef() as it is no more needed.
7896 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
7898 return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
7901 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const throw(INTERP_KERNEL::Exception)
7903 return new MEDFileFieldMultiTS(*this);
7906 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const throw(INTERP_KERNEL::Exception)
7909 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7910 const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
7912 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
7916 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
7917 * following the given input policy.
7919 * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
7920 * By default (true) the globals are deeply copied.
7921 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
7923 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
7925 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret;
7926 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
7929 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
7931 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
7932 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
7933 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc,getFileName()));
7936 ret=MEDFileIntFieldMultiTS::New();
7938 ret->deepCpyGlobs(*this);
7940 ret->shallowCpyGlobs(*this);
7945 * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
7946 * \param [in] pos - a time step id.
7947 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
7948 * delete this field using decrRef() as it is no more needed.
7949 * \throw If \a pos is not a valid time step id.
7951 MEDFileAnyTypeField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception)
7953 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
7956 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
7957 throw INTERP_KERNEL::Exception(oss.str().c_str());
7959 const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
7962 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
7963 ret->shallowCpyGlobs(*this);
7966 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
7967 throw INTERP_KERNEL::Exception(oss.str().c_str());
7971 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
7972 * mesh entities of a given dimension of the first mesh in MED file.
7973 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7974 * \param [in] type - a spatial discretization of interest.
7975 * \param [in] iteration - the iteration number of a required time step.
7976 * \param [in] order - the iteration order number of required time step.
7977 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7978 * \param [in] renumPol - specifies how to permute values of the result field according to
7979 * the optional numbers of cells and nodes, if any. The valid values are
7980 * - 0 - do not permute.
7981 * - 1 - permute cells.
7982 * - 2 - permute nodes.
7983 * - 3 - permute cells and nodes.
7985 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
7986 * caller is to delete this field using decrRef() as it is no more needed.
7987 * \throw If the MED file is not readable.
7988 * \throw If there is no mesh in the MED file.
7989 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7990 * \throw If no field values of the required parameters are available.
7992 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
7994 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
7995 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
7997 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
7998 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
7999 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut,*contentNotNullBase());
8000 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8005 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8006 * the top level cells of the first mesh in MED file.
8007 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8008 * \param [in] type - a spatial discretization of interest.
8009 * \param [in] iteration - the iteration number of a required time step.
8010 * \param [in] order - the iteration order number of required time step.
8011 * \param [in] renumPol - specifies how to permute values of the result field according to
8012 * the optional numbers of cells and nodes, if any. The valid values are
8013 * - 0 - do not permute.
8014 * - 1 - permute cells.
8015 * - 2 - permute nodes.
8016 * - 3 - permute cells and nodes.
8018 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8019 * caller is to delete this field using decrRef() as it is no more needed.
8020 * \throw If the MED file is not readable.
8021 * \throw If there is no mesh in the MED file.
8022 * \throw If no field values of the required parameters are available.
8024 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const throw(INTERP_KERNEL::Exception)
8026 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8027 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8029 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
8030 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8031 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,0,renumPol,this,arrOut,*contentNotNullBase());
8032 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8037 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8039 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8040 * \param [in] type - a spatial discretization of interest.
8041 * \param [in] iteration - the iteration number of a required time step.
8042 * \param [in] order - the iteration order number of required time step.
8043 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8044 * \param [in] mesh - the supporting mesh.
8045 * \param [in] renumPol - specifies how to permute values of the result field according to
8046 * the optional numbers of cells and nodes, if any. The valid values are
8047 * - 0 - do not permute.
8048 * - 1 - permute cells.
8049 * - 2 - permute nodes.
8050 * - 3 - permute cells and nodes.
8052 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8053 * caller is to delete this field using decrRef() as it is no more needed.
8054 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8055 * \throw If no field of \a this is lying on \a mesh.
8056 * \throw If no field values of the required parameters are available.
8058 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
8060 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8061 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8063 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
8064 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8065 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
8066 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8071 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
8073 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8074 * \param [in] type - a spatial discretization of the new field.
8075 * \param [in] iteration - the iteration number of a required time step.
8076 * \param [in] order - the iteration order number of required time step.
8077 * \param [in] mesh - the supporting mesh.
8078 * \param [in] renumPol - specifies how to permute values of the result field according to
8079 * the optional numbers of cells and nodes, if any. The valid values are
8080 * - 0 - do not permute.
8081 * - 1 - permute cells.
8082 * - 2 - permute nodes.
8083 * - 3 - permute cells and nodes.
8085 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8086 * caller is to delete this field using decrRef() as it is no more needed.
8087 * \throw If no field of \a this is lying on \a mesh.
8088 * \throw If no field values of the required parameters are available.
8090 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
8092 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8093 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8095 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
8096 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8097 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
8098 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8103 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
8104 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
8105 * This method is useful for MED2 file format when field on different mesh was autorized.
8107 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const char *mname, int iteration, int order, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
8109 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8110 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8112 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
8113 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8114 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
8115 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8120 * Returns values and a profile of the field of a given type, of a given time step,
8121 * lying on a given support.
8122 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8123 * \param [in] type - a spatial discretization of the field.
8124 * \param [in] iteration - the iteration number of a required time step.
8125 * \param [in] order - the iteration order number of required time step.
8126 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8127 * \param [in] mesh - the supporting mesh.
8128 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
8129 * field of interest lies on. If the field lies on all entities of the given
8130 * dimension, all ids in \a pfl are zero. The caller is to delete this array
8131 * using decrRef() as it is no more needed.
8132 * \param [in] glob - the global data storing profiles and localization.
8133 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
8134 * field. The caller is to delete this array using decrRef() as it is no more needed.
8135 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8136 * \throw If no field of \a this is lying on \a mesh.
8137 * \throw If no field values of the required parameters are available.
8139 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
8141 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8142 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8144 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
8145 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
8146 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
8149 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const throw(INTERP_KERNEL::Exception)
8151 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8153 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
8154 const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
8156 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 !");
8160 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() throw(INTERP_KERNEL::Exception)
8162 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8164 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
8165 MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
8167 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 !");
8172 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
8173 * the given field is checked if its elements are sorted suitable for writing to MED file
8174 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
8175 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8176 * \param [in] field - the field to add to \a this.
8177 * \throw If the name of \a field is empty.
8178 * \throw If the data array of \a field is not set.
8179 * \throw If existing time steps have different name or number of components than \a field.
8180 * \throw If the underlying mesh of \a field has no name.
8181 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
8183 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
8185 const DataArrayDouble *arr=0;
8187 arr=field->getArray();
8188 contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
8192 * Adds a MEDCouplingFieldDouble to \a this as another time step. Specified entities of
8193 * a given dimension of a given mesh are used as the support of the given field.
8194 * Elements of the given mesh must be sorted suitable for writing to MED file.
8195 * Order of underlying mesh entities of the given field specified by \a profile parameter
8196 * is not prescribed; this method permutes field values to have them sorted by element
8197 * type as required for writing to MED file.
8198 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8199 * \param [in] field - the field to add to \a this.
8200 * \param [in] mesh - the supporting mesh of \a field.
8201 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
8202 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
8203 * \throw If either \a field or \a mesh or \a profile has an empty name.
8204 * \throw If existing time steps have different name or number of components than \a field.
8205 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8206 * \throw If the data array of \a field is not set.
8207 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
8209 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
8211 const DataArrayDouble *arr=0;
8213 arr=field->getArray();
8214 contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
8217 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
8219 _content=new MEDFileFieldMultiTSWithoutSDA;
8222 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
8223 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll)
8226 catch(INTERP_KERNEL::Exception& e)
8229 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
8230 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll)
8233 catch(INTERP_KERNEL::Exception& e)
8236 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
8240 std::vector< std::vector<DataArrayDouble *> > MEDFileFieldMultiTS::getFieldSplitedByType2(int iteration, int order, const char *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 throw(INTERP_KERNEL::Exception)
8242 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
8245 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
8247 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
8250 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
8252 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
8255 //= MEDFileAnyTypeFieldMultiTSIterator
8257 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
8262 _nb_iter=fmts->getNumberOfTS();
8266 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
8270 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt() throw(INTERP_KERNEL::Exception)
8272 if(_iter_id<_nb_iter)
8274 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
8276 return fmts->getTimeStepAtPos(_iter_id++);
8284 //= MEDFileIntFieldMultiTS
8287 * Returns a new empty instance of MEDFileFieldMultiTS.
8288 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8289 * is to delete this field using decrRef() as it is no more needed.
8291 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
8293 return new MEDFileIntFieldMultiTS;
8297 * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
8298 * that has been read from a specified MED file.
8299 * \param [in] fileName - the name of the MED file to read.
8300 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8301 * is to delete this field using decrRef() as it is no more needed.
8302 * \throw If reading the file fails.
8304 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
8306 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,loadAll);
8307 ret->contentNotNull();//to check that content type matches with \a this type.
8312 * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
8313 * that has been read from a specified MED file.
8314 * \param [in] fileName - the name of the MED file to read.
8315 * \param [in] fieldName - the name of the field to read.
8316 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8317 * is to delete this field using decrRef() as it is no more needed.
8318 * \throw If reading the file fails.
8319 * \throw If there is no field named \a fieldName in the file.
8321 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
8323 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll);
8324 ret->contentNotNull();//to check that content type matches with \a this type.
8329 * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8330 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8332 * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
8333 * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
8334 * \warning this is a shallow copy constructor
8335 * \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
8336 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
8337 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8338 * is to delete this field using decrRef() as it is no more needed.
8340 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8342 return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
8346 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
8347 * following the given input policy.
8349 * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
8350 * By default (true) the globals are deeply copied.
8351 * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
8353 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
8355 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret;
8356 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8359 const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
8361 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
8362 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
8363 ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc,getFileName()));
8366 ret=MEDFileFieldMultiTS::New();
8368 ret->deepCpyGlobs(*this);
8370 ret->shallowCpyGlobs(*this);
8374 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const throw(INTERP_KERNEL::Exception)
8376 return new MEDFileIntFieldMultiTS(*this);
8379 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const throw(INTERP_KERNEL::Exception)
8382 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8383 const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
8385 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8389 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8390 * mesh entities of a given dimension of the first mesh in MED file.
8391 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8392 * \param [in] type - a spatial discretization of interest.
8393 * \param [in] iteration - the iteration number of a required time step.
8394 * \param [in] order - the iteration order number of required time step.
8395 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8396 * \param [out] arrOut - the DataArrayInt containing values of field.
8397 * \param [in] renumPol - specifies how to permute values of the result field according to
8398 * the optional numbers of cells and nodes, if any. The valid values are
8399 * - 0 - do not permute.
8400 * - 1 - permute cells.
8401 * - 2 - permute nodes.
8402 * - 3 - permute cells and nodes.
8404 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8405 * caller is to delete this field using decrRef() as it is no more needed.
8406 * \throw If the MED file is not readable.
8407 * \throw If there is no mesh in the MED file.
8408 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8409 * \throw If no field values of the required parameters are available.
8411 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8413 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8414 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8416 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
8417 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8418 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arr,*contentNotNullBase());
8419 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8424 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8425 * the top level cells of the first mesh in MED file.
8426 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8427 * \param [in] type - a spatial discretization of interest.
8428 * \param [in] iteration - the iteration number of a required time step.
8429 * \param [in] order - the iteration order number of required time step.
8430 * \param [out] arrOut - the DataArrayInt containing values of field.
8431 * \param [in] renumPol - specifies how to permute values of the result field according to
8432 * the optional numbers of cells and nodes, if any. The valid values are
8433 * - 0 - do not permute.
8434 * - 1 - permute cells.
8435 * - 2 - permute nodes.
8436 * - 3 - permute cells and nodes.
8438 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8439 * caller is to delete this field using decrRef() as it is no more needed.
8440 * \throw If the MED file is not readable.
8441 * \throw If there is no mesh in the MED file.
8442 * \throw If no field values of the required parameters are available.
8444 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8446 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8447 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8449 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
8450 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8451 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,0,renumPol,this,arr,*contentNotNullBase());
8452 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8457 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8459 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8460 * \param [in] type - a spatial discretization of interest.
8461 * \param [in] iteration - the iteration number of a required time step.
8462 * \param [in] order - the iteration order number of required time step.
8463 * \param [out] arrOut - the DataArrayInt containing values of field.
8464 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8465 * \param [in] mesh - the supporting mesh.
8466 * \param [in] renumPol - specifies how to permute values of the result field according to
8467 * the optional numbers of cells and nodes, if any. The valid values are
8468 * - 0 - do not permute.
8469 * - 1 - permute cells.
8470 * - 2 - permute nodes.
8471 * - 3 - permute cells and nodes.
8473 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8474 * caller is to delete this field using decrRef() as it is no more needed.
8475 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8476 * \throw If no field of \a this is lying on \a mesh.
8477 * \throw If no field values of the required parameters are available.
8479 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8481 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8482 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8484 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
8485 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8486 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase());
8487 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8492 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
8494 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8495 * \param [in] type - a spatial discretization of the new field.
8496 * \param [in] iteration - the iteration number of a required time step.
8497 * \param [in] order - the iteration order number of required time step.
8498 * \param [in] mesh - the supporting mesh.
8499 * \param [out] arrOut - the DataArrayInt containing values of field.
8500 * \param [in] renumPol - specifies how to permute values of the result field according to
8501 * the optional numbers of cells and nodes, if any. The valid values are
8502 * - 0 - do not permute.
8503 * - 1 - permute cells.
8504 * - 2 - permute nodes.
8505 * - 3 - permute cells and nodes.
8507 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8508 * caller is to delete this field using decrRef() as it is no more needed.
8509 * \throw If no field of \a this is lying on \a mesh.
8510 * \throw If no field values of the required parameters are available.
8512 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8514 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8515 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8517 throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
8518 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8519 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase());
8520 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8525 * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
8526 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
8527 * This method is useful for MED2 file format when field on different mesh was autorized.
8529 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const char *mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8531 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8532 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8534 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
8535 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8536 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase());
8537 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8542 * Returns values and a profile of the field of a given type, of a given time step,
8543 * lying on a given support.
8544 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8545 * \param [in] type - a spatial discretization of the field.
8546 * \param [in] iteration - the iteration number of a required time step.
8547 * \param [in] order - the iteration order number of required time step.
8548 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8549 * \param [in] mesh - the supporting mesh.
8550 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
8551 * field of interest lies on. If the field lies on all entities of the given
8552 * dimension, all ids in \a pfl are zero. The caller is to delete this array
8553 * using decrRef() as it is no more needed.
8554 * \param [in] glob - the global data storing profiles and localization.
8555 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
8556 * field. The caller is to delete this array using decrRef() as it is no more needed.
8557 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8558 * \throw If no field of \a this is lying on \a mesh.
8559 * \throw If no field values of the required parameters are available.
8561 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
8563 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8564 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8566 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
8567 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
8568 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
8572 * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
8573 * \param [in] pos - a time step id.
8574 * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
8575 * delete this field using decrRef() as it is no more needed.
8576 * \throw If \a pos is not a valid time step id.
8578 MEDFileAnyTypeField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception)
8580 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
8583 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
8584 throw INTERP_KERNEL::Exception(oss.str().c_str());
8586 const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
8589 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
8590 ret->shallowCpyGlobs(*this);
8593 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
8594 throw INTERP_KERNEL::Exception(oss.str().c_str());
8598 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
8599 * the given field is checked if its elements are sorted suitable for writing to MED file
8600 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
8601 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8602 * \param [in] field - the field to add to \a this.
8603 * \throw If the name of \a field is empty.
8604 * \throw If the data array of \a field is not set.
8605 * \throw If existing time steps have different name or number of components than \a field.
8606 * \throw If the underlying mesh of \a field has no name.
8607 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
8609 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals) throw(INTERP_KERNEL::Exception)
8611 contentNotNull()->appendFieldNoProfileSBT(field,arrOfVals,*this);
8615 * Adds a MEDCouplingFieldDouble to \a this as another time step. Specified entities of
8616 * a given dimension of a given mesh are used as the support of the given field.
8617 * Elements of the given mesh must be sorted suitable for writing to MED file.
8618 * Order of underlying mesh entities of the given field specified by \a profile parameter
8619 * is not prescribed; this method permutes field values to have them sorted by element
8620 * type as required for writing to MED file.
8621 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8622 * \param [in] field - the field to add to \a this.
8623 * \param [in] mesh - the supporting mesh of \a field.
8624 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
8625 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
8626 * \throw If either \a field or \a mesh or \a profile has an empty name.
8627 * \throw If existing time steps have different name or number of components than \a field.
8628 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8629 * \throw If the data array of \a field is not set.
8630 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
8632 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
8634 contentNotNull()->appendFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this);
8637 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const throw(INTERP_KERNEL::Exception)
8639 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8641 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
8642 const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
8644 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 !");
8648 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() throw(INTERP_KERNEL::Exception)
8650 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8652 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
8653 MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
8655 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 !");
8659 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
8661 _content=new MEDFileIntFieldMultiTSWithoutSDA;
8664 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
8668 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
8669 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll)
8672 catch(INTERP_KERNEL::Exception& e)
8675 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
8676 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll)
8679 catch(INTERP_KERNEL::Exception& e)
8682 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
8684 return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
8689 MEDFileFields *MEDFileFields::New()
8691 return new MEDFileFields;
8694 MEDFileFields *MEDFileFields::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
8696 return new MEDFileFields(fileName,loadAll);
8699 std::size_t MEDFileFields::getHeapMemorySize() const
8701 std::size_t ret=_fields.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
8702 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
8703 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it)
8704 ret+=(*it)->getHeapMemorySize();
8705 return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
8708 MEDFileFields *MEDFileFields::deepCpy() const throw(INTERP_KERNEL::Exception)
8710 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
8712 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
8714 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
8715 ret->_fields[i]=(*it)->deepCpy();
8717 ret->deepCpyGlobs(*this);
8721 MEDFileFields *MEDFileFields::shallowCpy() const throw(INTERP_KERNEL::Exception)
8723 return new MEDFileFields(*this);
8727 * 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
8728 * 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.
8729 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
8731 * \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.
8732 * \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.
8734 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
8736 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const throw(INTERP_KERNEL::Exception)
8738 std::set< std::pair<int,int> > s;
8739 bool firstShot=true;
8740 areThereSomeForgottenTS=false;
8741 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
8743 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
8745 std::vector< std::pair<int,int> > v=(*it)->getIterations();
8746 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
8748 { s=s1; firstShot=false; }
8751 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
8753 areThereSomeForgottenTS=true;
8757 std::vector< std::pair<int,int> > ret;
8758 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
8762 int MEDFileFields::getNumberOfFields() const
8764 return _fields.size();
8767 std::vector<std::string> MEDFileFields::getFieldsNames() const throw(INTERP_KERNEL::Exception)
8769 std::vector<std::string> ret(_fields.size());
8771 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
8773 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
8776 ret[i]=f->getName();
8780 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
8781 throw INTERP_KERNEL::Exception(oss.str().c_str());
8787 std::vector<std::string> MEDFileFields::getMeshesNames() const throw(INTERP_KERNEL::Exception)
8789 std::vector<std::string> ret;
8790 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
8792 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
8794 ret.push_back(cur->getMeshName());
8799 std::string MEDFileFields::simpleRepr() const
8801 std::ostringstream oss;
8802 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
8807 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
8809 int nbOfFields=getNumberOfFields();
8810 std::string startLine(bkOffset,' ');
8811 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
8813 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
8815 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
8818 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
8822 oss << startLine << " - not defined !" << std::endl;
8826 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
8828 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
8829 std::string chapter(17,'0'+i);
8830 oss << startLine << chapter << std::endl;
8833 cur->simpleRepr(bkOffset+2,oss,i);
8837 oss << startLine << " - not defined !" << std::endl;
8839 oss << startLine << chapter << std::endl;
8841 simpleReprGlobs(oss);
8844 MEDFileFields::MEDFileFields()
8848 MEDFileFields::MEDFileFields(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
8849 try:MEDFileFieldGlobsReal(fileName)
8851 MEDFileUtilities::CheckFileForRead(fileName);
8852 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
8853 int nbFields=MEDnField(fid);
8854 _fields.resize(nbFields);
8855 med_field_type typcha;
8856 for(int i=0;i<nbFields;i++)
8858 std::vector<std::string> infos;
8859 std::string fieldName,dtunit;
8860 int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,fileName,i,false,fieldName,typcha,infos,dtunit);
8865 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll);
8870 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll);
8875 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] !";
8876 throw INTERP_KERNEL::Exception(oss.str().c_str());
8880 loadAllGlobals(fid);
8882 catch(INTERP_KERNEL::Exception& e)
8887 void MEDFileFields::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
8890 writeGlobals(fid,*this);
8891 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
8893 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
8896 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
8897 throw INTERP_KERNEL::Exception(oss.str().c_str());
8899 elt->writeLL(fid,*this);
8903 void MEDFileFields::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
8905 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
8906 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
8910 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
8912 std::vector<std::string> ret;
8913 std::set<std::string> ret2;
8914 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
8916 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
8917 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
8918 if(ret2.find(*it2)==ret2.end())
8920 ret.push_back(*it2);
8927 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
8929 std::vector<std::string> ret;
8930 std::set<std::string> ret2;
8931 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
8933 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
8934 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
8935 if(ret2.find(*it2)==ret2.end())
8937 ret.push_back(*it2);
8944 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
8946 std::vector<std::string> ret;
8947 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
8949 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
8950 ret.insert(ret.end(),tmp.begin(),tmp.end());
8955 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
8957 std::vector<std::string> ret;
8958 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
8960 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
8961 ret.insert(ret.end(),tmp.begin(),tmp.end());
8966 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
8968 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
8969 (*it)->changePflsRefsNamesGen2(mapOfModif);
8972 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
8974 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
8975 (*it)->changeLocsRefsNamesGen2(mapOfModif);
8978 void MEDFileFields::resize(int newSize) throw(INTERP_KERNEL::Exception)
8980 _fields.resize(newSize);
8983 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields) throw(INTERP_KERNEL::Exception)
8985 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
8989 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
8992 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
8993 _fields.push_back(field->getContent());
8994 appendGlobs(*field,1e-12);
8997 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
9000 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
9001 if(i>=(int)_fields.size())
9002 _fields.resize(i+1);
9003 _fields[i]=field->getContent();
9004 appendGlobs(*field,1e-12);
9007 void MEDFileFields::destroyFieldAtPos(int i) throw(INTERP_KERNEL::Exception)
9009 destroyFieldsAtPos(&i,&i+1);
9012 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
9014 std::vector<bool> b(_fields.size(),true);
9015 for(const int *i=startIds;i!=endIds;i++)
9017 if(*i<0 || *i>=(int)_fields.size())
9019 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
9020 throw INTERP_KERNEL::Exception(oss.str().c_str());
9024 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
9026 for(std::size_t i=0;i<_fields.size();i++)
9028 fields[j++]=_fields[i];
9032 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step) throw(INTERP_KERNEL::Exception)
9034 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
9035 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
9036 std::vector<bool> b(_fields.size(),true);
9038 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
9040 if(k<0 || k>=(int)_fields.size())
9042 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
9043 throw INTERP_KERNEL::Exception(oss.str().c_str());
9047 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
9049 for(std::size_t i=0;i<_fields.size();i++)
9051 fields[j++]=_fields[i];
9055 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
9058 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9060 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9062 ret=cur->changeMeshNames(modifTab) || ret;
9068 * \param [in] meshName the name of the mesh that will be renumbered.
9069 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
9070 * This code corresponds to the distribution of types in the corresponding mesh.
9071 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
9072 * \param [in] renumO2N the old to new renumber array.
9073 * \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
9076 bool MEDFileFields::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N) throw(INTERP_KERNEL::Exception)
9079 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9081 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
9084 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
9090 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const throw(INTERP_KERNEL::Exception)
9092 if(i<0 || i>=(int)_fields.size())
9094 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
9095 throw INTERP_KERNEL::Exception(oss.str().c_str());
9097 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
9100 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret;
9101 const MEDFileFieldMultiTSWithoutSDA *fmtsC=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts);
9102 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts);
9104 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
9106 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
9109 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
9110 throw INTERP_KERNEL::Exception(oss.str().c_str());
9112 ret->shallowCpyGlobs(*this);
9117 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
9118 * This method is accessible in python using __getitem__ with a list in input.
9119 * \return a new object that the caller should deal with.
9121 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception)
9123 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
9124 std::size_t sz=std::distance(startIds,endIds);
9125 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
9127 for(const int *i=startIds;i!=endIds;i++,j++)
9129 if(*i<0 || *i>=(int)_fields.size())
9131 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
9132 throw INTERP_KERNEL::Exception(oss.str().c_str());
9134 fields[j]=_fields[*i];
9136 ret->_fields=fields;
9140 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const char *fieldName) const throw(INTERP_KERNEL::Exception)
9142 return getFieldAtPos(getPosFromFieldName(fieldName));
9146 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
9147 * This method can be seen as a filter applied on \a this, that returns an object containing
9148 * 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
9149 * shallow copied from \a this.
9151 * \param [in] meshName - the name of the mesh on w
9152 * \return a new object that the caller should deal with.
9154 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const char *meshName) const throw(INTERP_KERNEL::Exception)
9156 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
9157 ret->shallowCpyOnlyUsedGlobs(*this);
9158 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9160 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9163 if(cur->getMeshName()==meshName)
9166 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
9167 ret->_fields.push_back(cur2);
9174 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
9175 * Input time steps are specified using a pair of integer (iteration, order).
9176 * 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,
9177 * but for each multitimestep only the time steps in \a timeSteps are kept.
9178 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
9180 * The returned object points to shallow copy of elements in \a this.
9182 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
9183 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
9184 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9186 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
9188 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
9189 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9191 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9194 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
9195 ret->_fields.push_back(elt);
9197 ret->shallowCpyOnlyUsedGlobs(*this);
9202 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
9204 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
9206 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
9207 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9209 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9212 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
9213 if(elt->getNumberOfTS()!=0)
9214 ret->_fields.push_back(elt);
9216 ret->shallowCpyOnlyUsedGlobs(*this);
9220 MEDFileFieldsIterator *MEDFileFields::iterator() throw(INTERP_KERNEL::Exception)
9222 return new MEDFileFieldsIterator(this);
9225 int MEDFileFields::getPosFromFieldName(const char *fieldName) const throw(INTERP_KERNEL::Exception)
9227 std::string tmp(fieldName);
9228 std::vector<std::string> poss;
9229 for(std::size_t i=0;i<_fields.size();i++)
9231 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=_fields[i];
9234 std::string fname(f->getName());
9238 poss.push_back(fname);
9241 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
9242 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
9244 throw INTERP_KERNEL::Exception(oss.str().c_str());
9247 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
9252 _nb_iter=fs->getNumberOfFields();
9256 MEDFileFieldsIterator::~MEDFileFieldsIterator()
9260 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
9262 if(_iter_id<_nb_iter)
9264 MEDFileFields *fs(_fs);
9266 return fs->getFieldAtPos(_iter_id++);