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);
486 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !");
489 DataArray *arr=getOrCreateAndGetArray();//arr is not null due to the spec of getOrCreateAndGetArray
490 if(_start<0 || _start>=arr->getNumberOfTuples())
492 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << ") !";
493 throw INTERP_KERNEL::Exception(oss.str().c_str());
495 if(_end<0 || _end>arr->getNumberOfTuples())
497 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !";
498 throw INTERP_KERNEL::Exception(oss.str().c_str());
501 INTERP_KERNEL::AutoPtr<char> locname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
502 med_int nbValsInFile=MEDfieldnValueWithProfileByName(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile.c_str(),MED_COMPACT_PFLMODE,&tmp1,locname,&nbi);
503 int nbOfCompo=arr->getNumberOfComponents();
504 if(_end-_start!=nbValsInFile*nbi)
506 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : The number of tuples to read is " << nbValsInFile << "*" << nbi << " (nb integration points) ! But in data structure it values " << _end-_start << " is expected !";
507 throw INTERP_KERNEL::Exception(oss.str().c_str());
509 DataArrayDouble *arrD=dynamic_cast<DataArrayDouble *>(arr);
512 double *startFeeding=arrD->getPointer()+_start*nbOfCompo;
513 MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,
514 _profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast<unsigned char*>(startFeeding));
517 DataArrayInt *arrI=dynamic_cast<DataArrayInt *>(arr);
520 int *startFeeding=arrI->getPointer()+_start*nbOfCompo;
521 MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,
522 _profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast<unsigned char*>(startFeeding));
525 throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
529 * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
531 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart) throw(INTERP_KERNEL::Exception)
533 int delta=_end-_start;
534 _start=newValueOfStart;
538 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
540 return _father->getIteration();
543 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
545 return _father->getOrder();
548 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
550 return _father->getTime();
553 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
555 return _father->getMeshName();
558 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
560 const char startLine[]=" ## ";
561 std::string startLine2(bkOffset,' ');
562 startLine2+=startLine;
563 MEDCouplingFieldDiscretization *tmp=MEDCouplingFieldDiscretization::New(_type);
564 oss << startLine2 << "Localization #" << id << "." << std::endl;
565 oss << startLine2 << " Type=" << tmp->getRepr() << "." << std::endl;
567 oss << startLine2 << " This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
568 oss << startLine2 << " This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
569 oss << startLine2 << " This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
572 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
577 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
582 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
587 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
589 return _father->getGeoType();
592 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
594 return _father->getNumberOfComponents();
597 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
602 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray()
604 return _father->getOrCreateAndGetArray();
607 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const
609 const MEDFileFieldPerMeshPerType *fath=_father;
610 return fath->getOrCreateAndGetArray();
613 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
615 return _father->getInfo();
618 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
623 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const char *newPflName)
628 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
630 return _localization;
633 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const char *newLocName)
635 _localization=newLocName;
638 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
640 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
642 if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
644 _profile=(*it2).second;
650 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
652 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
654 if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
656 _localization=(*it2).second;
662 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
666 dads.push_back(std::pair<int,int>(_start,_end));
667 geoTypes.push_back(getGeoType());
672 pfls.push_back(glob->getProfile(_profile.c_str()));
674 if(_localization.empty())
678 locs.push_back(glob->getLocalizationId(_localization.c_str()));
682 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
684 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));
688 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
690 TypeOfField type=getType();
691 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
692 med_geometry_type mgeoti;
693 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
694 const DataArray *arr=getOrCreateAndGetArray();
696 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
697 const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
698 const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
699 const unsigned char *locToWrite=0;
701 locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
703 locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
705 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
706 MEDfieldValueWithProfileWr(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
707 MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
711 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const throw(INTERP_KERNEL::Exception)
716 dad.first=_start; dad.second=_end;
720 * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
721 * This code corresponds to the distribution of types in the corresponding mesh.
722 * \param [out] ptToFill memory zone where the output will be stored.
723 * \return the size of data pushed into output param \a ptToFill
725 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const throw(INTERP_KERNEL::Exception)
728 std::ostringstream oss;
729 std::size_t nbOfType=codeOfMesh.size()/3;
731 for(std::size_t i=0;i<nbOfType && found==-1;i++)
732 if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
736 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
737 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
738 throw INTERP_KERNEL::Exception(oss.str().c_str());
743 if(_nval!=codeOfMesh[3*found+1])
745 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
746 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
747 oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
748 throw INTERP_KERNEL::Exception(oss.str().c_str());
750 for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
755 const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
756 if(pfl->getNumberOfTuples()!=_nval)
758 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
759 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
761 oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
762 throw INTERP_KERNEL::Exception(oss.str().c_str());
764 int offset2=codeOfMesh[3*found+2];
765 for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
767 if(*pflId<codeOfMesh[3*found+1])
768 *work++=offset2+*pflId;
774 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const throw(INTERP_KERNEL::Exception)
776 for(int i=_start;i<_end;i++)
781 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId) throw(INTERP_KERNEL::Exception)
792 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
796 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
799 std::map<std::pair<std::string,TypeOfField>,int> m;
800 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
801 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
802 if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
803 m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
805 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
806 ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
811 * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
813 * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
814 * \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.
815 * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
816 * \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)
817 * \param [in,out] glob if necessary by the method, new profiles can be added to it
818 * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
819 * \param [out] result All new entries will be appended on it.
820 * \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 !)
822 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
823 const DataArrayInt *explicitIdsInMesh,
824 const std::vector<int>& newCode,
825 MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
826 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >& result)
828 if(entriesOnSameDisc.empty())
830 TypeOfField type=entriesOnSameDisc[0]->getType();
831 int szEntities=0,szTuples=0;
832 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
833 { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
834 int nbi=szTuples/szEntities;
835 if(szTuples%szEntities!=0)
836 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
837 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
838 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
839 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
840 std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
841 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
842 std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
843 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
845 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
847 int startOfEltIdOfChunk=(*it)->_start;
848 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newEltIds=explicitIdsInMesh->substr(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
849 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
850 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
852 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
853 newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
855 newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
856 newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
858 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
859 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
860 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
861 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
863 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
865 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arrPart=arr->substr(offset,offset+szTuples);
866 arrPart->renumberInPlace(renumTupleIds->begin());
867 arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
869 const int *idIt=diffVals->begin();
870 std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
872 for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
874 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=newGeoTypesEltIdsAllGather->getIdsEqual(*idIt);
875 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
876 int nbEntityElts=subIds->getNumberOfTuples();
878 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
879 NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIdentity() || nbEntityElts!=newCode[3*(*idIt)+1],nbi,
883 result.push_back(eltToAdd);
884 offset2+=nbEntityElts*nbi;
886 ret=ret || li.empty();
891 * \param [in] typeF type of field of new chunk
892 * \param [in] geoType the geometric type of the chunk
893 * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
894 * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
895 * \param [in] nbi number of integration points
896 * \param [in] offset The offset in the **global array of data**.
897 * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
898 * to the new chunk to create.
899 * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
900 * \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
901 * and corresponding entry erased from \a entriesOnSameDisc.
902 * \return a newly allocated chunk
904 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
905 bool isPfl, int nbi, int offset,
906 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
907 MEDFileFieldGlobsReal& glob,
908 bool ¬InExisting) throw(INTERP_KERNEL::Exception)
910 int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
911 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
912 for(;it!=entriesOnSameDisc.end();it++)
914 if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
918 if((*it)->_profile.empty())
921 if(!(*it)->_profile.empty())
923 const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
924 if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
930 if(it==entriesOnSameDisc.end())
933 MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
935 ret->_loc_id=(int)geoType;
936 ret->_nval=nbMeshEntities;
938 ret->_end=ret->_start+ret->_nval*nbi;
941 idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
942 glob.appendProfile(idsOfMeshElt);
943 ret->_profile=idsOfMeshElt->getName();
945 //tony treatment of localization
951 MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
952 ret->_loc_id=(int)geoType;
953 ret->setNewStart(offset);
954 entriesOnSameDisc.erase(it);
960 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
962 return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc);
965 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception)
967 return new MEDFileFieldPerMeshPerType(fath,geoType);
970 std::size_t MEDFileFieldPerMeshPerType::getHeapMemorySize() const
972 std::size_t ret=_field_pm_pt_pd.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc>);
973 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
974 ret+=(*it)->getHeapMemorySize();
978 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCpy(MEDFileFieldPerMesh *father) const throw(INTERP_KERNEL::Exception)
980 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
983 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
985 if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
986 ret->_field_pm_pt_pd[i]=(*it)->deepCpy((MEDFileFieldPerMeshPerType *)ret);
991 void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
993 std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
994 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
995 _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
999 * This method is the most general one. No optimization is done here.
1000 * \param [in] multiTypePfl is the end user profile specified in high level API
1001 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1002 * \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.
1003 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1004 * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1005 * \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.
1007 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)
1009 std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1010 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1011 _field_pm_pt_pd[*it]->assignFieldProfile(start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1014 void MEDFileFieldPerMeshPerType::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1016 _field_pm_pt_pd.resize(1);
1017 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1018 _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1021 void MEDFileFieldPerMeshPerType::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1023 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2=pfl->deepCpy();
1024 if(!arr || !arr->isAllocated())
1025 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::assignNodeFieldProfile : input array is null, or not allocated !");
1026 _field_pm_pt_pd.resize(1);
1027 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1028 _field_pm_pt_pd[0]->assignFieldProfile(start,pfl,pfl2,pfl2,-1,field,arr,0,glob,nasc);//mesh is not requested so 0 is send.
1031 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception)
1033 TypeOfField type=field->getTypeOfField();
1034 if(type!=ON_GAUSS_PT)
1036 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1037 int sz=_field_pm_pt_pd.size();
1039 for(int j=0;j<sz && !found;j++)
1041 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1043 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1049 _field_pm_pt_pd.resize(sz+1);
1050 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1052 std::vector<int> ret(1,(int)sz);
1057 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1058 int sz2=ret2.size();
1059 std::vector<int> ret3(sz2);
1061 for(int i=0;i<sz2;i++)
1063 int sz=_field_pm_pt_pd.size();
1064 int locIdToFind=ret2[i];
1066 for(int j=0;j<sz && !found;j++)
1068 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1070 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1077 _field_pm_pt_pd.resize(sz+1);
1078 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1086 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception)
1088 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1089 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1091 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1092 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1094 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1095 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleId2(offset,offset+nbOfCells,1);
1096 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1097 if(retTmp->presenceOfValue(-1))
1098 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1099 std::vector<int> ret(retTmp->begin(),retTmp->end());
1103 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) throw(INTERP_KERNEL::Exception)
1105 TypeOfField type=field->getTypeOfField();
1106 if(type!=ON_GAUSS_PT)
1108 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1109 int sz=_field_pm_pt_pd.size();
1111 for(int j=0;j<sz && !found;j++)
1113 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1115 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1121 _field_pm_pt_pd.resize(sz+1);
1122 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1124 std::vector<int> ret(1,0);
1129 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1130 int sz2=ret2.size();
1131 std::vector<int> ret3(sz2);
1133 for(int i=0;i<sz2;i++)
1135 int sz=_field_pm_pt_pd.size();
1136 int locIdToFind=ret2[i];
1138 for(int j=0;j<sz && !found;j++)
1140 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1142 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1149 _field_pm_pt_pd.resize(sz+1);
1150 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1158 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) throw(INTERP_KERNEL::Exception)
1160 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1161 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1163 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1164 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1166 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1167 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1168 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1169 if(retTmp->presenceOfValue(-1))
1170 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1171 std::vector<int> ret(retTmp->begin(),retTmp->end());
1175 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerType::getFather() const
1180 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1182 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1183 int curDim=(int)cm.getDimension();
1184 dim=std::max(dim,curDim);
1187 void MEDFileFieldPerMeshPerType::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
1189 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1191 (*it)->fillTypesOfFieldAvailable(types);
1195 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)
1197 int sz=_field_pm_pt_pd.size();
1198 dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1199 for(int i=0;i<sz;i++)
1201 _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1205 int MEDFileFieldPerMeshPerType::getIteration() const
1207 return _father->getIteration();
1210 int MEDFileFieldPerMeshPerType::getOrder() const
1212 return _father->getOrder();
1215 double MEDFileFieldPerMeshPerType::getTime() const
1217 return _father->getTime();
1220 std::string MEDFileFieldPerMeshPerType::getMeshName() const
1222 return _father->getMeshName();
1225 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1227 const char startLine[]=" ## ";
1228 std::string startLine2(bkOffset,' ');
1229 std::string startLine3(startLine2);
1230 startLine3+=startLine;
1231 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1233 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1234 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1237 oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1238 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1240 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1242 const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1244 cur->simpleRepr(bkOffset,oss,i);
1247 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1252 void MEDFileFieldPerMeshPerType::getSizes(int& globalSz, int& nbOfEntries) const
1254 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1256 globalSz+=(*it)->getNumberOfTuples();
1258 nbOfEntries+=(int)_field_pm_pt_pd.size();
1261 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1267 int MEDFileFieldPerMeshPerType::getNumberOfComponents() const
1269 return _father->getNumberOfComponents();
1272 DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray()
1274 return _father->getOrCreateAndGetArray();
1277 const DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray() const
1279 const MEDFileFieldPerMesh *fath=_father;
1280 return fath->getOrCreateAndGetArray();
1283 const std::vector<std::string>& MEDFileFieldPerMeshPerType::getInfo() const
1285 return _father->getInfo();
1288 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsed() const
1290 std::vector<std::string> ret;
1291 std::set<std::string> ret2;
1292 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1294 std::string tmp=(*it1)->getProfile();
1296 if(ret2.find(tmp)==ret2.end())
1305 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsed() const
1307 std::vector<std::string> ret;
1308 std::set<std::string> ret2;
1309 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1311 std::string tmp=(*it1)->getLocalization();
1312 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1313 if(ret2.find(tmp)==ret2.end())
1322 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsedMulti() const
1324 std::vector<std::string> ret;
1325 std::set<std::string> ret2;
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)->getProfile();
1335 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsedMulti() const
1337 std::vector<std::string> ret;
1338 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1340 std::string tmp=(*it1)->getLocalization();
1341 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1347 void MEDFileFieldPerMeshPerType::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1349 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1350 (*it1)->changePflsRefsNamesGen(mapOfModif);
1353 void MEDFileFieldPerMeshPerType::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1355 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1356 (*it1)->changeLocsRefsNamesGen(mapOfModif);
1359 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) throw(INTERP_KERNEL::Exception)
1361 if(_field_pm_pt_pd.empty())
1363 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1364 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1365 throw INTERP_KERNEL::Exception(oss.str().c_str());
1367 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1368 return _field_pm_pt_pd[locId];
1369 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1370 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1371 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1372 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1373 return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1376 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) const throw(INTERP_KERNEL::Exception)
1378 if(_field_pm_pt_pd.empty())
1380 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1381 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1382 throw INTERP_KERNEL::Exception(oss.str().c_str());
1384 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1385 return _field_pm_pt_pd[locId];
1386 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1387 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1388 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1389 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1390 return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1393 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
1395 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1397 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1398 if(meshDim!=(int)cm.getDimension())
1401 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1402 (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1405 void MEDFileFieldPerMeshPerType::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1408 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1410 (*it)->fillValues(i,startEntryId,entries);
1414 void MEDFileFieldPerMeshPerType::setLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves) throw(INTERP_KERNEL::Exception)
1416 _field_pm_pt_pd=leaves;
1417 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1418 (*it)->setFather(this);
1422 * \param [in,out] globalNum a global numbering counter for the renumbering.
1423 * \param [out] its - list of pair (start,stop) kept
1424 * \return bool - false if the type of field \a tof is not contained in \a this.
1426 bool MEDFileFieldPerMeshPerType::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception)
1429 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1430 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1431 if((*it)->getType()==tof)
1433 newPmPtPd.push_back(*it);
1434 std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1435 (*it)->setNewStart(globalNum);
1436 globalNum=(*it)->getEnd();
1437 its.push_back(bgEnd);
1441 _field_pm_pt_pd=newPmPtPd;
1445 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception):_father(fath),_geo_type(geoType)
1449 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)
1451 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1452 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1453 med_geometry_type mgeoti;
1454 med_entity_type menti=ConvertIntoMEDFileType(type,geoType,mgeoti);
1455 int nbProfiles=MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName);
1456 _field_pm_pt_pd.resize(nbProfiles);
1457 for(int i=0;i<nbProfiles;i++)
1459 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i+1);
1463 void MEDFileFieldPerMeshPerType::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1466 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,pflId++)
1468 (*it)->loadOnlyStructureOfDataRecursively(fid,pflId+1,start,nasc);//tony
1472 void MEDFileFieldPerMeshPerType::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1475 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,pflId++)
1477 (*it)->loadBigArray(fid,pflId+1,nasc);//tony
1481 void MEDFileFieldPerMeshPerType::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
1483 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1485 (*it)->copyOptionsFrom(*this);
1486 (*it)->writeLL(fid,nasc);
1490 med_entity_type MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1495 medfGeoType=typmai3[(int)ikGeoType];
1498 medfGeoType=MED_NONE;
1501 medfGeoType=typmai3[(int)ikGeoType];
1502 return MED_NODE_ELEMENT;
1504 medfGeoType=typmai3[(int)ikGeoType];
1507 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1509 return MED_UNDEF_ENTITY_TYPE;
1512 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1514 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc);
1517 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1519 return new MEDFileFieldPerMesh(fath,mesh);
1522 std::size_t MEDFileFieldPerMesh::getHeapMemorySize() const
1524 std::size_t ret=_mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType >);
1525 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1526 if((const MEDFileFieldPerMeshPerType *)*it)
1527 ret+=(*it)->getHeapMemorySize();
1531 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCpy(MEDFileAnyTypeField1TSWithoutSDA *father) const throw(INTERP_KERNEL::Exception)
1533 MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1534 ret->_father=father;
1536 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1538 if((const MEDFileFieldPerMeshPerType *)*it)
1539 ret->_field_pm_pt[i]=(*it)->deepCpy((MEDFileFieldPerMesh *)(ret));
1544 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1546 std::string startLine(bkOffset,' ');
1547 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1548 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1550 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1552 const MEDFileFieldPerMeshPerType *cur=*it;
1554 cur->simpleRepr(bkOffset,oss,i);
1557 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1562 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
1564 _mesh_name=mesh->getName();
1565 mesh->getTime(_mesh_iteration,_mesh_order);
1568 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)
1570 int nbOfTypes=code.size()/3;
1572 for(int i=0;i<nbOfTypes;i++)
1574 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1575 int nbOfCells=code[3*i+1];
1576 int pos=addNewEntryIfNecessary(type);
1577 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1583 * This method is the most general one. No optimization is done here.
1584 * \param [in] multiTypePfl is the end user profile specified in high level API
1585 * \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].
1586 * \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.
1587 * \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.
1588 * \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.
1589 * \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.
1591 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)
1593 int nbOfTypes=code.size()/3;
1594 for(int i=0;i<nbOfTypes;i++)
1596 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1597 int pos=addNewEntryIfNecessary(type);
1598 DataArrayInt *pfl=0;
1600 pfl=idsPerType[code[3*i+2]];
1601 int nbOfTupes2=code2.size()/3;
1603 for(;found<nbOfTupes2;found++)
1604 if(code[3*i]==code2[3*found])
1606 if(found==nbOfTupes2)
1607 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1608 _field_pm_pt[pos]->assignFieldProfile(start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1612 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1614 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1615 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1618 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1620 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1621 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1624 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1626 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1627 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1630 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1632 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1633 (*it)->loadBigArraysRecursively(fid,nasc);
1636 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
1638 int nbOfTypes=_field_pm_pt.size();
1639 for(int i=0;i<nbOfTypes;i++)
1641 _field_pm_pt[i]->copyOptionsFrom(*this);
1642 _field_pm_pt[i]->writeLL(fid,nasc);
1646 void MEDFileFieldPerMesh::getDimension(int& dim) const
1648 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1649 (*it)->getDimension(dim);
1652 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
1654 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1655 (*it)->fillTypesOfFieldAvailable(types);
1658 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)
1660 int sz=_field_pm_pt.size();
1661 std::vector< std::vector<std::pair<int,int> > > ret(sz);
1662 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1663 for(int i=0;i<sz;i++)
1665 types[i]=_field_pm_pt[i]->getGeoType();
1666 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1671 double MEDFileFieldPerMesh::getTime() const
1674 return _father->getTime(tmp1,tmp2);
1677 int MEDFileFieldPerMesh::getIteration() const
1679 return _father->getIteration();
1682 int MEDFileFieldPerMesh::getOrder() const
1684 return _father->getOrder();
1687 int MEDFileFieldPerMesh::getNumberOfComponents() const
1689 return _father->getNumberOfComponents();
1692 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
1695 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1696 return _father->getOrCreateAndGetArray();
1699 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
1702 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1703 return _father->getOrCreateAndGetArray();
1706 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1708 return _father->getInfo();
1712 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
1713 * 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.
1714 * It returns 2 output vectors :
1715 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
1716 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
1717 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
1719 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)
1721 int notNullPflsSz=0;
1722 int nbOfArrs=geoTypes.size();
1723 for(int i=0;i<nbOfArrs;i++)
1726 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
1727 int nbOfDiffGeoTypes=geoTypes3.size();
1728 code.resize(3*nbOfDiffGeoTypes);
1729 notNullPfls.resize(notNullPflsSz);
1732 for(int i=0;i<nbOfDiffGeoTypes;i++)
1735 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
1736 std::vector<const DataArrayInt *> notNullTmp;
1738 notNullTmp.push_back(pfls[j]);
1740 for(;j<nbOfArrs;j++)
1741 if(geoTypes[j]==refType)
1744 notNullTmp.push_back(pfls[j]);
1748 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
1749 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
1750 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
1751 code[3*i]=(int)refType;
1752 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
1753 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
1754 if(notNullTmp.empty())
1758 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
1759 code[3*i+2]=notNullPflsSz++;
1765 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
1767 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)
1771 for(int i=0;i<sz;i++)
1775 if(type!=ON_GAUSS_NE)
1776 ret+=dads[i].second-dads[i].first;
1779 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
1780 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
1785 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
1786 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
1792 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
1794 std::vector<std::string> ret;
1795 std::set<std::string> ret2;
1796 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1798 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
1799 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1800 if(ret2.find(*it2)==ret2.end())
1802 ret.push_back(*it2);
1809 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
1811 std::vector<std::string> ret;
1812 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1814 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
1815 ret.insert(ret.end(),tmp.begin(),tmp.end());
1820 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
1822 std::vector<std::string> ret;
1823 std::set<std::string> ret2;
1824 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1826 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
1827 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1828 if(ret2.find(*it2)==ret2.end())
1830 ret.push_back(*it2);
1837 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
1839 std::vector<std::string> ret;
1840 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1842 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
1843 ret.insert(ret.end(),tmp.begin(),tmp.end());
1848 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
1850 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
1852 if((*it).first==_mesh_name)
1854 _mesh_name=(*it).second;
1861 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
1862 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1864 if(_mesh_name!=meshName)
1866 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
1867 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
1868 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
1869 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
1870 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
1871 getUndergroundDataArrayExt(entries);
1872 DataArray *arr0=getOrCreateAndGetArray();//tony
1874 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
1875 DataArrayDouble *arr=dynamic_cast<DataArrayDouble *>(arr0);//tony
1877 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
1880 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
1881 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
1883 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
1885 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1886 sz+=(*it).second.second-(*it).second.first;
1889 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1891 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
1892 ////////////////////
1893 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
1894 int *workI2=explicitIdsOldInMesh->getPointer();
1895 int sz1=0,sz2=0,sid=1;
1896 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
1897 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
1898 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
1900 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
1901 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
1902 int *workI=explicitIdsOldInArr->getPointer();
1903 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
1905 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
1906 (*itL2)->setLocId(sz2);
1907 (*itL2)->_tmp_work1=(*itL2)->getStart();
1908 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
1910 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
1912 explicitIdsOldInMesh->reAlloc(sz2);
1913 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
1914 ////////////////////
1915 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
1916 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
1917 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
1918 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
1920 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
1921 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
1922 otherEntriesNew.back()->setLocId((*it)->getGeoType());
1924 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
1925 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
1926 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
1928 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1929 int newStart=elt->getLocId();
1930 elt->setLocId((*it)->getGeoType());
1931 elt->setNewStart(newStart);
1932 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
1933 entriesKeptNew.push_back(elt);
1934 entriesKeptNew2.push_back(elt);
1936 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
1937 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
1938 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
1939 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
1941 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
1944 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
1946 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
1947 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
1949 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
1950 glob,arr2,otherEntriesNew) || ret;
1954 // Assign new dispatching
1955 assignNewLeaves(otherEntriesNew);
1956 arr->cpyFrom(*arr2);
1961 * \param [in,out] globalNum a global numbering counter for the renumbering.
1962 * \param [out] its - list of pair (start,stop) kept
1964 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception)
1966 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > ret;
1967 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1969 std::vector< std::pair<int,int> > its2;
1970 if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
1973 its.insert(its.end(),its2.begin(),its2.end());
1979 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves) throw(INTERP_KERNEL::Exception)
1981 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > > types;
1982 for( std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
1983 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
1985 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > fieldPmPt(types.size());
1986 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
1987 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=fieldPmPt.begin();
1988 for(;it1!=types.end();it1++,it2++)
1990 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
1991 elt->setLeaves((*it1).second);
1994 _field_pm_pt=fieldPmPt;
1997 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1999 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2000 (*it)->changePflsRefsNamesGen(mapOfModif);
2003 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2005 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2006 (*it)->changeLocsRefsNamesGen(mapOfModif);
2010 * \param [in] mesh is the whole mesh
2012 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2014 if(_field_pm_pt.empty())
2015 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2017 std::vector< std::pair<int,int> > dads;
2018 std::vector<const DataArrayInt *> pfls;
2019 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2020 std::vector<int> locs,code;
2021 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2022 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2023 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2025 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2028 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2029 throw INTERP_KERNEL::Exception(oss.str().c_str());
2032 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2033 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2036 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2038 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2041 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr);
2042 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2048 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2052 if(nb!=mesh->getNumberOfNodes())
2054 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2055 oss << " nodes in mesh !";
2056 throw INTERP_KERNEL::Exception(oss.str().c_str());
2058 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2061 return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2065 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2067 if(_field_pm_pt.empty())
2068 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2070 std::vector<std::pair<int,int> > dads;
2071 std::vector<const DataArrayInt *> pfls;
2072 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2073 std::vector<int> locs,code;
2074 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2075 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2076 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2078 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2081 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2082 throw INTERP_KERNEL::Exception(oss.str().c_str());
2084 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2085 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2088 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2089 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2094 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2098 if(nb!=mesh->getNumberOfNodes())
2100 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2101 oss << " nodes in mesh !";
2102 throw INTERP_KERNEL::Exception(oss.str().c_str());
2105 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2111 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
2115 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2117 (*it)->getSizes(globalSz,nbOfEntries);
2119 entries.resize(nbOfEntries);
2121 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2123 (*it)->fillValues(nbOfEntries,entries);
2127 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
2129 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2131 if((*it)->getGeoType()==typ)
2132 return (*it)->getLeafGivenLocId(locId);
2134 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2135 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2136 oss << "Possiblities are : ";
2137 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2139 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2140 oss << "\"" << cm2.getRepr() << "\", ";
2142 throw INTERP_KERNEL::Exception(oss.str().c_str());
2145 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
2147 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2149 if((*it)->getGeoType()==typ)
2150 return (*it)->getLeafGivenLocId(locId);
2152 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2153 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2154 oss << "Possiblities are : ";
2155 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2157 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2158 oss << "\"" << cm2.getRepr() << "\", ";
2160 throw INTERP_KERNEL::Exception(oss.str().c_str());
2163 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2166 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2167 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=_field_pm_pt.begin();
2168 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2170 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2175 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2180 int ret=std::distance(_field_pm_pt.begin(),it2);
2181 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2186 * 'dads' and 'locs' input parameters have the same number of elements
2187 * \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
2189 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2190 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2191 const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2194 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2195 ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2196 MEDCouplingAutoRefCountObjectPtr<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2197 const std::vector<std::string>& infos=getInfo();
2198 da->setInfoOnComponents(infos);
2200 if(type==ON_GAUSS_PT)
2203 int nbOfArrs=dads.size();
2204 for(int i=0;i<nbOfArrs;i++)
2206 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2207 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2208 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2209 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> di=DataArrayInt::New();
2210 di->alloc(nbOfElems,1);
2212 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2213 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2222 * 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.
2223 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2224 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2225 * The order of cells in the returned field is those imposed by the profile.
2226 * \param [in] mesh is the global mesh.
2228 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2229 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2230 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2231 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2233 if(da->isIdentity())
2235 int nbOfTuples=da->getNumberOfTuples();
2236 if(nbOfTuples==mesh->getNumberOfCells())
2237 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2239 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2240 m2->setName(mesh->getName());
2241 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2247 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2249 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2250 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2251 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2253 if(da->isIdentity())
2255 int nbOfTuples=da->getNumberOfTuples();
2256 if(nbOfTuples==mesh->getNumberOfNodes())//No problem for NORM_ERROR because it is in context of node
2257 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2259 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2260 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2263 if(meshu->getNodalConnectivity()==0)
2265 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2266 int nb=da->getNbOfElems();
2267 const int *ptr=da->getConstPointer();
2268 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2269 meshuc->allocateCells(nb);
2270 for(int i=0;i<nb;i++)
2271 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2272 meshuc->finishInsertingCells();
2273 ret->setMesh(meshuc);
2274 const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2275 if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2276 disc->checkCoherencyBetween(meshuc,arrOut);
2281 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2283 DataArrayInt *arr2=0;
2284 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2285 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2286 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3(arr2);
2287 int nnodes=mesh2->getNumberOfNodes();
2288 if(nnodes==(int)da->getNbOfElems())
2290 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2291 arrOut->renumberInPlace(da3->getConstPointer());
2292 mesh2->setName(mesh->getName());
2293 ret->setMesh(mesh2);
2298 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 !!!";
2299 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2300 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2301 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2302 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2303 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2304 throw INTERP_KERNEL::Exception(oss.str().c_str());
2310 * This method is the most light method of field retrieving.
2312 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const throw(INTERP_KERNEL::Exception)
2316 pflOut=DataArrayInt::New();
2317 pflOut->alloc(nbOfElems,1);
2322 pflOut=const_cast<DataArrayInt*>(pflIn);
2325 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> safePfl(pflOut);
2326 MEDCouplingAutoRefCountObjectPtr<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2327 const std::vector<std::string>& infos=getInfo();
2328 int nbOfComp=infos.size();
2329 for(int i=0;i<nbOfComp;i++)
2330 da->setInfoOnComponent(i,infos[i].c_str());
2335 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),
2336 _mesh_csit(meshCsit),_father(fath)
2338 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2339 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2340 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2341 for(int i=0;i<MED_N_CELL_FIXED_GEO;i++)
2343 int nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL,typmai[i],_mesh_csit,meshName,pflName,locName);
2346 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[i],nasc));
2347 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2349 nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[i],_mesh_csit,meshName,pflName,locName);
2352 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_GAUSS_NE,typmai2[i],nasc));
2353 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2356 int nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,_mesh_csit,meshName,pflName,locName);
2359 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc));
2360 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2364 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2366 copyTinyInfoFrom(mesh);
2369 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception)
2371 if(id>=(int)_pfls.size())
2373 _pfls[id]=DataArrayInt::New();
2374 int lgth=MEDprofileSizeByName(fid,pflName);
2375 _pfls[id]->setName(pflName);
2376 _pfls[id]->alloc(lgth,1);
2377 MEDprofileRd(fid,pflName,_pfls[id]->getPointer());
2378 _pfls[id]->applyLin(1,-1,0);//Converting into C format
2381 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2383 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2385 MEDprofileInfo(fid,i+1,pflName,&sz);
2386 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2387 if(i>=(int)_pfls.size())
2389 _pfls[i]=DataArrayInt::New();
2390 _pfls[i]->alloc(sz,1);
2391 _pfls[i]->setName(pflCpp.c_str());
2392 MEDprofileRd(fid,pflName,_pfls[i]->getPointer());
2393 _pfls[i]->applyLin(1,-1,0);//Converting into C format
2396 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception)
2398 int nbOfPfls=_pfls.size();
2399 for(int i=0;i<nbOfPfls;i++)
2401 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cpy=_pfls[i]->deepCpy();
2402 cpy->applyLin(1,1,0);
2403 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2404 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2405 MEDprofileWr(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer());
2408 int nbOfLocs=_locs.size();
2409 for(int i=0;i<nbOfLocs;i++)
2410 _locs[i]->writeLL(fid);
2413 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps) throw(INTERP_KERNEL::Exception)
2415 std::vector<std::string> pfls=getPfls();
2416 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2418 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2421 _pfls.push_back(*it);
2425 int id=std::distance(pfls.begin(),it2);
2426 if(!(*it)->isEqual(*_pfls[id]))
2428 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2429 throw INTERP_KERNEL::Exception(oss.str().c_str());
2433 std::vector<std::string> locs=getLocs();
2434 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
2436 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2439 _locs.push_back(*it);
2443 int id=std::distance(locs.begin(),it2);
2444 if(!(*it)->isEqual(*_locs[id],eps))
2446 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2447 throw INTERP_KERNEL::Exception(oss.str().c_str());
2453 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const throw(INTERP_KERNEL::Exception)
2455 for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
2456 getProfile((*it).c_str());
2459 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const throw(INTERP_KERNEL::Exception)
2461 for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
2462 getLocalization((*it).c_str());
2465 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real) throw(INTERP_KERNEL::Exception)
2467 std::vector<std::string> profiles=real.getPflsReallyUsed();
2468 int sz=profiles.size();
2470 for(int i=0;i<sz;i++)
2471 loadProfileInFile(fid,i,profiles[i].c_str());
2473 std::vector<std::string> locs=real.getLocsReallyUsed();
2476 for(int i=0;i<sz;i++)
2477 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2480 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
2482 int nProfil=MEDnProfile(fid);
2483 for(int i=0;i<nProfil;i++)
2484 loadProfileInFile(fid,i);
2485 int sz=MEDnLocalization(fid);
2487 for(int i=0;i<sz;i++)
2489 _locs[i]=MEDFileFieldLoc::New(fid,i);
2493 MEDFileFieldGlobs *MEDFileFieldGlobs::New(const char *fname)
2495 return new MEDFileFieldGlobs(fname);
2498 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2500 return new MEDFileFieldGlobs;
2503 std::size_t MEDFileFieldGlobs::getHeapMemorySize() const
2505 std::size_t ret=_file_name.capacity()+_pfls.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<DataArrayInt>)+_locs.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>);
2506 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2507 ret+=(*it)->getHeapMemorySize();
2508 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2509 ret+=(*it)->getHeapMemorySize();
2513 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpy() const throw(INTERP_KERNEL::Exception)
2515 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
2517 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2519 if((const DataArrayInt *)*it)
2520 ret->_pfls[i]=(*it)->deepCpy();
2523 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2525 if((const MEDFileFieldLoc*)*it)
2526 ret->_locs[i]=(*it)->deepCpy();
2532 * \throw if a profile in \a pfls in not in \a this.
2533 * \throw if a localization in \a locs in not in \a this.
2534 * \sa MEDFileFieldGlobs::deepCpyPart
2536 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const throw(INTERP_KERNEL::Exception)
2538 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2539 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2541 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2543 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
2545 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2(pfl);
2546 ret->_pfls.push_back(pfl2);
2548 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2550 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2552 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
2554 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> loc2(loc);
2555 ret->_locs.push_back(loc2);
2557 ret->setFileName(getFileName());
2562 * \throw if a profile in \a pfls in not in \a this.
2563 * \throw if a localization in \a locs in not in \a this.
2564 * \sa MEDFileFieldGlobs::shallowCpyPart
2566 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const throw(INTERP_KERNEL::Exception)
2568 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2569 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2571 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2573 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
2574 ret->_pfls.push_back(pfl->deepCpy());
2576 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2578 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2580 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
2581 ret->_locs.push_back(loc->deepCpy());
2583 ret->setFileName(getFileName());
2587 MEDFileFieldGlobs::MEDFileFieldGlobs(const char *fname):_file_name(fname)
2591 MEDFileFieldGlobs::MEDFileFieldGlobs()
2595 MEDFileFieldGlobs::~MEDFileFieldGlobs()
2599 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
2601 oss << "Profiles :\n";
2602 std::size_t n=_pfls.size();
2603 for(std::size_t i=0;i<n;i++)
2605 oss << " - #" << i << " ";
2606 const DataArrayInt *pfl=_pfls[i];
2608 oss << "\"" << pfl->getName() << "\"\n";
2613 oss << "Localizations :\n";
2614 for(std::size_t i=0;i<n;i++)
2616 oss << " - #" << i << " ";
2617 const MEDFileFieldLoc *loc=_locs[i];
2619 loc->simpleRepr(oss);
2625 void MEDFileFieldGlobs::setFileName(const char *fileName)
2627 _file_name=fileName;
2630 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2632 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
2634 DataArrayInt *elt(*it);
2637 std::string name(elt->getName());
2638 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2640 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2642 elt->setName((*it2).second.c_str());
2650 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2652 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
2654 MEDFileFieldLoc *elt(*it);
2657 std::string name(elt->getName());
2658 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2660 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2662 elt->setName((*it2).second.c_str());
2670 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception)
2672 if(locId<0 || locId>=(int)_locs.size())
2673 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
2674 return _locs[locId]->getNbOfGaussPtPerCell();
2677 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception)
2679 return getLocalizationFromId(getLocalizationId(locName));
2682 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception)
2684 if(locId<0 || locId>=(int)_locs.size())
2685 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2686 return *_locs[locId];
2689 namespace ParaMEDMEMImpl
2694 LocFinder(const char *loc):_loc(loc) { }
2695 bool operator() (const MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
2703 PflFinder(const std::string& pfl):_pfl(pfl) { }
2704 bool operator() (const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
2706 const std::string& _pfl;
2710 int MEDFileFieldGlobs::getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception)
2712 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),ParaMEDMEMImpl::LocFinder(loc));
2715 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
2716 for(it=_locs.begin();it!=_locs.end();it++)
2717 oss << "\"" << (*it)->getName() << "\", ";
2718 throw INTERP_KERNEL::Exception(oss.str().c_str());
2720 return std::distance(_locs.begin(),it);
2724 * The returned value is never null.
2726 const DataArrayInt *MEDFileFieldGlobs::getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception)
2728 std::string pflNameCpp(pflName);
2729 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2732 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2733 for(it=_pfls.begin();it!=_pfls.end();it++)
2734 oss << "\"" << (*it)->getName() << "\", ";
2735 throw INTERP_KERNEL::Exception(oss.str().c_str());
2740 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception)
2742 if(pflId<0 || pflId>=(int)_pfls.size())
2743 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2744 return _pfls[pflId];
2747 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception)
2749 if(locId<0 || locId>=(int)_locs.size())
2750 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2751 return *_locs[locId];
2754 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const char *locName) throw(INTERP_KERNEL::Exception)
2756 return getLocalizationFromId(getLocalizationId(locName));
2760 * The returned value is never null.
2762 DataArrayInt *MEDFileFieldGlobs::getProfile(const char *pflName) throw(INTERP_KERNEL::Exception)
2764 std::string pflNameCpp(pflName);
2765 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2768 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2769 for(it=_pfls.begin();it!=_pfls.end();it++)
2770 oss << "\"" << (*it)->getName() << "\", ";
2771 throw INTERP_KERNEL::Exception(oss.str().c_str());
2776 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception)
2778 if(pflId<0 || pflId>=(int)_pfls.size())
2779 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2780 return _pfls[pflId];
2783 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds) throw(INTERP_KERNEL::Exception)
2785 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newPfls;
2787 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2789 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
2790 newPfls.push_back(*it);
2795 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds) throw(INTERP_KERNEL::Exception)
2797 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> > newLocs;
2799 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2801 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
2802 newLocs.push_back(*it);
2807 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
2809 int sz=_pfls.size();
2810 std::vector<std::string> ret(sz);
2811 for(int i=0;i<sz;i++)
2812 ret[i]=_pfls[i]->getName();
2816 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
2818 int sz=_locs.size();
2819 std::vector<std::string> ret(sz);
2820 for(int i=0;i<sz;i++)
2821 ret[i]=_locs[i]->getName();
2825 bool MEDFileFieldGlobs::existsPfl(const char *pflName) const
2827 std::vector<std::string> v=getPfls();
2828 std::string s(pflName);
2829 return std::find(v.begin(),v.end(),s)!=v.end();
2832 bool MEDFileFieldGlobs::existsLoc(const char *locName) const
2834 std::vector<std::string> v=getLocs();
2835 std::string s(locName);
2836 return std::find(v.begin(),v.end(),s)!=v.end();
2839 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
2841 std::map<int,std::vector<int> > m;
2843 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2845 const DataArrayInt *tmp=(*it);
2848 m[tmp->getHashCode()].push_back(i);
2851 std::vector< std::vector<int> > ret;
2852 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
2854 if((*it2).second.size()>1)
2856 std::vector<int> ret0;
2857 bool equalityOrNot=false;
2858 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
2860 std::vector<int>::const_iterator it4=it3; it4++;
2861 for(;it4!=(*it2).second.end();it4++)
2863 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
2866 ret0.push_back(*it3);
2867 ret0.push_back(*it4);
2873 ret.push_back(ret0);
2879 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
2881 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
2884 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception)
2886 std::string name(pfl->getName());
2888 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
2889 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2890 if(name==(*it)->getName())
2892 if(!pfl->isEqual(*(*it)))
2894 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
2895 throw INTERP_KERNEL::Exception(oss.str().c_str());
2899 _pfls.push_back(pfl);
2902 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)
2904 std::string name(locName);
2906 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
2907 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
2908 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2909 if((*it)->isName(locName))
2911 if(!(*it)->isEqual(*obj,1e-12))
2913 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
2914 throw INTERP_KERNEL::Exception(oss.str().c_str());
2917 _locs.push_back(obj);
2920 std::string MEDFileFieldGlobs::createNewNameOfPfl() const throw(INTERP_KERNEL::Exception)
2922 std::vector<std::string> names=getPfls();
2923 return CreateNewNameNotIn("NewPfl_",names);
2926 std::string MEDFileFieldGlobs::createNewNameOfLoc() const throw(INTERP_KERNEL::Exception)
2928 std::vector<std::string> names=getLocs();
2929 return CreateNewNameNotIn("NewLoc_",names);
2932 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const char *prefix, const std::vector<std::string>& namesToAvoid) throw(INTERP_KERNEL::Exception)
2934 for(std::size_t sz=0;sz<100000;sz++)
2936 std::ostringstream tryName;
2937 tryName << prefix << sz;
2938 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
2939 return tryName.str();
2941 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
2945 * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
2946 * \param [in] fname - the file name.
2948 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(const char *fname):_globals(MEDFileFieldGlobs::New(fname))
2953 * Creates an empty MEDFileFieldGlobsReal.
2955 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
2959 std::size_t MEDFileFieldGlobsReal::getHeapMemorySize() const
2962 if((const MEDFileFieldGlobs *)_globals)
2963 ret+=_globals->getHeapMemorySize();
2968 * Returns a string describing profiles and Gauss points held in \a this.
2969 * \return std::string - the description string.
2971 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
2973 const MEDFileFieldGlobs *glob=_globals;
2974 std::ostringstream oss2; oss2 << glob;
2975 std::string stars(oss2.str().length(),'*');
2976 oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n";
2978 glob->simpleRepr(oss);
2980 oss << "NO GLOBAL INFORMATION !\n";
2983 void MEDFileFieldGlobsReal::resetContent()
2985 _globals=MEDFileFieldGlobs::New();
2988 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
2993 * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
2994 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
2996 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
2998 _globals=other._globals;
3002 * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3003 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3005 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other) throw(INTERP_KERNEL::Exception)
3007 const MEDFileFieldGlobs *otherg(other._globals);
3010 _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3014 * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3015 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3017 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other) throw(INTERP_KERNEL::Exception)
3019 const MEDFileFieldGlobs *otherg(other._globals);
3022 _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3025 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3027 _globals=other._globals;
3028 if((const MEDFileFieldGlobs *)_globals)
3029 _globals=other._globals->deepCpy();
3033 * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3034 * \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3035 * \param [in] eps - a precision used to compare Gauss points with same name held by
3036 * \a this and \a other MEDFileFieldGlobsReal.
3037 * \throw If \a this and \a other hold profiles with equal names but different ids.
3038 * \throw If \a this and \a other hold different Gauss points with equal names.
3040 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps) throw(INTERP_KERNEL::Exception)
3042 const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3043 if(thisGlobals==otherGlobals)
3047 _globals=other._globals;
3050 _globals->appendGlobs(*other._globals,eps);
3053 void MEDFileFieldGlobsReal::checkGlobsCoherency() const throw(INTERP_KERNEL::Exception)
3055 checkGlobsPflsPartCoherency();
3056 checkGlobsLocsPartCoherency();
3059 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const throw(INTERP_KERNEL::Exception)
3061 contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3064 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const throw(INTERP_KERNEL::Exception)
3066 contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3069 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception)
3071 contentNotNull()->loadProfileInFile(fid,id,pflName);
3074 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3076 contentNotNull()->loadProfileInFile(fid,id);
3079 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
3081 contentNotNull()->loadGlobals(fid,*this);
3084 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
3086 contentNotNull()->loadAllGlobals(fid);
3089 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception)
3091 contentNotNull()->writeGlobals(fid,opt);
3095 * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3096 * or getPflsReallyUsedMulti().
3097 * \return std::vector<std::string> - a sequence of names of all profiles.
3099 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3101 return contentNotNull()->getPfls();
3105 * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3106 * or getLocsReallyUsedMulti().
3107 * \return std::vector<std::string> - a sequence of names of all localizations.
3109 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3111 return contentNotNull()->getLocs();
3115 * Checks if the profile with a given name exists.
3116 * \param [in] pflName - the profile name of interest.
3117 * \return bool - \c true if the profile named \a pflName exists.
3119 bool MEDFileFieldGlobsReal::existsPfl(const char *pflName) const
3121 return contentNotNull()->existsPfl(pflName);
3125 * Checks if the localization with a given name exists.
3126 * \param [in] locName - the localization name of interest.
3127 * \return bool - \c true if the localization named \a locName exists.
3129 bool MEDFileFieldGlobsReal::existsLoc(const char *locName) const
3131 return contentNotNull()->existsLoc(locName);
3134 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const throw(INTERP_KERNEL::Exception)
3136 return contentNotNull()->createNewNameOfPfl();
3139 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const throw(INTERP_KERNEL::Exception)
3141 return contentNotNull()->createNewNameOfLoc();
3145 * Sets the name of a MED file.
3146 * \param [inout] fileName - the file name.
3148 void MEDFileFieldGlobsReal::setFileName(const char *fileName)
3150 contentNotNull()->setFileName(fileName);
3154 * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3155 * in the same order.
3156 * \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3157 * Each item of this sequence is a vector containing ids of equal profiles.
3159 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3161 return contentNotNull()->whichAreEqualProfiles();
3165 * Finds equal localizations.
3166 * \param [in] eps - a precision used to compare real values of the localizations.
3167 * \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3168 * Each item of this sequence is a vector containing ids of equal localizations.
3170 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3172 return contentNotNull()->whichAreEqualLocs(eps);
3176 * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3177 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3178 * this sequence is a pair whose
3179 * - the first item is a vector of profile names to replace by the second item,
3180 * - the second item is a profile name to replace every profile name of the first item.
3182 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3184 contentNotNull()->changePflsNamesInStruct(mapOfModif);
3188 * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3189 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3190 * this sequence is a pair whose
3191 * - the first item is a vector of localization names to replace by the second item,
3192 * - the second item is a localization name to replace every localization name of the first item.
3194 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3196 contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3200 * Replaces references to some profiles (a reference is a profile name) by references
3201 * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3202 * them-selves accordingly. <br>
3203 * This method is a generalization of changePflName().
3204 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3205 * this sequence is a pair whose
3206 * - the first item is a vector of profile names to replace by the second item,
3207 * - the second item is a profile name to replace every profile of the first item.
3208 * \sa changePflsRefsNamesGen()
3209 * \sa changePflName()
3211 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3213 changePflsRefsNamesGen(mapOfModif);
3214 changePflsNamesInStruct(mapOfModif);
3218 * Replaces references to some localizations (a reference is a localization name) by references
3219 * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3220 * them-selves accordingly. <br>
3221 * This method is a generalization of changeLocName().
3222 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3223 * this sequence is a pair whose
3224 * - the first item is a vector of localization names to replace by the second item,
3225 * - the second item is a localization name to replace every localization of the first item.
3226 * \sa changeLocsRefsNamesGen()
3227 * \sa changeLocName()
3229 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3231 changeLocsRefsNamesGen(mapOfModif);
3232 changeLocsNamesInStruct(mapOfModif);
3236 * Renames the profile having a given name and updates references to this profile.
3237 * \param [in] oldName - the name of the profile to rename.
3238 * \param [in] newName - a new name of the profile.
3239 * \sa changePflsNames().
3241 void MEDFileFieldGlobsReal::changePflName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
3243 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3244 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3246 changePflsNames(mapOfModif);
3250 * Renames the localization having a given name and updates references to this localization.
3251 * \param [in] oldName - the name of the localization to rename.
3252 * \param [in] newName - a new name of the localization.
3253 * \sa changeLocsNames().
3255 void MEDFileFieldGlobsReal::changeLocName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
3257 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3258 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3260 changeLocsNames(mapOfModif);
3264 * Removes duplicated profiles. Returns a map used to update references to removed
3265 * profiles via changePflsRefsNamesGen().
3266 * Equal profiles are found using whichAreEqualProfiles().
3267 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3268 * a sequence describing the performed replacements of profiles. Each element of
3269 * this sequence is a pair whose
3270 * - the first item is a vector of profile names replaced by the second item,
3271 * - the second item is a profile name replacing every profile of the first item.
3273 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames() throw(INTERP_KERNEL::Exception)
3275 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3276 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3278 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3280 std::vector< std::string > tmp((*it).size());
3282 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3283 tmp[j]=std::string(getProfileFromId(*it2)->getName());
3284 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3286 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3287 killProfileIds(tmp2);
3289 changePflsRefsNamesGen(ret);
3294 * Removes duplicated localizations. Returns a map used to update references to removed
3295 * localizations via changeLocsRefsNamesGen().
3296 * Equal localizations are found using whichAreEqualLocs().
3297 * \param [in] eps - a precision used to compare real values of the localizations.
3298 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3299 * a sequence describing the performed replacements of localizations. Each element of
3300 * this sequence is a pair whose
3301 * - the first item is a vector of localization names replaced by the second item,
3302 * - the second item is a localization name replacing every localization of the first item.
3304 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps) throw(INTERP_KERNEL::Exception)
3306 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3307 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3309 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3311 std::vector< std::string > tmp((*it).size());
3313 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3314 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3315 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3317 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3318 killLocalizationIds(tmp2);
3320 changeLocsRefsNamesGen(ret);
3325 * Returns number of Gauss points per cell in a given localization.
3326 * \param [in] locId - an id of the localization of interest.
3327 * \return int - the number of the Gauss points per cell.
3329 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception)
3331 return contentNotNull()->getNbOfGaussPtPerCell(locId);
3335 * Returns an id of a localization by its name.
3336 * \param [in] loc - the localization name of interest.
3337 * \return int - the id of the localization.
3338 * \throw If there is no a localization named \a loc.
3340 int MEDFileFieldGlobsReal::getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception)
3342 return contentNotNull()->getLocalizationId(loc);
3346 * Returns the name of the MED file.
3347 * \return const char * - the MED file name.
3349 const char *MEDFileFieldGlobsReal::getFileName() const
3351 return contentNotNull()->getFileName();
3354 std::string MEDFileFieldGlobsReal::getFileName2() const
3356 return contentNotNull()->getFileName2();
3360 * Returns a localization object by its name.
3361 * \param [in] locName - the name of the localization of interest.
3362 * \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3363 * \throw If there is no a localization named \a locName.
3365 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception)
3367 return contentNotNull()->getLocalization(locName);
3371 * Returns a localization object by its id.
3372 * \param [in] locId - the id of the localization of interest.
3373 * \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3374 * \throw If there is no a localization with id \a locId.
3376 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception)
3378 return contentNotNull()->getLocalizationFromId(locId);
3382 * Returns a profile array by its name.
3383 * \param [in] pflName - the name of the profile of interest.
3384 * \return const DataArrayInt * - the profile array having the name \a pflName.
3385 * \throw If there is no a profile named \a pflName.
3387 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception)
3389 return contentNotNull()->getProfile(pflName);
3393 * Returns a profile array by its id.
3394 * \param [in] pflId - the id of the profile of interest.
3395 * \return const DataArrayInt * - the profile array having the id \a pflId.
3396 * \throw If there is no a profile with id \a pflId.
3398 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception)
3400 return contentNotNull()->getProfileFromId(pflId);
3404 * Returns a localization object, apt for modification, by its id.
3405 * \param [in] locId - the id of the localization of interest.
3406 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3407 * having the id \a locId.
3408 * \throw If there is no a localization with id \a locId.
3410 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception)
3412 return contentNotNull()->getLocalizationFromId(locId);
3416 * Returns a localization object, apt for modification, by its name.
3417 * \param [in] locName - the name of the localization of interest.
3418 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3419 * having the name \a locName.
3420 * \throw If there is no a localization named \a locName.
3422 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const char *locName) throw(INTERP_KERNEL::Exception)
3424 return contentNotNull()->getLocalization(locName);
3428 * Returns a profile array, apt for modification, by its name.
3429 * \param [in] pflName - the name of the profile of interest.
3430 * \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3431 * \throw If there is no a profile named \a pflName.
3433 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const char *pflName) throw(INTERP_KERNEL::Exception)
3435 return contentNotNull()->getProfile(pflName);
3439 * Returns a profile array, apt for modification, by its id.
3440 * \param [in] pflId - the id of the profile of interest.
3441 * \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3442 * \throw If there is no a profile with id \a pflId.
3444 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception)
3446 return contentNotNull()->getProfileFromId(pflId);
3450 * Removes profiles given by their ids. No data is updated to track this removal.
3451 * \param [in] pflIds - a sequence of ids of the profiles to remove.
3453 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds) throw(INTERP_KERNEL::Exception)
3455 contentNotNull()->killProfileIds(pflIds);
3459 * Removes localizations given by their ids. No data is updated to track this removal.
3460 * \param [in] locIds - a sequence of ids of the localizations to remove.
3462 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds) throw(INTERP_KERNEL::Exception)
3464 contentNotNull()->killLocalizationIds(locIds);
3468 * Stores a profile array.
3469 * \param [in] pfl - the profile array to store.
3470 * \throw If the name of \a pfl is empty.
3471 * \throw If a profile with the same name as that of \a pfl already exists but contains
3474 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception)
3476 contentNotNull()->appendProfile(pfl);
3480 * Adds a new localization of Gauss points.
3481 * \param [in] locName - the name of the new localization.
3482 * \param [in] geoType - a geometrical type of the reference cell.
3483 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
3484 * must be \c nbOfNodesPerCell * \c dimOfType.
3485 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
3486 * must be _wg_.size() * \c dimOfType.
3487 * \param [in] w - the weights of Gauss points.
3488 * \throw If \a locName is empty.
3489 * \throw If a localization with the name \a locName already exists but is
3490 * different form the new one.
3492 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)
3494 contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
3497 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() throw(INTERP_KERNEL::Exception)
3499 MEDFileFieldGlobs *g(_globals);
3501 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
3505 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const throw(INTERP_KERNEL::Exception)
3507 const MEDFileFieldGlobs *g(_globals);
3509 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
3513 //= MEDFileFieldNameScope
3515 MEDFileFieldNameScope::MEDFileFieldNameScope()
3519 MEDFileFieldNameScope::MEDFileFieldNameScope(const char *fieldName):_name(fieldName)
3524 * Returns the name of \a this field.
3525 * \return std::string - a string containing the field name.
3527 std::string MEDFileFieldNameScope::getName() const throw(INTERP_KERNEL::Exception)
3533 * Sets name of \a this field
3534 * \param [in] name - the new field name.
3536 void MEDFileFieldNameScope::setName(const char *fieldName) throw(INTERP_KERNEL::Exception)
3541 std::string MEDFileFieldNameScope::getDtUnit() const throw(INTERP_KERNEL::Exception)
3546 void MEDFileFieldNameScope::setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception)
3551 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
3554 _dt_unit=other._dt_unit;
3557 //= MEDFileAnyTypeField1TSWithoutSDA
3559 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other) throw(INTERP_KERNEL::Exception)
3561 _field_per_mesh.resize(other._field_per_mesh.size());
3563 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
3565 if((const MEDFileFieldPerMesh *)*it)
3566 _field_per_mesh[i]=(*it)->deepCpy(this);
3571 * Prints a string describing \a this field into a stream. This string is outputted
3572 * by \c print Python command.
3573 * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
3574 * \param [in,out] oss - the out stream.
3575 * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
3576 * info id printed, else, not.
3578 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
3580 std::string startOfLine(bkOffset,' ');
3581 oss << startOfLine << "Field ";
3583 oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
3584 oss << "on one time Step ";
3586 oss << "(" << f1tsId << ") ";
3587 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
3588 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
3589 const DataArray *arr=getUndergroundDataArray();
3592 const std::vector<std::string> &comps=arr->getInfoOnComponents();
3595 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
3596 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
3597 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
3599 if(arr->isAllocated())
3601 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
3604 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
3608 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
3610 oss << startOfLine << "----------------------" << std::endl;
3611 if(!_field_per_mesh.empty())
3614 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
3616 const MEDFileFieldPerMesh *cur=(*it2);
3618 cur->simpleRepr(bkOffset,oss,i);
3620 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
3625 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
3627 oss << startOfLine << "----------------------" << std::endl;
3630 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const throw(INTERP_KERNEL::Exception)
3632 const DataArray *arr(getUndergroundDataArray());
3634 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
3635 int nbOfCompo=arr->getNumberOfComponents();
3636 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
3637 for(int i=0;i<nbOfCompo;i++)
3640 std::vector<int> v(1,i);
3641 MEDCouplingAutoRefCountObjectPtr<DataArray> arr2=arr->keepSelectedComponents(v);
3642 ret[i]->setArray(arr2);
3647 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)
3651 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
3656 * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
3657 * empty. Returns -1 if this in on nodes.
3658 * \return int - the dimension of \a this.
3660 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
3663 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3664 (*it)->getDimension(ret);
3669 * Returns the mesh name.
3670 * \return std::string - a string holding the mesh name.
3671 * \throw If \c _field_per_mesh.empty()
3673 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const throw(INTERP_KERNEL::Exception)
3675 if(_field_per_mesh.empty())
3676 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
3677 return _field_per_mesh[0]->getMeshName();
3680 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
3682 std::string oldName(getMeshName());
3683 std::vector< std::pair<std::string,std::string> > v(1);
3684 v[0].first=oldName; v[0].second=newMeshName;
3688 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
3691 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3693 MEDFileFieldPerMesh *cur(*it);
3695 ret=cur->changeMeshNames(modifTab) || ret;
3701 * Returns the number of iteration of the state of underlying mesh.
3702 * \return int - the iteration number.
3703 * \throw If \c _field_per_mesh.empty()
3705 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const throw(INTERP_KERNEL::Exception)
3707 if(_field_per_mesh.empty())
3708 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
3709 return _field_per_mesh[0]->getMeshIteration();
3713 * Returns the order number of iteration of the state of underlying mesh.
3714 * \return int - the order number.
3715 * \throw If \c _field_per_mesh.empty()
3717 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const throw(INTERP_KERNEL::Exception)
3719 if(_field_per_mesh.empty())
3720 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
3721 return _field_per_mesh[0]->getMeshOrder();
3725 * Checks if \a this field is tagged by a given iteration number and a given
3726 * iteration order number.
3727 * \param [in] iteration - the iteration number of interest.
3728 * \param [in] order - the iteration order number of interest.
3729 * \return bool - \c true if \a this->getIteration() == \a iteration &&
3730 * \a this->getOrder() == \a order.
3732 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
3734 return iteration==_iteration && order==_order;
3738 * Returns number of iteration and order number of iteration when
3739 * \a this field has been calculated.
3740 * \return std::pair<int,int> - a pair of the iteration number and the iteration
3743 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
3745 std::pair<int,int> p;
3751 * Returns number of iteration and order number of iteration when
3752 * \a this field has been calculated.
3753 * \param [in,out] p - a pair returning the iteration number and the iteration
3756 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
3763 * Returns all types of spatial discretization of \a this field.
3764 * \param [in,out] types - a sequence of types of \a this field.
3766 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
3768 std::set<TypeOfField> types2;
3769 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3771 (*it)->fillTypesOfFieldAvailable(types2);
3773 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
3774 std::copy(types2.begin(),types2.end(),bi);
3778 * Returns all types of spatial discretization of \a this field.
3779 * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
3782 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
3784 std::vector<TypeOfField> ret;
3785 fillTypesOfFieldAvailable(ret);
3789 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
3791 std::vector<std::string> ret;
3792 std::set<std::string> ret2;
3793 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3795 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
3796 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3797 if(ret2.find(*it2)==ret2.end())
3799 ret.push_back(*it2);
3806 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
3808 std::vector<std::string> ret;
3809 std::set<std::string> ret2;
3810 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3812 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
3813 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3814 if(ret2.find(*it2)==ret2.end())
3816 ret.push_back(*it2);
3823 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
3825 std::vector<std::string> ret;
3826 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3828 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
3829 ret.insert(ret.end(),tmp.begin(),tmp.end());
3834 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
3836 std::vector<std::string> ret;
3837 std::set<std::string> ret2;
3838 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3840 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
3841 ret.insert(ret.end(),tmp.begin(),tmp.end());
3846 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3848 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3849 (*it)->changePflsRefsNamesGen(mapOfModif);
3852 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3854 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3855 (*it)->changeLocsRefsNamesGen(mapOfModif);
3859 * Returns all attributes of parts of \a this field lying on a given mesh.
3860 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
3861 * item of every of returned sequences refers to the _i_-th part of \a this field.
3862 * Thus all sequences returned by this method are of the same length equal to number
3863 * of different types of supporting entities.<br>
3864 * A field part can include sub-parts with several different spatial discretizations,
3865 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
3866 * for example. Hence, some of the returned sequences contains nested sequences, and an item
3867 * of a nested sequence corresponds to a type of spatial discretization.<br>
3868 * This method allows for iteration over MEDFile DataStructure without any overhead.
3869 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
3870 * for the case with only one underlying mesh. (Actually, the number of meshes is
3871 * not checked if \a mname == \c NULL).
3872 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
3873 * a field part is returned.
3874 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
3875 * This sequence is of the same length as \a types.
3876 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
3877 * discretization. A profile name can be empty.
3878 * Length of this and of nested sequences is the same as that of \a typesF.
3879 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
3880 * discretization. A localization name can be empty.
3881 * Length of this and of nested sequences is the same as that of \a typesF.
3882 * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
3883 * of ids of tuples within the data array, per each type of spatial
3884 * discretization within one mesh entity type.
3885 * Length of this and of nested sequences is the same as that of \a typesF.
3886 * \throw If no field is lying on \a mname.
3888 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)
3892 meshId=getMeshIdFromMeshName(mname);
3894 if(_field_per_mesh.empty())
3895 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
3896 return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3900 * Returns dimensions of mesh elements \a this field lies on. The returned value is a
3901 * maximal absolute dimension and values returned via the out parameter \a levs are
3902 * dimensions relative to the maximal absolute dimension. <br>
3903 * This method is designed for MEDFileField1TS instances that have a discretization
3904 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS",
3905 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT",
3906 * \ref ParaMEDMEM::ON_GAUSS_NE "ON_GAUSS_NE".
3907 * Only these 3 discretizations will be taken into account here. If \a this is
3908 * \ref ParaMEDMEM::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
3909 * This method is useful to make the link between the dimension of the underlying mesh
3910 * and the levels of \a this, because it is possible that the highest dimension of \a this
3911 * field is not equal to the dimension of the underlying mesh.
3913 * Let's consider the following case:
3914 * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
3915 * TETRA4, HEXA8, TRI3 and SEG2.
3916 * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
3917 * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
3919 * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
3920 * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
3921 * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
3922 * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
3923 * parameter of getFieldAtLevel() is computed basing on the returned values as this:
3924 * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
3926 * to retrieve the highest level of
3927 * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br>
3928 * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
3929 * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
3930 * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
3931 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
3932 * for the case with only one underlying mesh. (Actually, the number of meshes is
3933 * not checked if \a mname == \c NULL).
3934 * \param [in,out] levs - a sequence returning the dimensions relative to the maximal
3935 * absolute one. They are in decreasing order. This sequence is cleared before
3937 * \return int - the maximal absolute dimension of elements \a this fields lies on.
3938 * \throw If no field is lying on \a mname.
3940 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
3943 int meshId=getMeshIdFromMeshName(mname);
3944 std::vector<INTERP_KERNEL::NormalizedCellType> types;
3945 std::vector< std::vector<TypeOfField> > typesF;
3946 std::vector< std::vector<std::string> > pfls, locs;
3947 _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3949 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
3950 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
3951 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
3953 st.erase(INTERP_KERNEL::NORM_ERROR);
3955 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
3957 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
3958 ret1.insert((int)cm.getDimension());
3960 int ret=*std::max_element(ret1.begin(),ret1.end());
3961 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
3962 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
3967 * \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.
3968 * \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.
3969 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
3970 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
3972 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
3974 int mid=getMeshIdFromMeshName(mName);
3975 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
3979 * \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.
3980 * \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.
3981 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
3982 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
3984 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
3986 int mid=getMeshIdFromMeshName(mName);
3987 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
3991 * \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.
3993 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const char *mName) const throw(INTERP_KERNEL::Exception)
3995 if(_field_per_mesh.empty())
3996 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
3999 std::string mName2(mName);
4001 std::vector<std::string> msg;
4002 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4003 if(mName2==(*it)->getMeshName())
4006 msg.push_back((*it)->getMeshName());
4007 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4008 oss << "Possible meshes are : ";
4009 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4010 oss << "\"" << (*it2) << "\" ";
4011 throw INTERP_KERNEL::Exception(oss.str().c_str());
4014 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
4017 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4018 std::string tmp(mesh->getName());
4020 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4021 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4023 for(;it!=_field_per_mesh.end();it++,i++)
4025 if((*it)->getMeshName()==tmp)
4028 int sz=_field_per_mesh.size();
4029 _field_per_mesh.resize(sz+1);
4030 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4034 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4035 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
4038 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4040 MEDFileFieldPerMesh *fpm(*it);
4042 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4047 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const throw(INTERP_KERNEL::Exception)
4049 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4050 std::vector< std::vector<TypeOfField> > typesF;
4051 std::vector< std::vector<std::string> > pfls,locs;
4052 std::vector< std::vector<std::pair<int,int> > > bgEnd=getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs);
4053 std::set<TypeOfField> allEnt;
4054 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4055 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4056 allEnt.insert(*it2);
4057 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4058 std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4059 for(std::size_t i=0;i<allEnt.size();i++,it3++)
4061 std::vector< std::pair<int,int> > its;
4062 ret[i]=shallowCpy();
4063 int newLgth=ret[i]->keepOnlySpatialDiscretization(*it3,its);
4064 ret[i]->updateData(newLgth,its);
4069 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception)
4071 int globalCounter=0;
4072 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4073 (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4074 return globalCounter;
4077 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops) throw(INTERP_KERNEL::Exception)
4079 if(_nb_of_tuples_to_be_allocated>=0)
4081 _nb_of_tuples_to_be_allocated=newLgth;
4084 if(_nb_of_tuples_to_be_allocated==-1)
4086 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4088 const DataArray *oldArr=getUndergroundDataArray();
4089 if(!oldArr || !oldArr->isAllocated())
4090 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4091 MEDCouplingAutoRefCountObjectPtr<DataArray> newArr=createNewEmptyDataArrayInstance();
4092 newArr->alloc(newLgth,getNumberOfComponents());
4094 for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4096 if((*it).second<(*it).first)
4097 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4098 newArr->setContigPartOfSelectedValues2(pos,oldArr,(*it).first,(*it).second,1);
4099 pos+=(*it).second-(*it).first;
4104 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4107 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4109 if(_field_per_mesh.empty())
4110 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4111 if(_field_per_mesh.size()>1)
4112 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4113 _field_per_mesh[0]->copyOptionsFrom(opts);
4114 _field_per_mesh[0]->writeLL(fid,nasc);
4118 * This methods returns true is the allocation has been needed leading to a modification of state in \a this->_nb_of_tuples_to_be_allocated.
4119 * If false is returned the memory allocation is not required.
4121 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile() throw(INTERP_KERNEL::Exception)
4123 if(_nb_of_tuples_to_be_allocated>=0)
4125 getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4126 _nb_of_tuples_to_be_allocated=-2;
4129 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4131 if(_nb_of_tuples_to_be_allocated==-1)
4132 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4133 if(_nb_of_tuples_to_be_allocated<-3)
4134 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4138 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4140 med_int numdt,numit;
4144 med_int meshnumdt,meshnumit;
4145 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4146 MEDfieldComputingStepInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt);
4147 MEDfield23ComputingStepMeshInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit);
4148 if(_iteration!=numdt || _order!=numit)
4149 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4150 _field_per_mesh.resize(nmesh);
4151 for(int i=0;i<nmesh;i++)
4152 _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i+1,meshnumdt,meshnumit,nasc);//tony
4153 _nb_of_tuples_to_be_allocated=0;
4154 for(int i=0;i<nmesh;i++)
4155 _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4158 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4160 allocIfNecessaryTheArrayToReceiveDataFromFile();
4161 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4162 (*it)->loadBigArraysRecursively(fid,nasc);
4165 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4167 if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4168 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4169 (*it)->loadBigArraysRecursively(fid,nasc);
4172 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4174 loadOnlyStructureOfDataRecursively(fid,nasc);
4175 loadBigArraysRecursively(fid,nasc);
4178 void MEDFileAnyTypeField1TSWithoutSDA::releaseArrays() throw(INTERP_KERNEL::Exception)
4180 DataArray *thisArr(getUndergroundDataArray());
4181 if(thisArr && thisArr->isAllocated())
4183 _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
4184 thisArr->desallocate();
4188 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySize() const
4190 std::size_t ret=_dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh >);
4191 if(getUndergroundDataArray())
4192 ret+=getUndergroundDataArray()->getHeapMemorySize();
4193 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4194 ret+=(*it)->getHeapMemorySize();
4199 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4200 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4201 * "Sort By Type"), if not, an exception is thrown.
4202 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
4203 * \param [in] arr - the array of values.
4204 * \param [in,out] glob - the global data where profiles and localization present in
4205 * \a field, if any, are added.
4206 * \throw If the name of \a field is empty.
4207 * \throw If the data array of \a field is not set.
4208 * \throw If \a this->_arr is already allocated but has different number of components
4210 * \throw If the underlying mesh of \a field has no name.
4211 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4213 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4215 const MEDCouplingMesh *mesh=field->getMesh();
4217 TypeOfField type=field->getTypeOfField();
4218 std::vector<DataArrayInt *> dummy;
4219 int start=copyTinyInfoFrom(field,arr);
4220 int pos=addNewEntryIfNecessary(mesh);
4223 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4224 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4227 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4231 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4232 * of a given mesh are used as the support of the given field (a real support is not used).
4233 * Elements of the given mesh must be sorted suitable for writing to MED file.
4234 * Order of underlying mesh entities of the given field specified by \a profile parameter
4235 * is not prescribed; this method permutes field values to have them sorted by element
4236 * type as required for writing to MED file. A new profile is added only if no equal
4237 * profile is missing.
4238 * \param [in] field - the field to add to \a this. The field double values are ignored.
4239 * \param [in] arrOfVals - the values of the field \a field used.
4240 * \param [in] mesh - the supporting mesh of \a field.
4241 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4242 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
4243 * \param [in,out] glob - the global data where profiles and localization present in
4244 * \a field, if any, are added.
4245 * \throw If either \a field or \a mesh or \a profile has an empty name.
4246 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4247 * \throw If the data array of \a field is not set.
4248 * \throw If \a this->_arr is already allocated but has different number of components
4250 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4251 * \sa setFieldNoProfileSBT()
4253 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)
4256 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
4257 if(!arrOfVals || !arrOfVals->isAllocated())
4258 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
4259 TypeOfField type=field->getTypeOfField();
4260 std::vector<DataArrayInt *> idsInPflPerType;
4261 std::vector<DataArrayInt *> idsPerType;
4262 std::vector<int> code,code2;
4263 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4266 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4267 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
4268 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin());
4269 std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
4271 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> field2=field->clone(false);
4272 if(type==ON_GAUSS_NE)
4274 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mPart=m->buildPart(profile->begin(),profile->end());
4275 field2->setMesh(mPart);
4277 int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
4278 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4280 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4281 throw INTERP_KERNEL::Exception(oss.str().c_str());
4284 int start=copyTinyInfoFrom(field,arrOfVals);
4285 code2=m->getDistributionOfTypes();
4287 int pos=addNewEntryIfNecessary(m);
4288 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4292 if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
4293 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
4294 std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
4295 std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
4296 int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
4297 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4299 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4300 throw INTERP_KERNEL::Exception(oss.str().c_str());
4302 int start=copyTinyInfoFrom(field,arrOfVals);
4303 int pos=addNewEntryIfNecessary(m);
4304 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4309 * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
4311 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples) throw(INTERP_KERNEL::Exception)
4313 if(_nb_of_tuples_to_be_allocated>=0)
4314 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 !");
4315 DataArray *arr(getOrCreateAndGetArray());
4316 arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
4317 _nb_of_tuples_to_be_allocated=-3;
4321 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4322 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4323 * larger by the size of \a field. Returns an id of the first not filled
4324 * tuple of \a this->_arr.
4325 * \param [in] field - the field to copy the info on components and the name from.
4326 * \return int - the id of first not initialized tuple of \a this->_arr.
4327 * \throw If the name of \a field is empty.
4328 * \throw If the data array of \a field is not set.
4329 * \throw If \a this->_arr is already allocated but has different number of components
4332 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception)
4335 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4336 std::string name(field->getName());
4337 setName(name.c_str());
4338 setDtUnit(field->getTimeUnit());
4340 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4342 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4343 if(!arr->isAllocated())
4344 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
4345 _dt=field->getTime(_iteration,_order);
4346 int nbOfComponents=arr->getNumberOfComponents();
4347 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4348 if(!getOrCreateAndGetArray()->isAllocated())
4350 allocNotFromFile(arr->getNumberOfTuples());
4355 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4356 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4357 getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
4358 _nb_of_tuples_to_be_allocated=-3;
4359 return oldNbOfTuples;
4364 * Returns number of components in \a this field
4365 * \return int - the number of components.
4367 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4369 return getOrCreateAndGetArray()->getNumberOfComponents();
4373 * Change info on components in \a this.
4374 * \throw If size of \a infos is not equal to the number of components already in \a this.
4376 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos) throw(INTERP_KERNEL::Exception)
4378 DataArray *arr=getOrCreateAndGetArray();
4379 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
4383 * Returns info on components of \a this field.
4384 * \return const std::vector<std::string>& - a sequence of strings each being an
4385 * information on _i_-th component.
4387 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
4389 const DataArray *arr=getOrCreateAndGetArray();
4390 return arr->getInfoOnComponents();
4394 * Returns a mutable info on components of \a this field.
4395 * \return std::vector<std::string>& - a sequence of strings each being an
4396 * information on _i_-th component.
4398 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
4400 DataArray *arr=getOrCreateAndGetArray();
4401 return arr->getInfoOnComponents();
4405 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4406 * \param [in] type - a spatial discretization of the new field.
4407 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4408 * \param [in] mName - a name of the supporting mesh.
4409 * \param [in] renumPol - specifies how to permute values of the result field according to
4410 * the optional numbers of cells and nodes, if any. The valid values are
4411 * - 0 - do not permute.
4412 * - 1 - permute cells.
4413 * - 2 - permute nodes.
4414 * - 3 - permute cells and nodes.
4416 * \param [in] glob - the global data storing profiles and localization.
4417 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4418 * caller is to delete this field using decrRef() as it is no more needed.
4419 * \throw If the MED file is not readable.
4420 * \throw If there is no mesh named \a mName in the MED file.
4421 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4422 * \throw If no field of \a this is lying on the mesh \a mName.
4423 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4425 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)
4427 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4429 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4431 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4432 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4436 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4437 * \param [in] type - a spatial discretization of the new field.
4438 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4439 * \param [in] renumPol - specifies how to permute values of the result field according to
4440 * the optional numbers of cells and nodes, if any. The valid values are
4441 * - 0 - do not permute.
4442 * - 1 - permute cells.
4443 * - 2 - permute nodes.
4444 * - 3 - permute cells and nodes.
4446 * \param [in] glob - the global data storing profiles and localization.
4447 * \param [in] mesh - the supporting mesh.
4448 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4449 * caller is to delete this field using decrRef() as it is no more needed.
4450 * \throw If the MED file is not readable.
4451 * \throw If no field of \a this is lying on \a mesh.
4452 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4453 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4455 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)
4457 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax,false);
4458 const DataArrayInt *d=mesh->getNumberFieldAtLevel(meshDimRelToMax);
4459 const DataArrayInt *e=mesh->getNumberFieldAtLevel(1);
4460 if(meshDimRelToMax==1)
4461 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
4462 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
4466 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
4468 * \param [in] type - a spatial discretization of the new field.
4469 * \param [in] mName - a name of the supporting mesh.
4470 * \param [in] renumPol - specifies how to permute values of the result field according to
4471 * the optional numbers of cells and nodes, if any. The valid values are
4472 * - 0 - do not permute.
4473 * - 1 - permute cells.
4474 * - 2 - permute nodes.
4475 * - 3 - permute cells and nodes.
4477 * \param [in] glob - the global data storing profiles and localization.
4478 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4479 * caller is to delete this field using decrRef() as it is no more needed.
4480 * \throw If the MED file is not readable.
4481 * \throw If there is no mesh named \a mName in the MED file.
4482 * \throw If there are no mesh entities in the mesh.
4483 * \throw If no field values of the given \a type are available.
4485 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4487 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4489 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4491 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4492 int absDim=getDimension();
4493 int meshDimRelToMax=absDim-mm->getMeshDimension();
4494 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4498 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4499 * \param [in] type - a spatial discretization of the new field.
4500 * \param [in] renumPol - specifies how to permute values of the result field according to
4501 * the optional numbers of cells and nodes, if any. The valid values are
4502 * - 0 - do not permute.
4503 * - 1 - permute cells.
4504 * - 2 - permute nodes.
4505 * - 3 - permute cells and nodes.
4507 * \param [in] glob - the global data storing profiles and localization.
4508 * \param [in] mesh - the supporting mesh.
4509 * \param [in] cellRenum - the cell numbers array used for permutation of the result
4510 * field according to \a renumPol.
4511 * \param [in] nodeRenum - the node numbers array used for permutation of the result
4512 * field according to \a renumPol.
4513 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4514 * caller is to delete this field using decrRef() as it is no more needed.
4515 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4516 * \throw If no field of \a this is lying on \a mesh.
4517 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4519 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)
4521 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
4522 int meshId=getMeshIdFromMeshName(mesh->getName());
4524 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
4529 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4536 throw INTERP_KERNEL::Exception(msg1);
4537 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4540 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
4542 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4543 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
4544 throw INTERP_KERNEL::Exception(oss.str().c_str());
4546 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
4547 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
4548 std::vector<DataArray *> arrOut2(1,arrOut);
4549 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
4550 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
4551 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
4558 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4560 throw INTERP_KERNEL::Exception(msg1);
4563 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
4565 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4566 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
4567 throw INTERP_KERNEL::Exception(oss.str().c_str());
4569 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
4570 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
4571 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
4572 ret->renumberNodes(nodeRenumSafe->getConstPointer());
4577 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
4582 * Returns values and a profile of the field of a given type lying on a given support.
4583 * \param [in] type - a spatial discretization of the field.
4584 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4585 * \param [in] mesh - the supporting mesh.
4586 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
4587 * field of interest lies on. If the field lies on all entities of the given
4588 * dimension, all ids in \a pfl are zero. The caller is to delete this array
4589 * using decrRef() as it is no more needed.
4590 * \param [in] glob - the global data storing profiles and localization.
4591 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
4592 * field. The caller is to delete this array using decrRef() as it is no more needed.
4593 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4594 * \throw If no field of \a this is lying on \a mesh.
4595 * \throw If no field values of the given \a type are available.
4597 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4599 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4600 int meshId=getMeshIdFromMeshName(mesh->getName());
4601 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
4602 ret->setName(nasc.getName().c_str());
4606 //= MEDFileField1TSWithoutSDA
4609 * Throws if a given value is not a valid (non-extended) relative dimension.
4610 * \param [in] meshDimRelToMax - the relative dimension value.
4611 * \throw If \a meshDimRelToMax > 0.
4613 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax) throw(INTERP_KERNEL::Exception)
4615 if(meshDimRelToMax>0)
4616 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
4620 * Checks if elements of a given mesh are in the order suitable for writing
4621 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
4622 * vector describing types of elements and their number.
4623 * \param [in] mesh - the mesh to check.
4624 * \return std::vector<int> - a vector holding for each element type (1) item of
4625 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
4626 * These values are in full-interlace mode.
4627 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4629 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
4632 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
4633 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
4634 int nbOfTypes=geoTypes.size();
4635 std::vector<int> code(3*nbOfTypes);
4636 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr1=DataArrayInt::New();
4637 arr1->alloc(nbOfTypes,1);
4638 int *arrPtr=arr1->getPointer();
4639 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
4640 for(int i=0;i<nbOfTypes;i++,it++)
4641 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
4642 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
4643 const int *arrPtr2=arr2->getConstPointer();
4645 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
4648 int nbCells=mesh->getNumberOfCellsWithType(*it);
4649 code[3*pos]=(int)(*it);
4650 code[3*pos+1]=nbCells;
4651 code[3*pos+2]=-1;//no profiles
4653 std::vector<const DataArrayInt *> idsPerType;//no profiles
4654 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
4658 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
4663 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const char *fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
4665 return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
4669 * Returns all attributes and values of parts of \a this field lying on a given mesh.
4670 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4671 * item of every of returned sequences refers to the _i_-th part of \a this field.
4672 * Thus all sequences returned by this method are of the same length equal to number
4673 * of different types of supporting entities.<br>
4674 * A field part can include sub-parts with several different spatial discretizations,
4675 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
4676 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4677 * of a nested sequence corresponds to a type of spatial discretization.<br>
4678 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
4679 * The overhead is due to selecting values into new instances of DataArrayDouble.
4680 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4681 * for the case with only one underlying mesh. (Actually, the number of meshes is
4682 * not checked if \a mname == \c NULL).
4683 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4684 * a field part is returned.
4685 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4686 * A field part can include sub-parts with several different spatial discretizations,
4687 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and
4688 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT" for example.
4689 * This sequence is of the same length as \a types.
4690 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4691 * discretization. A profile name can be empty.
4692 * Length of this and of nested sequences is the same as that of \a typesF.
4693 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4694 * discretization. A localization name can be empty.
4695 * Length of this and of nested sequences is the same as that of \a typesF.
4696 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
4697 * per each type of spatial discretization within one mesh entity type.
4698 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
4699 * Length of this and of nested sequences is the same as that of \a typesF.
4700 * \throw If no field is lying on \a mname.
4702 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)
4706 meshId=getMeshIdFromMeshName(mname);
4708 if(_field_per_mesh.empty())
4709 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4710 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4711 int nbOfRet=ret0.size();
4712 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
4713 for(int i=0;i<nbOfRet;i++)
4715 const std::vector< std::pair<int,int> >& p=ret0[i];
4716 int nbOfRet1=p.size();
4717 ret[i].resize(nbOfRet1);
4718 for(int j=0;j<nbOfRet1;j++)
4720 DataArrayDouble *tmp=_arr->selectByTupleId2(p[j].first,p[j].second,1);
4728 * Returns a pointer to the underground DataArrayDouble instance. So the
4729 * caller should not decrRef() it. This method allows for a direct access to the field
4730 * values. This method is quite unusable if there is more than a nodal field or a cell
4731 * field on single geometric cell type.
4732 * \return DataArrayDouble * - the pointer to the field values array.
4734 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDouble() const throw(INTERP_KERNEL::Exception)
4736 const DataArrayDouble *ret=_arr;
4738 return const_cast<DataArrayDouble *>(ret);
4743 const char *MEDFileField1TSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
4748 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const throw(INTERP_KERNEL::Exception)
4750 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
4751 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
4752 ret->deepCpyLeavesFrom(*this);
4753 const DataArrayDouble *arr(_arr);
4756 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr->convertToIntArr());
4757 ret->setArray(arr2);
4763 * Returns a pointer to the underground DataArrayDouble instance. So the
4764 * caller should not decrRef() it. This method allows for a direct access to the field
4765 * values. This method is quite unusable if there is more than a nodal field or a cell
4766 * field on single geometric cell type.
4767 * \return DataArrayDouble * - the pointer to the field values array.
4769 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
4771 return getUndergroundDataArrayDouble();
4775 * Returns a pointer to the underground DataArrayDouble instance and a
4776 * sequence describing parameters of a support of each part of \a this field. The
4777 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
4778 * direct access to the field values. This method is intended for the field lying on one
4780 * \param [in,out] entries - the sequence describing parameters of a support of each
4781 * part of \a this field. Each item of this sequence consists of two parts. The
4782 * first part describes a type of mesh entity and an id of discretization of a
4783 * current field part. The second part describes a range of values [begin,end)
4784 * within the returned array relating to the current field part.
4785 * \return DataArrayDouble * - the pointer to the field values array.
4786 * \throw If the number of underlying meshes is not equal to 1.
4787 * \throw If no field values are available.
4788 * \sa getUndergroundDataArray()
4790 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4792 if(_field_per_mesh.size()!=1)
4793 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
4794 if(_field_per_mesh[0]==0)
4795 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
4796 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
4797 return getUndergroundDataArrayDouble();
4801 * Returns a pointer to the underground DataArrayDouble instance and a
4802 * sequence describing parameters of a support of each part of \a this field. The
4803 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
4804 * direct access to the field values. This method is intended for the field lying on one
4806 * \param [in,out] entries - the sequence describing parameters of a support of each
4807 * part of \a this field. Each item of this sequence consists of two parts. The
4808 * first part describes a type of mesh entity and an id of discretization of a
4809 * current field part. The second part describes a range of values [begin,end)
4810 * within the returned array relating to the current field part.
4811 * \return DataArrayDouble * - the pointer to the field values array.
4812 * \throw If the number of underlying meshes is not equal to 1.
4813 * \throw If no field values are available.
4814 * \sa getUndergroundDataArray()
4816 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4818 return getUndergroundDataArrayDoubleExt(entries);
4821 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order,
4822 const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
4824 DataArrayDouble *arr=getOrCreateAndGetArrayDouble();
4825 arr->setInfoAndChangeNbOfCompo(infos);
4828 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
4832 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
4834 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
4835 ret->deepCpyLeavesFrom(*this);
4839 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
4841 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret=static_cast<MEDFileField1TSWithoutSDA *>(shallowCpy());
4842 if((const DataArrayDouble *)_arr)
4843 ret->_arr=_arr->deepCpy();
4847 void MEDFileField1TSWithoutSDA::setArray(DataArray *arr) throw(INTERP_KERNEL::Exception)
4851 _nb_of_tuples_to_be_allocated=-1;
4855 DataArrayDouble *arrC=dynamic_cast<DataArrayDouble *>(arr);
4857 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayDouble !");
4859 _nb_of_tuples_to_be_allocated=-3;
4864 DataArray *MEDFileField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
4866 return DataArrayDouble::New();
4869 DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble()
4871 DataArrayDouble *ret=_arr;
4874 _arr=DataArrayDouble::New();
4878 DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray()
4880 return getOrCreateAndGetArrayDouble();
4883 const DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble() const
4885 const DataArrayDouble *ret=_arr;
4888 DataArrayDouble *ret2=DataArrayDouble::New();
4889 const_cast<MEDFileField1TSWithoutSDA *>(this)->_arr=DataArrayDouble::New();
4893 const DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray() const
4895 return getOrCreateAndGetArrayDouble();
4898 //= MEDFileIntField1TSWithoutSDA
4900 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const char *fieldName, int csit, int iteration, int order,
4901 const std::vector<std::string>& infos)
4903 return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
4906 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
4910 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order,
4911 const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
4913 DataArrayInt *arr=getOrCreateAndGetArrayInt();
4914 arr->setInfoAndChangeNbOfCompo(infos);
4917 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
4922 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const throw(INTERP_KERNEL::Exception)
4924 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
4925 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
4926 ret->deepCpyLeavesFrom(*this);
4927 const DataArrayInt *arr(_arr);
4930 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2(arr->convertToDblArr());
4931 ret->setArray(arr2);
4937 * Returns a pointer to the underground DataArrayInt instance. So the
4938 * caller should not decrRef() it. This method allows for a direct access to the field
4939 * values. This method is quite unusable if there is more than a nodal field or a cell
4940 * field on single geometric cell type.
4941 * \return DataArrayInt * - the pointer to the field values array.
4943 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
4945 return getUndergroundDataArrayInt();
4949 * Returns a pointer to the underground DataArrayInt instance. So the
4950 * caller should not decrRef() it. This method allows for a direct access to the field
4951 * values. This method is quite unusable if there is more than a nodal field or a cell
4952 * field on single geometric cell type.
4953 * \return DataArrayInt * - the pointer to the field values array.
4955 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayInt() const throw(INTERP_KERNEL::Exception)
4957 const DataArrayInt *ret=_arr;
4959 return const_cast<DataArrayInt *>(ret);
4965 * Returns a pointer to the underground DataArrayInt instance and a
4966 * sequence describing parameters of a support of each part of \a this field. The
4967 * caller should not decrRef() the returned DataArrayInt. This method allows for a
4968 * direct access to the field values. This method is intended for the field lying on one
4970 * \param [in,out] entries - the sequence describing parameters of a support of each
4971 * part of \a this field. Each item of this sequence consists of two parts. The
4972 * first part describes a type of mesh entity and an id of discretization of a
4973 * current field part. The second part describes a range of values [begin,end)
4974 * within the returned array relating to the current field part.
4975 * \return DataArrayInt * - the pointer to the field values array.
4976 * \throw If the number of underlying meshes is not equal to 1.
4977 * \throw If no field values are available.
4978 * \sa getUndergroundDataArray()
4980 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4982 return getUndergroundDataArrayIntExt(entries);
4986 * Returns a pointer to the underground DataArrayInt instance and a
4987 * sequence describing parameters of a support of each part of \a this field. The
4988 * caller should not decrRef() the returned DataArrayInt. This method allows for a
4989 * direct access to the field values. This method is intended for the field lying on one
4991 * \param [in,out] entries - the sequence describing parameters of a support of each
4992 * part of \a this field. Each item of this sequence consists of two parts. The
4993 * first part describes a type of mesh entity and an id of discretization of a
4994 * current field part. The second part describes a range of values [begin,end)
4995 * within the returned array relating to the current field part.
4996 * \return DataArrayInt * - the pointer to the field values array.
4997 * \throw If the number of underlying meshes is not equal to 1.
4998 * \throw If no field values are available.
4999 * \sa getUndergroundDataArray()
5001 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
5003 if(_field_per_mesh.size()!=1)
5004 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5005 if(_field_per_mesh[0]==0)
5006 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5007 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5008 return getUndergroundDataArrayInt();
5011 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
5013 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5014 ret->deepCpyLeavesFrom(*this);
5018 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
5020 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret=static_cast<MEDFileIntField1TSWithoutSDA *>(shallowCpy());
5021 if((const DataArrayInt *)_arr)
5022 ret->_arr=_arr->deepCpy();
5026 void MEDFileIntField1TSWithoutSDA::setArray(DataArray *arr) throw(INTERP_KERNEL::Exception)
5030 _nb_of_tuples_to_be_allocated=-1;
5034 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>(arr);
5036 throw INTERP_KERNEL::Exception("MEDFileIntField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayInt !");
5038 _nb_of_tuples_to_be_allocated=-3;
5043 DataArray *MEDFileIntField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
5045 return DataArrayInt::New();
5048 DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt()
5050 DataArrayInt *ret=_arr;
5053 _arr=DataArrayInt::New();
5057 DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray()
5059 return getOrCreateAndGetArrayInt();
5062 const DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt() const
5064 const DataArrayInt *ret=_arr;
5067 DataArrayInt *ret2=DataArrayInt::New();
5068 const_cast<MEDFileIntField1TSWithoutSDA *>(this)->_arr=DataArrayInt::New();
5072 const DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray() const
5074 return getOrCreateAndGetArrayInt();
5077 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5081 //= MEDFileAnyTypeField1TS
5083 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
5085 med_field_type typcha;
5087 std::vector<std::string> infos;
5088 std::string dtunit,fieldName;
5089 LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
5090 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5095 ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5100 ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5105 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] !";
5106 throw INTERP_KERNEL::Exception(oss.str().c_str());
5109 ret->setDtUnit(dtunit.c_str());
5110 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5112 med_int numdt,numit;
5114 MEDfieldComputingStepInfo(fid,fieldName.c_str(),1,&numdt,&numit,&dt);
5115 ret->setTime(numdt,numit,dt);
5118 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5120 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5124 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
5125 try:MEDFileFieldGlobsReal(fileName)
5127 MEDFileUtilities::CheckFileForRead(fileName);
5128 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5129 _content=BuildContentFrom(fid,fileName,loadAll);
5132 catch(INTERP_KERNEL::Exception& e)
5137 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5139 med_field_type typcha;
5140 std::vector<std::string> infos;
5143 int nbSteps=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5144 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5149 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5154 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5159 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] !";
5160 throw INTERP_KERNEL::Exception(oss.str().c_str());
5163 ret->setDtUnit(dtunit.c_str());
5164 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5168 std::ostringstream oss; oss << "MEDFileField1TS(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5169 throw INTERP_KERNEL::Exception(oss.str().c_str());
5172 med_int numdt,numit;
5174 MEDfieldComputingStepInfo(fid,fieldName,1,&numdt,&numit,&dt);
5175 ret->setTime(numdt,numit,dt);
5178 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5180 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5184 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5185 try:MEDFileFieldGlobsReal(fileName)
5187 MEDFileUtilities::CheckFileForRead(fileName);
5188 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5189 _content=BuildContentFrom(fid,fileName,fieldName,loadAll);
5192 catch(INTERP_KERNEL::Exception& e)
5197 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, const char *fileName) throw(INTERP_KERNEL::Exception)
5200 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5201 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5203 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New();
5204 ret->setFileName(fileName);
5205 ret->_content=c; c->incrRef();
5208 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5210 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New();
5211 ret->setFileName(fileName);
5212 ret->_content=c; c->incrRef();
5215 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5218 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
5220 MEDFileUtilities::CheckFileForRead(fileName);
5221 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5222 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll);
5223 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5224 ret->loadGlobals(fid);
5228 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5230 MEDFileUtilities::CheckFileForRead(fileName);
5231 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5232 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll);
5233 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5234 ret->loadGlobals(fid);
5238 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
5240 MEDFileUtilities::CheckFileForRead(fileName);
5241 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5242 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,iteration,order,loadAll);
5243 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5244 ret->loadGlobals(fid);
5248 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
5250 med_field_type typcha;
5251 std::vector<std::string> infos;
5254 int nbOfStep2=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5255 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5260 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5265 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5270 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] !";
5271 throw INTERP_KERNEL::Exception(oss.str().c_str());
5274 ret->setDtUnit(dtunit.c_str());
5275 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5278 std::vector< std::pair<int,int> > dtits(nbOfStep2);
5279 for(int i=0;i<nbOfStep2 && !found;i++)
5281 med_int numdt,numit;
5283 MEDfieldComputingStepInfo(fid,fieldName,i+1,&numdt,&numit,&dt);
5284 if(numdt==iteration && numit==order)
5290 dtits[i]=std::pair<int,int>(numdt,numit);
5294 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << fileName << "' ! Available iterations are : ";
5295 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5296 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5297 throw INTERP_KERNEL::Exception(oss.str().c_str());
5300 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5302 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5306 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
5307 try:MEDFileFieldGlobsReal(fileName)
5309 MEDFileUtilities::CheckFileForRead(fileName);
5310 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5311 _content=BuildContentFrom(fid,fileName,fieldName,iteration,order,loadAll);
5314 catch(INTERP_KERNEL::Exception& e)
5320 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5321 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5323 * \warning this is a shallow copy constructor
5325 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5327 if(!shallowCopyOfContent)
5329 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5330 otherPtr->incrRef();
5331 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5335 _content=other.shallowCpy();
5339 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)
5343 int nbFields=MEDnField(fid);
5344 if(fieldIdCFormat>=nbFields)
5346 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << fileName << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5347 throw INTERP_KERNEL::Exception(oss.str().c_str());
5350 int ncomp=MEDfieldnComponent(fid,fieldIdCFormat+1);
5351 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5352 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5353 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5354 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5355 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5358 MEDfieldInfo(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
5359 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5360 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5361 infos.clear(); infos.resize(ncomp);
5362 for(int j=0;j<ncomp;j++)
5363 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5368 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5371 * \return in case of success the number of time steps available for the field with name \a fieldName.
5373 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)
5375 int nbFields=MEDnField(fid);
5377 std::vector<std::string> fns(nbFields);
5379 for(int i=0;i<nbFields && !found;i++)
5382 nbOfStep2=LocateField2(fid,fileName,i,false,tmp,typcha,infos,dtunitOut);
5384 found=(tmp==fieldName);
5390 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
5391 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5392 oss << "\"" << *it << "\" ";
5393 throw INTERP_KERNEL::Exception(oss.str().c_str());
5399 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5400 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5401 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5402 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5403 * to keep a valid instance.
5404 * 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.
5405 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5406 * 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.
5408 * \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.
5409 * \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.
5410 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5411 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5412 * \param [in] newLocName is the new localization name.
5413 * \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.
5414 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5416 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newPflName, bool forceRenameOnGlob) throw(INTERP_KERNEL::Exception)
5418 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5419 std::string oldPflName=disc->getProfile();
5420 std::vector<std::string> vv=getPflsReallyUsedMulti();
5421 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5422 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5424 disc->setProfile(newPflName);
5425 DataArrayInt *pfl=getProfile(oldPflName.c_str());
5426 pfl->setName(newPflName);
5430 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5431 throw INTERP_KERNEL::Exception(oss.str().c_str());
5436 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5437 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5438 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5439 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5440 * to keep a valid instance.
5441 * 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.
5442 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5443 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5444 * 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.
5446 * \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.
5447 * \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.
5448 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5449 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5450 * \param [in] newLocName is the new localization name.
5451 * \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.
5452 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
5454 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newLocName, bool forceRenameOnGlob) throw(INTERP_KERNEL::Exception)
5456 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5457 std::string oldLocName=disc->getLocalization();
5458 std::vector<std::string> vv=getLocsReallyUsedMulti();
5459 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
5460 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
5462 disc->setLocalization(newLocName);
5463 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
5464 loc.setName(newLocName);
5468 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
5469 throw INTERP_KERNEL::Exception(oss.str().c_str());
5473 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() throw(INTERP_KERNEL::Exception)
5475 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5477 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
5481 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const throw(INTERP_KERNEL::Exception)
5483 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5485 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
5490 * Writes \a this field into a MED file specified by its name.
5491 * \param [in] fileName - the MED file name.
5492 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
5493 * - 2 - erase; an existing file is removed.
5494 * - 1 - append; same data should not be present in an existing file.
5495 * - 0 - overwrite; same data present in an existing file is overwritten.
5496 * \throw If the field name is not set.
5497 * \throw If no field data is set.
5498 * \throw If \a mode == 1 and the same data is present in an existing file.
5500 void MEDFileAnyTypeField1TS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
5502 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
5503 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
5508 * This method alloc the arrays and load potentially huge arrays contained in this field.
5509 * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
5510 * This method can be also called to refresh or reinit values from a file.
5512 * \throw If the fileName is not set or points to a non readable MED file.
5513 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5515 void MEDFileAnyTypeField1TS::loadArrays() throw(INTERP_KERNEL::Exception)
5517 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
5518 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
5522 * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
5523 * But once data loaded once, this method does nothing.
5525 * \throw If the fileName is not set or points to a non readable MED file.
5526 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::releaseArrays
5528 void MEDFileAnyTypeField1TS::loadArraysIfNecessary() throw(INTERP_KERNEL::Exception)
5530 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
5531 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
5535 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
5536 * This method does not release arrays set outside the context of a MED file.
5538 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary
5540 void MEDFileAnyTypeField1TS::releaseArrays() throw(INTERP_KERNEL::Exception)
5542 contentNotNullBase()->releaseArrays();
5545 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
5547 int nbComp=getNumberOfComponents();
5548 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5549 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5550 for(int i=0;i<nbComp;i++)
5552 std::string info=getInfo()[i];
5554 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
5555 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
5556 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
5558 if(getName().empty())
5559 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
5560 MEDfieldCr(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
5561 writeGlobals(fid,*this);
5562 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
5565 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySize() const
5568 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
5569 ret+=_content->getHeapMemorySize();
5570 return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
5574 * Returns a string describing \a this field. This string is outputted
5575 * by \c print Python command.
5577 std::string MEDFileAnyTypeField1TS::simpleRepr() const
5579 std::ostringstream oss;
5580 contentNotNullBase()->simpleRepr(0,oss,-1);
5581 simpleReprGlobs(oss);
5586 * This method returns all profiles whose name is non empty used.
5587 * \b WARNING If profile is used several times it will be reported \b only \b once.
5588 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
5590 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
5592 return contentNotNullBase()->getPflsReallyUsed2();
5596 * This method returns all localizations whose name is non empty used.
5597 * \b WARNING If localization is used several times it will be reported \b only \b once.
5599 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
5601 return contentNotNullBase()->getLocsReallyUsed2();
5605 * This method returns all profiles whose name is non empty used.
5606 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
5608 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
5610 return contentNotNullBase()->getPflsReallyUsedMulti2();
5614 * This method returns all localizations whose name is non empty used.
5615 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
5617 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
5619 return contentNotNullBase()->getLocsReallyUsedMulti2();
5622 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5624 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
5627 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5629 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
5632 int MEDFileAnyTypeField1TS::getDimension() const
5634 return contentNotNullBase()->getDimension();
5637 int MEDFileAnyTypeField1TS::getIteration() const
5639 return contentNotNullBase()->getIteration();
5642 int MEDFileAnyTypeField1TS::getOrder() const
5644 return contentNotNullBase()->getOrder();
5647 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
5649 return contentNotNullBase()->getTime(iteration,order);
5652 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
5654 contentNotNullBase()->setTime(iteration,order,val);
5657 std::string MEDFileAnyTypeField1TS::getName() const
5659 return contentNotNullBase()->getName();
5662 void MEDFileAnyTypeField1TS::setName(const char *name)
5664 contentNotNullBase()->setName(name);
5667 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
5669 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
5672 std::string MEDFileAnyTypeField1TS::getDtUnit() const throw(INTERP_KERNEL::Exception)
5674 return contentNotNullBase()->getDtUnit();
5677 void MEDFileAnyTypeField1TS::setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception)
5679 contentNotNullBase()->setDtUnit(dtUnit);
5682 std::string MEDFileAnyTypeField1TS::getMeshName() const throw(INTERP_KERNEL::Exception)
5684 return contentNotNullBase()->getMeshName();
5687 void MEDFileAnyTypeField1TS::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
5689 contentNotNullBase()->setMeshName(newMeshName);
5692 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
5694 return contentNotNullBase()->changeMeshNames(modifTab);
5697 int MEDFileAnyTypeField1TS::getMeshIteration() const throw(INTERP_KERNEL::Exception)
5699 return contentNotNullBase()->getMeshIteration();
5702 int MEDFileAnyTypeField1TS::getMeshOrder() const throw(INTERP_KERNEL::Exception)
5704 return contentNotNullBase()->getMeshOrder();
5707 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
5709 return contentNotNullBase()->getNumberOfComponents();
5712 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
5714 return contentNotNullBase()->isDealingTS(iteration,order);
5717 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
5719 return contentNotNullBase()->getDtIt();
5722 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
5724 contentNotNullBase()->fillIteration(p);
5727 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
5729 contentNotNullBase()->fillTypesOfFieldAvailable(types);
5732 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos) throw(INTERP_KERNEL::Exception)
5734 contentNotNullBase()->setInfo(infos);
5737 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
5739 return contentNotNullBase()->getInfo();
5741 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
5743 return contentNotNullBase()->getInfo();
5746 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
5748 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5751 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
5753 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5756 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
5758 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
5761 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
5763 return contentNotNullBase()->getTypesOfFieldAvailable();
5766 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,
5767 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
5769 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
5773 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
5774 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
5775 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
5777 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const throw(INTERP_KERNEL::Exception)
5779 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5781 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
5782 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
5783 std::size_t sz(contentsSplit.size());
5784 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
5785 for(std::size_t i=0;i<sz;i++)
5787 ret[i]=shallowCpy();
5788 ret[i]->_content=contentsSplit[i];
5794 * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
5795 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
5797 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const throw(INTERP_KERNEL::Exception)
5799 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5801 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
5802 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitDiscretizations();
5803 std::size_t sz(contentsSplit.size());
5804 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
5805 for(std::size_t i=0;i<sz;i++)
5807 ret[i]=shallowCpy();
5808 ret[i]->_content=contentsSplit[i];
5813 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCpy() const throw(INTERP_KERNEL::Exception)
5815 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=shallowCpy();
5816 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
5817 ret->_content=_content->deepCpy();
5818 ret->deepCpyGlobs(*this);
5822 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception)
5824 return contentNotNullBase()->copyTinyInfoFrom(field,arr);
5830 * Returns a new instance of MEDFileField1TS holding data of the first time step of
5831 * the first field that has been read from a specified MED file.
5832 * \param [in] fileName - the name of the MED file to read.
5833 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5834 * is to delete this field using decrRef() as it is no more needed.
5835 * \throw If reading the file fails.
5837 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
5839 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,loadAll);
5840 ret->contentNotNull();
5845 * Returns a new instance of MEDFileField1TS holding data of the first time step of
5846 * a given field that has been read from a specified MED file.
5847 * \param [in] fileName - the name of the MED file to read.
5848 * \param [in] fieldName - the name of the field to read.
5849 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5850 * is to delete this field using decrRef() as it is no more needed.
5851 * \throw If reading the file fails.
5852 * \throw If there is no field named \a fieldName in the file.
5854 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5856 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,fieldName,loadAll);
5857 ret->contentNotNull();
5862 * Returns a new instance of MEDFileField1TS holding data of a given time step of
5863 * a given field that has been read from a specified MED file.
5864 * \param [in] fileName - the name of the MED file to read.
5865 * \param [in] fieldName - the name of the field to read.
5866 * \param [in] iteration - the iteration number of a required time step.
5867 * \param [in] order - the iteration order number of required time step.
5868 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5869 * is to delete this field using decrRef() as it is no more needed.
5870 * \throw If reading the file fails.
5871 * \throw If there is no field named \a fieldName in the file.
5872 * \throw If the required time step is missing from the file.
5874 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
5876 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,fieldName,iteration,order,loadAll);
5877 ret->contentNotNull();
5882 * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5883 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5885 * Returns a new instance of MEDFileField1TS holding either a shallow copy
5886 * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
5887 * \warning this is a shallow copy constructor
5888 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
5889 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
5890 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
5891 * is to delete this field using decrRef() as it is no more needed.
5893 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
5895 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(other,shallowCopyOfContent);
5896 ret->contentNotNull();
5901 * Returns a new empty instance of MEDFileField1TS.
5902 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
5903 * is to delete this field using decrRef() as it is no more needed.
5905 MEDFileField1TS *MEDFileField1TS::New()
5907 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS;
5908 ret->contentNotNull();
5913 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
5914 * following the given input policy.
5916 * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
5917 * By default (true) the globals are deeply copied.
5918 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
5920 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
5922 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret;
5923 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5926 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
5928 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
5929 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
5930 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc,getFileName()));
5933 ret=MEDFileIntField1TS::New();
5935 ret->deepCpyGlobs(*this);
5937 ret->shallowCpyGlobs(*this);
5941 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const throw(INTERP_KERNEL::Exception)
5943 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
5945 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
5946 const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
5948 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 !");
5952 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() throw(INTERP_KERNEL::Exception)
5954 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
5956 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
5957 MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
5959 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 !");
5963 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception)
5966 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
5967 if(!((DataArray*)arr))
5968 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
5969 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
5971 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
5972 f->setArray(arrOutC);
5975 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception)
5977 if(!((DataArray*)arr))
5978 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
5979 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
5981 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
5986 MEDFileField1TS::MEDFileField1TS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
5987 try:MEDFileAnyTypeField1TS(fileName,loadAll)
5990 catch(INTERP_KERNEL::Exception& e)
5993 MEDFileField1TS::MEDFileField1TS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5994 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll)
5997 catch(INTERP_KERNEL::Exception& e)
6000 MEDFileField1TS::MEDFileField1TS(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
6001 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll)
6004 catch(INTERP_KERNEL::Exception& e)
6008 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6009 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6011 * \warning this is a shallow copy constructor
6013 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6014 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6017 catch(INTERP_KERNEL::Exception& e)
6020 MEDFileField1TS::MEDFileField1TS()
6022 _content=new MEDFileField1TSWithoutSDA;
6026 * Returns a new MEDCouplingFieldDouble of a given type lying on
6027 * mesh entities of a given dimension of the first mesh in MED file. If \a this field
6028 * has not been constructed via file reading, an exception is thrown.
6029 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6030 * \param [in] type - a spatial discretization of interest.
6031 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6032 * \param [in] renumPol - specifies how to permute values of the result field according to
6033 * the optional numbers of cells and nodes, if any. The valid values are
6034 * - 0 - do not permute.
6035 * - 1 - permute cells.
6036 * - 2 - permute nodes.
6037 * - 3 - permute cells and nodes.
6039 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6040 * caller is to delete this field using decrRef() as it is no more needed.
6041 * \throw If \a this field has not been constructed via file reading.
6042 * \throw If the MED file is not readable.
6043 * \throw If there is no mesh in the MED file.
6044 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6045 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6046 * \sa getFieldOnMeshAtLevel()
6048 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
6050 if(getFileName2().empty())
6051 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6052 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6053 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut,*contentNotNull());
6054 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6059 * Returns a new MEDCouplingFieldDouble of a given type lying on
6060 * the top level cells of the first mesh in MED file. If \a this field
6061 * has not been constructed via file reading, an exception is thrown.
6062 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6063 * \param [in] type - a spatial discretization of interest.
6064 * \param [in] renumPol - specifies how to permute values of the result field according to
6065 * the optional numbers of cells and nodes, if any. The valid values are
6066 * - 0 - do not permute.
6067 * - 1 - permute cells.
6068 * - 2 - permute nodes.
6069 * - 3 - permute cells and nodes.
6071 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6072 * caller is to delete this field using decrRef() as it is no more needed.
6073 * \throw If \a this field has not been constructed via file reading.
6074 * \throw If the MED file is not readable.
6075 * \throw If there is no mesh in the MED file.
6076 * \throw If no field values of the given \a type.
6077 * \throw If no field values lying on the top level support.
6078 * \sa getFieldAtLevel()
6080 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const throw(INTERP_KERNEL::Exception)
6082 if(getFileName2().empty())
6083 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6084 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6085 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,0,renumPol,this,arrOut,*contentNotNull());
6086 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6091 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6092 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6093 * \param [in] type - a spatial discretization of the new field.
6094 * \param [in] mesh - the supporting mesh.
6095 * \param [in] renumPol - specifies how to permute values of the result field according to
6096 * the optional numbers of cells and nodes, if any. The valid values are
6097 * - 0 - do not permute.
6098 * - 1 - permute cells.
6099 * - 2 - permute nodes.
6100 * - 3 - permute cells and nodes.
6102 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6103 * caller is to delete this field using decrRef() as it is no more needed.
6104 * \throw If no field of \a this is lying on \a mesh.
6105 * \throw If the mesh is empty.
6106 * \throw If no field values of the given \a type are available.
6107 * \sa getFieldAtLevel()
6108 * \sa getFieldOnMeshAtLevel()
6110 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
6112 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6113 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull());
6114 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6119 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6120 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6121 * \param [in] type - a spatial discretization of interest.
6122 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6123 * \param [in] mesh - the supporting mesh.
6124 * \param [in] renumPol - specifies how to permute values of the result field according to
6125 * the optional numbers of cells and nodes, if any. The valid values are
6126 * - 0 - do not permute.
6127 * - 1 - permute cells.
6128 * - 2 - permute nodes.
6129 * - 3 - permute cells and nodes.
6131 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6132 * caller is to delete this field using decrRef() as it is no more needed.
6133 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6134 * \throw If no field of \a this is lying on \a mesh.
6135 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6136 * \sa getFieldAtLevel()
6137 * \sa getFieldOnMeshAtLevel()
6139 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
6141 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6142 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull());
6143 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6148 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6149 * This method is called "Old" because in MED3 norm a field has only one meshName
6150 * attached, so this method is for readers of MED2 files. If \a this field
6151 * has not been constructed via file reading, an exception is thrown.
6152 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6153 * \param [in] type - a spatial discretization of interest.
6154 * \param [in] mName - a name of the supporting mesh.
6155 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6156 * \param [in] renumPol - specifies how to permute values of the result field according to
6157 * the optional numbers of cells and nodes, if any. The valid values are
6158 * - 0 - do not permute.
6159 * - 1 - permute cells.
6160 * - 2 - permute nodes.
6161 * - 3 - permute cells and nodes.
6163 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6164 * caller is to delete this field using decrRef() as it is no more needed.
6165 * \throw If the MED file is not readable.
6166 * \throw If there is no mesh named \a mName in the MED file.
6167 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6168 * \throw If \a this field has not been constructed via file reading.
6169 * \throw If no field of \a this is lying on the mesh named \a mName.
6170 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6171 * \sa getFieldAtLevel()
6173 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
6175 if(getFileName2().empty())
6176 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6177 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6178 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
6179 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6184 * Returns values and a profile of the field of a given type lying on a given support.
6185 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6186 * \param [in] type - a spatial discretization of the field.
6187 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6188 * \param [in] mesh - the supporting mesh.
6189 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6190 * field of interest lies on. If the field lies on all entities of the given
6191 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6192 * using decrRef() as it is no more needed.
6193 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6194 * field. The caller is to delete this array using decrRef() as it is no more needed.
6195 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6196 * \throw If no field of \a this is lying on \a mesh.
6197 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6199 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
6201 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6202 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
6206 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6207 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6208 * "Sort By Type"), if not, an exception is thrown.
6209 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6210 * \param [in] field - the field to add to \a this.
6211 * \throw If the name of \a field is empty.
6212 * \throw If the data array of \a field is not set.
6213 * \throw If the data array is already allocated but has different number of components
6215 * \throw If the underlying mesh of \a field has no name.
6216 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6218 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
6221 contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
6225 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6226 * can be an aggregation of several MEDCouplingFieldDouble instances.
6227 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6228 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6231 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6232 * A new profile is added only if no equal profile is missing.
6233 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6234 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
6235 * \param [in] mesh - the supporting mesh of \a field.
6236 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6237 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6238 * \throw If either \a field or \a mesh or \a profile has an empty name.
6239 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6240 * \throw If the data array of \a field is not set.
6241 * \throw If the data array of \a this is already allocated but has different number of
6242 * components than \a field.
6243 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6244 * \sa setFieldNoProfileSBT()
6246 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
6249 contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6252 MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const throw(INTERP_KERNEL::Exception)
6254 return new MEDFileField1TS(*this);
6257 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
6259 return contentNotNull()->getUndergroundDataArrayDouble();
6262 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
6264 return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
6267 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6268 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
6270 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6273 //= MEDFileIntField1TS
6275 MEDFileIntField1TS *MEDFileIntField1TS::New()
6277 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS;
6278 ret->contentNotNull();
6282 MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
6284 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,loadAll);
6285 ret->contentNotNull();
6289 MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
6291 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,fieldName,loadAll);
6292 ret->contentNotNull();
6296 MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
6298 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,fieldName,iteration,order,loadAll);
6299 ret->contentNotNull();
6303 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6305 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6306 ret->contentNotNull();
6310 MEDFileIntField1TS::MEDFileIntField1TS()
6312 _content=new MEDFileIntField1TSWithoutSDA;
6315 MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
6316 try:MEDFileAnyTypeField1TS(fileName,loadAll)
6319 catch(INTERP_KERNEL::Exception& e)
6322 MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
6323 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll)
6326 catch(INTERP_KERNEL::Exception& e)
6329 MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
6330 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll)
6333 catch(INTERP_KERNEL::Exception& e)
6337 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6338 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6340 * \warning this is a shallow copy constructor
6342 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6346 MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const throw(INTERP_KERNEL::Exception)
6348 return new MEDFileIntField1TS(*this);
6352 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
6353 * following the given input policy.
6355 * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6356 * By default (true) the globals are deeply copied.
6357 * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
6359 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
6361 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret;
6362 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6365 const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
6367 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
6368 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
6369 ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc,getFileName()));
6372 ret=MEDFileField1TS::New();
6374 ret->deepCpyGlobs(*this);
6376 ret->shallowCpyGlobs(*this);
6381 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6382 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6383 * "Sort By Type"), if not, an exception is thrown.
6384 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6385 * \param [in] field - the field to add to \a this. The field double values are ignored.
6386 * \param [in] arrOfVals - the values of the field \a field used.
6387 * \throw If the name of \a field is empty.
6388 * \throw If the data array of \a field is not set.
6389 * \throw If the data array is already allocated but has different number of components
6391 * \throw If the underlying mesh of \a field has no name.
6392 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6394 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals) throw(INTERP_KERNEL::Exception)
6397 contentNotNull()->setFieldNoProfileSBT(field,arrOfVals,*this,*contentNotNull());
6401 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6402 * can be an aggregation of several MEDCouplingFieldDouble instances.
6403 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6404 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6407 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6408 * A new profile is added only if no equal profile is missing.
6409 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6410 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
6411 * \param [in] arrOfVals - the values of the field \a field used.
6412 * \param [in] mesh - the supporting mesh of \a field.
6413 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6414 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6415 * \throw If either \a field or \a mesh or \a profile has an empty name.
6416 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6417 * \throw If the data array of \a field is not set.
6418 * \throw If the data array of \a this is already allocated but has different number of
6419 * components than \a field.
6420 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6421 * \sa setFieldNoProfileSBT()
6423 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
6426 contentNotNull()->setFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6429 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const throw(INTERP_KERNEL::Exception)
6431 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6433 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
6434 const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
6436 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 !");
6440 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6442 if(getFileName2().empty())
6443 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6444 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut2;
6445 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut2,*contentNotNull());
6446 DataArrayInt *arrOutC=dynamic_cast<DataArrayInt *>((DataArray *)arrOut2);
6448 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : mismatch between dataArrays type and MEDFileIntField1TS ! Expected int32 !");
6453 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception)
6455 if(!((DataArray *)arr))
6456 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
6457 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>((DataArray *)arr);
6459 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
6465 * Returns a new MEDCouplingFieldDouble of a given type lying on
6466 * the top level cells of the first mesh in MED file. If \a this field
6467 * has not been constructed via file reading, an exception is thrown.
6468 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6469 * \param [in] type - a spatial discretization of interest.
6470 * \param [out] arrOut - the DataArrayInt containing values of field.
6471 * \param [in] renumPol - specifies how to permute values of the result field according to
6472 * the optional numbers of cells and nodes, if any. The valid values are
6473 * - 0 - do not permute.
6474 * - 1 - permute cells.
6475 * - 2 - permute nodes.
6476 * - 3 - permute cells and nodes.
6478 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6479 * caller is to delete this field using decrRef() as it is no more needed.
6480 * \throw If \a this field has not been constructed via file reading.
6481 * \throw If the MED file is not readable.
6482 * \throw If there is no mesh in the MED file.
6483 * \throw If no field values of the given \a type.
6484 * \throw If no field values lying on the top level support.
6485 * \sa getFieldAtLevel()
6487 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6489 if(getFileName2().empty())
6490 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6491 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6492 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,0,renumPol,this,arr,*contentNotNull());
6493 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6498 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6499 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6500 * \param [in] type - a spatial discretization of the new field.
6501 * \param [in] mesh - the supporting mesh.
6502 * \param [out] arrOut - the DataArrayInt containing values of field.
6503 * \param [in] renumPol - specifies how to permute values of the result field according to
6504 * the optional numbers of cells and nodes, if any. The valid values are
6505 * - 0 - do not permute.
6506 * - 1 - permute cells.
6507 * - 2 - permute nodes.
6508 * - 3 - permute cells and nodes.
6510 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6511 * caller is to delete this field using decrRef() as it is no more needed.
6512 * \throw If no field of \a this is lying on \a mesh.
6513 * \throw If the mesh is empty.
6514 * \throw If no field values of the given \a type are available.
6515 * \sa getFieldAtLevel()
6516 * \sa getFieldOnMeshAtLevel()
6518 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6520 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6521 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNull());
6522 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6527 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6528 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6529 * \param [in] type - a spatial discretization of interest.
6530 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6531 * \param [out] arrOut - the DataArrayInt containing values of field.
6532 * \param [in] mesh - the supporting mesh.
6533 * \param [in] renumPol - specifies how to permute values of the result field according to
6534 * the optional numbers of cells and nodes, if any. The valid values are
6535 * - 0 - do not permute.
6536 * - 1 - permute cells.
6537 * - 2 - permute nodes.
6538 * - 3 - permute cells and nodes.
6540 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6541 * caller is to delete this field using decrRef() as it is no more needed.
6542 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6543 * \throw If no field of \a this is lying on \a mesh.
6544 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6545 * \sa getFieldAtLevel()
6546 * \sa getFieldOnMeshAtLevel()
6548 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6550 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6551 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNull());
6552 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6557 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6558 * This method is called "Old" because in MED3 norm a field has only one meshName
6559 * attached, so this method is for readers of MED2 files. If \a this field
6560 * has not been constructed via file reading, an exception is thrown.
6561 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6562 * \param [in] type - a spatial discretization of interest.
6563 * \param [in] mName - a name of the supporting mesh.
6564 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6565 * \param [out] arrOut - the DataArrayInt containing values of field.
6566 * \param [in] renumPol - specifies how to permute values of the result field according to
6567 * the optional numbers of cells and nodes, if any. The valid values are
6568 * - 0 - do not permute.
6569 * - 1 - permute cells.
6570 * - 2 - permute nodes.
6571 * - 3 - permute cells and nodes.
6573 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6574 * caller is to delete this field using decrRef() as it is no more needed.
6575 * \throw If the MED file is not readable.
6576 * \throw If there is no mesh named \a mName in the MED file.
6577 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6578 * \throw If \a this field has not been constructed via file reading.
6579 * \throw If no field of \a this is lying on the mesh named \a mName.
6580 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6581 * \sa getFieldAtLevel()
6583 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6585 if(getFileName2().empty())
6586 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6587 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6588 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNull());
6589 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6594 * Returns values and a profile of the field of a given type lying on a given support.
6595 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6596 * \param [in] type - a spatial discretization of the field.
6597 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6598 * \param [in] mesh - the supporting mesh.
6599 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6600 * field of interest lies on. If the field lies on all entities of the given
6601 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6602 * using decrRef() as it is no more needed.
6603 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
6604 * field. The caller is to delete this array using decrRef() as it is no more needed.
6605 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6606 * \throw If no field of \a this is lying on \a mesh.
6607 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6609 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
6611 MEDCouplingAutoRefCountObjectPtr<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6612 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6615 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() throw(INTERP_KERNEL::Exception)
6617 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6619 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
6620 MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
6622 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 !");
6626 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
6628 return contentNotNull()->getUndergroundDataArrayInt();
6631 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
6633 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
6637 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const char *fieldName):MEDFileFieldNameScope(fieldName)
6642 * \param [in] fieldId field id in C mode
6644 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll) throw(INTERP_KERNEL::Exception)
6646 med_field_type typcha;
6647 std::string dtunitOut;
6648 int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,"",fieldId,false,_name,typcha,_infos,dtunitOut);
6649 setDtUnit(dtunitOut.c_str());
6650 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll);
6653 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)
6654 try:MEDFileFieldNameScope(fieldName),_infos(infos)
6656 setDtUnit(dtunit.c_str());
6657 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll);
6659 catch(INTERP_KERNEL::Exception& e)
6664 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySize() const
6666 std::size_t ret=_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA>);
6667 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
6668 ret+=(*it).capacity();
6669 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6670 if((const MEDFileAnyTypeField1TSWithoutSDA *)(*it))
6671 ret+=(*it)->getHeapMemorySize();
6676 * 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
6679 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception)
6681 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6682 ret->setInfo(_infos);
6683 int sz=(int)_time_steps.size();
6684 for(const int *id=startIds;id!=endIds;id++)
6686 if(*id>=0 && *id<sz)
6688 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
6689 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6693 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6695 ret->pushBackTimeStep(tse2);
6699 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
6700 oss << " ! Should be in [0," << sz << ") !";
6701 throw INTERP_KERNEL::Exception(oss.str().c_str());
6704 if(ret->getNumberOfTS()>0)
6705 ret->synchronizeNameScope();
6706 ret->copyNameScope(*this);
6711 * 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
6714 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const throw(INTERP_KERNEL::Exception)
6716 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
6717 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
6718 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6719 ret->setInfo(_infos);
6720 int sz=(int)_time_steps.size();
6722 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
6726 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
6727 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6731 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6733 ret->pushBackTimeStep(tse2);
6737 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
6738 oss << " ! Should be in [0," << sz << ") !";
6739 throw INTERP_KERNEL::Exception(oss.str().c_str());
6742 if(ret->getNumberOfTS()>0)
6743 ret->synchronizeNameScope();
6744 ret->copyNameScope(*this);
6748 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
6751 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
6752 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
6754 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6757 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
6758 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
6759 ids->pushBackSilent(id);
6761 return buildFromTimeStepIds(ids->begin(),ids->end());
6764 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
6767 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
6768 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
6770 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6773 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
6774 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
6775 ids->pushBackSilent(id);
6777 return buildFromTimeStepIds(ids->begin(),ids->end());
6780 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const throw(INTERP_KERNEL::Exception)
6785 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception)
6790 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6793 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
6795 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
6796 if(pt->isDealingTS(iteration,order))
6799 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
6800 std::vector< std::pair<int,int> > vp=getIterations();
6801 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
6802 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
6803 throw INTERP_KERNEL::Exception(oss.str().c_str());
6806 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6808 return *_time_steps[getTimeStepPos(iteration,order)];
6811 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) throw(INTERP_KERNEL::Exception)
6813 return *_time_steps[getTimeStepPos(iteration,order)];
6816 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const throw(INTERP_KERNEL::Exception)
6818 if(_time_steps.empty())
6819 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
6820 return _time_steps[0]->getMeshName();
6823 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
6825 std::string oldName(getMeshName());
6826 std::vector< std::pair<std::string,std::string> > v(1);
6827 v[0].first=oldName; v[0].second=newMeshName;
6831 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
6834 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6836 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6838 ret=cur->changeMeshNames(modifTab) || ret;
6844 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
6846 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6848 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
6852 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
6854 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)
6856 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
6859 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
6860 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
6863 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6865 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
6867 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
6872 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
6874 std::string startLine(bkOffset,' ');
6875 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
6877 oss << " (" << fmtsId << ")";
6878 oss << " has the following name: \"" << _name << "\"." << std::endl;
6879 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
6880 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
6882 oss << startLine << " - \"" << *it << "\"" << std::endl;
6885 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
6887 std::string chapter(17,'0'+i);
6888 oss << startLine << chapter << std::endl;
6889 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
6891 cur->simpleRepr(bkOffset+2,oss,i);
6893 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
6894 oss << startLine << chapter << std::endl;
6898 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception)
6900 std::size_t sz=_time_steps.size();
6901 std::vector< std::pair<int,int> > ret(sz);
6903 for(std::size_t i=0;i<sz;i++)
6905 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
6908 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
6912 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
6913 throw INTERP_KERNEL::Exception(oss.str().c_str());
6919 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>& tse) throw(INTERP_KERNEL::Exception)
6921 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
6923 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
6924 checkCoherencyOfType(tse2);
6925 if(_time_steps.empty())
6927 setName(tse2->getName().c_str());
6928 setInfo(tse2->getInfo());
6930 checkThatComponentsMatch(tse2->getInfo());
6931 _time_steps.push_back(tse);
6934 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope() throw(INTERP_KERNEL::Exception)
6936 std::size_t nbOfCompo=_infos.size();
6937 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6939 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
6942 if((cur->getInfo()).size()!=nbOfCompo)
6944 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
6945 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
6946 throw INTERP_KERNEL::Exception(oss.str().c_str());
6948 cur->copyNameScope(*this);
6953 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll) throw(INTERP_KERNEL::Exception)
6955 _time_steps.resize(nbPdt);
6956 for(int i=0;i<nbPdt;i++)
6958 std::vector< std::pair<int,int> > ts;
6959 med_int numdt=0,numo=0;
6960 med_int meshIt=0,meshOrder=0;
6962 MEDfieldComputingStepMeshInfo(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder);
6967 _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
6972 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
6976 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
6979 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this);
6981 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this);
6985 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const throw(INTERP_KERNEL::Exception)
6987 if(_time_steps.empty())
6988 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
6989 checkThatNbOfCompoOfTSMatchThis();
6990 std::vector<std::string> infos(getInfo());
6991 int nbComp=infos.size();
6992 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
6993 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
6994 for(int i=0;i<nbComp;i++)
6996 std::string info=infos[i];
6998 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
6999 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7000 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7003 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7004 MEDfieldCr(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
7005 int nbOfTS=_time_steps.size();
7006 for(int i=0;i<nbOfTS;i++)
7007 _time_steps[i]->writeLL(fid,opts,*this);
7010 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
7012 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7014 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7016 elt->loadBigArraysRecursively(fid,nasc);
7020 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
7022 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7024 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7026 elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7030 void MEDFileAnyTypeFieldMultiTSWithoutSDA::releaseArrays() throw(INTERP_KERNEL::Exception)
7032 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7034 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7036 elt->releaseArrays();
7040 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7042 return _time_steps.size();
7045 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS() throw(INTERP_KERNEL::Exception)
7047 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7048 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7050 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7052 newTS.push_back(*it);
7057 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
7059 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7060 int maxId=(int)_time_steps.size();
7062 std::set<int> idsToDel;
7063 for(const int *id=startIds;id!=endIds;id++,ii++)
7065 if(*id>=0 && *id<maxId)
7067 idsToDel.insert(*id);
7071 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7072 throw INTERP_KERNEL::Exception(oss.str().c_str());
7075 for(int iii=0;iii<maxId;iii++)
7076 if(idsToDel.find(iii)==idsToDel.end())
7077 newTS.push_back(_time_steps[iii]);
7081 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step) throw(INTERP_KERNEL::Exception)
7083 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7084 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7085 if(nbOfEntriesToKill==0)
7087 std::size_t sz=_time_steps.size();
7088 std::vector<bool> b(sz,true);
7090 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7092 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7093 for(std::size_t i=0;i<sz;i++)
7095 newTS.push_back(_time_steps[i]);
7099 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
7102 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
7103 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7105 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7109 tmp->getTime(it2,ord);
7110 if(it2==iteration && order==ord)
7113 oss << "(" << it2 << "," << ord << "), ";
7116 throw INTERP_KERNEL::Exception(oss.str().c_str());
7119 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
7122 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
7124 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7126 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7130 double ti=tmp->getTime(it2,ord);
7131 if(fabs(time-ti)<eps)
7137 throw INTERP_KERNEL::Exception(oss.str().c_str());
7140 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
7142 int lgth=_time_steps.size();
7143 std::vector< std::pair<int,int> > ret(lgth);
7144 for(int i=0;i<lgth;i++)
7145 _time_steps[i]->fillIteration(ret[i]);
7150 * 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'
7151 * This method returns two things.
7152 * - The absolute dimension of 'this' in first parameter.
7153 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7154 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
7156 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7157 * Only these 3 discretizations will be taken into account here.
7159 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7160 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7161 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7163 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7164 * 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'.
7166 * Let's consider the typical following case :
7167 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7168 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7169 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7171 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7173 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7175 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7176 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7177 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7178 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7180 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
7182 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7185 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const throw(INTERP_KERNEL::Exception)
7187 if(pos<0 || pos>=(int)_time_steps.size())
7189 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7190 throw INTERP_KERNEL::Exception(oss.str().c_str());
7192 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7195 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7196 oss << "\nTry to use following method eraseEmptyTS !";
7197 throw INTERP_KERNEL::Exception(oss.str().c_str());
7202 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) throw(INTERP_KERNEL::Exception)
7204 if(pos<0 || pos>=(int)_time_steps.size())
7206 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7207 throw INTERP_KERNEL::Exception(oss.str().c_str());
7209 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7212 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7213 oss << "\nTry to use following method eraseEmptyTS !";
7214 throw INTERP_KERNEL::Exception(oss.str().c_str());
7219 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
7221 std::vector<std::string> ret;
7222 std::set<std::string> ret2;
7223 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7225 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
7226 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7227 if(ret2.find(*it2)==ret2.end())
7229 ret.push_back(*it2);
7236 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
7238 std::vector<std::string> ret;
7239 std::set<std::string> ret2;
7240 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7242 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
7243 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7244 if(ret2.find(*it2)==ret2.end())
7246 ret.push_back(*it2);
7253 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
7255 std::vector<std::string> ret;
7256 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7258 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
7259 ret.insert(ret.end(),tmp.begin(),tmp.end());
7264 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
7266 std::vector<std::string> ret;
7267 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7269 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
7270 ret.insert(ret.end(),tmp.begin(),tmp.end());
7275 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7277 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7278 (*it)->changePflsRefsNamesGen2(mapOfModif);
7281 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7283 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7284 (*it)->changeLocsRefsNamesGen2(mapOfModif);
7287 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
7289 int lgth=_time_steps.size();
7290 std::vector< std::vector<TypeOfField> > ret(lgth);
7291 for(int i=0;i<lgth;i++)
7292 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
7297 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
7299 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)
7301 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
7304 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
7306 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
7308 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7310 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
7311 ret->_time_steps[i]=(*it)->deepCpy();
7316 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const throw(INTERP_KERNEL::Exception)
7318 std::size_t sz(_infos.size()),sz2(_time_steps.size());
7319 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7320 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7321 for(std::size_t i=0;i<sz;i++)
7323 ret[i]=shallowCpy();
7324 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7326 for(std::size_t i=0;i<sz2;i++)
7328 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7331 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7332 throw INTERP_KERNEL::Exception(oss.str().c_str());
7336 for(std::size_t i=0;i<sz;i++)
7337 for(std::size_t j=0;j<sz2;j++)
7338 ret[i]->_time_steps[j]=ts[j][i];
7343 * This method splits into discretization each time steps in \a this.
7344 * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
7346 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const throw(INTERP_KERNEL::Exception)
7348 std::size_t sz(_time_steps.size());
7349 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7350 for(std::size_t i=0;i<sz;i++)
7352 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7355 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
7356 throw INTERP_KERNEL::Exception(oss.str().c_str());
7358 items[i]=timeStep->splitDiscretizations();
7361 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
7362 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
7363 std::vector< TypeOfField > types;
7364 for(std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7365 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7367 std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
7369 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
7370 std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
7371 if(it2==types.end())
7372 types.push_back(ts[0]);
7374 ret.resize(types.size()); ret2.resize(types.size());
7375 for(std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7376 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7378 TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
7379 std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
7380 ret2[pos].push_back(*it1);
7382 for(std::size_t i=0;i<types.size();i++)
7384 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=createNew();
7385 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
7386 elt->pushBackTimeStep(*it1);//also updates infos in elt
7388 elt->MEDFileFieldNameScope::operator=(*this);
7393 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception)
7395 _name=field->getName();
7397 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
7399 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
7400 _infos=arr->getInfoOnComponents();
7403 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const throw(INTERP_KERNEL::Exception)
7405 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
7406 if(_name!=field->getName())
7408 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
7409 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
7410 throw INTERP_KERNEL::Exception(oss.str().c_str());
7413 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
7414 checkThatComponentsMatch(arr->getInfoOnComponents());
7417 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const throw(INTERP_KERNEL::Exception)
7419 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
7420 if(getInfo().size()!=compos.size())
7422 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
7423 oss << " number of components of element to append (" << compos.size() << ") !";
7424 throw INTERP_KERNEL::Exception(oss.str().c_str());
7428 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
7429 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
7430 oss << " But compo in input fields are : ";
7431 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
7433 throw INTERP_KERNEL::Exception(oss.str().c_str());
7437 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const throw(INTERP_KERNEL::Exception)
7439 std::size_t sz=_infos.size();
7441 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
7443 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7445 if(elt->getInfo().size()!=sz)
7447 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
7448 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
7449 throw INTERP_KERNEL::Exception(oss.str().c_str());
7454 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
7457 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7458 if(!_time_steps.empty())
7459 checkCoherencyOfTinyInfo(field,arr);
7460 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
7461 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7462 objC->setFieldNoProfileSBT(field,arr,glob,*this);
7463 copyTinyInfoFrom(field,arr);
7464 _time_steps.push_back(obj);
7467 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
7470 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7471 if(!_time_steps.empty())
7472 checkCoherencyOfTinyInfo(field,arr);
7473 MEDFileField1TSWithoutSDA *objC=new MEDFileField1TSWithoutSDA;
7474 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7475 objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
7476 copyTinyInfoFrom(field,arr);
7477 _time_steps.push_back(obj);
7480 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ts) throw(INTERP_KERNEL::Exception)
7482 int sz=(int)_time_steps.size();
7485 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
7486 throw INTERP_KERNEL::Exception(oss.str().c_str());
7488 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
7491 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
7493 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
7494 throw INTERP_KERNEL::Exception(oss.str().c_str());
7500 //= MEDFileFieldMultiTSWithoutSDA
7502 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)
7504 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll);
7507 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
7511 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const char *fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7516 * \param [in] fieldId field id in C mode
7518 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll) throw(INTERP_KERNEL::Exception)
7519 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll)
7522 catch(INTERP_KERNEL::Exception& e)
7525 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)
7526 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll)
7529 catch(INTERP_KERNEL::Exception& e)
7532 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const throw(INTERP_KERNEL::Exception)
7534 return new MEDFileField1TSWithoutSDA;
7537 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const throw(INTERP_KERNEL::Exception)
7540 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7541 const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
7543 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
7546 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
7548 return MEDFileField1TSWithoutSDA::TYPE_STR;
7551 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
7553 return new MEDFileFieldMultiTSWithoutSDA(*this);
7556 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const throw(INTERP_KERNEL::Exception)
7558 return new MEDFileFieldMultiTSWithoutSDA;
7562 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
7563 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
7565 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)
7567 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
7568 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
7570 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
7571 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
7574 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const throw(INTERP_KERNEL::Exception)
7576 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
7577 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
7579 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7581 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
7584 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
7586 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
7587 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
7588 ret->setIteration(i,elt);
7594 //= MEDFileAnyTypeFieldMultiTS
7596 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
7600 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
7601 try:MEDFileFieldGlobsReal(fileName)
7603 MEDFileUtilities::CheckFileForRead(fileName);
7604 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7605 _content=BuildContentFrom(fid,fileName,loadAll);
7608 catch(INTERP_KERNEL::Exception& e)
7613 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
7615 med_field_type typcha;
7616 std::vector<std::string> infos;
7619 MEDFileAnyTypeField1TS::LocateField(fid,fileName,fieldName,i,typcha,infos,dtunit);
7620 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7625 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll);
7630 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll);
7635 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] !";
7636 throw INTERP_KERNEL::Exception(oss.str().c_str());
7639 ret->setDtUnit(dtunit.c_str());
7643 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
7645 med_field_type typcha;
7647 std::vector<std::string> infos;
7648 std::string dtunit,fieldName;
7649 MEDFileAnyTypeField1TS::LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
7650 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7655 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll);
7660 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll);
7665 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] !";
7666 throw INTERP_KERNEL::Exception(oss.str().c_str());
7669 ret->setDtUnit(dtunit.c_str());
7673 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, const char *fileName) throw(INTERP_KERNEL::Exception)
7676 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
7677 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
7679 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=MEDFileFieldMultiTS::New();
7680 ret->setFileName(fileName);
7681 ret->_content=c; c->incrRef();
7684 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
7686 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=MEDFileIntFieldMultiTS::New();
7687 ret->setFileName(fileName);
7688 ret->_content=c; c->incrRef();
7691 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
7694 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
7695 try:MEDFileFieldGlobsReal(fileName)
7697 MEDFileUtilities::CheckFileForRead(fileName);
7698 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7699 _content=BuildContentFrom(fid,fileName,fieldName,loadAll);
7702 catch(INTERP_KERNEL::Exception& e)
7707 //= MEDFileIntFieldMultiTSWithoutSDA
7709 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)
7711 return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll);
7714 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
7718 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const char *fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7722 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)
7723 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll)
7726 catch(INTERP_KERNEL::Exception& e)
7730 * \param [in] fieldId field id in C mode
7732 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll) throw(INTERP_KERNEL::Exception)
7733 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll)
7736 catch(INTERP_KERNEL::Exception& e)
7739 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const throw(INTERP_KERNEL::Exception)
7741 return new MEDFileIntField1TSWithoutSDA;
7744 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const throw(INTERP_KERNEL::Exception)
7747 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7748 const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
7750 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
7753 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
7755 return MEDFileIntField1TSWithoutSDA::TYPE_STR;
7758 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
7760 return new MEDFileIntFieldMultiTSWithoutSDA(*this);
7763 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const throw(INTERP_KERNEL::Exception)
7765 return new MEDFileIntFieldMultiTSWithoutSDA;
7768 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const throw(INTERP_KERNEL::Exception)
7770 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
7771 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
7773 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7775 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
7778 const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
7780 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
7781 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
7782 ret->setIteration(i,elt);
7788 //= MEDFileAnyTypeFieldMultiTS
7791 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
7792 * that has been read from a specified MED file.
7793 * \param [in] fileName - the name of the MED file to read.
7794 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
7795 * is to delete this field using decrRef() as it is no more needed.
7796 * \throw If reading the file fails.
7798 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
7800 MEDFileUtilities::CheckFileForRead(fileName);
7801 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7802 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll);
7803 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
7804 ret->loadGlobals(fid);
7809 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
7810 * that has been read from a specified MED file.
7811 * \param [in] fileName - the name of the MED file to read.
7812 * \param [in] fieldName - the name of the field to read.
7813 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
7814 * is to delete this field using decrRef() as it is no more needed.
7815 * \throw If reading the file fails.
7816 * \throw If there is no field named \a fieldName in the file.
7818 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
7820 MEDFileUtilities::CheckFileForRead(fileName);
7821 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7822 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll);
7823 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
7824 ret->loadGlobals(fid);
7829 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
7830 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
7832 * \warning this is a shallow copy constructor
7834 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
7836 if(!shallowCopyOfContent)
7838 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
7839 otherPtr->incrRef();
7840 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
7844 _content=other.shallowCpy();
7848 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() throw(INTERP_KERNEL::Exception)
7850 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
7852 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
7856 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const throw(INTERP_KERNEL::Exception)
7858 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
7860 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
7864 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
7866 return contentNotNullBase()->getPflsReallyUsed2();
7869 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
7871 return contentNotNullBase()->getLocsReallyUsed2();
7874 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
7876 return contentNotNullBase()->getPflsReallyUsedMulti2();
7879 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
7881 return contentNotNullBase()->getLocsReallyUsedMulti2();
7884 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7886 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
7889 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7891 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
7894 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
7896 return contentNotNullBase()->getNumberOfTS();
7899 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS() throw(INTERP_KERNEL::Exception)
7901 contentNotNullBase()->eraseEmptyTS();
7904 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
7906 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
7909 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step) throw(INTERP_KERNEL::Exception)
7911 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
7914 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception)
7916 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
7917 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
7922 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const throw(INTERP_KERNEL::Exception)
7924 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
7925 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
7930 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
7932 return contentNotNullBase()->getIterations();
7935 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts) throw(INTERP_KERNEL::Exception)
7937 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
7938 pushBackTimeStep(*it);
7941 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts) throw(INTERP_KERNEL::Exception)
7944 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
7945 checkCoherencyOfType(f1ts);
7947 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
7948 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
7950 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
7951 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
7952 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
7953 _content->pushBackTimeStep(cSafe);
7954 appendGlobs(*f1ts,1e-12);
7957 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope() throw(INTERP_KERNEL::Exception)
7959 contentNotNullBase()->synchronizeNameScope();
7962 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
7964 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
7967 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
7969 return contentNotNullBase()->getPosGivenTime(time,eps);
7972 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
7974 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
7977 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
7979 return contentNotNullBase()->getTypesOfFieldAvailable();
7982 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)
7984 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
7987 std::string MEDFileAnyTypeFieldMultiTS::getName() const
7989 return contentNotNullBase()->getName();
7992 void MEDFileAnyTypeFieldMultiTS::setName(const char *name)
7994 contentNotNullBase()->setName(name);
7997 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const throw(INTERP_KERNEL::Exception)
7999 return contentNotNullBase()->getDtUnit();
8002 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception)
8004 contentNotNullBase()->setDtUnit(dtUnit);
8007 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8009 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
8012 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception)
8014 return contentNotNullBase()->getTimeSteps(ret1);
8017 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const throw(INTERP_KERNEL::Exception)
8019 return contentNotNullBase()->getMeshName();
8022 void MEDFileAnyTypeFieldMultiTS::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
8024 contentNotNullBase()->setMeshName(newMeshName);
8027 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
8029 return contentNotNullBase()->changeMeshNames(modifTab);
8032 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const throw(INTERP_KERNEL::Exception)
8034 return contentNotNullBase()->getInfo();
8037 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception)
8039 return contentNotNullBase()->setInfo(info);
8042 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const throw(INTERP_KERNEL::Exception)
8044 const std::vector<std::string> ret=getInfo();
8045 return (int)ret.size();
8048 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
8050 writeGlobals(fid,*this);
8051 contentNotNullBase()->writeLL(fid,*this);
8055 * Writes \a this field into a MED file specified by its name.
8056 * \param [in] fileName - the MED file name.
8057 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
8058 * - 2 - erase; an existing file is removed.
8059 * - 1 - append; same data should not be present in an existing file.
8060 * - 0 - overwrite; same data present in an existing file is overwritten.
8061 * \throw If the field name is not set.
8062 * \throw If no field data is set.
8063 * \throw If \a mode == 1 and the same data is present in an existing file.
8065 void MEDFileAnyTypeFieldMultiTS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
8067 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
8068 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
8073 * This method alloc the arrays and load potentially huge arrays contained in this field.
8074 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
8075 * This method can be also called to refresh or reinit values from a file.
8077 * \throw If the fileName is not set or points to a non readable MED file.
8079 void MEDFileAnyTypeFieldMultiTS::loadArrays() throw(INTERP_KERNEL::Exception)
8081 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
8082 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
8086 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
8087 * But once data loaded once, this method does nothing.
8089 * \throw If the fileName is not set or points to a non readable MED file.
8090 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::releaseArrays
8092 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary() throw(INTERP_KERNEL::Exception)
8094 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
8095 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
8099 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
8100 * This method does not release arrays set outside the context of a MED file.
8102 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
8104 void MEDFileAnyTypeFieldMultiTS::releaseArrays() throw(INTERP_KERNEL::Exception)
8106 contentNotNullBase()->releaseArrays();
8109 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
8111 std::ostringstream oss;
8112 contentNotNullBase()->simpleRepr(0,oss,-1);
8113 simpleReprGlobs(oss);
8117 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySize() const
8120 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)_content)
8121 ret+=_content->getHeapMemorySize();
8122 return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
8126 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
8127 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8128 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
8130 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const throw(INTERP_KERNEL::Exception)
8132 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8134 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
8135 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
8136 std::size_t sz(contentsSplit.size());
8137 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8138 for(std::size_t i=0;i<sz;i++)
8140 ret[i]=shallowCpy();
8141 ret[i]->_content=contentsSplit[i];
8147 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
8148 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8150 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const throw(INTERP_KERNEL::Exception)
8152 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8154 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
8155 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitDiscretizations();
8156 std::size_t sz(contentsSplit.size());
8157 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8158 for(std::size_t i=0;i<sz;i++)
8160 ret[i]=shallowCpy();
8161 ret[i]->_content=contentsSplit[i];
8166 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCpy() const throw(INTERP_KERNEL::Exception)
8168 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8169 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
8170 ret->_content=_content->deepCpy();
8171 ret->deepCpyGlobs(*this);
8175 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
8181 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8182 * \param [in] iteration - the iteration number of a required time step.
8183 * \param [in] order - the iteration order number of required time step.
8184 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
8185 * delete this field using decrRef() as it is no more needed.
8186 * \throw If there is no required time step in \a this field.
8188 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
8190 int pos=getPosOfTimeStep(iteration,order);
8191 return getTimeStepAtPos(pos);
8195 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8196 * \param [in] time - the time of the time step of interest.
8197 * \param [in] eps - a precision used to compare time values.
8198 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8199 * delete this field using decrRef() as it is no more needed.
8200 * \throw If there is no required time step in \a this field.
8202 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
8204 int pos=getPosGivenTime(time,eps);
8205 return getTimeStepAtPos(pos);
8209 * This method groups not null items in \a vectFMTS per time step series. Two time series are considered equal if the list of their pair of integers iteration,order are equal.
8210 * The float64 value of time attached to the pair of integers are not considered here.
8212 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
8213 * \throw If there is a null pointer in \a vectFMTS.
8215 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS) throw(INTERP_KERNEL::Exception)
8217 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
8218 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8219 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8220 while(!lstFMTS.empty())
8222 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8223 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8225 throw INTERP_KERNEL::Exception(msg);
8226 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
8227 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8228 elt.push_back(curIt); it=lstFMTS.erase(it);
8229 while(it!=lstFMTS.end())
8233 throw INTERP_KERNEL::Exception(msg);
8234 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
8236 { elt.push_back(curIt); it=lstFMTS.erase(it);}
8245 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator() throw(INTERP_KERNEL::Exception)
8247 return new MEDFileAnyTypeFieldMultiTSIterator(this);
8250 //= MEDFileFieldMultiTS
8253 * Returns a new empty instance of MEDFileFieldMultiTS.
8254 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8255 * is to delete this field using decrRef() as it is no more needed.
8257 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
8259 return new MEDFileFieldMultiTS;
8263 * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
8264 * that has been read from a specified MED file.
8265 * \param [in] fileName - the name of the MED file to read.
8266 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8267 * is to delete this field using decrRef() as it is no more needed.
8268 * \throw If reading the file fails.
8270 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
8272 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,loadAll);
8273 ret->contentNotNull();//to check that content type matches with \a this type.
8278 * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
8279 * that has been read from a specified MED file.
8280 * \param [in] fileName - the name of the MED file to read.
8281 * \param [in] fieldName - the name of the field to read.
8282 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8283 * is to delete this field using decrRef() as it is no more needed.
8284 * \throw If reading the file fails.
8285 * \throw If there is no field named \a fieldName in the file.
8287 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
8289 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,fieldName,loadAll);
8290 ret->contentNotNull();//to check that content type matches with \a this type.
8295 * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8296 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8298 * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
8299 * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
8300 * \warning this is a shallow copy constructor
8301 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
8302 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
8303 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8304 * is to delete this field using decrRef() as it is no more needed.
8306 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8308 return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
8311 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const throw(INTERP_KERNEL::Exception)
8313 return new MEDFileFieldMultiTS(*this);
8316 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const throw(INTERP_KERNEL::Exception)
8319 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8320 const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
8322 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8326 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
8327 * following the given input policy.
8329 * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
8330 * By default (true) the globals are deeply copied.
8331 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
8333 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
8335 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret;
8336 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8339 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
8341 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
8342 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
8343 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc,getFileName()));
8346 ret=MEDFileIntFieldMultiTS::New();
8348 ret->deepCpyGlobs(*this);
8350 ret->shallowCpyGlobs(*this);
8355 * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
8356 * \param [in] pos - a time step id.
8357 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8358 * delete this field using decrRef() as it is no more needed.
8359 * \throw If \a pos is not a valid time step id.
8361 MEDFileAnyTypeField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception)
8363 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
8366 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
8367 throw INTERP_KERNEL::Exception(oss.str().c_str());
8369 const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
8372 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
8373 ret->shallowCpyGlobs(*this);
8376 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
8377 throw INTERP_KERNEL::Exception(oss.str().c_str());
8381 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8382 * mesh entities of a given dimension of the first mesh in MED file.
8383 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8384 * \param [in] type - a spatial discretization of interest.
8385 * \param [in] iteration - the iteration number of a required time step.
8386 * \param [in] order - the iteration order number of required time step.
8387 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8388 * \param [in] renumPol - specifies how to permute values of the result field according to
8389 * the optional numbers of cells and nodes, if any. The valid values are
8390 * - 0 - do not permute.
8391 * - 1 - permute cells.
8392 * - 2 - permute nodes.
8393 * - 3 - permute cells and nodes.
8395 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8396 * caller is to delete this field using decrRef() as it is no more needed.
8397 * \throw If the MED file is not readable.
8398 * \throw If there is no mesh in the MED file.
8399 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8400 * \throw If no field values of the required parameters are available.
8402 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
8404 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8405 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8407 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
8408 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8409 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut,*contentNotNullBase());
8410 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8415 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8416 * the top level cells of the first mesh in MED file.
8417 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8418 * \param [in] type - a spatial discretization of interest.
8419 * \param [in] iteration - the iteration number of a required time step.
8420 * \param [in] order - the iteration order number of required time step.
8421 * \param [in] renumPol - specifies how to permute values of the result field according to
8422 * the optional numbers of cells and nodes, if any. The valid values are
8423 * - 0 - do not permute.
8424 * - 1 - permute cells.
8425 * - 2 - permute nodes.
8426 * - 3 - permute cells and nodes.
8428 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8429 * caller is to delete this field using decrRef() as it is no more needed.
8430 * \throw If the MED file is not readable.
8431 * \throw If there is no mesh in the MED file.
8432 * \throw If no field values of the required parameters are available.
8434 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const throw(INTERP_KERNEL::Exception)
8436 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8437 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8439 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
8440 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8441 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,0,renumPol,this,arrOut,*contentNotNullBase());
8442 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8447 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8449 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8450 * \param [in] type - a spatial discretization of interest.
8451 * \param [in] iteration - the iteration number of a required time step.
8452 * \param [in] order - the iteration order number of required time step.
8453 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8454 * \param [in] mesh - the supporting mesh.
8455 * \param [in] renumPol - specifies how to permute values of the result field according to
8456 * the optional numbers of cells and nodes, if any. The valid values are
8457 * - 0 - do not permute.
8458 * - 1 - permute cells.
8459 * - 2 - permute nodes.
8460 * - 3 - permute cells and nodes.
8462 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8463 * caller is to delete this field using decrRef() as it is no more needed.
8464 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8465 * \throw If no field of \a this is lying on \a mesh.
8466 * \throw If no field values of the required parameters are available.
8468 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
8470 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8471 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8473 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
8474 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8475 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
8476 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8481 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
8483 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8484 * \param [in] type - a spatial discretization of the new field.
8485 * \param [in] iteration - the iteration number of a required time step.
8486 * \param [in] order - the iteration order number of required time step.
8487 * \param [in] mesh - the supporting mesh.
8488 * \param [in] renumPol - specifies how to permute values of the result field according to
8489 * the optional numbers of cells and nodes, if any. The valid values are
8490 * - 0 - do not permute.
8491 * - 1 - permute cells.
8492 * - 2 - permute nodes.
8493 * - 3 - permute cells and nodes.
8495 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8496 * caller is to delete this field using decrRef() as it is no more needed.
8497 * \throw If no field of \a this is lying on \a mesh.
8498 * \throw If no field values of the required parameters are available.
8500 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
8502 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8503 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8505 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
8506 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8507 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
8508 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8513 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
8514 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
8515 * This method is useful for MED2 file format when field on different mesh was autorized.
8517 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const char *mname, int iteration, int order, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
8519 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8520 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8522 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
8523 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8524 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
8525 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8530 * Returns values and a profile of the field of a given type, of a given time step,
8531 * lying on a given support.
8532 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8533 * \param [in] type - a spatial discretization of the field.
8534 * \param [in] iteration - the iteration number of a required time step.
8535 * \param [in] order - the iteration order number of required time step.
8536 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8537 * \param [in] mesh - the supporting mesh.
8538 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
8539 * field of interest lies on. If the field lies on all entities of the given
8540 * dimension, all ids in \a pfl are zero. The caller is to delete this array
8541 * using decrRef() as it is no more needed.
8542 * \param [in] glob - the global data storing profiles and localization.
8543 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
8544 * field. The caller is to delete this array using decrRef() as it is no more needed.
8545 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8546 * \throw If no field of \a this is lying on \a mesh.
8547 * \throw If no field values of the required parameters are available.
8549 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
8551 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8552 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8554 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
8555 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
8556 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
8559 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const throw(INTERP_KERNEL::Exception)
8561 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8563 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
8564 const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
8566 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 !");
8570 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() throw(INTERP_KERNEL::Exception)
8572 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8574 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
8575 MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
8577 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 !");
8582 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
8583 * the given field is checked if its elements are sorted suitable for writing to MED file
8584 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
8585 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8586 * \param [in] field - the field to add to \a this.
8587 * \throw If the name of \a field is empty.
8588 * \throw If the data array of \a field is not set.
8589 * \throw If existing time steps have different name or number of components than \a field.
8590 * \throw If the underlying mesh of \a field has no name.
8591 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
8593 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
8595 const DataArrayDouble *arr=0;
8597 arr=field->getArray();
8598 contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
8602 * Adds a MEDCouplingFieldDouble to \a this as another time step.
8603 * The mesh support of input parameter \a field is ignored here, it can be NULL.
8604 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
8607 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
8608 * A new profile is added only if no equal profile is missing.
8609 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8610 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
8611 * \param [in] mesh - the supporting mesh of \a field.
8612 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
8613 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
8614 * \throw If either \a field or \a mesh or \a profile has an empty name.
8615 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8616 * \throw If the data array of \a field is not set.
8617 * \throw If the data array of \a this is already allocated but has different number of
8618 * components than \a field.
8619 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
8620 * \sa setFieldNoProfileSBT()
8622 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
8624 const DataArrayDouble *arr=0;
8626 arr=field->getArray();
8627 contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
8630 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
8632 _content=new MEDFileFieldMultiTSWithoutSDA;
8635 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
8636 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll)
8639 catch(INTERP_KERNEL::Exception& e)
8642 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
8643 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll)
8646 catch(INTERP_KERNEL::Exception& e)
8649 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
8653 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)
8655 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
8658 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
8660 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
8663 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)
8665 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
8668 //= MEDFileAnyTypeFieldMultiTSIterator
8670 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
8675 _nb_iter=fmts->getNumberOfTS();
8679 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
8683 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt() throw(INTERP_KERNEL::Exception)
8685 if(_iter_id<_nb_iter)
8687 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
8689 return fmts->getTimeStepAtPos(_iter_id++);
8697 //= MEDFileIntFieldMultiTS
8700 * Returns a new empty instance of MEDFileFieldMultiTS.
8701 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8702 * is to delete this field using decrRef() as it is no more needed.
8704 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
8706 return new MEDFileIntFieldMultiTS;
8710 * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
8711 * that has been read from a specified MED file.
8712 * \param [in] fileName - the name of the MED file to read.
8713 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8714 * is to delete this field using decrRef() as it is no more needed.
8715 * \throw If reading the file fails.
8717 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
8719 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,loadAll);
8720 ret->contentNotNull();//to check that content type matches with \a this type.
8725 * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
8726 * that has been read from a specified MED file.
8727 * \param [in] fileName - the name of the MED file to read.
8728 * \param [in] fieldName - the name of the field to read.
8729 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8730 * is to delete this field using decrRef() as it is no more needed.
8731 * \throw If reading the file fails.
8732 * \throw If there is no field named \a fieldName in the file.
8734 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
8736 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll);
8737 ret->contentNotNull();//to check that content type matches with \a this type.
8742 * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8743 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8745 * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
8746 * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
8747 * \warning this is a shallow copy constructor
8748 * \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
8749 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
8750 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8751 * is to delete this field using decrRef() as it is no more needed.
8753 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8755 return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
8759 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
8760 * following the given input policy.
8762 * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
8763 * By default (true) the globals are deeply copied.
8764 * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
8766 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
8768 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret;
8769 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8772 const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
8774 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
8775 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
8776 ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc,getFileName()));
8779 ret=MEDFileFieldMultiTS::New();
8781 ret->deepCpyGlobs(*this);
8783 ret->shallowCpyGlobs(*this);
8787 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const throw(INTERP_KERNEL::Exception)
8789 return new MEDFileIntFieldMultiTS(*this);
8792 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const throw(INTERP_KERNEL::Exception)
8795 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8796 const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
8798 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8802 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8803 * mesh entities of a given dimension of the first mesh in MED file.
8804 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8805 * \param [in] type - a spatial discretization of interest.
8806 * \param [in] iteration - the iteration number of a required time step.
8807 * \param [in] order - the iteration order number of required time step.
8808 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8809 * \param [out] arrOut - the DataArrayInt containing values of field.
8810 * \param [in] renumPol - specifies how to permute values of the result field according to
8811 * the optional numbers of cells and nodes, if any. The valid values are
8812 * - 0 - do not permute.
8813 * - 1 - permute cells.
8814 * - 2 - permute nodes.
8815 * - 3 - permute cells and nodes.
8817 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8818 * caller is to delete this field using decrRef() as it is no more needed.
8819 * \throw If the MED file is not readable.
8820 * \throw If there is no mesh in the MED file.
8821 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8822 * \throw If no field values of the required parameters are available.
8824 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8826 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8827 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8829 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
8830 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8831 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arr,*contentNotNullBase());
8832 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8837 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8838 * the top level cells of the first mesh in MED file.
8839 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8840 * \param [in] type - a spatial discretization of interest.
8841 * \param [in] iteration - the iteration number of a required time step.
8842 * \param [in] order - the iteration order number of required time step.
8843 * \param [out] arrOut - the DataArrayInt containing values of field.
8844 * \param [in] renumPol - specifies how to permute values of the result field according to
8845 * the optional numbers of cells and nodes, if any. The valid values are
8846 * - 0 - do not permute.
8847 * - 1 - permute cells.
8848 * - 2 - permute nodes.
8849 * - 3 - permute cells and nodes.
8851 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8852 * caller is to delete this field using decrRef() as it is no more needed.
8853 * \throw If the MED file is not readable.
8854 * \throw If there is no mesh in the MED file.
8855 * \throw If no field values of the required parameters are available.
8857 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8859 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8860 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8862 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
8863 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8864 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,0,renumPol,this,arr,*contentNotNullBase());
8865 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8870 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8872 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8873 * \param [in] type - a spatial discretization of interest.
8874 * \param [in] iteration - the iteration number of a required time step.
8875 * \param [in] order - the iteration order number of required time step.
8876 * \param [out] arrOut - the DataArrayInt containing values of field.
8877 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8878 * \param [in] mesh - the supporting mesh.
8879 * \param [in] renumPol - specifies how to permute values of the result field according to
8880 * the optional numbers of cells and nodes, if any. The valid values are
8881 * - 0 - do not permute.
8882 * - 1 - permute cells.
8883 * - 2 - permute nodes.
8884 * - 3 - permute cells and nodes.
8886 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8887 * caller is to delete this field using decrRef() as it is no more needed.
8888 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8889 * \throw If no field of \a this is lying on \a mesh.
8890 * \throw If no field values of the required parameters are available.
8892 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8894 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8895 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8897 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
8898 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8899 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase());
8900 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8905 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
8907 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8908 * \param [in] type - a spatial discretization of the new field.
8909 * \param [in] iteration - the iteration number of a required time step.
8910 * \param [in] order - the iteration order number of required time step.
8911 * \param [in] mesh - the supporting mesh.
8912 * \param [out] arrOut - the DataArrayInt containing values of field.
8913 * \param [in] renumPol - specifies how to permute values of the result field according to
8914 * the optional numbers of cells and nodes, if any. The valid values are
8915 * - 0 - do not permute.
8916 * - 1 - permute cells.
8917 * - 2 - permute nodes.
8918 * - 3 - permute cells and nodes.
8920 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8921 * caller is to delete this field using decrRef() as it is no more needed.
8922 * \throw If no field of \a this is lying on \a mesh.
8923 * \throw If no field values of the required parameters are available.
8925 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8927 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8928 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8930 throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
8931 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8932 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase());
8933 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8938 * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
8939 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
8940 * This method is useful for MED2 file format when field on different mesh was autorized.
8942 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const char *mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8944 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8945 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8947 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
8948 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8949 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase());
8950 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8955 * Returns values and a profile of the field of a given type, of a given time step,
8956 * lying on a given support.
8957 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8958 * \param [in] type - a spatial discretization of the field.
8959 * \param [in] iteration - the iteration number of a required time step.
8960 * \param [in] order - the iteration order number of required time step.
8961 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8962 * \param [in] mesh - the supporting mesh.
8963 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
8964 * field of interest lies on. If the field lies on all entities of the given
8965 * dimension, all ids in \a pfl are zero. The caller is to delete this array
8966 * using decrRef() as it is no more needed.
8967 * \param [in] glob - the global data storing profiles and localization.
8968 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
8969 * field. The caller is to delete this array using decrRef() as it is no more needed.
8970 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8971 * \throw If no field of \a this is lying on \a mesh.
8972 * \throw If no field values of the required parameters are available.
8974 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
8976 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8977 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8979 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
8980 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
8981 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
8985 * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
8986 * \param [in] pos - a time step id.
8987 * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
8988 * delete this field using decrRef() as it is no more needed.
8989 * \throw If \a pos is not a valid time step id.
8991 MEDFileAnyTypeField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception)
8993 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
8996 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
8997 throw INTERP_KERNEL::Exception(oss.str().c_str());
8999 const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
9002 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
9003 ret->shallowCpyGlobs(*this);
9006 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
9007 throw INTERP_KERNEL::Exception(oss.str().c_str());
9011 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9012 * the given field is checked if its elements are sorted suitable for writing to MED file
9013 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9014 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9015 * \param [in] field - the field to add to \a this.
9016 * \throw If the name of \a field is empty.
9017 * \throw If the data array of \a field is not set.
9018 * \throw If existing time steps have different name or number of components than \a field.
9019 * \throw If the underlying mesh of \a field has no name.
9020 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9022 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals) throw(INTERP_KERNEL::Exception)
9024 contentNotNull()->appendFieldNoProfileSBT(field,arrOfVals,*this);
9028 * Adds a MEDCouplingFieldDouble to \a this as another time step.
9029 * The mesh support of input parameter \a field is ignored here, it can be NULL.
9030 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9033 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9034 * A new profile is added only if no equal profile is missing.
9035 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9036 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
9037 * \param [in] arrOfVals - the values of the field \a field used.
9038 * \param [in] mesh - the supporting mesh of \a field.
9039 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9040 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
9041 * \throw If either \a field or \a mesh or \a profile has an empty name.
9042 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9043 * \throw If the data array of \a field is not set.
9044 * \throw If the data array of \a this is already allocated but has different number of
9045 * components than \a field.
9046 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9047 * \sa setFieldNoProfileSBT()
9049 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
9051 contentNotNull()->appendFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this);
9054 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const throw(INTERP_KERNEL::Exception)
9056 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9058 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
9059 const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9061 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 !");
9065 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() throw(INTERP_KERNEL::Exception)
9067 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9069 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
9070 MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9072 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 !");
9076 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
9078 _content=new MEDFileIntFieldMultiTSWithoutSDA;
9081 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9085 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
9086 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll)
9089 catch(INTERP_KERNEL::Exception& e)
9092 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
9093 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll)
9096 catch(INTERP_KERNEL::Exception& e)
9099 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
9101 return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9106 MEDFileFields *MEDFileFields::New()
9108 return new MEDFileFields;
9111 MEDFileFields *MEDFileFields::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
9113 return new MEDFileFields(fileName,loadAll);
9116 std::size_t MEDFileFields::getHeapMemorySize() const
9118 std::size_t ret=_fields.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
9119 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9120 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it)
9121 ret+=(*it)->getHeapMemorySize();
9122 return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
9125 MEDFileFields *MEDFileFields::deepCpy() const throw(INTERP_KERNEL::Exception)
9127 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
9129 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9131 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9132 ret->_fields[i]=(*it)->deepCpy();
9134 ret->deepCpyGlobs(*this);
9138 MEDFileFields *MEDFileFields::shallowCpy() const throw(INTERP_KERNEL::Exception)
9140 return new MEDFileFields(*this);
9144 * 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
9145 * 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.
9146 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
9148 * \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.
9149 * \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.
9151 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9153 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const throw(INTERP_KERNEL::Exception)
9155 std::set< std::pair<int,int> > s;
9156 bool firstShot=true;
9157 areThereSomeForgottenTS=false;
9158 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9160 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9162 std::vector< std::pair<int,int> > v=(*it)->getIterations();
9163 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
9165 { s=s1; firstShot=false; }
9168 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
9170 areThereSomeForgottenTS=true;
9174 std::vector< std::pair<int,int> > ret;
9175 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
9179 int MEDFileFields::getNumberOfFields() const
9181 return _fields.size();
9184 std::vector<std::string> MEDFileFields::getFieldsNames() const throw(INTERP_KERNEL::Exception)
9186 std::vector<std::string> ret(_fields.size());
9188 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9190 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
9193 ret[i]=f->getName();
9197 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
9198 throw INTERP_KERNEL::Exception(oss.str().c_str());
9204 std::vector<std::string> MEDFileFields::getMeshesNames() const throw(INTERP_KERNEL::Exception)
9206 std::vector<std::string> ret;
9207 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9209 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9211 ret.push_back(cur->getMeshName());
9216 std::string MEDFileFields::simpleRepr() const
9218 std::ostringstream oss;
9219 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
9224 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
9226 int nbOfFields=getNumberOfFields();
9227 std::string startLine(bkOffset,' ');
9228 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
9230 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9232 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9235 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
9239 oss << startLine << " - not defined !" << std::endl;
9243 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9245 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9246 std::string chapter(17,'0'+i);
9247 oss << startLine << chapter << std::endl;
9250 cur->simpleRepr(bkOffset+2,oss,i);
9254 oss << startLine << " - not defined !" << std::endl;
9256 oss << startLine << chapter << std::endl;
9258 simpleReprGlobs(oss);
9261 MEDFileFields::MEDFileFields()
9265 MEDFileFields::MEDFileFields(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
9266 try:MEDFileFieldGlobsReal(fileName)
9268 MEDFileUtilities::CheckFileForRead(fileName);
9269 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
9270 int nbFields=MEDnField(fid);
9271 _fields.resize(nbFields);
9272 med_field_type typcha;
9273 for(int i=0;i<nbFields;i++)
9275 std::vector<std::string> infos;
9276 std::string fieldName,dtunit;
9277 int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,fileName,i,false,fieldName,typcha,infos,dtunit);
9282 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll);
9287 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll);
9292 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] !";
9293 throw INTERP_KERNEL::Exception(oss.str().c_str());
9297 loadAllGlobals(fid);
9299 catch(INTERP_KERNEL::Exception& e)
9304 void MEDFileFields::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
9307 writeGlobals(fid,*this);
9308 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9310 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
9313 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
9314 throw INTERP_KERNEL::Exception(oss.str().c_str());
9316 elt->writeLL(fid,*this);
9320 void MEDFileFields::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
9322 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
9323 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
9328 * This method alloc the arrays and load potentially huge arrays contained in this field.
9329 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
9330 * This method can be also called to refresh or reinit values from a file.
9332 * \throw If the fileName is not set or points to a non readable MED file.
9334 void MEDFileFields::loadArrays() throw(INTERP_KERNEL::Exception)
9336 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
9337 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9339 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9341 elt->loadBigArraysRecursively(fid,*elt);
9346 * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
9347 * But once data loaded once, this method does nothing.
9349 * \throw If the fileName is not set or points to a non readable MED file.
9350 * \sa MEDFileFields::loadArrays, MEDFileFields::releaseArrays
9352 void MEDFileFields::loadArraysIfNecessary() throw(INTERP_KERNEL::Exception)
9354 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
9355 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9357 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9359 elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
9364 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
9365 * This method does not release arrays set outside the context of a MED file.
9367 * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary
9369 void MEDFileFields::releaseArrays() throw(INTERP_KERNEL::Exception)
9371 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
9372 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9374 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9376 elt->releaseArrays();
9380 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
9382 std::vector<std::string> ret;
9383 std::set<std::string> ret2;
9384 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9386 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
9387 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
9388 if(ret2.find(*it2)==ret2.end())
9390 ret.push_back(*it2);
9397 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
9399 std::vector<std::string> ret;
9400 std::set<std::string> ret2;
9401 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9403 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
9404 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
9405 if(ret2.find(*it2)==ret2.end())
9407 ret.push_back(*it2);
9414 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
9416 std::vector<std::string> ret;
9417 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9419 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
9420 ret.insert(ret.end(),tmp.begin(),tmp.end());
9425 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
9427 std::vector<std::string> ret;
9428 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9430 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
9431 ret.insert(ret.end(),tmp.begin(),tmp.end());
9436 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
9438 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
9439 (*it)->changePflsRefsNamesGen2(mapOfModif);
9442 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
9444 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
9445 (*it)->changeLocsRefsNamesGen2(mapOfModif);
9448 void MEDFileFields::resize(int newSize) throw(INTERP_KERNEL::Exception)
9450 _fields.resize(newSize);
9453 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields) throw(INTERP_KERNEL::Exception)
9455 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
9459 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
9462 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
9463 _fields.push_back(field->getContent());
9464 appendGlobs(*field,1e-12);
9467 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
9470 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
9471 if(i>=(int)_fields.size())
9472 _fields.resize(i+1);
9473 _fields[i]=field->getContent();
9474 appendGlobs(*field,1e-12);
9477 void MEDFileFields::destroyFieldAtPos(int i) throw(INTERP_KERNEL::Exception)
9479 destroyFieldsAtPos(&i,&i+1);
9482 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
9484 std::vector<bool> b(_fields.size(),true);
9485 for(const int *i=startIds;i!=endIds;i++)
9487 if(*i<0 || *i>=(int)_fields.size())
9489 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
9490 throw INTERP_KERNEL::Exception(oss.str().c_str());
9494 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
9496 for(std::size_t i=0;i<_fields.size();i++)
9498 fields[j++]=_fields[i];
9502 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step) throw(INTERP_KERNEL::Exception)
9504 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
9505 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
9506 std::vector<bool> b(_fields.size(),true);
9508 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
9510 if(k<0 || k>=(int)_fields.size())
9512 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
9513 throw INTERP_KERNEL::Exception(oss.str().c_str());
9517 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
9519 for(std::size_t i=0;i<_fields.size();i++)
9521 fields[j++]=_fields[i];
9525 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
9528 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9530 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9532 ret=cur->changeMeshNames(modifTab) || ret;
9538 * \param [in] meshName the name of the mesh that will be renumbered.
9539 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
9540 * This code corresponds to the distribution of types in the corresponding mesh.
9541 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
9542 * \param [in] renumO2N the old to new renumber array.
9543 * \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
9546 bool MEDFileFields::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N) throw(INTERP_KERNEL::Exception)
9549 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9551 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
9554 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
9560 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const throw(INTERP_KERNEL::Exception)
9562 if(i<0 || i>=(int)_fields.size())
9564 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
9565 throw INTERP_KERNEL::Exception(oss.str().c_str());
9567 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
9570 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret;
9571 const MEDFileFieldMultiTSWithoutSDA *fmtsC=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts);
9572 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts);
9574 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
9576 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
9579 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
9580 throw INTERP_KERNEL::Exception(oss.str().c_str());
9582 ret->shallowCpyGlobs(*this);
9587 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
9588 * This method is accessible in python using __getitem__ with a list in input.
9589 * \return a new object that the caller should deal with.
9591 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception)
9593 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
9594 std::size_t sz=std::distance(startIds,endIds);
9595 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
9597 for(const int *i=startIds;i!=endIds;i++,j++)
9599 if(*i<0 || *i>=(int)_fields.size())
9601 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
9602 throw INTERP_KERNEL::Exception(oss.str().c_str());
9604 fields[j]=_fields[*i];
9606 ret->_fields=fields;
9610 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const char *fieldName) const throw(INTERP_KERNEL::Exception)
9612 return getFieldAtPos(getPosFromFieldName(fieldName));
9616 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
9617 * This method can be seen as a filter applied on \a this, that returns an object containing
9618 * 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
9619 * shallow copied from \a this.
9621 * \param [in] meshName - the name of the mesh on w
9622 * \return a new object that the caller should deal with.
9624 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const char *meshName) const throw(INTERP_KERNEL::Exception)
9626 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
9627 ret->shallowCpyOnlyUsedGlobs(*this);
9628 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9630 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9633 if(cur->getMeshName()==meshName)
9636 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
9637 ret->_fields.push_back(cur2);
9644 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
9645 * Input time steps are specified using a pair of integer (iteration, order).
9646 * 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,
9647 * but for each multitimestep only the time steps in \a timeSteps are kept.
9648 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
9650 * The returned object points to shallow copy of elements in \a this.
9652 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
9653 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
9654 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9656 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
9658 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
9659 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9661 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9664 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
9665 ret->_fields.push_back(elt);
9667 ret->shallowCpyOnlyUsedGlobs(*this);
9672 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
9674 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
9676 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
9677 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9679 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9682 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
9683 if(elt->getNumberOfTS()!=0)
9684 ret->_fields.push_back(elt);
9686 ret->shallowCpyOnlyUsedGlobs(*this);
9690 MEDFileFieldsIterator *MEDFileFields::iterator() throw(INTERP_KERNEL::Exception)
9692 return new MEDFileFieldsIterator(this);
9695 int MEDFileFields::getPosFromFieldName(const char *fieldName) const throw(INTERP_KERNEL::Exception)
9697 std::string tmp(fieldName);
9698 std::vector<std::string> poss;
9699 for(std::size_t i=0;i<_fields.size();i++)
9701 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=_fields[i];
9704 std::string fname(f->getName());
9708 poss.push_back(fname);
9711 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
9712 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
9714 throw INTERP_KERNEL::Exception(oss.str().c_str());
9717 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
9722 _nb_iter=fs->getNumberOfFields();
9726 MEDFileFieldsIterator::~MEDFileFieldsIterator()
9730 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
9732 if(_iter_id<_nb_iter)
9734 MEDFileFields *fs(_fs);
9736 return fs->getFieldAtPos(_iter_id++);